diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Kconfig.debug | 57 | ||||
| -rw-r--r-- | lib/Makefile | 3 | ||||
| -rw-r--r-- | lib/bitmap.c | 2 | ||||
| -rw-r--r-- | lib/bsearch.c | 53 | ||||
| -rw-r--r-- | lib/btree.c | 4 | ||||
| -rw-r--r-- | lib/decompress_unxz.c | 2 | ||||
| -rw-r--r-- | lib/dma-debug.c | 18 | ||||
| -rw-r--r-- | lib/flex_array.c | 24 | ||||
| -rw-r--r-- | lib/kstrtox.c | 9 | ||||
| -rw-r--r-- | lib/parser.c | 2 | ||||
| -rw-r--r-- | lib/string.c | 29 | ||||
| -rw-r--r-- | lib/test-kstrtox.c | 32 | ||||
| -rw-r--r-- | lib/timerqueue.c | 2 | ||||
| -rw-r--r-- | lib/vsprintf.c | 2 | ||||
| -rw-r--r-- | lib/xz/xz_dec_lzma2.c | 6 |
15 files changed, 166 insertions, 79 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index df9234c5f9d1..10ef61981149 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -238,6 +238,21 @@ config DETECT_HUNG_TASK | |||
| 238 | enabled then all held locks will also be reported. This | 238 | enabled then all held locks will also be reported. This |
| 239 | feature has negligible overhead. | 239 | feature has negligible overhead. |
| 240 | 240 | ||
| 241 | config DEFAULT_HUNG_TASK_TIMEOUT | ||
| 242 | int "Default timeout for hung task detection (in seconds)" | ||
| 243 | depends on DETECT_HUNG_TASK | ||
| 244 | default 120 | ||
| 245 | help | ||
| 246 | This option controls the default timeout (in seconds) used | ||
| 247 | to determine when a task has become non-responsive and should | ||
| 248 | be considered hung. | ||
| 249 | |||
| 250 | It can be adjusted at runtime via the kernel.hung_task_timeout | ||
| 251 | sysctl or by writing a value to /proc/sys/kernel/hung_task_timeout. | ||
| 252 | |||
| 253 | A timeout of 0 disables the check. The default is two minutes. | ||
| 254 | Keeping the default should be fine in most cases. | ||
| 255 | |||
| 241 | config BOOTPARAM_HUNG_TASK_PANIC | 256 | config BOOTPARAM_HUNG_TASK_PANIC |
| 242 | bool "Panic (Reboot) On Hung Tasks" | 257 | bool "Panic (Reboot) On Hung Tasks" |
| 243 | depends on DETECT_HUNG_TASK | 258 | depends on DETECT_HUNG_TASK |
| @@ -337,7 +352,7 @@ config DEBUG_OBJECTS_WORK | |||
| 337 | 352 | ||
| 338 | config DEBUG_OBJECTS_RCU_HEAD | 353 | config DEBUG_OBJECTS_RCU_HEAD |
| 339 | bool "Debug RCU callbacks objects" | 354 | bool "Debug RCU callbacks objects" |
| 340 | depends on DEBUG_OBJECTS && PREEMPT | 355 | depends on DEBUG_OBJECTS |
| 341 | help | 356 | help |
| 342 | Enable this to turn on debugging of RCU list heads (call_rcu() usage). | 357 | Enable this to turn on debugging of RCU list heads (call_rcu() usage). |
| 343 | 358 | ||
| @@ -398,9 +413,9 @@ config SLUB_STATS | |||
| 398 | config DEBUG_KMEMLEAK | 413 | config DEBUG_KMEMLEAK |
| 399 | bool "Kernel memory leak detector" | 414 | bool "Kernel memory leak detector" |
| 400 | depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ | 415 | depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \ |
| 401 | (X86 || ARM || PPC || S390 || SPARC64 || SUPERH || MICROBLAZE || TILE) | 416 | (X86 || ARM || PPC || MIPS || S390 || SPARC64 || SUPERH || MICROBLAZE || TILE) |
| 402 | 417 | ||
| 403 | select DEBUG_FS if SYSFS | 418 | select DEBUG_FS |
| 404 | select STACKTRACE if STACKTRACE_SUPPORT | 419 | select STACKTRACE if STACKTRACE_SUPPORT |
| 405 | select KALLSYMS | 420 | select KALLSYMS |
| 406 | select CRC32 | 421 | select CRC32 |
| @@ -434,11 +449,9 @@ config DEBUG_KMEMLEAK_EARLY_LOG_SIZE | |||
| 434 | 449 | ||
| 435 | config DEBUG_KMEMLEAK_TEST | 450 | config DEBUG_KMEMLEAK_TEST |
| 436 | tristate "Simple test for the kernel memory leak detector" | 451 | tristate "Simple test for the kernel memory leak detector" |
| 437 | depends on DEBUG_KMEMLEAK | 452 | depends on DEBUG_KMEMLEAK && m |
| 438 | help | 453 | help |
| 439 | Say Y or M here to build a test for the kernel memory leak | 454 | This option enables a module that explicitly leaks memory. |
| 440 | detector. This option enables a module that explicitly leaks | ||
| 441 | memory. | ||
| 442 | 455 | ||
| 443 | If unsure, say N. | 456 | If unsure, say N. |
| 444 | 457 | ||
| @@ -877,22 +890,9 @@ config RCU_TORTURE_TEST_RUNNABLE | |||
| 877 | Say N here if you want the RCU torture tests to start only | 890 | Say N here if you want the RCU torture tests to start only |
| 878 | after being manually enabled via /proc. | 891 | after being manually enabled via /proc. |
| 879 | 892 | ||
| 880 | config RCU_CPU_STALL_DETECTOR | ||
| 881 | bool "Check for stalled CPUs delaying RCU grace periods" | ||
| 882 | depends on TREE_RCU || TREE_PREEMPT_RCU | ||
| 883 | default y | ||
| 884 | help | ||
| 885 | This option causes RCU to printk information on which | ||
| 886 | CPUs are delaying the current grace period, but only when | ||
| 887 | the grace period extends for excessive time periods. | ||
| 888 | |||
| 889 | Say N if you want to disable such checks. | ||
| 890 | |||
| 891 | Say Y if you are unsure. | ||
| 892 | |||
| 893 | config RCU_CPU_STALL_TIMEOUT | 893 | config RCU_CPU_STALL_TIMEOUT |
| 894 | int "RCU CPU stall timeout in seconds" | 894 | int "RCU CPU stall timeout in seconds" |
| 895 | depends on RCU_CPU_STALL_DETECTOR | 895 | depends on TREE_RCU || TREE_PREEMPT_RCU |
| 896 | range 3 300 | 896 | range 3 300 |
| 897 | default 60 | 897 | default 60 |
| 898 | help | 898 | help |
| @@ -901,22 +901,9 @@ config RCU_CPU_STALL_TIMEOUT | |||
| 901 | RCU grace period persists, additional CPU stall warnings are | 901 | RCU grace period persists, additional CPU stall warnings are |
| 902 | printed at more widely spaced intervals. | 902 | printed at more widely spaced intervals. |
| 903 | 903 | ||
| 904 | config RCU_CPU_STALL_DETECTOR_RUNNABLE | ||
| 905 | bool "RCU CPU stall checking starts automatically at boot" | ||
| 906 | depends on RCU_CPU_STALL_DETECTOR | ||
| 907 | default y | ||
| 908 | help | ||
| 909 | If set, start checking for RCU CPU stalls immediately on | ||
| 910 | boot. Otherwise, RCU CPU stall checking must be manually | ||
| 911 | enabled. | ||
| 912 | |||
| 913 | Say Y if you are unsure. | ||
| 914 | |||
| 915 | Say N if you wish to suppress RCU CPU stall checking during boot. | ||
| 916 | |||
| 917 | config RCU_CPU_STALL_VERBOSE | 904 | config RCU_CPU_STALL_VERBOSE |
| 918 | bool "Print additional per-task information for RCU_CPU_STALL_DETECTOR" | 905 | bool "Print additional per-task information for RCU_CPU_STALL_DETECTOR" |
| 919 | depends on RCU_CPU_STALL_DETECTOR && TREE_PREEMPT_RCU | 906 | depends on TREE_PREEMPT_RCU |
| 920 | default y | 907 | default y |
| 921 | help | 908 | help |
| 922 | This option causes RCU to printk detailed per-task information | 909 | This option causes RCU to printk detailed per-task information |
diff --git a/lib/Makefile b/lib/Makefile index ef0f28571156..4b49a249064b 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
| @@ -21,7 +21,8 @@ lib-y += kobject.o kref.o klist.o | |||
| 21 | 21 | ||
| 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ | 22 | obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \ |
| 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ | 23 | bust_spinlocks.o hexdump.o kasprintf.o bitmap.o scatterlist.o \ |
| 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o | 24 | string_helpers.o gcd.o lcm.o list_sort.o uuid.o flex_array.o \ |
| 25 | bsearch.o | ||
| 25 | obj-y += kstrtox.o | 26 | obj-y += kstrtox.o |
| 26 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 27 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
| 27 | 28 | ||
diff --git a/lib/bitmap.c b/lib/bitmap.c index 741fae905ae3..91e0ccfdb424 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
| @@ -830,7 +830,7 @@ EXPORT_SYMBOL(bitmap_bitremap); | |||
| 830 | * @orig (i.e. bits 3, 5, 7 and 9) were also set. | 830 | * @orig (i.e. bits 3, 5, 7 and 9) were also set. |
| 831 | * | 831 | * |
| 832 | * When bit 11 is set in @orig, it means turn on the bit in | 832 | * When bit 11 is set in @orig, it means turn on the bit in |
| 833 | * @dst corresponding to whatever is the twelth bit that is | 833 | * @dst corresponding to whatever is the twelfth bit that is |
| 834 | * turned on in @relmap. In the above example, there were | 834 | * turned on in @relmap. In the above example, there were |
| 835 | * only ten bits turned on in @relmap (30..39), so that bit | 835 | * only ten bits turned on in @relmap (30..39), so that bit |
| 836 | * 11 was set in @orig had no affect on @dst. | 836 | * 11 was set in @orig had no affect on @dst. |
diff --git a/lib/bsearch.c b/lib/bsearch.c new file mode 100644 index 000000000000..5b54758e2afb --- /dev/null +++ b/lib/bsearch.c | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | /* | ||
| 2 | * A generic implementation of binary search for the Linux kernel | ||
| 3 | * | ||
| 4 | * Copyright (C) 2008-2009 Ksplice, Inc. | ||
| 5 | * Author: Tim Abbott <tabbott@ksplice.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU General Public License as | ||
| 9 | * published by the Free Software Foundation; version 2. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/bsearch.h> | ||
| 14 | |||
| 15 | /* | ||
| 16 | * bsearch - binary search an array of elements | ||
| 17 | * @key: pointer to item being searched for | ||
| 18 | * @base: pointer to first element to search | ||
| 19 | * @num: number of elements | ||
| 20 | * @size: size of each element | ||
| 21 | * @cmp: pointer to comparison function | ||
| 22 | * | ||
| 23 | * This function does a binary search on the given array. The | ||
| 24 | * contents of the array should already be in ascending sorted order | ||
| 25 | * under the provided comparison function. | ||
| 26 | * | ||
| 27 | * Note that the key need not have the same type as the elements in | ||
| 28 | * the array, e.g. key could be a string and the comparison function | ||
| 29 | * could compare the string with the struct's name field. However, if | ||
| 30 | * the key and elements in the array are of the same type, you can use | ||
| 31 | * the same comparison function for both sort() and bsearch(). | ||
| 32 | */ | ||
| 33 | void *bsearch(const void *key, const void *base, size_t num, size_t size, | ||
| 34 | int (*cmp)(const void *key, const void *elt)) | ||
| 35 | { | ||
| 36 | size_t start = 0, end = num; | ||
| 37 | int result; | ||
| 38 | |||
| 39 | while (start < end) { | ||
| 40 | size_t mid = start + (end - start) / 2; | ||
| 41 | |||
| 42 | result = cmp(key, base + mid * size); | ||
| 43 | if (result < 0) | ||
| 44 | end = mid; | ||
| 45 | else if (result > 0) | ||
| 46 | start = mid + 1; | ||
| 47 | else | ||
| 48 | return (void *)base + mid * size; | ||
| 49 | } | ||
| 50 | |||
| 51 | return NULL; | ||
| 52 | } | ||
| 53 | EXPORT_SYMBOL(bsearch); | ||
diff --git a/lib/btree.c b/lib/btree.c index c9c6f0351526..2a34392bcecc 100644 --- a/lib/btree.c +++ b/lib/btree.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | * see http://programming.kicks-ass.net/kernel-patches/vma_lookup/btree.patch | 11 | * see http://programming.kicks-ass.net/kernel-patches/vma_lookup/btree.patch |
| 12 | * | 12 | * |
| 13 | * A relatively simple B+Tree implementation. I have written it as a learning | 13 | * A relatively simple B+Tree implementation. I have written it as a learning |
| 14 | * excercise to understand how B+Trees work. Turned out to be useful as well. | 14 | * exercise to understand how B+Trees work. Turned out to be useful as well. |
| 15 | * | 15 | * |
| 16 | * B+Trees can be used similar to Linux radix trees (which don't have anything | 16 | * B+Trees can be used similar to Linux radix trees (which don't have anything |
| 17 | * in common with textbook radix trees, beware). Prerequisite for them working | 17 | * in common with textbook radix trees, beware). Prerequisite for them working |
| @@ -541,7 +541,7 @@ static void rebalance(struct btree_head *head, struct btree_geo *geo, | |||
| 541 | int i, no_left, no_right; | 541 | int i, no_left, no_right; |
| 542 | 542 | ||
| 543 | if (fill == 0) { | 543 | if (fill == 0) { |
| 544 | /* Because we don't steal entries from a neigbour, this case | 544 | /* Because we don't steal entries from a neighbour, this case |
| 545 | * can happen. Parent node contains a single child, this | 545 | * can happen. Parent node contains a single child, this |
| 546 | * node, so merging with a sibling never happens. | 546 | * node, so merging with a sibling never happens. |
| 547 | */ | 547 | */ |
diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c index cecd23df2b9a..9f34eb56854d 100644 --- a/lib/decompress_unxz.c +++ b/lib/decompress_unxz.c | |||
| @@ -83,7 +83,7 @@ | |||
| 83 | * safety_margin = 128 + uncompressed_size * 8 / 32768 + 65536 | 83 | * safety_margin = 128 + uncompressed_size * 8 / 32768 + 65536 |
| 84 | * = 128 + (uncompressed_size >> 12) + 65536 | 84 | * = 128 + (uncompressed_size >> 12) + 65536 |
| 85 | * | 85 | * |
| 86 | * For comparision, according to arch/x86/boot/compressed/misc.c, the | 86 | * For comparison, according to arch/x86/boot/compressed/misc.c, the |
| 87 | * equivalent formula for Deflate is this: | 87 | * equivalent formula for Deflate is this: |
| 88 | * | 88 | * |
| 89 | * safety_margin = 18 + (uncompressed_size >> 12) + 32768 | 89 | * safety_margin = 18 + (uncompressed_size >> 12) + 32768 |
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index 4bfb0471f106..db07bfd9298e 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
| @@ -649,7 +649,7 @@ out_err: | |||
| 649 | return -ENOMEM; | 649 | return -ENOMEM; |
| 650 | } | 650 | } |
| 651 | 651 | ||
| 652 | static int device_dma_allocations(struct device *dev) | 652 | static int device_dma_allocations(struct device *dev, struct dma_debug_entry **out_entry) |
| 653 | { | 653 | { |
| 654 | struct dma_debug_entry *entry; | 654 | struct dma_debug_entry *entry; |
| 655 | unsigned long flags; | 655 | unsigned long flags; |
| @@ -660,8 +660,10 @@ static int device_dma_allocations(struct device *dev) | |||
| 660 | for (i = 0; i < HASH_SIZE; ++i) { | 660 | for (i = 0; i < HASH_SIZE; ++i) { |
| 661 | spin_lock(&dma_entry_hash[i].lock); | 661 | spin_lock(&dma_entry_hash[i].lock); |
| 662 | list_for_each_entry(entry, &dma_entry_hash[i].list, list) { | 662 | list_for_each_entry(entry, &dma_entry_hash[i].list, list) { |
| 663 | if (entry->dev == dev) | 663 | if (entry->dev == dev) { |
| 664 | count += 1; | 664 | count += 1; |
| 665 | *out_entry = entry; | ||
| 666 | } | ||
| 665 | } | 667 | } |
| 666 | spin_unlock(&dma_entry_hash[i].lock); | 668 | spin_unlock(&dma_entry_hash[i].lock); |
| 667 | } | 669 | } |
| @@ -674,6 +676,7 @@ static int device_dma_allocations(struct device *dev) | |||
| 674 | static int dma_debug_device_change(struct notifier_block *nb, unsigned long action, void *data) | 676 | static int dma_debug_device_change(struct notifier_block *nb, unsigned long action, void *data) |
| 675 | { | 677 | { |
| 676 | struct device *dev = data; | 678 | struct device *dev = data; |
| 679 | struct dma_debug_entry *uninitialized_var(entry); | ||
| 677 | int count; | 680 | int count; |
| 678 | 681 | ||
| 679 | if (global_disable) | 682 | if (global_disable) |
| @@ -681,12 +684,17 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti | |||
| 681 | 684 | ||
| 682 | switch (action) { | 685 | switch (action) { |
| 683 | case BUS_NOTIFY_UNBOUND_DRIVER: | 686 | case BUS_NOTIFY_UNBOUND_DRIVER: |
| 684 | count = device_dma_allocations(dev); | 687 | count = device_dma_allocations(dev, &entry); |
| 685 | if (count == 0) | 688 | if (count == 0) |
| 686 | break; | 689 | break; |
| 687 | err_printk(dev, NULL, "DMA-API: device driver has pending " | 690 | err_printk(dev, entry, "DMA-API: device driver has pending " |
| 688 | "DMA allocations while released from device " | 691 | "DMA allocations while released from device " |
| 689 | "[count=%d]\n", count); | 692 | "[count=%d]\n" |
| 693 | "One of leaked entries details: " | ||
| 694 | "[device address=0x%016llx] [size=%llu bytes] " | ||
| 695 | "[mapped with %s] [mapped as %s]\n", | ||
| 696 | count, entry->dev_addr, entry->size, | ||
| 697 | dir2name[entry->direction], type2name[entry->type]); | ||
| 690 | break; | 698 | break; |
| 691 | default: | 699 | default: |
| 692 | break; | 700 | break; |
diff --git a/lib/flex_array.c b/lib/flex_array.c index c0ea40ba2082..854b57bd7d9d 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
| @@ -232,10 +232,10 @@ EXPORT_SYMBOL(flex_array_clear); | |||
| 232 | 232 | ||
| 233 | /** | 233 | /** |
| 234 | * flex_array_prealloc - guarantee that array space exists | 234 | * flex_array_prealloc - guarantee that array space exists |
| 235 | * @fa: the flex array for which to preallocate parts | 235 | * @fa: the flex array for which to preallocate parts |
| 236 | * @start: index of first array element for which space is allocated | 236 | * @start: index of first array element for which space is allocated |
| 237 | * @end: index of last (inclusive) element for which space is allocated | 237 | * @nr_elements: number of elements for which space is allocated |
| 238 | * @flags: page allocation flags | 238 | * @flags: page allocation flags |
| 239 | * | 239 | * |
| 240 | * This will guarantee that no future calls to flex_array_put() | 240 | * This will guarantee that no future calls to flex_array_put() |
| 241 | * will allocate memory. It can be used if you are expecting to | 241 | * will allocate memory. It can be used if you are expecting to |
| @@ -245,14 +245,24 @@ EXPORT_SYMBOL(flex_array_clear); | |||
| 245 | * Locking must be provided by the caller. | 245 | * Locking must be provided by the caller. |
| 246 | */ | 246 | */ |
| 247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, | 247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
| 248 | unsigned int end, gfp_t flags) | 248 | unsigned int nr_elements, gfp_t flags) |
| 249 | { | 249 | { |
| 250 | int start_part; | 250 | int start_part; |
| 251 | int end_part; | 251 | int end_part; |
| 252 | int part_nr; | 252 | int part_nr; |
| 253 | unsigned int end; | ||
| 253 | struct flex_array_part *part; | 254 | struct flex_array_part *part; |
| 254 | 255 | ||
| 255 | if (start >= fa->total_nr_elements || end >= fa->total_nr_elements) | 256 | if (!start && !nr_elements) |
| 257 | return 0; | ||
| 258 | if (start >= fa->total_nr_elements) | ||
| 259 | return -ENOSPC; | ||
| 260 | if (!nr_elements) | ||
| 261 | return 0; | ||
| 262 | |||
| 263 | end = start + nr_elements - 1; | ||
| 264 | |||
| 265 | if (end >= fa->total_nr_elements) | ||
| 256 | return -ENOSPC; | 266 | return -ENOSPC; |
| 257 | if (elements_fit_in_base(fa)) | 267 | if (elements_fit_in_base(fa)) |
| 258 | return 0; | 268 | return 0; |
| @@ -343,6 +353,8 @@ int flex_array_shrink(struct flex_array *fa) | |||
| 343 | int part_nr; | 353 | int part_nr; |
| 344 | int ret = 0; | 354 | int ret = 0; |
| 345 | 355 | ||
| 356 | if (!fa->total_nr_elements) | ||
| 357 | return 0; | ||
| 346 | if (elements_fit_in_base(fa)) | 358 | if (elements_fit_in_base(fa)) |
| 347 | return ret; | 359 | return ret; |
| 348 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { | 360 | for (part_nr = 0; part_nr < FLEX_ARRAY_NR_BASE_PTRS; part_nr++) { |
diff --git a/lib/kstrtox.c b/lib/kstrtox.c index 05672e819f8c..a235f3cc471c 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c | |||
| @@ -49,12 +49,9 @@ static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) | |||
| 49 | val = *s - '0'; | 49 | val = *s - '0'; |
| 50 | else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') | 50 | else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') |
| 51 | val = _tolower(*s) - 'a' + 10; | 51 | val = _tolower(*s) - 'a' + 10; |
| 52 | else if (*s == '\n') { | 52 | else if (*s == '\n' && *(s + 1) == '\0') |
| 53 | if (*(s + 1) == '\0') | 53 | break; |
| 54 | break; | 54 | else |
| 55 | else | ||
| 56 | return -EINVAL; | ||
| 57 | } else | ||
| 58 | return -EINVAL; | 55 | return -EINVAL; |
| 59 | 56 | ||
| 60 | if (val >= base) | 57 | if (val >= base) |
diff --git a/lib/parser.c b/lib/parser.c index 6e89eca5cca0..dcbaaef6cf11 100644 --- a/lib/parser.c +++ b/lib/parser.c | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | * match_one: - Determines if a string matches a simple pattern | 15 | * match_one: - Determines if a string matches a simple pattern |
| 16 | * @s: the string to examine for presense of the pattern | 16 | * @s: the string to examine for presence of the pattern |
| 17 | * @p: the string containing the pattern | 17 | * @p: the string containing the pattern |
| 18 | * @args: array of %MAX_OPT_ARGS &substring_t elements. Used to return match | 18 | * @args: array of %MAX_OPT_ARGS &substring_t elements. Used to return match |
| 19 | * locations. | 19 | * locations. |
diff --git a/lib/string.c b/lib/string.c index f71bead1be3e..01fad9b203e1 100644 --- a/lib/string.c +++ b/lib/string.c | |||
| @@ -535,6 +535,35 @@ bool sysfs_streq(const char *s1, const char *s2) | |||
| 535 | } | 535 | } |
| 536 | EXPORT_SYMBOL(sysfs_streq); | 536 | EXPORT_SYMBOL(sysfs_streq); |
| 537 | 537 | ||
| 538 | /** | ||
| 539 | * strtobool - convert common user inputs into boolean values | ||
| 540 | * @s: input string | ||
| 541 | * @res: result | ||
| 542 | * | ||
| 543 | * This routine returns 0 iff the first character is one of 'Yy1Nn0'. | ||
| 544 | * Otherwise it will return -EINVAL. Value pointed to by res is | ||
| 545 | * updated upon finding a match. | ||
| 546 | */ | ||
| 547 | int strtobool(const char *s, bool *res) | ||
| 548 | { | ||
| 549 | switch (s[0]) { | ||
| 550 | case 'y': | ||
| 551 | case 'Y': | ||
| 552 | case '1': | ||
| 553 | *res = true; | ||
| 554 | break; | ||
| 555 | case 'n': | ||
| 556 | case 'N': | ||
| 557 | case '0': | ||
| 558 | *res = false; | ||
| 559 | break; | ||
| 560 | default: | ||
| 561 | return -EINVAL; | ||
| 562 | } | ||
| 563 | return 0; | ||
| 564 | } | ||
| 565 | EXPORT_SYMBOL(strtobool); | ||
| 566 | |||
| 538 | #ifndef __HAVE_ARCH_MEMSET | 567 | #ifndef __HAVE_ARCH_MEMSET |
| 539 | /** | 568 | /** |
| 540 | * memset - Fill a region of memory with the given value | 569 | * memset - Fill a region of memory with the given value |
diff --git a/lib/test-kstrtox.c b/lib/test-kstrtox.c index 325c2f9ecebd..d55769d63cb8 100644 --- a/lib/test-kstrtox.c +++ b/lib/test-kstrtox.c | |||
| @@ -315,12 +315,12 @@ static void __init test_kstrtou64_ok(void) | |||
| 315 | {"65537", 10, 65537}, | 315 | {"65537", 10, 65537}, |
| 316 | {"2147483646", 10, 2147483646}, | 316 | {"2147483646", 10, 2147483646}, |
| 317 | {"2147483647", 10, 2147483647}, | 317 | {"2147483647", 10, 2147483647}, |
| 318 | {"2147483648", 10, 2147483648}, | 318 | {"2147483648", 10, 2147483648ULL}, |
| 319 | {"2147483649", 10, 2147483649}, | 319 | {"2147483649", 10, 2147483649ULL}, |
| 320 | {"4294967294", 10, 4294967294}, | 320 | {"4294967294", 10, 4294967294ULL}, |
| 321 | {"4294967295", 10, 4294967295}, | 321 | {"4294967295", 10, 4294967295ULL}, |
| 322 | {"4294967296", 10, 4294967296}, | 322 | {"4294967296", 10, 4294967296ULL}, |
| 323 | {"4294967297", 10, 4294967297}, | 323 | {"4294967297", 10, 4294967297ULL}, |
| 324 | {"9223372036854775806", 10, 9223372036854775806ULL}, | 324 | {"9223372036854775806", 10, 9223372036854775806ULL}, |
| 325 | {"9223372036854775807", 10, 9223372036854775807ULL}, | 325 | {"9223372036854775807", 10, 9223372036854775807ULL}, |
| 326 | {"9223372036854775808", 10, 9223372036854775808ULL}, | 326 | {"9223372036854775808", 10, 9223372036854775808ULL}, |
| @@ -369,12 +369,12 @@ static void __init test_kstrtos64_ok(void) | |||
| 369 | {"65537", 10, 65537}, | 369 | {"65537", 10, 65537}, |
| 370 | {"2147483646", 10, 2147483646}, | 370 | {"2147483646", 10, 2147483646}, |
| 371 | {"2147483647", 10, 2147483647}, | 371 | {"2147483647", 10, 2147483647}, |
| 372 | {"2147483648", 10, 2147483648}, | 372 | {"2147483648", 10, 2147483648LL}, |
| 373 | {"2147483649", 10, 2147483649}, | 373 | {"2147483649", 10, 2147483649LL}, |
| 374 | {"4294967294", 10, 4294967294}, | 374 | {"4294967294", 10, 4294967294LL}, |
| 375 | {"4294967295", 10, 4294967295}, | 375 | {"4294967295", 10, 4294967295LL}, |
| 376 | {"4294967296", 10, 4294967296}, | 376 | {"4294967296", 10, 4294967296LL}, |
| 377 | {"4294967297", 10, 4294967297}, | 377 | {"4294967297", 10, 4294967297LL}, |
| 378 | {"9223372036854775806", 10, 9223372036854775806LL}, | 378 | {"9223372036854775806", 10, 9223372036854775806LL}, |
| 379 | {"9223372036854775807", 10, 9223372036854775807LL}, | 379 | {"9223372036854775807", 10, 9223372036854775807LL}, |
| 380 | }; | 380 | }; |
| @@ -418,10 +418,10 @@ static void __init test_kstrtou32_ok(void) | |||
| 418 | {"65537", 10, 65537}, | 418 | {"65537", 10, 65537}, |
| 419 | {"2147483646", 10, 2147483646}, | 419 | {"2147483646", 10, 2147483646}, |
| 420 | {"2147483647", 10, 2147483647}, | 420 | {"2147483647", 10, 2147483647}, |
| 421 | {"2147483648", 10, 2147483648}, | 421 | {"2147483648", 10, 2147483648U}, |
| 422 | {"2147483649", 10, 2147483649}, | 422 | {"2147483649", 10, 2147483649U}, |
| 423 | {"4294967294", 10, 4294967294}, | 423 | {"4294967294", 10, 4294967294U}, |
| 424 | {"4294967295", 10, 4294967295}, | 424 | {"4294967295", 10, 4294967295U}, |
| 425 | }; | 425 | }; |
| 426 | TEST_OK(kstrtou32, u32, "%u", test_u32_ok); | 426 | TEST_OK(kstrtou32, u32, "%u", test_u32_ok); |
| 427 | } | 427 | } |
diff --git a/lib/timerqueue.c b/lib/timerqueue.c index e3a1050e6820..191176a43e9a 100644 --- a/lib/timerqueue.c +++ b/lib/timerqueue.c | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | * Uses rbtrees for quick list adds and expiration. | 5 | * Uses rbtrees for quick list adds and expiration. |
| 6 | * | 6 | * |
| 7 | * NOTE: All of the following functions need to be serialized | 7 | * NOTE: All of the following functions need to be serialized |
| 8 | * to avoid races. No locking is done by this libary code. | 8 | * to avoid races. No locking is done by this library code. |
| 9 | * | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by | 11 | * it under the terms of the GNU General Public License as published by |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index bc0ac6b333dc..dfd60192bc2e 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
| @@ -797,7 +797,7 @@ char *uuid_string(char *buf, char *end, const u8 *addr, | |||
| 797 | return string(buf, end, uuid, spec); | 797 | return string(buf, end, uuid, spec); |
| 798 | } | 798 | } |
| 799 | 799 | ||
| 800 | int kptr_restrict = 1; | 800 | int kptr_restrict __read_mostly; |
| 801 | 801 | ||
| 802 | /* | 802 | /* |
| 803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed | 803 | * Show a '%p' thing. A kernel extension is that the '%p' is followed |
diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c index ea5fa4fe9d67..a6cdc969ea42 100644 --- a/lib/xz/xz_dec_lzma2.c +++ b/lib/xz/xz_dec_lzma2.c | |||
| @@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
| 969 | */ | 969 | */ |
| 970 | tmp = b->in[b->in_pos++]; | 970 | tmp = b->in[b->in_pos++]; |
| 971 | 971 | ||
| 972 | if (tmp == 0x00) | ||
| 973 | return XZ_STREAM_END; | ||
| 974 | |||
| 972 | if (tmp >= 0xE0 || tmp == 0x01) { | 975 | if (tmp >= 0xE0 || tmp == 0x01) { |
| 973 | s->lzma2.need_props = true; | 976 | s->lzma2.need_props = true; |
| 974 | s->lzma2.need_dict_reset = false; | 977 | s->lzma2.need_dict_reset = false; |
| @@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(struct xz_dec_lzma2 *s, | |||
| 1001 | lzma_reset(s); | 1004 | lzma_reset(s); |
| 1002 | } | 1005 | } |
| 1003 | } else { | 1006 | } else { |
| 1004 | if (tmp == 0x00) | ||
| 1005 | return XZ_STREAM_END; | ||
| 1006 | |||
| 1007 | if (tmp > 0x02) | 1007 | if (tmp > 0x02) |
| 1008 | return XZ_DATA_ERROR; | 1008 | return XZ_DATA_ERROR; |
| 1009 | 1009 | ||
