Merge misc updates from Andrew Morton: - a few misc things - the rest of MM - remove flex_arrays, replace with new simple radix-tree implementation * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (38 commits) Drop flex_arrays sctp: convert to genradix proc: commit to genradix generic radix trees selinux: convert to kvmalloc md: convert to kvmalloc openvswitch: convert to kvmalloc of: fix kmemleak crash caused by imbalance in early memory reservation mm: memblock: update comments and kernel-doc memblock: split checks whether a region should be skipped to a helper function memblock: remove memblock_{set,clear}_region_flags memblock: drop memblock_alloc_*_nopanic() variants memblock: memblock_alloc_try_nid: don't panic treewide: add checks for the return value of memblock_alloc*() swiotlb: add checks for the return value of memblock_alloc*() init/main: add checks for the return value of memblock_alloc*() mm/percpu: add checks for the return value of memblock_alloc*() sparc: add checks for the return value of memblock_alloc*() ia64: add checks for the return value of memblock_alloc*() arch: don't memset(0) memory returned by memblock_alloc() ...
Showing the changes to kernel (4 of 159 files). Show all
Unified · Split
| @@ -199,6 +199,7 @@ void __init swiotlb_update_mem_attributes(void) · 198 unmodified lines | |||
| 199 | int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) | 199 | int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) |
| 200 | { | 200 | { |
| 201 | unsigned long i, bytes; | 201 | unsigned long i, bytes; |
| 202 | size_t alloc_size; | ||
| 202 | 203 | ||
| 203 | bytes = nslabs << IO_TLB_SHIFT; | 204 | bytes = nslabs << IO_TLB_SHIFT; |
| 204 | 205 | ||
| @@ -211,12 +212,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) · 6 unmodified lines | |||
| 211 | * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE | 212 | * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE |
| 212 | * between io_tlb_start and io_tlb_end. | 213 | * between io_tlb_start and io_tlb_end. |
| 213 | */ | 214 | */ |
| 214 | io_tlb_list = memblock_alloc( | 215 | alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int)); |
| 215 | PAGE_ALIGN(io_tlb_nslabs * sizeof(int)), | 216 | io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE); |
| 216 | PAGE_SIZE); | 217 | if (!io_tlb_list) |
| 217 | io_tlb_orig_addr = memblock_alloc( | 218 | panic("%s: Failed to allocate %zu bytes align=0x%lx\n", |
| 218 | PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)), | 219 | __func__, alloc_size, PAGE_SIZE); |
| 219 | PAGE_SIZE); | 220 | |
| 221 | alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)); | ||
| 222 | io_tlb_orig_addr = memblock_alloc(alloc_size, PAGE_SIZE); | ||
| 223 | if (!io_tlb_orig_addr) | ||
| 224 | panic("%s: Failed to allocate %zu bytes align=0x%lx\n", | ||
| 225 | __func__, alloc_size, PAGE_SIZE); | ||
| 226 | |||
| 220 | for (i = 0; i < io_tlb_nslabs; i++) { | 227 | for (i = 0; i < io_tlb_nslabs; i++) { |
| 221 | io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); | 228 | io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE); |
| 222 | io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; | 229 | io_tlb_orig_addr[i] = INVALID_PHYS_ADDR; |
| @@ -249,7 +256,7 @@ swiotlb_init(int verbose) · 26 unmodified lines | |||
| 249 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; | 256 | bytes = io_tlb_nslabs << IO_TLB_SHIFT; |
| 250 | 257 | ||
| 251 | /* Get IO TLB memory from the low pages */ | 258 | /* Get IO TLB memory from the low pages */ |
| 252 | vstart = memblock_alloc_low_nopanic(PAGE_ALIGN(bytes), PAGE_SIZE); | 259 | vstart = memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE); |
| 253 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) | 260 | if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose)) |
| 254 | return; | 261 | return; |
| 255 | 262 | ||
| @@ -965,6 +965,9 @@ void __init __register_nosave_region(unsigned long start_pfn, · 964 unmodified lines | |||
| 965 | /* This allocation cannot fail */ | 965 | /* This allocation cannot fail */ |
| 966 | region = memblock_alloc(sizeof(struct nosave_region), | 966 | region = memblock_alloc(sizeof(struct nosave_region), |
| 967 | SMP_CACHE_BYTES); | 967 | SMP_CACHE_BYTES); |
| 968 | if (!region) | ||
| 969 | panic("%s: Failed to allocate %zu bytes\n", __func__, | ||
| 970 | sizeof(struct nosave_region)); | ||
| 968 | } | 971 | } |
| 969 | region->start_pfn = start_pfn; | 972 | region->start_pfn = start_pfn; |
| 970 | region->end_pfn = end_pfn; | 973 | region->end_pfn = end_pfn; |
| @@ -1143,14 +1143,7 @@ void __init setup_log_buf(int early) · 1142 unmodified lines | |||
| 1143 | if (!new_log_buf_len) | 1143 | if (!new_log_buf_len) |
| 1144 | return; | 1144 | return; |
| 1145 | 1145 | ||
| 1146 | if (early) { | 1146 | new_log_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN); |
| 1147 | new_log_buf = | ||
| 1148 | memblock_alloc(new_log_buf_len, LOG_ALIGN); | ||
| 1149 | } else { | ||
| 1150 | new_log_buf = memblock_alloc_nopanic(new_log_buf_len, | ||
| 1151 | LOG_ALIGN); | ||
| 1152 | } | ||
| 1153 | |||
| 1154 | if (unlikely(!new_log_buf)) { | 1147 | if (unlikely(!new_log_buf)) { |
| 1155 | pr_err("log_buf_len: %lu bytes not available\n", | 1148 | pr_err("log_buf_len: %lu bytes not available\n", |
| 1156 | new_log_buf_len); | 1149 | new_log_buf_len); |
| @@ -2643,23 +2643,25 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, · 2642 unmodified lines | |||
| 2643 | int *valp, | 2643 | int *valp, |
| 2644 | int write, void *data) | 2644 | int write, void *data) |
| 2645 | { | 2645 | { |
| 2646 | int tmp, ret; | ||
| 2646 | struct do_proc_dointvec_minmax_conv_param *param = data; | 2647 | struct do_proc_dointvec_minmax_conv_param *param = data; |
| 2648 | /* | ||
| 2649 | * If writing, first do so via a temporary local int so we can | ||
| 2650 | * bounds-check it before touching *valp. | ||
| 2651 | */ | ||
| 2652 | int *ip = write ? &tmp : valp; | ||
| 2653 | |||
| 2654 | ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data); | ||
| 2655 | if (ret) | ||
| 2656 | return ret; | ||
| 2657 | |||
| 2647 | if (write) { | 2658 | if (write) { |
| 2648 | int val = *negp ? -*lvalp : *lvalp; | 2659 | if ((param->min && *param->min > tmp) || |
| 2649 | if ((param->min && *param->min > val) || | 2660 | (param->max && *param->max < tmp)) |
| 2650 | (param->max && *param->max < val)) | ||
| 2651 | return -EINVAL; | 2661 | return -EINVAL; |
| 2652 | *valp = val; | 2662 | *valp = tmp; |
| 2653 | } else { | ||
| 2654 | int val = *valp; | ||
| 2655 | if (val < 0) { | ||
| 2656 | *negp = true; | ||
| 2657 | *lvalp = -(unsigned long)val; | ||
| 2658 | } else { | ||
| 2659 | *negp = false; | ||
| 2660 | *lvalp = (unsigned long)val; | ||
| 2661 | } | ||
| 2662 | } | 2663 | } |
| 2664 | |||
| 2663 | return 0; | 2665 | return 0; |
| 2664 | } | 2666 | } |
| 2665 | 2667 | ||
| @@ -2708,22 +2710,22 @@ static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, · 42 unmodified lines | |||
| 2708 | unsigned int *valp, | 2710 | unsigned int *valp, |
| 2709 | int write, void *data) | 2711 | int write, void *data) |
| 2710 | { | 2712 | { |
| 2713 | int ret; | ||
| 2714 | unsigned int tmp; | ||
| 2711 | struct do_proc_douintvec_minmax_conv_param *param = data; | 2715 | struct do_proc_douintvec_minmax_conv_param *param = data; |
| 2716 | /* write via temporary local uint for bounds-checking */ | ||
| 2717 | unsigned int *up = write ? &tmp : valp; | ||
| 2712 | 2718 | ||
| 2713 | if (write) { | 2719 | ret = do_proc_douintvec_conv(lvalp, up, write, data); |
| 2714 | unsigned int val = *lvalp; | 2720 | if (ret) |
| 2715 | 2721 | return ret; | |
| 2716 | if (*lvalp > UINT_MAX) | ||
| 2717 | return -EINVAL; | ||
| 2718 | 2722 | ||
| 2719 | if ((param->min && *param->min > val) || | 2723 | if (write) { |
| 2720 | (param->max && *param->max < val)) | 2724 | if ((param->min && *param->min > tmp) || |
| 2725 | (param->max && *param->max < tmp)) | ||
| 2721 | return -ERANGE; | 2726 | return -ERANGE; |
| 2722 | 2727 | ||
| 2723 | *valp = val; | 2728 | *valp = tmp; |
| 2724 | } else { | ||
| 2725 | unsigned int val = *valp; | ||
| 2726 | *lvalp = (unsigned long) val; | ||
| 2727 | } | 2729 | } |
| 2728 | 2730 | ||
| 2729 | return 0; | 2731 | return 0; |