History

Merge branch 'akpm' (patches from Andrew)

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() ...

Linus Torvalds committed 7 years ago

Commit a667cb72 parents cb1d150 586187d159 files · +1651 −1707Browse files

Showing the changes to kernel (4 of 159 files). Show all

Unified · Split

4 files
  1. kernel/dma/swiotlb.c +14 −7
  2. kernel/power/snapshot.c +3 −0
  3. kernel/printk/printk.c +1 −8
  4. kernel/sysctl.c +26 −24
kernel/dma/swiotlb.c+14−7
@@ -199,6 +199,7 @@ void __init swiotlb_update_mem_attributes(void) · 198 unmodified lines
199199 int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose)
200200 {
201201 unsigned long i, bytes;
202+ size_t alloc_size;
202203
203204 bytes = nslabs << IO_TLB_SHIFT;
204205
@@ -211,12 +212,18 @@ int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int verbose) · 6 unmodified lines
211212 * to find contiguous free memory regions of size up to IO_TLB_SEGSIZE
212213 * between io_tlb_start and io_tlb_end.
213214 */
214− io_tlb_list = memblock_alloc(
215− PAGE_ALIGN(io_tlb_nslabs * sizeof(int)),
216− PAGE_SIZE);
217− io_tlb_orig_addr = memblock_alloc(
218− PAGE_ALIGN(io_tlb_nslabs * sizeof(phys_addr_t)),
219− PAGE_SIZE);
215+ alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(int));
216+ io_tlb_list = memblock_alloc(alloc_size, PAGE_SIZE);
217+ if (!io_tlb_list)
218+ panic("%s: Failed to allocate %zu bytes align=0x%lx\n",
219+ __func__, alloc_size, 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+
220227 for (i = 0; i < io_tlb_nslabs; i++) {
221228 io_tlb_list[i] = IO_TLB_SEGSIZE - OFFSET(i, IO_TLB_SEGSIZE);
222229 io_tlb_orig_addr[i] = INVALID_PHYS_ADDR;
@@ -249,7 +256,7 @@ swiotlb_init(int verbose) · 26 unmodified lines
249256 bytes = io_tlb_nslabs << IO_TLB_SHIFT;
250257
251258 /* 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);
253260 if (vstart && !swiotlb_init_with_tbl(vstart, io_tlb_nslabs, verbose))
254261 return;
255262
kernel/power/snapshot.c+3−0
@@ -965,6 +965,9 @@ void __init __register_nosave_region(unsigned long start_pfn, · 964 unmodified lines
965965 /* This allocation cannot fail */
966966 region = memblock_alloc(sizeof(struct nosave_region),
967967 SMP_CACHE_BYTES);
968+ if (!region)
969+ panic("%s: Failed to allocate %zu bytes\n", __func__,
970+ sizeof(struct nosave_region));
968971 }
969972 region->start_pfn = start_pfn;
970973 region->end_pfn = end_pfn;
kernel/printk/printk.c+1−8
@@ -1143,14 +1143,7 @@ void __init setup_log_buf(int early) · 1142 unmodified lines
11431143 if (!new_log_buf_len)
11441144 return;
11451145
1146− if (early) {
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−
1146+ new_log_buf = memblock_alloc(new_log_buf_len, LOG_ALIGN);
11541147 if (unlikely(!new_log_buf)) {
11551148 pr_err("log_buf_len: %lu bytes not available\n",
11561149 new_log_buf_len);
kernel/sysctl.c+26−24
@@ -2643,23 +2643,25 @@ static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp, · 2642 unmodified lines
26432643 int *valp,
26442644 int write, void *data)
26452645 {
2646+ int tmp, ret;
26462647 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+
26472658 if (write) {
2648− int val = *negp ? -*lvalp : *lvalp;
2649− if ((param->min && *param->min > val) ||
2650− (param->max && *param->max < val))
2659+ if ((param->min && *param->min > tmp) ||
2660+ (param->max && *param->max < tmp))
26512661 return -EINVAL;
2652− *valp = val;
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+ *valp = tmp;
26622663 }
2664+
26632665 return 0;
26642666 }
26652667
@@ -2708,22 +2710,22 @@ static int do_proc_douintvec_minmax_conv(unsigned long *lvalp, · 42 unmodified lines
27082710 unsigned int *valp,
27092711 int write, void *data)
27102712 {
2713+ int ret;
2714+ unsigned int tmp;
27112715 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;
27122718
2713− if (write) {
2714− unsigned int val = *lvalp;
2715−
2716− if (*lvalp > UINT_MAX)
2717− return -EINVAL;
2719+ ret = do_proc_douintvec_conv(lvalp, up, write, data);
2720+ if (ret)
2721+ return ret;
27182722
2719− if ((param->min && *param->min > val) ||
2720− (param->max && *param->max < val))
2723+ if (write) {
2724+ if ((param->min && *param->min > tmp) ||
2725+ (param->max && *param->max < tmp))
27212726 return -ERANGE;
27222727
2723− *valp = val;
2724− } else {
2725− unsigned int val = *valp;
2726− *lvalp = (unsigned long) val;
2728+ *valp = tmp;
27272729 }
27282730
27292731 return 0;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t