ALSA: hda - Adding one more ALC255 pin definition for headset problem
[linux/fpc-iii.git] / tools / testing / radix-tree / regression3.c
blob1f06ed73d0a84e8b5ebd14cfe0911cb329368695
1 /*
2 * Regression3
3 * Description:
4 * Helper radix_tree_iter_retry resets next_index to the current index.
5 * In following radix_tree_next_slot current chunk size becomes zero.
6 * This isn't checked and it tries to dereference null pointer in slot.
8 * Helper radix_tree_iter_next reset slot to NULL and next_index to index + 1,
9 * for tagger iteraction it also must reset cached tags in iterator to abort
10 * next radix_tree_next_slot and go to slow-path into radix_tree_next_chunk.
12 * Running:
13 * This test should run to completion immediately. The above bug would
14 * cause it to segfault.
16 * Upstream commit:
17 * Not yet
19 #include <linux/kernel.h>
20 #include <linux/gfp.h>
21 #include <linux/slab.h>
22 #include <linux/radix-tree.h>
23 #include <stdlib.h>
24 #include <stdio.h>
26 #include "regression.h"
28 void regression3_test(void)
30 RADIX_TREE(root, GFP_KERNEL);
31 void *ptr0 = (void *)4ul;
32 void *ptr = (void *)8ul;
33 struct radix_tree_iter iter;
34 void **slot;
35 bool first;
37 printf("running regression test 3 (should take milliseconds)\n");
39 radix_tree_insert(&root, 0, ptr0);
40 radix_tree_tag_set(&root, 0, 0);
42 first = true;
43 radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
44 printf("tagged %ld %p\n", iter.index, *slot);
45 if (first) {
46 radix_tree_insert(&root, 1, ptr);
47 radix_tree_tag_set(&root, 1, 0);
48 first = false;
50 if (radix_tree_deref_retry(*slot)) {
51 printf("retry at %ld\n", iter.index);
52 slot = radix_tree_iter_retry(&iter);
53 continue;
56 radix_tree_delete(&root, 1);
58 first = true;
59 radix_tree_for_each_slot(slot, &root, &iter, 0) {
60 printf("slot %ld %p\n", iter.index, *slot);
61 if (first) {
62 radix_tree_insert(&root, 1, ptr);
63 first = false;
65 if (radix_tree_deref_retry(*slot)) {
66 printk("retry at %ld\n", iter.index);
67 slot = radix_tree_iter_retry(&iter);
68 continue;
71 radix_tree_delete(&root, 1);
73 first = true;
74 radix_tree_for_each_contig(slot, &root, &iter, 0) {
75 printk("contig %ld %p\n", iter.index, *slot);
76 if (first) {
77 radix_tree_insert(&root, 1, ptr);
78 first = false;
80 if (radix_tree_deref_retry(*slot)) {
81 printk("retry at %ld\n", iter.index);
82 slot = radix_tree_iter_retry(&iter);
83 continue;
87 radix_tree_for_each_slot(slot, &root, &iter, 0) {
88 printf("slot %ld %p\n", iter.index, *slot);
89 if (!iter.index) {
90 printf("next at %ld\n", iter.index);
91 slot = radix_tree_iter_next(&iter);
95 radix_tree_for_each_contig(slot, &root, &iter, 0) {
96 printf("contig %ld %p\n", iter.index, *slot);
97 if (!iter.index) {
98 printf("next at %ld\n", iter.index);
99 slot = radix_tree_iter_next(&iter);
103 radix_tree_tag_set(&root, 0, 0);
104 radix_tree_tag_set(&root, 1, 0);
105 radix_tree_for_each_tagged(slot, &root, &iter, 0, 0) {
106 printf("tagged %ld %p\n", iter.index, *slot);
107 if (!iter.index) {
108 printf("next at %ld\n", iter.index);
109 slot = radix_tree_iter_next(&iter);
113 radix_tree_delete(&root, 0);
114 radix_tree_delete(&root, 1);
116 printf("regression test 3 passed\n");