Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0375-4.9.276-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3677 - (show annotations) (download)
Mon Oct 24 14:07:54 2022 UTC (18 months ago) by niro
File size: 206393 byte(s)
-linux-4.9.276
1 diff --git a/Makefile b/Makefile
2 index dfd253648758c..0668843d7b3e6 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 275
9 +SUBLEVEL = 276
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/arch/arm/boot/dts/am335x-cm-t335.dts b/arch/arm/boot/dts/am335x-cm-t335.dts
14 index 947c81b7aaafb..56a04d3086c32 100644
15 --- a/arch/arm/boot/dts/am335x-cm-t335.dts
16 +++ b/arch/arm/boot/dts/am335x-cm-t335.dts
17 @@ -552,7 +552,7 @@ status = "okay";
18 status = "okay";
19 pinctrl-names = "default";
20 pinctrl-0 = <&spi0_pins>;
21 - ti,pindir-d0-out-d1-in = <1>;
22 + ti,pindir-d0-out-d1-in;
23 /* WLS1271 WiFi */
24 wlcore: wlcore@1 {
25 compatible = "ti,wl1271";
26 diff --git a/arch/arm/boot/dts/exynos5422-odroidxu4.dts b/arch/arm/boot/dts/exynos5422-odroidxu4.dts
27 index 2faf88627a489..b45e2a0c3908e 100644
28 --- a/arch/arm/boot/dts/exynos5422-odroidxu4.dts
29 +++ b/arch/arm/boot/dts/exynos5422-odroidxu4.dts
30 @@ -26,7 +26,7 @@
31 label = "blue:heartbeat";
32 pwms = <&pwm 2 2000000 0>;
33 pwm-names = "pwm2";
34 - max_brightness = <255>;
35 + max-brightness = <255>;
36 linux,default-trigger = "heartbeat";
37 };
38 };
39 diff --git a/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi b/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
40 index 0ed30206625c4..f547f67f27833 100644
41 --- a/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
42 +++ b/arch/arm/boot/dts/exynos54xx-odroidxu-leds.dtsi
43 @@ -25,7 +25,7 @@
44 * Green LED is much brighter than the others
45 * so limit its max brightness
46 */
47 - max_brightness = <127>;
48 + max-brightness = <127>;
49 linux,default-trigger = "mmc0";
50 };
51
52 @@ -33,7 +33,7 @@
53 label = "blue:heartbeat";
54 pwms = <&pwm 2 2000000 0>;
55 pwm-names = "pwm2";
56 - max_brightness = <255>;
57 + max-brightness = <255>;
58 linux,default-trigger = "heartbeat";
59 };
60 };
61 diff --git a/arch/arm/boot/dts/r8a7779-marzen.dts b/arch/arm/boot/dts/r8a7779-marzen.dts
62 index 541678df90a98..50ec24bb1d79f 100644
63 --- a/arch/arm/boot/dts/r8a7779-marzen.dts
64 +++ b/arch/arm/boot/dts/r8a7779-marzen.dts
65 @@ -136,7 +136,7 @@
66 status = "okay";
67
68 clocks = <&mstp1_clks R8A7779_CLK_DU>, <&x3_clk>;
69 - clock-names = "du", "dclkin.0";
70 + clock-names = "du.0", "dclkin.0";
71
72 ports {
73 port@0 {
74 diff --git a/arch/arm/boot/dts/r8a7779.dtsi b/arch/arm/boot/dts/r8a7779.dtsi
75 index 6c6d4893e92d4..3fb0a8d2530bd 100644
76 --- a/arch/arm/boot/dts/r8a7779.dtsi
77 +++ b/arch/arm/boot/dts/r8a7779.dtsi
78 @@ -431,6 +431,7 @@
79 reg = <0 0xfff80000 0 0x40000>;
80 interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
81 clocks = <&mstp1_clks R8A7779_CLK_DU>;
82 + clock-names = "du.0";
83 power-domains = <&sysc R8A7779_PD_ALWAYS_ON>;
84 status = "disabled";
85
86 diff --git a/arch/arm/boot/dts/sama5d4.dtsi b/arch/arm/boot/dts/sama5d4.dtsi
87 index de0e189711f6e..8c94bf57a38cf 100644
88 --- a/arch/arm/boot/dts/sama5d4.dtsi
89 +++ b/arch/arm/boot/dts/sama5d4.dtsi
90 @@ -1371,7 +1371,7 @@
91 0xffffffff 0x3ffcfe7c 0x1c010101 /* pioA */
92 0x7fffffff 0xfffccc3a 0x3f00cc3a /* pioB */
93 0xffffffff 0x3ff83fff 0xff00ffff /* pioC */
94 - 0x0003ff00 0x8002a800 0x00000000 /* pioD */
95 + 0xb003ff00 0x8002a800 0x00000000 /* pioD */
96 0xffffffff 0x7fffffff 0x76fff1bf /* pioE */
97 >;
98
99 diff --git a/arch/arm/probes/kprobes/test-thumb.c b/arch/arm/probes/kprobes/test-thumb.c
100 index b683b4517458c..4254391f39064 100644
101 --- a/arch/arm/probes/kprobes/test-thumb.c
102 +++ b/arch/arm/probes/kprobes/test-thumb.c
103 @@ -444,21 +444,21 @@ void kprobe_thumb32_test_cases(void)
104 "3: mvn r0, r0 \n\t"
105 "2: nop \n\t")
106
107 - TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,"]",
108 + TEST_RX("tbh [pc, r",7, (9f-(1f+4))>>1,", lsl #1]",
109 "9: \n\t"
110 ".short (2f-1b-4)>>1 \n\t"
111 ".short (3f-1b-4)>>1 \n\t"
112 "3: mvn r0, r0 \n\t"
113 "2: nop \n\t")
114
115 - TEST_RX("tbh [pc, r",12, ((9f-(1f+4))>>1)+1,"]",
116 + TEST_RX("tbh [pc, r",12, ((9f-(1f+4))>>1)+1,", lsl #1]",
117 "9: \n\t"
118 ".short (2f-1b-4)>>1 \n\t"
119 ".short (3f-1b-4)>>1 \n\t"
120 "3: mvn r0, r0 \n\t"
121 "2: nop \n\t")
122
123 - TEST_RRX("tbh [r",1,9f, ", r",14,1,"]",
124 + TEST_RRX("tbh [r",1,9f, ", r",14,1,", lsl #1]",
125 "9: \n\t"
126 ".short (2f-1b-4)>>1 \n\t"
127 ".short (3f-1b-4)>>1 \n\t"
128 @@ -471,10 +471,10 @@ void kprobe_thumb32_test_cases(void)
129
130 TEST_UNSUPPORTED("strexb r0, r1, [r2]")
131 TEST_UNSUPPORTED("strexh r0, r1, [r2]")
132 - TEST_UNSUPPORTED("strexd r0, r1, [r2]")
133 + TEST_UNSUPPORTED("strexd r0, r1, r2, [r2]")
134 TEST_UNSUPPORTED("ldrexb r0, [r1]")
135 TEST_UNSUPPORTED("ldrexh r0, [r1]")
136 - TEST_UNSUPPORTED("ldrexd r0, [r1]")
137 + TEST_UNSUPPORTED("ldrexd r0, r1, [r1]")
138
139 TEST_GROUP("Data-processing (shifted register) and (modified immediate)")
140
141 diff --git a/arch/hexagon/kernel/vmlinux.lds.S b/arch/hexagon/kernel/vmlinux.lds.S
142 index ec87e67feb19e..22c10102712a5 100644
143 --- a/arch/hexagon/kernel/vmlinux.lds.S
144 +++ b/arch/hexagon/kernel/vmlinux.lds.S
145 @@ -71,13 +71,8 @@ SECTIONS
146
147 _end = .;
148
149 - /DISCARD/ : {
150 - EXIT_TEXT
151 - EXIT_DATA
152 - EXIT_CALL
153 - }
154 -
155 STABS_DEBUG
156 DWARF_DEBUG
157
158 + DISCARDS
159 }
160 diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c
161 index 94f8bf777afa6..3503d488e9b3f 100644
162 --- a/arch/ia64/kernel/mca_drv.c
163 +++ b/arch/ia64/kernel/mca_drv.c
164 @@ -343,7 +343,7 @@ init_record_index_pools(void)
165
166 /* - 2 - */
167 sect_min_size = sal_log_sect_min_sizes[0];
168 - for (i = 1; i < sizeof sal_log_sect_min_sizes/sizeof(size_t); i++)
169 + for (i = 1; i < ARRAY_SIZE(sal_log_sect_min_sizes); i++)
170 if (sect_min_size > sal_log_sect_min_sizes[i])
171 sect_min_size = sal_log_sect_min_sizes[i];
172
173 diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
174 index 0fa91c981658e..3e93eea5a5f50 100644
175 --- a/arch/mips/boot/compressed/Makefile
176 +++ b/arch/mips/boot/compressed/Makefile
177 @@ -33,7 +33,7 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \
178 KCOV_INSTRUMENT := n
179
180 # decompressor objects (linked with vmlinuz)
181 -vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o
182 +vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/bswapsi.o
183
184 ifdef CONFIG_DEBUG_ZBOOT
185 vmlinuzobjs-$(CONFIG_DEBUG_ZBOOT) += $(obj)/dbg.o
186 @@ -47,7 +47,7 @@ extra-y += uart-ath79.c
187 $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
188 $(call cmd,shipped)
189
190 -vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
191 +vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o
192
193 extra-y += ashldi3.c bswapsi.c
194 $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
195 diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c
196 index 3a015e41b762b..66096c766a60d 100644
197 --- a/arch/mips/boot/compressed/decompress.c
198 +++ b/arch/mips/boot/compressed/decompress.c
199 @@ -11,6 +11,8 @@
200 * option) any later version.
201 */
202
203 +#define DISABLE_BRANCH_PROFILING
204 +
205 #include <linux/types.h>
206 #include <linux/kernel.h>
207 #include <linux/string.h>
208 diff --git a/arch/mips/include/asm/hugetlb.h b/arch/mips/include/asm/hugetlb.h
209 index 982bc06853302..4747a46946699 100644
210 --- a/arch/mips/include/asm/hugetlb.h
211 +++ b/arch/mips/include/asm/hugetlb.h
212 @@ -67,7 +67,13 @@ static inline pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
213 static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,
214 unsigned long addr, pte_t *ptep)
215 {
216 - flush_tlb_page(vma, addr & huge_page_mask(hstate_vma(vma)));
217 + /*
218 + * clear the huge pte entry firstly, so that the other smp threads will
219 + * not get old pte entry after finishing flush_tlb_page and before
220 + * setting new huge pte entry
221 + */
222 + huge_ptep_get_and_clear(vma->vm_mm, addr, ptep);
223 + flush_tlb_page(vma, addr);
224 }
225
226 static inline int huge_pte_none(pte_t pte)
227 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
228 index a03e86969f78a..ff982d8b62f6e 100644
229 --- a/arch/mips/include/asm/pgalloc.h
230 +++ b/arch/mips/include/asm/pgalloc.h
231 @@ -107,11 +107,15 @@ do { \
232
233 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
234 {
235 - pmd_t *pmd;
236 + pmd_t *pmd = NULL;
237 + struct page *pg;
238
239 - pmd = (pmd_t *) __get_free_pages(GFP_KERNEL, PMD_ORDER);
240 - if (pmd)
241 + pg = alloc_pages(GFP_KERNEL | __GFP_ACCOUNT, PMD_ORDER);
242 + if (pg) {
243 + pgtable_pmd_page_ctor(pg);
244 + pmd = (pmd_t *)page_address(pg);
245 pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
246 + }
247 return pmd;
248 }
249
250 diff --git a/arch/mips/vdso/vdso.h b/arch/mips/vdso/vdso.h
251 index cfb1be441decc..921589b45bc20 100644
252 --- a/arch/mips/vdso/vdso.h
253 +++ b/arch/mips/vdso/vdso.h
254 @@ -81,7 +81,7 @@ static inline const union mips_vdso_data *get_vdso_data(void)
255
256 static inline void __iomem *get_gic(const union mips_vdso_data *data)
257 {
258 - return (void __iomem *)data - PAGE_SIZE;
259 + return (void __iomem *)((unsigned long)data & PAGE_MASK) - PAGE_SIZE;
260 }
261
262 #endif /* CONFIG_CLKSRC_MIPS_GIC */
263 diff --git a/arch/powerpc/boot/devtree.c b/arch/powerpc/boot/devtree.c
264 index a7e21a35c03af..27c84b82b588e 100644
265 --- a/arch/powerpc/boot/devtree.c
266 +++ b/arch/powerpc/boot/devtree.c
267 @@ -17,6 +17,7 @@
268 #include "string.h"
269 #include "stdio.h"
270 #include "ops.h"
271 +#include "of.h"
272
273 void dt_fixup_memory(u64 start, u64 size)
274 {
275 @@ -27,21 +28,25 @@ void dt_fixup_memory(u64 start, u64 size)
276 root = finddevice("/");
277 if (getprop(root, "#address-cells", &naddr, sizeof(naddr)) < 0)
278 naddr = 2;
279 + else
280 + naddr = be32_to_cpu(naddr);
281 if (naddr < 1 || naddr > 2)
282 fatal("Can't cope with #address-cells == %d in /\n\r", naddr);
283
284 if (getprop(root, "#size-cells", &nsize, sizeof(nsize)) < 0)
285 nsize = 1;
286 + else
287 + nsize = be32_to_cpu(nsize);
288 if (nsize < 1 || nsize > 2)
289 fatal("Can't cope with #size-cells == %d in /\n\r", nsize);
290
291 i = 0;
292 if (naddr == 2)
293 - memreg[i++] = start >> 32;
294 - memreg[i++] = start & 0xffffffff;
295 + memreg[i++] = cpu_to_be32(start >> 32);
296 + memreg[i++] = cpu_to_be32(start & 0xffffffff);
297 if (nsize == 2)
298 - memreg[i++] = size >> 32;
299 - memreg[i++] = size & 0xffffffff;
300 + memreg[i++] = cpu_to_be32(size >> 32);
301 + memreg[i++] = cpu_to_be32(size & 0xffffffff);
302
303 memory = finddevice("/memory");
304 if (! memory) {
305 @@ -49,9 +54,9 @@ void dt_fixup_memory(u64 start, u64 size)
306 setprop_str(memory, "device_type", "memory");
307 }
308
309 - printf("Memory <- <0x%x", memreg[0]);
310 + printf("Memory <- <0x%x", be32_to_cpu(memreg[0]));
311 for (i = 1; i < (naddr + nsize); i++)
312 - printf(" 0x%x", memreg[i]);
313 + printf(" 0x%x", be32_to_cpu(memreg[i]));
314 printf("> (%ldMB)\n\r", (unsigned long)(size >> 20));
315
316 setprop(memory, "reg", memreg, (naddr + nsize)*sizeof(u32));
317 @@ -69,10 +74,10 @@ void dt_fixup_cpu_clocks(u32 cpu, u32 tb, u32 bus)
318 printf("CPU bus-frequency <- 0x%x (%dMHz)\n\r", bus, MHZ(bus));
319
320 while ((devp = find_node_by_devtype(devp, "cpu"))) {
321 - setprop_val(devp, "clock-frequency", cpu);
322 - setprop_val(devp, "timebase-frequency", tb);
323 + setprop_val(devp, "clock-frequency", cpu_to_be32(cpu));
324 + setprop_val(devp, "timebase-frequency", cpu_to_be32(tb));
325 if (bus > 0)
326 - setprop_val(devp, "bus-frequency", bus);
327 + setprop_val(devp, "bus-frequency", cpu_to_be32(bus));
328 }
329
330 timebase_period_ns = 1000000000 / tb;
331 @@ -84,7 +89,7 @@ void dt_fixup_clock(const char *path, u32 freq)
332
333 if (devp) {
334 printf("%s: clock-frequency <- %x (%dMHz)\n\r", path, freq, MHZ(freq));
335 - setprop_val(devp, "clock-frequency", freq);
336 + setprop_val(devp, "clock-frequency", cpu_to_be32(freq));
337 }
338 }
339
340 @@ -137,8 +142,12 @@ void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize)
341 {
342 if (getprop(node, "#address-cells", naddr, 4) != 4)
343 *naddr = 2;
344 + else
345 + *naddr = be32_to_cpu(*naddr);
346 if (getprop(node, "#size-cells", nsize, 4) != 4)
347 *nsize = 1;
348 + else
349 + *nsize = be32_to_cpu(*nsize);
350 }
351
352 static void copy_val(u32 *dest, u32 *src, int naddr)
353 @@ -167,9 +176,9 @@ static int add_reg(u32 *reg, u32 *add, int naddr)
354 int i, carry = 0;
355
356 for (i = MAX_ADDR_CELLS - 1; i >= MAX_ADDR_CELLS - naddr; i--) {
357 - u64 tmp = (u64)reg[i] + add[i] + carry;
358 + u64 tmp = (u64)be32_to_cpu(reg[i]) + be32_to_cpu(add[i]) + carry;
359 carry = tmp >> 32;
360 - reg[i] = (u32)tmp;
361 + reg[i] = cpu_to_be32((u32)tmp);
362 }
363
364 return !carry;
365 @@ -184,18 +193,18 @@ static int compare_reg(u32 *reg, u32 *range, u32 *rangesize)
366 u32 end;
367
368 for (i = 0; i < MAX_ADDR_CELLS; i++) {
369 - if (reg[i] < range[i])
370 + if (be32_to_cpu(reg[i]) < be32_to_cpu(range[i]))
371 return 0;
372 - if (reg[i] > range[i])
373 + if (be32_to_cpu(reg[i]) > be32_to_cpu(range[i]))
374 break;
375 }
376
377 for (i = 0; i < MAX_ADDR_CELLS; i++) {
378 - end = range[i] + rangesize[i];
379 + end = be32_to_cpu(range[i]) + be32_to_cpu(rangesize[i]);
380
381 - if (reg[i] < end)
382 + if (be32_to_cpu(reg[i]) < end)
383 break;
384 - if (reg[i] > end)
385 + if (be32_to_cpu(reg[i]) > end)
386 return 0;
387 }
388
389 @@ -244,7 +253,6 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
390 return 0;
391
392 dt_get_reg_format(parent, &naddr, &nsize);
393 -
394 if (nsize > 2)
395 return 0;
396
397 @@ -256,10 +264,10 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
398
399 copy_val(last_addr, prop_buf + offset, naddr);
400
401 - ret_size = prop_buf[offset + naddr];
402 + ret_size = be32_to_cpu(prop_buf[offset + naddr]);
403 if (nsize == 2) {
404 ret_size <<= 32;
405 - ret_size |= prop_buf[offset + naddr + 1];
406 + ret_size |= be32_to_cpu(prop_buf[offset + naddr + 1]);
407 }
408
409 for (;;) {
410 @@ -282,7 +290,6 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
411
412 offset = find_range(last_addr, prop_buf, prev_naddr,
413 naddr, prev_nsize, buflen / 4);
414 -
415 if (offset < 0)
416 return 0;
417
418 @@ -300,8 +307,7 @@ static int dt_xlate(void *node, int res, int reglen, unsigned long *addr,
419 if (naddr > 2)
420 return 0;
421
422 - ret_addr = ((u64)last_addr[2] << 32) | last_addr[3];
423 -
424 + ret_addr = ((u64)be32_to_cpu(last_addr[2]) << 32) | be32_to_cpu(last_addr[3]);
425 if (sizeof(void *) == 4 &&
426 (ret_addr >= 0x100000000ULL || ret_size > 0x100000000ULL ||
427 ret_addr + ret_size > 0x100000000ULL))
428 @@ -354,11 +360,14 @@ int dt_is_compatible(void *node, const char *compat)
429 int dt_get_virtual_reg(void *node, void **addr, int nres)
430 {
431 unsigned long xaddr;
432 - int n;
433 + int n, i;
434
435 n = getprop(node, "virtual-reg", addr, nres * 4);
436 - if (n > 0)
437 + if (n > 0) {
438 + for (i = 0; i < n/4; i ++)
439 + ((u32 *)addr)[i] = be32_to_cpu(((u32 *)addr)[i]);
440 return n / 4;
441 + }
442
443 for (n = 0; n < nres; n++) {
444 if (!dt_xlate_reg(node, n, &xaddr, NULL))
445 diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
446 index 8c9ead94be06f..cea34a20085c0 100644
447 --- a/arch/powerpc/boot/ns16550.c
448 +++ b/arch/powerpc/boot/ns16550.c
449 @@ -14,6 +14,7 @@
450 #include "stdio.h"
451 #include "io.h"
452 #include "ops.h"
453 +#include "of.h"
454
455 #define UART_DLL 0 /* Out: Divisor Latch Low */
456 #define UART_DLM 1 /* Out: Divisor Latch High */
457 @@ -57,16 +58,20 @@ int ns16550_console_init(void *devp, struct serial_console_data *scdp)
458 int n;
459 u32 reg_offset;
460
461 - if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1)
462 + if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1) {
463 + printf("virt reg parse fail...\r\n");
464 return -1;
465 + }
466
467 n = getprop(devp, "reg-offset", &reg_offset, sizeof(reg_offset));
468 if (n == sizeof(reg_offset))
469 - reg_base += reg_offset;
470 + reg_base += be32_to_cpu(reg_offset);
471
472 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
473 if (n != sizeof(reg_shift))
474 reg_shift = 0;
475 + else
476 + reg_shift = be32_to_cpu(reg_shift);
477
478 scdp->open = ns16550_open;
479 scdp->putc = ns16550_putc;
480 diff --git a/arch/powerpc/include/asm/barrier.h b/arch/powerpc/include/asm/barrier.h
481 index 80024c4f2093c..0dbdf88162b7b 100644
482 --- a/arch/powerpc/include/asm/barrier.h
483 +++ b/arch/powerpc/include/asm/barrier.h
484 @@ -41,6 +41,8 @@
485 # define SMPWMB eieio
486 #endif
487
488 +/* clang defines this macro for a builtin, which will not work with runtime patching */
489 +#undef __lwsync
490 #define __lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : :"memory")
491 #define dma_rmb() __lwsync()
492 #define dma_wmb() __asm__ __volatile__ (stringify_in_c(SMPWMB) : : :"memory")
493 diff --git a/arch/powerpc/include/asm/ps3.h b/arch/powerpc/include/asm/ps3.h
494 index a19f831a4cc9a..83a6d99e9994e 100644
495 --- a/arch/powerpc/include/asm/ps3.h
496 +++ b/arch/powerpc/include/asm/ps3.h
497 @@ -83,6 +83,7 @@ struct ps3_dma_region_ops;
498 * @bus_addr: The 'translated' bus address of the region.
499 * @len: The length in bytes of the region.
500 * @offset: The offset from the start of memory of the region.
501 + * @dma_mask: Device dma_mask.
502 * @ioid: The IOID of the device who owns this region
503 * @chunk_list: Opaque variable used by the ioc page manager.
504 * @region_ops: struct ps3_dma_region_ops - dma region operations
505 @@ -97,6 +98,7 @@ struct ps3_dma_region {
506 enum ps3_dma_region_type region_type;
507 unsigned long len;
508 unsigned long offset;
509 + u64 dma_mask;
510
511 /* driver variables (set by ps3_dma_region_create) */
512 unsigned long bus_addr;
513 diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
514 index 19bae78b1f25b..76cbf1be9962b 100644
515 --- a/arch/powerpc/platforms/ps3/mm.c
516 +++ b/arch/powerpc/platforms/ps3/mm.c
517 @@ -18,6 +18,7 @@
518 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
519 */
520
521 +#include <linux/dma-mapping.h>
522 #include <linux/kernel.h>
523 #include <linux/export.h>
524 #include <linux/memblock.h>
525 @@ -1132,6 +1133,7 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
526 enum ps3_dma_region_type region_type, void *addr, unsigned long len)
527 {
528 unsigned long lpar_addr;
529 + int result;
530
531 lpar_addr = addr ? ps3_mm_phys_to_lpar(__pa(addr)) : 0;
532
533 @@ -1143,6 +1145,16 @@ int ps3_dma_region_init(struct ps3_system_bus_device *dev,
534 r->offset -= map.r1.offset;
535 r->len = len ? len : _ALIGN_UP(map.total, 1 << r->page_size);
536
537 + dev->core.dma_mask = &r->dma_mask;
538 +
539 + result = dma_set_mask_and_coherent(&dev->core, DMA_BIT_MASK(32));
540 +
541 + if (result < 0) {
542 + dev_err(&dev->core, "%s:%d: dma_set_mask_and_coherent failed: %d\n",
543 + __func__, __LINE__, result);
544 + return result;
545 + }
546 +
547 switch (dev->dev_type) {
548 case PS3_DEVICE_TYPE_SB:
549 r->region_ops = (USE_DYNAMIC_DMA)
550 diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
551 index 1c4a595e8224d..1dff52abc7863 100644
552 --- a/arch/s390/Kconfig
553 +++ b/arch/s390/Kconfig
554 @@ -833,7 +833,7 @@ config CMM_IUCV
555 config APPLDATA_BASE
556 def_bool n
557 prompt "Linux - VM Monitor Stream, base infrastructure"
558 - depends on PROC_FS
559 + depends on PROC_SYSCTL
560 help
561 This provides a kernel interface for creating and updating z/VM APPLDATA
562 monitor records. The monitor records are updated at certain time
563 diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
564 index ce49c2b9db7ee..9939879f5f253 100644
565 --- a/arch/s390/kernel/setup.c
566 +++ b/arch/s390/kernel/setup.c
567 @@ -137,7 +137,7 @@ static void __init set_preferred_console(void)
568 else if (CONSOLE_IS_3270)
569 add_preferred_console("tty3270", 0, NULL);
570 else if (CONSOLE_IS_VT220)
571 - add_preferred_console("ttyS", 1, NULL);
572 + add_preferred_console("ttysclp", 0, NULL);
573 else if (CONSOLE_IS_HVC)
574 add_preferred_console("hvc", 0, NULL);
575 }
576 diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
577 index 3fd7c3efdb18d..feb7f5ab40841 100644
578 --- a/arch/um/drivers/chan_user.c
579 +++ b/arch/um/drivers/chan_user.c
580 @@ -256,7 +256,8 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
581 goto out_close;
582 }
583
584 - if (os_set_fd_block(*fd_out, 0)) {
585 + err = os_set_fd_block(*fd_out, 0);
586 + if (err) {
587 printk(UM_KERN_ERR "winch_tramp: failed to set thread_fd "
588 "non-blocking.\n");
589 goto out_close;
590 diff --git a/arch/um/drivers/slip_user.c b/arch/um/drivers/slip_user.c
591 index 0d6b66c64a813..76d155631c5d7 100644
592 --- a/arch/um/drivers/slip_user.c
593 +++ b/arch/um/drivers/slip_user.c
594 @@ -145,7 +145,8 @@ static int slip_open(void *data)
595 }
596 sfd = err;
597
598 - if (set_up_tty(sfd))
599 + err = set_up_tty(sfd);
600 + if (err)
601 goto out_close2;
602
603 pri->slave = sfd;
604 diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h
605 index 21d6fa27b4a9c..ebda4718eb8f7 100644
606 --- a/arch/x86/include/asm/fpu/internal.h
607 +++ b/arch/x86/include/asm/fpu/internal.h
608 @@ -94,6 +94,7 @@ static inline void fpstate_init_fxstate(struct fxregs_state *fx)
609 }
610 extern void fpstate_sanitize_xstate(struct fpu *fpu);
611
612 +/* Returns 0 or the negated trap number, which results in -EFAULT for #PF */
613 #define user_insn(insn, output, input...) \
614 ({ \
615 int err; \
616 @@ -101,14 +102,14 @@ extern void fpstate_sanitize_xstate(struct fpu *fpu);
617 might_fault(); \
618 \
619 asm volatile(ASM_STAC "\n" \
620 - "1:" #insn "\n\t" \
621 + "1: " #insn "\n" \
622 "2: " ASM_CLAC "\n" \
623 ".section .fixup,\"ax\"\n" \
624 - "3: movl $-1,%[err]\n" \
625 + "3: negl %%eax\n" \
626 " jmp 2b\n" \
627 ".previous\n" \
628 - _ASM_EXTABLE(1b, 3b) \
629 - : [err] "=r" (err), output \
630 + _ASM_EXTABLE_FAULT(1b, 3b) \
631 + : [err] "=a" (err), output \
632 : "0"(0), input); \
633 err; \
634 })
635 @@ -227,16 +228,20 @@ static inline void copy_fxregs_to_kernel(struct fpu *fpu)
636 #define XRSTOR ".byte " REX_PREFIX "0x0f,0xae,0x2f"
637 #define XRSTORS ".byte " REX_PREFIX "0x0f,0xc7,0x1f"
638
639 +/*
640 + * After this @err contains 0 on success or the negated trap number when
641 + * the operation raises an exception. For faults this results in -EFAULT.
642 + */
643 #define XSTATE_OP(op, st, lmask, hmask, err) \
644 asm volatile("1:" op "\n\t" \
645 "xor %[err], %[err]\n" \
646 "2:\n\t" \
647 ".pushsection .fixup,\"ax\"\n\t" \
648 - "3: movl $-2,%[err]\n\t" \
649 + "3: negl %%eax\n\t" \
650 "jmp 2b\n\t" \
651 ".popsection\n\t" \
652 - _ASM_EXTABLE(1b, 3b) \
653 - : [err] "=r" (err) \
654 + _ASM_EXTABLE_FAULT(1b, 3b) \
655 + : [err] "=a" (err) \
656 : "D" (st), "m" (*st), "a" (lmask), "d" (hmask) \
657 : "memory")
658
659 diff --git a/arch/x86/kernel/fpu/regset.c b/arch/x86/kernel/fpu/regset.c
660 index 7052d9a65fe9b..e1c9e94fcce6d 100644
661 --- a/arch/x86/kernel/fpu/regset.c
662 +++ b/arch/x86/kernel/fpu/regset.c
663 @@ -123,7 +123,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
664 /*
665 * A whole standard-format XSAVE buffer is needed:
666 */
667 - if ((pos != 0) || (count < fpu_user_xstate_size))
668 + if (pos != 0 || count != fpu_user_xstate_size)
669 return -EFAULT;
670
671 xsave = &fpu->state.xsave;
672 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
673 index 63c3ff9e74d42..a6f8600672d75 100644
674 --- a/arch/x86/kvm/cpuid.c
675 +++ b/arch/x86/kvm/cpuid.c
676 @@ -633,8 +633,14 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
677 unsigned virt_as = max((entry->eax >> 8) & 0xff, 48U);
678 unsigned phys_as = entry->eax & 0xff;
679
680 - if (!g_phys_as)
681 + /*
682 + * Use bare metal's MAXPHADDR if the CPU doesn't report guest
683 + * MAXPHYADDR separately, or if TDP (NPT) is disabled, as the
684 + * guest version "applies only to guests using nested paging".
685 + */
686 + if (!g_phys_as || !tdp_enabled)
687 g_phys_as = phys_as;
688 +
689 entry->eax = g_phys_as | (virt_as << 8);
690 entry->edx = 0;
691 /*
692 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
693 index b945f362771fa..c959720c75938 100644
694 --- a/arch/x86/kvm/x86.c
695 +++ b/arch/x86/kvm/x86.c
696 @@ -7044,6 +7044,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
697 set_debugreg(vcpu->arch.eff_db[3], 3);
698 set_debugreg(vcpu->arch.dr6, 6);
699 vcpu->arch.switch_db_regs &= ~KVM_DEBUGREG_RELOAD;
700 + } else if (unlikely(hw_breakpoint_active())) {
701 + set_debugreg(0, 7);
702 }
703
704 kvm_x86_ops->run(vcpu);
705 diff --git a/crypto/shash.c b/crypto/shash.c
706 index a1c7609578eab..7eebf3cde7b7b 100644
707 --- a/crypto/shash.c
708 +++ b/crypto/shash.c
709 @@ -24,12 +24,24 @@
710
711 static const struct crypto_type crypto_shash_type;
712
713 -int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
714 - unsigned int keylen)
715 +static int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
716 + unsigned int keylen)
717 {
718 return -ENOSYS;
719 }
720 -EXPORT_SYMBOL_GPL(shash_no_setkey);
721 +
722 +/*
723 + * Check whether an shash algorithm has a setkey function.
724 + *
725 + * For CFI compatibility, this must not be an inline function. This is because
726 + * when CFI is enabled, modules won't get the same address for shash_no_setkey
727 + * (if it were exported, which inlining would require) as the core kernel will.
728 + */
729 +bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
730 +{
731 + return alg->setkey != shash_no_setkey;
732 +}
733 +EXPORT_SYMBOL_GPL(crypto_shash_alg_has_setkey);
734
735 static int shash_setkey_unaligned(struct crypto_shash *tfm, const u8 *key,
736 unsigned int keylen)
737 diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
738 index 4c5678cfa9c49..c466d7bc861ae 100644
739 --- a/drivers/acpi/Makefile
740 +++ b/drivers/acpi/Makefile
741 @@ -7,6 +7,11 @@ ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
742 #
743 # ACPI Boot-Time Table Parsing
744 #
745 +ifeq ($(CONFIG_ACPI_CUSTOM_DSDT),y)
746 +tables.o: $(src)/../../include/$(subst $\",,$(CONFIG_ACPI_CUSTOM_DSDT_FILE)) ;
747 +
748 +endif
749 +
750 obj-$(CONFIG_ACPI) += tables.o
751 obj-$(CONFIG_X86) += blacklist.o
752
753 diff --git a/drivers/acpi/acpi_amba.c b/drivers/acpi/acpi_amba.c
754 index 7f77c071709a7..eb09ee71ceb2e 100644
755 --- a/drivers/acpi/acpi_amba.c
756 +++ b/drivers/acpi/acpi_amba.c
757 @@ -70,6 +70,7 @@ static int amba_handler_attach(struct acpi_device *adev,
758 case IORESOURCE_MEM:
759 if (!address_found) {
760 dev->res = *rentry->res;
761 + dev->res.name = dev_name(&dev->dev);
762 address_found = true;
763 }
764 break;
765 diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
766 index 6b2c9d68d8107..1c13e5fe10d98 100644
767 --- a/drivers/acpi/bus.c
768 +++ b/drivers/acpi/bus.c
769 @@ -1184,6 +1184,7 @@ static int __init acpi_init(void)
770 init_acpi_device_notify();
771 result = acpi_bus_init();
772 if (result) {
773 + kobject_put(acpi_kobj);
774 disable_acpi();
775 return result;
776 }
777 diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
778 index fb610ad495f10..152ba55fd908b 100644
779 --- a/drivers/acpi/device_sysfs.c
780 +++ b/drivers/acpi/device_sysfs.c
781 @@ -452,7 +452,7 @@ static ssize_t description_show(struct device *dev,
782 (wchar_t *)acpi_dev->pnp.str_obj->buffer.pointer,
783 acpi_dev->pnp.str_obj->buffer.length,
784 UTF16_LITTLE_ENDIAN, buf,
785 - PAGE_SIZE);
786 + PAGE_SIZE - 1);
787
788 buf[result++] = '\n';
789
790 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
791 index 2237d3f24f0e7..8242e16f57c6a 100644
792 --- a/drivers/acpi/processor_idle.c
793 +++ b/drivers/acpi/processor_idle.c
794 @@ -29,6 +29,7 @@
795 #include <linux/acpi.h>
796 #include <linux/dmi.h>
797 #include <linux/sched.h> /* need_resched() */
798 +#include <linux/sort.h>
799 #include <linux/tick.h>
800 #include <linux/cpuidle.h>
801 #include <linux/cpu.h>
802 @@ -538,10 +539,37 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
803 return;
804 }
805
806 +static int acpi_cst_latency_cmp(const void *a, const void *b)
807 +{
808 + const struct acpi_processor_cx *x = a, *y = b;
809 +
810 + if (!(x->valid && y->valid))
811 + return 0;
812 + if (x->latency > y->latency)
813 + return 1;
814 + if (x->latency < y->latency)
815 + return -1;
816 + return 0;
817 +}
818 +static void acpi_cst_latency_swap(void *a, void *b, int n)
819 +{
820 + struct acpi_processor_cx *x = a, *y = b;
821 + u32 tmp;
822 +
823 + if (!(x->valid && y->valid))
824 + return;
825 + tmp = x->latency;
826 + x->latency = y->latency;
827 + y->latency = tmp;
828 +}
829 +
830 static int acpi_processor_power_verify(struct acpi_processor *pr)
831 {
832 unsigned int i;
833 unsigned int working = 0;
834 + unsigned int last_latency = 0;
835 + unsigned int last_type = 0;
836 + bool buggy_latency = false;
837
838 pr->power.timer_broadcast_on_state = INT_MAX;
839
840 @@ -565,12 +593,24 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
841 }
842 if (!cx->valid)
843 continue;
844 + if (cx->type >= last_type && cx->latency < last_latency)
845 + buggy_latency = true;
846 + last_latency = cx->latency;
847 + last_type = cx->type;
848
849 lapic_timer_check_state(i, pr, cx);
850 tsc_check_state(cx->type);
851 working++;
852 }
853
854 + if (buggy_latency) {
855 + pr_notice("FW issue: working around C-state latencies out of order\n");
856 + sort(&pr->power.states[1], max_cstate,
857 + sizeof(struct acpi_processor_cx),
858 + acpi_cst_latency_cmp,
859 + acpi_cst_latency_swap);
860 + }
861 +
862 lapic_timer_propagate_broadcast(pr);
863
864 return (working);
865 diff --git a/drivers/ata/ahci_sunxi.c b/drivers/ata/ahci_sunxi.c
866 index b26437430163e..98b4f0d898d64 100644
867 --- a/drivers/ata/ahci_sunxi.c
868 +++ b/drivers/ata/ahci_sunxi.c
869 @@ -165,7 +165,7 @@ static void ahci_sunxi_start_engine(struct ata_port *ap)
870 }
871
872 static const struct ata_port_info ahci_sunxi_port_info = {
873 - .flags = AHCI_FLAG_COMMON | ATA_FLAG_NCQ,
874 + .flags = AHCI_FLAG_COMMON | ATA_FLAG_NCQ | ATA_FLAG_NO_DIPM,
875 .pio_mask = ATA_PIO4,
876 .udma_mask = ATA_UDMA6,
877 .port_ops = &ahci_platform_ops,
878 diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c
879 index 634c814cbeda4..ebdd2dfabbebc 100644
880 --- a/drivers/ata/pata_ep93xx.c
881 +++ b/drivers/ata/pata_ep93xx.c
882 @@ -927,7 +927,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev)
883 /* INT[3] (IRQ_EP93XX_EXT3) line connected as pull down */
884 irq = platform_get_irq(pdev, 0);
885 if (irq < 0) {
886 - err = -ENXIO;
887 + err = irq;
888 goto err_rel_gpio;
889 }
890
891 diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
892 index 475a006694273..7e6359e32ab63 100644
893 --- a/drivers/ata/pata_octeon_cf.c
894 +++ b/drivers/ata/pata_octeon_cf.c
895 @@ -908,10 +908,11 @@ static int octeon_cf_probe(struct platform_device *pdev)
896 return -EINVAL;
897 }
898
899 - irq_handler = octeon_cf_interrupt;
900 i = platform_get_irq(dma_dev, 0);
901 - if (i > 0)
902 + if (i > 0) {
903 irq = i;
904 + irq_handler = octeon_cf_interrupt;
905 + }
906 }
907 of_node_put(dma_node);
908 }
909 diff --git a/drivers/ata/pata_rb532_cf.c b/drivers/ata/pata_rb532_cf.c
910 index c8b6a780a2905..76c550e160f6e 100644
911 --- a/drivers/ata/pata_rb532_cf.c
912 +++ b/drivers/ata/pata_rb532_cf.c
913 @@ -120,10 +120,12 @@ static int rb532_pata_driver_probe(struct platform_device *pdev)
914 }
915
916 irq = platform_get_irq(pdev, 0);
917 - if (irq <= 0) {
918 + if (irq < 0) {
919 dev_err(&pdev->dev, "no IRQ resource found\n");
920 - return -ENOENT;
921 + return irq;
922 }
923 + if (!irq)
924 + return -EINVAL;
925
926 pdata = dev_get_platdata(&pdev->dev);
927 if (!pdata) {
928 diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
929 index aafb8cc035232..13f339f07f2a5 100644
930 --- a/drivers/ata/sata_highbank.c
931 +++ b/drivers/ata/sata_highbank.c
932 @@ -483,10 +483,12 @@ static int ahci_highbank_probe(struct platform_device *pdev)
933 }
934
935 irq = platform_get_irq(pdev, 0);
936 - if (irq <= 0) {
937 + if (irq < 0) {
938 dev_err(dev, "no irq\n");
939 - return -EINVAL;
940 + return irq;
941 }
942 + if (!irq)
943 + return -EINVAL;
944
945 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
946 if (!hpriv) {
947 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
948 index fe47c924dc642..a1427cb9b9ed1 100644
949 --- a/drivers/atm/iphase.c
950 +++ b/drivers/atm/iphase.c
951 @@ -3301,7 +3301,7 @@ static void __exit ia_module_exit(void)
952 {
953 pci_unregister_driver(&ia_driver);
954
955 - del_timer(&ia_timer);
956 + del_timer_sync(&ia_timer);
957 }
958
959 module_init(ia_module_init);
960 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
961 index 8bcd09fb0feb9..8c675c4f6d549 100644
962 --- a/drivers/atm/nicstar.c
963 +++ b/drivers/atm/nicstar.c
964 @@ -298,7 +298,7 @@ static void __exit nicstar_cleanup(void)
965 {
966 XPRINTK("nicstar: nicstar_cleanup() called.\n");
967
968 - del_timer(&ns_timer);
969 + del_timer_sync(&ns_timer);
970
971 pci_unregister_driver(&nicstar_driver);
972
973 @@ -526,6 +526,15 @@ static int ns_init_card(int i, struct pci_dev *pcidev)
974 /* Set the VPI/VCI MSb mask to zero so we can receive OAM cells */
975 writel(0x00000000, card->membase + VPM);
976
977 + card->intcnt = 0;
978 + if (request_irq
979 + (pcidev->irq, &ns_irq_handler, IRQF_SHARED, "nicstar", card) != 0) {
980 + pr_err("nicstar%d: can't allocate IRQ %d.\n", i, pcidev->irq);
981 + error = 9;
982 + ns_init_card_error(card, error);
983 + return error;
984 + }
985 +
986 /* Initialize TSQ */
987 card->tsq.org = dma_alloc_coherent(&card->pcidev->dev,
988 NS_TSQSIZE + NS_TSQ_ALIGNMENT,
989 @@ -752,15 +761,6 @@ static int ns_init_card(int i, struct pci_dev *pcidev)
990
991 card->efbie = 1;
992
993 - card->intcnt = 0;
994 - if (request_irq
995 - (pcidev->irq, &ns_irq_handler, IRQF_SHARED, "nicstar", card) != 0) {
996 - printk("nicstar%d: can't allocate IRQ %d.\n", i, pcidev->irq);
997 - error = 9;
998 - ns_init_card_error(card, error);
999 - return error;
1000 - }
1001 -
1002 /* Register device */
1003 card->atmdev = atm_dev_register("nicstar", &card->pcidev->dev, &atm_ops,
1004 -1, NULL);
1005 @@ -838,10 +838,12 @@ static void ns_init_card_error(ns_dev *card, int error)
1006 dev_kfree_skb_any(hb);
1007 }
1008 if (error >= 12) {
1009 - kfree(card->rsq.org);
1010 + dma_free_coherent(&card->pcidev->dev, NS_RSQSIZE + NS_RSQ_ALIGNMENT,
1011 + card->rsq.org, card->rsq.dma);
1012 }
1013 if (error >= 11) {
1014 - kfree(card->tsq.org);
1015 + dma_free_coherent(&card->pcidev->dev, NS_TSQSIZE + NS_TSQ_ALIGNMENT,
1016 + card->tsq.org, card->tsq.dma);
1017 }
1018 if (error >= 10) {
1019 free_irq(card->pcidev->irq, card);
1020 diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
1021 index e57a1f6e39d5c..302260e9002c7 100644
1022 --- a/drivers/block/virtio_blk.c
1023 +++ b/drivers/block/virtio_blk.c
1024 @@ -800,6 +800,8 @@ static int virtblk_freeze(struct virtio_device *vdev)
1025 blk_mq_stop_hw_queues(vblk->disk->queue);
1026
1027 vdev->config->del_vqs(vdev);
1028 + kfree(vblk->vqs);
1029 +
1030 return 0;
1031 }
1032
1033 diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
1034 index 4e3b24a0511ff..30c09b9ddbf0d 100644
1035 --- a/drivers/bluetooth/btusb.c
1036 +++ b/drivers/bluetooth/btusb.c
1037 @@ -2508,6 +2508,11 @@ static int btusb_setup_qca_download_fw(struct hci_dev *hdev,
1038 sent += size;
1039 count -= size;
1040
1041 + /* ep2 need time to switch from function acl to function dfu,
1042 + * so we add 20ms delay here.
1043 + */
1044 + msleep(20);
1045 +
1046 while (count) {
1047 size = min_t(size_t, count, QCA_DFU_PACKET_LEN);
1048
1049 diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
1050 index 055d2ce378a78..a5393e678fe9b 100644
1051 --- a/drivers/char/ipmi/ipmi_watchdog.c
1052 +++ b/drivers/char/ipmi/ipmi_watchdog.c
1053 @@ -393,16 +393,18 @@ static int i_ipmi_set_timeout(struct ipmi_smi_msg *smi_msg,
1054 data[0] = 0;
1055 WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS);
1056
1057 - if ((ipmi_version_major > 1)
1058 - || ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) {
1059 - /* This is an IPMI 1.5-only feature. */
1060 - data[0] |= WDOG_DONT_STOP_ON_SET;
1061 - } else if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
1062 - /*
1063 - * In ipmi 1.0, setting the timer stops the watchdog, we
1064 - * need to start it back up again.
1065 - */
1066 - hbnow = 1;
1067 + if (ipmi_watchdog_state != WDOG_TIMEOUT_NONE) {
1068 + if ((ipmi_version_major > 1) ||
1069 + ((ipmi_version_major == 1) && (ipmi_version_minor >= 5))) {
1070 + /* This is an IPMI 1.5-only feature. */
1071 + data[0] |= WDOG_DONT_STOP_ON_SET;
1072 + } else {
1073 + /*
1074 + * In ipmi 1.0, setting the timer stops the watchdog, we
1075 + * need to start it back up again.
1076 + */
1077 + hbnow = 1;
1078 + }
1079 }
1080
1081 data[1] = 0;
1082 diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
1083 index c115217c79aec..f8d98f7e6fb72 100644
1084 --- a/drivers/char/pcmcia/cm4000_cs.c
1085 +++ b/drivers/char/pcmcia/cm4000_cs.c
1086 @@ -544,6 +544,10 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
1087 io_read_num_rec_bytes(iobase, &num_bytes_read);
1088 if (num_bytes_read >= 4) {
1089 DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
1090 + if (num_bytes_read > 4) {
1091 + rc = -EIO;
1092 + goto exit_setprotocol;
1093 + }
1094 break;
1095 }
1096 mdelay(10);
1097 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
1098 index 4ec08c7a7b659..2632b0fdb1b53 100644
1099 --- a/drivers/char/virtio_console.c
1100 +++ b/drivers/char/virtio_console.c
1101 @@ -492,7 +492,7 @@ static struct port_buffer *get_inbuf(struct port *port)
1102
1103 buf = virtqueue_get_buf(port->in_vq, &len);
1104 if (buf) {
1105 - buf->len = len;
1106 + buf->len = min_t(size_t, len, buf->size);
1107 buf->offset = 0;
1108 port->stats.bytes_received += len;
1109 }
1110 @@ -1758,7 +1758,7 @@ static void control_work_handler(struct work_struct *work)
1111 while ((buf = virtqueue_get_buf(vq, &len))) {
1112 spin_unlock(&portdev->c_ivq_lock);
1113
1114 - buf->len = len;
1115 + buf->len = min_t(size_t, len, buf->size);
1116 buf->offset = 0;
1117
1118 handle_control_message(vq->vdev, portdev, buf);
1119 diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c
1120 index 1ab36a355daf0..789efad791a3b 100644
1121 --- a/drivers/clk/tegra/clk-pll.c
1122 +++ b/drivers/clk/tegra/clk-pll.c
1123 @@ -1085,7 +1085,8 @@ static int clk_pllu_enable(struct clk_hw *hw)
1124 if (pll->lock)
1125 spin_lock_irqsave(pll->lock, flags);
1126
1127 - _clk_pll_enable(hw);
1128 + if (!clk_pll_is_enabled(hw))
1129 + _clk_pll_enable(hw);
1130
1131 ret = clk_pll_wait_for_lock(pll);
1132 if (ret < 0)
1133 @@ -1702,7 +1703,8 @@ static int clk_pllu_tegra114_enable(struct clk_hw *hw)
1134 if (pll->lock)
1135 spin_lock_irqsave(pll->lock, flags);
1136
1137 - _clk_pll_enable(hw);
1138 + if (!clk_pll_is_enabled(hw))
1139 + _clk_pll_enable(hw);
1140
1141 ret = clk_pll_wait_for_lock(pll);
1142 if (ret < 0)
1143 diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c
1144 index a54de1299e9ef..81b61e256f7c4 100644
1145 --- a/drivers/crypto/ixp4xx_crypto.c
1146 +++ b/drivers/crypto/ixp4xx_crypto.c
1147 @@ -334,7 +334,7 @@ static void free_buf_chain(struct device *dev, struct buffer_desc *buf,u32 phys)
1148
1149 buf1 = buf->next;
1150 phys1 = buf->phys_next;
1151 - dma_unmap_single(dev, buf->phys_next, buf->buf_len, buf->dir);
1152 + dma_unmap_single(dev, buf->phys_addr, buf->buf_len, buf->dir);
1153 dma_pool_free(buffer_pool, buf, phys);
1154 buf = buf1;
1155 phys = phys1;
1156 diff --git a/drivers/crypto/nx/nx-842-pseries.c b/drivers/crypto/nx/nx-842-pseries.c
1157 index cddc6d8b55d9c..1b8c877706453 100644
1158 --- a/drivers/crypto/nx/nx-842-pseries.c
1159 +++ b/drivers/crypto/nx/nx-842-pseries.c
1160 @@ -553,13 +553,15 @@ static int nx842_OF_set_defaults(struct nx842_devdata *devdata)
1161 * The status field indicates if the device is enabled when the status
1162 * is 'okay'. Otherwise the device driver will be disabled.
1163 *
1164 - * @prop - struct property point containing the maxsyncop for the update
1165 + * @devdata: struct nx842_devdata to use for dev_info
1166 + * @prop: struct property point containing the maxsyncop for the update
1167 *
1168 * Returns:
1169 * 0 - Device is available
1170 * -ENODEV - Device is not available
1171 */
1172 -static int nx842_OF_upd_status(struct property *prop)
1173 +static int nx842_OF_upd_status(struct nx842_devdata *devdata,
1174 + struct property *prop)
1175 {
1176 const char *status = (const char *)prop->value;
1177
1178 @@ -773,7 +775,7 @@ static int nx842_OF_upd(struct property *new_prop)
1179 goto out;
1180
1181 /* Perform property updates */
1182 - ret = nx842_OF_upd_status(status);
1183 + ret = nx842_OF_upd_status(new_devdata, status);
1184 if (ret)
1185 goto error_out;
1186
1187 @@ -1086,6 +1088,7 @@ static struct vio_device_id nx842_vio_driver_ids[] = {
1188 {"ibm,compression-v1", "ibm,compression"},
1189 {"", ""},
1190 };
1191 +MODULE_DEVICE_TABLE(vio, nx842_vio_driver_ids);
1192
1193 static struct vio_driver nx842_vio_driver = {
1194 .name = KBUILD_MODNAME,
1195 diff --git a/drivers/crypto/qat/qat_common/qat_hal.c b/drivers/crypto/qat/qat_common/qat_hal.c
1196 index 8c4fd255a601b..cdf80c16a0333 100644
1197 --- a/drivers/crypto/qat/qat_common/qat_hal.c
1198 +++ b/drivers/crypto/qat/qat_common/qat_hal.c
1199 @@ -1255,7 +1255,11 @@ static int qat_hal_put_rel_wr_xfer(struct icp_qat_fw_loader_handle *handle,
1200 pr_err("QAT: bad xfrAddr=0x%x\n", xfr_addr);
1201 return -EINVAL;
1202 }
1203 - qat_hal_rd_rel_reg(handle, ae, ctx, ICP_GPB_REL, gprnum, &gprval);
1204 + status = qat_hal_rd_rel_reg(handle, ae, ctx, ICP_GPB_REL, gprnum, &gprval);
1205 + if (status) {
1206 + pr_err("QAT: failed to read register");
1207 + return status;
1208 + }
1209 gpr_addr = qat_hal_get_reg_addr(ICP_GPB_REL, gprnum);
1210 data16low = 0xffff & data;
1211 data16hi = 0xffff & (data >> 0x10);
1212 diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c
1213 index 4f1cd83bf56f9..a8e3191e51856 100644
1214 --- a/drivers/crypto/qat/qat_common/qat_uclo.c
1215 +++ b/drivers/crypto/qat/qat_common/qat_uclo.c
1216 @@ -385,7 +385,6 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,
1217 return 0;
1218 }
1219
1220 -#define ICP_DH895XCC_PESRAM_BAR_SIZE 0x80000
1221 static int qat_uclo_init_ae_memory(struct icp_qat_fw_loader_handle *handle,
1222 struct icp_qat_uof_initmem *init_mem)
1223 {
1224 diff --git a/drivers/crypto/ux500/hash/hash_core.c b/drivers/crypto/ux500/hash/hash_core.c
1225 index 17c8e2b28c422..7500ec9efa6ac 100644
1226 --- a/drivers/crypto/ux500/hash/hash_core.c
1227 +++ b/drivers/crypto/ux500/hash/hash_core.c
1228 @@ -1006,6 +1006,7 @@ static int hash_hw_final(struct ahash_request *req)
1229 goto out;
1230 }
1231 } else if (req->nbytes == 0 && ctx->keylen > 0) {
1232 + ret = -EPERM;
1233 dev_err(device_data->dev, "%s: Empty message with keylength > 0, NOT supported\n",
1234 __func__);
1235 goto out;
1236 diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
1237 index b9b48d45a6dc4..17d426829f5db 100644
1238 --- a/drivers/extcon/extcon-max8997.c
1239 +++ b/drivers/extcon/extcon-max8997.c
1240 @@ -783,3 +783,4 @@ module_platform_driver(max8997_muic_driver);
1241 MODULE_DESCRIPTION("Maxim MAX8997 Extcon driver");
1242 MODULE_AUTHOR("Donggeun Kim <dg77.kim@samsung.com>");
1243 MODULE_LICENSE("GPL");
1244 +MODULE_ALIAS("platform:max8997-muic");
1245 diff --git a/drivers/extcon/extcon-sm5502.c b/drivers/extcon/extcon-sm5502.c
1246 index 9d2d8a6673c88..dbe5fc278f091 100644
1247 --- a/drivers/extcon/extcon-sm5502.c
1248 +++ b/drivers/extcon/extcon-sm5502.c
1249 @@ -92,7 +92,6 @@ static struct reg_data sm5502_reg_data[] = {
1250 | SM5502_REG_INTM2_MHL_MASK,
1251 .invert = true,
1252 },
1253 - { }
1254 };
1255
1256 /* List of detectable cables */
1257 diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
1258 index 0e2011636fbbb..595bf12e76538 100644
1259 --- a/drivers/firmware/qemu_fw_cfg.c
1260 +++ b/drivers/firmware/qemu_fw_cfg.c
1261 @@ -192,15 +192,13 @@ static int fw_cfg_do_platform_probe(struct platform_device *pdev)
1262 /* fw_cfg revision attribute, in /sys/firmware/qemu_fw_cfg top-level dir. */
1263 static u32 fw_cfg_rev;
1264
1265 -static ssize_t fw_cfg_showrev(struct kobject *k, struct attribute *a, char *buf)
1266 +static ssize_t fw_cfg_showrev(struct kobject *k, struct kobj_attribute *a,
1267 + char *buf)
1268 {
1269 return sprintf(buf, "%u\n", fw_cfg_rev);
1270 }
1271
1272 -static const struct {
1273 - struct attribute attr;
1274 - ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf);
1275 -} fw_cfg_rev_attr = {
1276 +static const struct kobj_attribute fw_cfg_rev_attr = {
1277 .attr = { .name = "rev", .mode = S_IRUSR },
1278 .show = fw_cfg_showrev,
1279 };
1280 diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
1281 index 6b4d10d6e10f6..5038d771ac6e8 100644
1282 --- a/drivers/gpio/gpio-zynq.c
1283 +++ b/drivers/gpio/gpio-zynq.c
1284 @@ -778,8 +778,11 @@ err_pm_dis:
1285 static int zynq_gpio_remove(struct platform_device *pdev)
1286 {
1287 struct zynq_gpio *gpio = platform_get_drvdata(pdev);
1288 + int ret;
1289
1290 - pm_runtime_get_sync(&pdev->dev);
1291 + ret = pm_runtime_get_sync(&pdev->dev);
1292 + if (ret < 0)
1293 + dev_warn(&pdev->dev, "pm_runtime_get_sync() Failed\n");
1294 gpiochip_remove(&gpio->chip);
1295 clk_disable_unprepare(gpio->clk);
1296 device_set_wakeup_capable(&pdev->dev, 0);
1297 diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
1298 index 5e65d5d2d937d..e7b7b8a31e52d 100644
1299 --- a/drivers/gpu/drm/qxl/qxl_dumb.c
1300 +++ b/drivers/gpu/drm/qxl/qxl_dumb.c
1301 @@ -57,6 +57,8 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
1302 surf.height = args->height;
1303 surf.stride = pitch;
1304 surf.format = format;
1305 + surf.data = 0;
1306 +
1307 r = qxl_gem_object_create_with_handle(qdev, file_priv,
1308 QXL_GEM_DOMAIN_VRAM,
1309 args->size, &surf, &qobj,
1310 diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
1311 index ba7855da7c7f6..6058bdab5fb8f 100644
1312 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c
1313 +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
1314 @@ -234,6 +234,7 @@ err_ttm:
1315 err_vbufs:
1316 vgdev->vdev->config->del_vqs(vgdev->vdev);
1317 err_vqs:
1318 + dev->dev_private = NULL;
1319 kfree(vgdev);
1320 return ret;
1321 }
1322 diff --git a/drivers/hwmon/max31722.c b/drivers/hwmon/max31722.c
1323 index 30a100e70a0d0..877c3d7dca012 100644
1324 --- a/drivers/hwmon/max31722.c
1325 +++ b/drivers/hwmon/max31722.c
1326 @@ -9,7 +9,6 @@
1327 * directory of this archive for more details.
1328 */
1329
1330 -#include <linux/acpi.h>
1331 #include <linux/hwmon.h>
1332 #include <linux/hwmon-sysfs.h>
1333 #include <linux/kernel.h>
1334 @@ -138,20 +137,12 @@ static const struct spi_device_id max31722_spi_id[] = {
1335 {"max31723", 0},
1336 {}
1337 };
1338 -
1339 -static const struct acpi_device_id __maybe_unused max31722_acpi_id[] = {
1340 - {"MAX31722", 0},
1341 - {"MAX31723", 0},
1342 - {}
1343 -};
1344 -
1345 MODULE_DEVICE_TABLE(spi, max31722_spi_id);
1346
1347 static struct spi_driver max31722_driver = {
1348 .driver = {
1349 .name = "max31722",
1350 .pm = &max31722_pm_ops,
1351 - .acpi_match_table = ACPI_PTR(max31722_acpi_id),
1352 },
1353 .probe = max31722_probe,
1354 .remove = max31722_remove,
1355 diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
1356 index 281491cca5103..66cf772de7d29 100644
1357 --- a/drivers/hwmon/max31790.c
1358 +++ b/drivers/hwmon/max31790.c
1359 @@ -179,7 +179,7 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel,
1360
1361 switch (attr) {
1362 case hwmon_fan_input:
1363 - sr = get_tach_period(data->fan_dynamics[channel]);
1364 + sr = get_tach_period(data->fan_dynamics[channel % NR_CHANNEL]);
1365 rpm = RPM_FROM_REG(data->tach[channel], sr);
1366 *val = rpm;
1367 return 0;
1368 diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
1369 index 4fd7bfda2f9de..67e44e9907776 100644
1370 --- a/drivers/i2c/i2c-core.c
1371 +++ b/drivers/i2c/i2c-core.c
1372 @@ -42,6 +42,7 @@
1373 #include <linux/i2c.h>
1374 #include <linux/idr.h>
1375 #include <linux/init.h>
1376 +#include <linux/interrupt.h>
1377 #include <linux/irqflags.h>
1378 #include <linux/jump_label.h>
1379 #include <linux/kernel.h>
1380 @@ -1003,6 +1004,8 @@ static void i2c_device_shutdown(struct device *dev)
1381 driver = to_i2c_driver(dev->driver);
1382 if (driver->shutdown)
1383 driver->shutdown(client);
1384 + else if (client->irq > 0)
1385 + disable_irq(client->irq);
1386 }
1387
1388 static void i2c_client_dev_release(struct device *dev)
1389 diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
1390 index 0890934ef66f6..73ea64a2bff08 100644
1391 --- a/drivers/iio/accel/bma180.c
1392 +++ b/drivers/iio/accel/bma180.c
1393 @@ -120,7 +120,11 @@ struct bma180_data {
1394 int scale;
1395 int bw;
1396 bool pmode;
1397 - u8 buff[16]; /* 3x 16-bit + 8-bit + padding + timestamp */
1398 + /* Ensure timestamp is naturally aligned */
1399 + struct {
1400 + s16 chan[4];
1401 + s64 timestamp __aligned(8);
1402 + } scan;
1403 };
1404
1405 enum bma180_chan {
1406 @@ -667,12 +671,12 @@ static irqreturn_t bma180_trigger_handler(int irq, void *p)
1407 mutex_unlock(&data->mutex);
1408 goto err;
1409 }
1410 - ((s16 *)data->buff)[i++] = ret;
1411 + data->scan.chan[i++] = ret;
1412 }
1413
1414 mutex_unlock(&data->mutex);
1415
1416 - iio_push_to_buffers_with_timestamp(indio_dev, data->buff, time_ns);
1417 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, time_ns);
1418 err:
1419 iio_trigger_notify_done(indio_dev->trig);
1420
1421 diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
1422 index 5099f295dd378..a96f2d530ae34 100644
1423 --- a/drivers/iio/accel/bma220_spi.c
1424 +++ b/drivers/iio/accel/bma220_spi.c
1425 @@ -76,7 +76,11 @@ static const int bma220_scale_table[][4] = {
1426 struct bma220_data {
1427 struct spi_device *spi_device;
1428 struct mutex lock;
1429 - s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 8x8 timestamp */
1430 + struct {
1431 + s8 chans[3];
1432 + /* Ensure timestamp is naturally aligned. */
1433 + s64 timestamp __aligned(8);
1434 + } scan;
1435 u8 tx_buf[2] ____cacheline_aligned;
1436 };
1437
1438 @@ -107,12 +111,12 @@ static irqreturn_t bma220_trigger_handler(int irq, void *p)
1439
1440 mutex_lock(&data->lock);
1441 data->tx_buf[0] = BMA220_REG_ACCEL_X | BMA220_READ_MASK;
1442 - ret = spi_write_then_read(spi, data->tx_buf, 1, data->buffer,
1443 + ret = spi_write_then_read(spi, data->tx_buf, 1, &data->scan.chans,
1444 ARRAY_SIZE(bma220_channels) - 1);
1445 if (ret < 0)
1446 goto err;
1447
1448 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1449 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1450 pf->timestamp);
1451 err:
1452 mutex_unlock(&data->lock);
1453 diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
1454 index 261fbdb88fe15..626a605a0c0e6 100644
1455 --- a/drivers/iio/accel/kxcjk-1013.c
1456 +++ b/drivers/iio/accel/kxcjk-1013.c
1457 @@ -96,12 +96,23 @@ enum kx_acpi_type {
1458 ACPI_SMO8500,
1459 };
1460
1461 +enum kxcjk1013_axis {
1462 + AXIS_X,
1463 + AXIS_Y,
1464 + AXIS_Z,
1465 + AXIS_MAX
1466 +};
1467 +
1468 struct kxcjk1013_data {
1469 struct i2c_client *client;
1470 struct iio_trigger *dready_trig;
1471 struct iio_trigger *motion_trig;
1472 struct mutex mutex;
1473 - s16 buffer[8];
1474 + /* Ensure timestamp naturally aligned */
1475 + struct {
1476 + s16 chans[AXIS_MAX];
1477 + s64 timestamp __aligned(8);
1478 + } scan;
1479 u8 odr_bits;
1480 u8 range;
1481 int wake_thres;
1482 @@ -115,13 +126,6 @@ struct kxcjk1013_data {
1483 enum kx_acpi_type acpi_type;
1484 };
1485
1486 -enum kxcjk1013_axis {
1487 - AXIS_X,
1488 - AXIS_Y,
1489 - AXIS_Z,
1490 - AXIS_MAX,
1491 -};
1492 -
1493 enum kxcjk1013_mode {
1494 STANDBY,
1495 OPERATION,
1496 @@ -971,12 +975,12 @@ static irqreturn_t kxcjk1013_trigger_handler(int irq, void *p)
1497 ret = i2c_smbus_read_i2c_block_data_or_emulated(data->client,
1498 KXCJK1013_REG_XOUT_L,
1499 AXIS_MAX * 2,
1500 - (u8 *)data->buffer);
1501 + (u8 *)data->scan.chans);
1502 mutex_unlock(&data->mutex);
1503 if (ret < 0)
1504 goto err;
1505
1506 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1507 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1508 data->timestamp);
1509 err:
1510 iio_trigger_notify_done(indio_dev->trig);
1511 diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
1512 index e31023dc5f1b7..24a7499049f13 100644
1513 --- a/drivers/iio/accel/stk8312.c
1514 +++ b/drivers/iio/accel/stk8312.c
1515 @@ -106,7 +106,11 @@ struct stk8312_data {
1516 u8 mode;
1517 struct iio_trigger *dready_trig;
1518 bool dready_trigger_on;
1519 - s8 buffer[16]; /* 3x8-bit channels + 5x8 padding + 64-bit timestamp */
1520 + /* Ensure timestamp is naturally aligned */
1521 + struct {
1522 + s8 chans[3];
1523 + s64 timestamp __aligned(8);
1524 + } scan;
1525 };
1526
1527 static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
1528 @@ -443,7 +447,7 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
1529 ret = i2c_smbus_read_i2c_block_data(data->client,
1530 STK8312_REG_XOUT,
1531 STK8312_ALL_CHANNEL_SIZE,
1532 - data->buffer);
1533 + data->scan.chans);
1534 if (ret < STK8312_ALL_CHANNEL_SIZE) {
1535 dev_err(&data->client->dev, "register read failed\n");
1536 mutex_unlock(&data->lock);
1537 @@ -457,12 +461,12 @@ static irqreturn_t stk8312_trigger_handler(int irq, void *p)
1538 mutex_unlock(&data->lock);
1539 goto err;
1540 }
1541 - data->buffer[i++] = ret;
1542 + data->scan.chans[i++] = ret;
1543 }
1544 }
1545 mutex_unlock(&data->lock);
1546
1547 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1548 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1549 pf->timestamp);
1550 err:
1551 iio_trigger_notify_done(indio_dev->trig);
1552 diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
1553 index 300d955bad004..5ca179cea2fb4 100644
1554 --- a/drivers/iio/accel/stk8ba50.c
1555 +++ b/drivers/iio/accel/stk8ba50.c
1556 @@ -94,12 +94,11 @@ struct stk8ba50_data {
1557 u8 sample_rate_idx;
1558 struct iio_trigger *dready_trig;
1559 bool dready_trigger_on;
1560 - /*
1561 - * 3 x 16-bit channels (10-bit data, 6-bit padding) +
1562 - * 1 x 16 padding +
1563 - * 4 x 16 64-bit timestamp
1564 - */
1565 - s16 buffer[8];
1566 + /* Ensure timestamp is naturally aligned */
1567 + struct {
1568 + s16 chans[3];
1569 + s64 timetamp __aligned(8);
1570 + } scan;
1571 };
1572
1573 #define STK8BA50_ACCEL_CHANNEL(index, reg, axis) { \
1574 @@ -329,7 +328,7 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
1575 ret = i2c_smbus_read_i2c_block_data(data->client,
1576 STK8BA50_REG_XOUT,
1577 STK8BA50_ALL_CHANNEL_SIZE,
1578 - (u8 *)data->buffer);
1579 + (u8 *)data->scan.chans);
1580 if (ret < STK8BA50_ALL_CHANNEL_SIZE) {
1581 dev_err(&data->client->dev, "register read failed\n");
1582 goto err;
1583 @@ -342,10 +341,10 @@ static irqreturn_t stk8ba50_trigger_handler(int irq, void *p)
1584 if (ret < 0)
1585 goto err;
1586
1587 - data->buffer[i++] = ret;
1588 + data->scan.chans[i++] = ret;
1589 }
1590 }
1591 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1592 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1593 pf->timestamp);
1594 err:
1595 mutex_unlock(&data->lock);
1596 diff --git a/drivers/iio/adc/ti-ads1015.c b/drivers/iio/adc/ti-ads1015.c
1597 index 5afe32f6587bb..d892c0fe5c316 100644
1598 --- a/drivers/iio/adc/ti-ads1015.c
1599 +++ b/drivers/iio/adc/ti-ads1015.c
1600 @@ -292,10 +292,14 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
1601 struct iio_poll_func *pf = p;
1602 struct iio_dev *indio_dev = pf->indio_dev;
1603 struct ads1015_data *data = iio_priv(indio_dev);
1604 - s16 buf[8]; /* 1x s16 ADC val + 3x s16 padding + 4x s16 timestamp */
1605 + /* Ensure natural alignment of timestamp */
1606 + struct {
1607 + s16 chan;
1608 + s64 timestamp __aligned(8);
1609 + } scan;
1610 int chan, ret, res;
1611
1612 - memset(buf, 0, sizeof(buf));
1613 + memset(&scan, 0, sizeof(scan));
1614
1615 mutex_lock(&data->lock);
1616 chan = find_first_bit(indio_dev->active_scan_mask,
1617 @@ -306,10 +310,10 @@ static irqreturn_t ads1015_trigger_handler(int irq, void *p)
1618 goto err;
1619 }
1620
1621 - buf[0] = res;
1622 + scan.chan = res;
1623 mutex_unlock(&data->lock);
1624
1625 - iio_push_to_buffers_with_timestamp(indio_dev, buf,
1626 + iio_push_to_buffers_with_timestamp(indio_dev, &scan,
1627 iio_get_time_ns(indio_dev));
1628
1629 err:
1630 diff --git a/drivers/iio/adc/vf610_adc.c b/drivers/iio/adc/vf610_adc.c
1631 index d1bde6d2721ee..2a14800e6514b 100644
1632 --- a/drivers/iio/adc/vf610_adc.c
1633 +++ b/drivers/iio/adc/vf610_adc.c
1634 @@ -180,7 +180,11 @@ struct vf610_adc {
1635 u32 sample_freq_avail[5];
1636
1637 struct completion completion;
1638 - u16 buffer[8];
1639 + /* Ensure the timestamp is naturally aligned */
1640 + struct {
1641 + u16 chan;
1642 + s64 timestamp __aligned(8);
1643 + } scan;
1644 };
1645
1646 static const u32 vf610_hw_avgs[] = { 1, 4, 8, 16, 32 };
1647 @@ -592,9 +596,9 @@ static irqreturn_t vf610_adc_isr(int irq, void *dev_id)
1648 if (coco & VF610_ADC_HS_COCO0) {
1649 info->value = vf610_adc_read_data(info);
1650 if (iio_buffer_enabled(indio_dev)) {
1651 - info->buffer[0] = info->value;
1652 + info->scan.chan = info->value;
1653 iio_push_to_buffers_with_timestamp(indio_dev,
1654 - info->buffer,
1655 + &info->scan,
1656 iio_get_time_ns(indio_dev));
1657 iio_trigger_notify_done(indio_dev->trig);
1658 } else
1659 diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c
1660 index b5a5517e3ce1a..ec2830c164334 100644
1661 --- a/drivers/iio/gyro/bmg160_core.c
1662 +++ b/drivers/iio/gyro/bmg160_core.c
1663 @@ -104,7 +104,11 @@ struct bmg160_data {
1664 struct iio_trigger *dready_trig;
1665 struct iio_trigger *motion_trig;
1666 struct mutex mutex;
1667 - s16 buffer[8];
1668 + /* Ensure naturally aligned timestamp */
1669 + struct {
1670 + s16 chans[3];
1671 + s64 timestamp __aligned(8);
1672 + } scan;
1673 u32 dps_range;
1674 int ev_enable_state;
1675 int slope_thres;
1676 @@ -874,12 +878,12 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
1677
1678 mutex_lock(&data->mutex);
1679 ret = regmap_bulk_read(data->regmap, BMG160_REG_XOUT_L,
1680 - data->buffer, AXIS_MAX * 2);
1681 + data->scan.chans, AXIS_MAX * 2);
1682 mutex_unlock(&data->mutex);
1683 if (ret < 0)
1684 goto err;
1685
1686 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1687 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1688 pf->timestamp);
1689 err:
1690 iio_trigger_notify_done(indio_dev->trig);
1691 diff --git a/drivers/iio/humidity/am2315.c b/drivers/iio/humidity/am2315.c
1692 index ff96b6d0fdae4..77513fd84b99d 100644
1693 --- a/drivers/iio/humidity/am2315.c
1694 +++ b/drivers/iio/humidity/am2315.c
1695 @@ -36,7 +36,11 @@
1696 struct am2315_data {
1697 struct i2c_client *client;
1698 struct mutex lock;
1699 - s16 buffer[8]; /* 2x16-bit channels + 2x16 padding + 4x16 timestamp */
1700 + /* Ensure timestamp is naturally aligned */
1701 + struct {
1702 + s16 chans[2];
1703 + s64 timestamp __aligned(8);
1704 + } scan;
1705 };
1706
1707 struct am2315_sensor_data {
1708 @@ -170,20 +174,20 @@ static irqreturn_t am2315_trigger_handler(int irq, void *p)
1709
1710 mutex_lock(&data->lock);
1711 if (*(indio_dev->active_scan_mask) == AM2315_ALL_CHANNEL_MASK) {
1712 - data->buffer[0] = sensor_data.hum_data;
1713 - data->buffer[1] = sensor_data.temp_data;
1714 + data->scan.chans[0] = sensor_data.hum_data;
1715 + data->scan.chans[1] = sensor_data.temp_data;
1716 } else {
1717 i = 0;
1718 for_each_set_bit(bit, indio_dev->active_scan_mask,
1719 indio_dev->masklength) {
1720 - data->buffer[i] = (bit ? sensor_data.temp_data :
1721 - sensor_data.hum_data);
1722 + data->scan.chans[i] = (bit ? sensor_data.temp_data :
1723 + sensor_data.hum_data);
1724 i++;
1725 }
1726 }
1727 mutex_unlock(&data->lock);
1728
1729 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1730 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1731 pf->timestamp);
1732 err:
1733 iio_trigger_notify_done(indio_dev->trig);
1734 diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c
1735 index 9de553e8c214f..625f54d9e382f 100644
1736 --- a/drivers/iio/imu/adis_buffer.c
1737 +++ b/drivers/iio/imu/adis_buffer.c
1738 @@ -83,9 +83,6 @@ static irqreturn_t adis_trigger_handler(int irq, void *p)
1739 struct adis *adis = iio_device_get_drvdata(indio_dev);
1740 int ret;
1741
1742 - if (!adis->buffer)
1743 - return -ENOMEM;
1744 -
1745 if (adis->data->has_paging) {
1746 mutex_lock(&adis->txrx_lock);
1747 if (adis->current_page != 0) {
1748 diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c
1749 index 1d2c0c8a1d4f0..207b856cef8c0 100644
1750 --- a/drivers/iio/light/isl29125.c
1751 +++ b/drivers/iio/light/isl29125.c
1752 @@ -54,7 +54,11 @@
1753 struct isl29125_data {
1754 struct i2c_client *client;
1755 u8 conf1;
1756 - u16 buffer[8]; /* 3x 16-bit, padding, 8 bytes timestamp */
1757 + /* Ensure timestamp is naturally aligned */
1758 + struct {
1759 + u16 chans[3];
1760 + s64 timestamp __aligned(8);
1761 + } scan;
1762 };
1763
1764 #define ISL29125_CHANNEL(_color, _si) { \
1765 @@ -187,10 +191,10 @@ static irqreturn_t isl29125_trigger_handler(int irq, void *p)
1766 if (ret < 0)
1767 goto done;
1768
1769 - data->buffer[j++] = ret;
1770 + data->scan.chans[j++] = ret;
1771 }
1772
1773 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1774 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1775 iio_get_time_ns(indio_dev));
1776
1777 done:
1778 diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
1779 index a8f9bc12ee23a..414fe857fa9d7 100644
1780 --- a/drivers/iio/light/ltr501.c
1781 +++ b/drivers/iio/light/ltr501.c
1782 @@ -35,9 +35,12 @@
1783 #define LTR501_PART_ID 0x86
1784 #define LTR501_MANUFAC_ID 0x87
1785 #define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */
1786 +#define LTR501_ALS_DATA1_UPPER 0x89 /* upper 8 bits of LTR501_ALS_DATA1 */
1787 #define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */
1788 +#define LTR501_ALS_DATA0_UPPER 0x8b /* upper 8 bits of LTR501_ALS_DATA0 */
1789 #define LTR501_ALS_PS_STATUS 0x8c
1790 #define LTR501_PS_DATA 0x8d /* 16-bit, little endian */
1791 +#define LTR501_PS_DATA_UPPER 0x8e /* upper 8 bits of LTR501_PS_DATA */
1792 #define LTR501_INTR 0x8f /* output mode, polarity, mode */
1793 #define LTR501_PS_THRESH_UP 0x90 /* 11 bit, ps upper threshold */
1794 #define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */
1795 @@ -408,18 +411,19 @@ static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2])
1796
1797 static int ltr501_read_ps(struct ltr501_data *data)
1798 {
1799 - int ret, status;
1800 + __le16 status;
1801 + int ret;
1802
1803 ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
1804 if (ret < 0)
1805 return ret;
1806
1807 ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
1808 - &status, 2);
1809 + &status, sizeof(status));
1810 if (ret < 0)
1811 return ret;
1812
1813 - return status;
1814 + return le16_to_cpu(status);
1815 }
1816
1817 static int ltr501_read_intr_prst(struct ltr501_data *data,
1818 @@ -1180,7 +1184,7 @@ static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
1819 .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
1820 .ps_gain = ltr559_ps_gain_tbl,
1821 .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
1822 - .als_mode_active = BIT(1),
1823 + .als_mode_active = BIT(0),
1824 .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
1825 .als_gain_shift = 2,
1826 .info = &ltr501_info,
1827 @@ -1329,9 +1333,12 @@ static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg)
1828 {
1829 switch (reg) {
1830 case LTR501_ALS_DATA1:
1831 + case LTR501_ALS_DATA1_UPPER:
1832 case LTR501_ALS_DATA0:
1833 + case LTR501_ALS_DATA0_UPPER:
1834 case LTR501_ALS_PS_STATUS:
1835 case LTR501_PS_DATA:
1836 + case LTR501_PS_DATA_UPPER:
1837 return true;
1838 default:
1839 return false;
1840 diff --git a/drivers/iio/light/tcs3414.c b/drivers/iio/light/tcs3414.c
1841 index a795afb7667bd..b51cd43ef8249 100644
1842 --- a/drivers/iio/light/tcs3414.c
1843 +++ b/drivers/iio/light/tcs3414.c
1844 @@ -56,7 +56,11 @@ struct tcs3414_data {
1845 u8 control;
1846 u8 gain;
1847 u8 timing;
1848 - u16 buffer[8]; /* 4x 16-bit + 8 bytes timestamp */
1849 + /* Ensure timestamp is naturally aligned */
1850 + struct {
1851 + u16 chans[4];
1852 + s64 timestamp __aligned(8);
1853 + } scan;
1854 };
1855
1856 #define TCS3414_CHANNEL(_color, _si, _addr) { \
1857 @@ -212,10 +216,10 @@ static irqreturn_t tcs3414_trigger_handler(int irq, void *p)
1858 if (ret < 0)
1859 goto done;
1860
1861 - data->buffer[j++] = ret;
1862 + data->scan.chans[j++] = ret;
1863 }
1864
1865 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1866 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1867 iio_get_time_ns(indio_dev));
1868
1869 done:
1870 diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1871 index 46e969a3a9b7e..ed7397f0b4c81 100644
1872 --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1873 +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1874 @@ -51,7 +51,11 @@ struct lidar_data {
1875 int (*xfer)(struct lidar_data *data, u8 reg, u8 *val, int len);
1876 int i2c_enabled;
1877
1878 - u16 buffer[8]; /* 2 byte distance + 8 byte timestamp */
1879 + /* Ensure timestamp is naturally aligned */
1880 + struct {
1881 + u16 chan;
1882 + s64 timestamp __aligned(8);
1883 + } scan;
1884 };
1885
1886 static const struct iio_chan_spec lidar_channels[] = {
1887 @@ -236,9 +240,9 @@ static irqreturn_t lidar_trigger_handler(int irq, void *private)
1888 struct lidar_data *data = iio_priv(indio_dev);
1889 int ret;
1890
1891 - ret = lidar_get_measurement(data, data->buffer);
1892 + ret = lidar_get_measurement(data, &data->scan.chan);
1893 if (!ret) {
1894 - iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
1895 + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan,
1896 iio_get_time_ns(indio_dev));
1897 } else if (ret != -EINVAL) {
1898 dev_err(&data->client->dev, "cannot read LIDAR measurement");
1899 diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
1900 index 0a6cc78ebcf74..149d210c68aba 100644
1901 --- a/drivers/infiniband/core/cma.c
1902 +++ b/drivers/infiniband/core/cma.c
1903 @@ -2370,7 +2370,8 @@ static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
1904 work->new_state = RDMA_CM_ROUTE_RESOLVED;
1905 work->event.event = RDMA_CM_EVENT_ROUTE_RESOLVED;
1906
1907 - route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
1908 + if (!route->path_rec)
1909 + route->path_rec = kmalloc(sizeof *route->path_rec, GFP_KERNEL);
1910 if (!route->path_rec) {
1911 ret = -ENOMEM;
1912 goto err1;
1913 diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
1914 index 36bdb04f8f018..87bc7b0db892b 100644
1915 --- a/drivers/infiniband/hw/cxgb4/qp.c
1916 +++ b/drivers/infiniband/hw/cxgb4/qp.c
1917 @@ -277,6 +277,7 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
1918 if (user && (!wq->sq.bar2_pa || !wq->rq.bar2_pa)) {
1919 pr_warn(MOD "%s: sqid %u or rqid %u not in BAR2 range.\n",
1920 pci_name(rdev->lldi.pdev), wq->sq.qid, wq->rq.qid);
1921 + ret = -EINVAL;
1922 goto free_dma;
1923 }
1924
1925 diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c b/drivers/infiniband/sw/rxe/rxe_mr.c
1926 index 6d1ba75398a1a..e23b322224ab1 100644
1927 --- a/drivers/infiniband/sw/rxe/rxe_mr.c
1928 +++ b/drivers/infiniband/sw/rxe/rxe_mr.c
1929 @@ -175,7 +175,7 @@ int rxe_mem_init_user(struct rxe_dev *rxe, struct rxe_pd *pd, u64 start,
1930 if (IS_ERR(umem)) {
1931 pr_warn("err %d from rxe_umem_get\n",
1932 (int)PTR_ERR(umem));
1933 - err = -EINVAL;
1934 + err = PTR_ERR(umem);
1935 goto err1;
1936 }
1937
1938 diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
1939 index e392612345282..f431cecd8b562 100644
1940 --- a/drivers/infiniband/sw/rxe/rxe_net.c
1941 +++ b/drivers/infiniband/sw/rxe/rxe_net.c
1942 @@ -259,10 +259,8 @@ static struct socket *rxe_setup_udp_tunnel(struct net *net, __be16 port,
1943
1944 /* Create UDP socket */
1945 err = udp_sock_create(net, &udp_cfg, &sock);
1946 - if (err < 0) {
1947 - pr_err("failed to create udp socket. err = %d\n", err);
1948 + if (err < 0)
1949 return ERR_PTR(err);
1950 - }
1951
1952 tnl_cfg.encap_type = 1;
1953 tnl_cfg.encap_rcv = rxe_udp_encap_recv;
1954 @@ -665,6 +663,12 @@ int rxe_net_ipv6_init(void)
1955
1956 recv_sockets.sk6 = rxe_setup_udp_tunnel(&init_net,
1957 htons(ROCE_V2_UDP_DPORT), true);
1958 + if (PTR_ERR(recv_sockets.sk6) == -EAFNOSUPPORT) {
1959 + recv_sockets.sk6 = NULL;
1960 + pr_warn("IPv6 is not supported, can not create a UDPv6 socket\n");
1961 + return 0;
1962 + }
1963 +
1964 if (IS_ERR(recv_sockets.sk6)) {
1965 recv_sockets.sk6 = NULL;
1966 pr_err("Failed to create IPv6 UDP tunnel\n");
1967 diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
1968 index 1ebce211d875a..39a7abe4b48c1 100644
1969 --- a/drivers/input/joydev.c
1970 +++ b/drivers/input/joydev.c
1971 @@ -492,7 +492,7 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev,
1972 memcpy(joydev->keypam, keypam, len);
1973
1974 for (i = 0; i < joydev->nkey; i++)
1975 - joydev->keymap[keypam[i] - BTN_MISC] = i;
1976 + joydev->keymap[joydev->keypam[i] - BTN_MISC] = i;
1977
1978 out:
1979 kfree(keypam);
1980 diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
1981 index 5b152f25a8e1f..da07742fd9a43 100644
1982 --- a/drivers/input/keyboard/hil_kbd.c
1983 +++ b/drivers/input/keyboard/hil_kbd.c
1984 @@ -512,6 +512,7 @@ static int hil_dev_connect(struct serio *serio, struct serio_driver *drv)
1985 HIL_IDD_NUM_AXES_PER_SET(*idd)) {
1986 printk(KERN_INFO PREFIX
1987 "combo devices are not supported.\n");
1988 + error = -EINVAL;
1989 goto bail1;
1990 }
1991
1992 diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
1993 index 499402a975b3c..c5d34a7823724 100644
1994 --- a/drivers/input/touchscreen/usbtouchscreen.c
1995 +++ b/drivers/input/touchscreen/usbtouchscreen.c
1996 @@ -266,7 +266,7 @@ static int e2i_init(struct usbtouch_usb *usbtouch)
1997 int ret;
1998 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
1999
2000 - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2001 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2002 0x01, 0x02, 0x0000, 0x0081,
2003 NULL, 0, USB_CTRL_SET_TIMEOUT);
2004
2005 @@ -462,7 +462,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
2006 int ret, i;
2007 struct usb_device *udev = interface_to_usbdev(usbtouch->interface);
2008
2009 - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2010 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2011 MTOUCHUSB_RESET,
2012 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
2013 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
2014 @@ -474,7 +474,7 @@ static int mtouch_init(struct usbtouch_usb *usbtouch)
2015 msleep(150);
2016
2017 for (i = 0; i < 3; i++) {
2018 - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2019 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2020 MTOUCHUSB_ASYNC_REPORT,
2021 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
2022 1, 1, NULL, 0, USB_CTRL_SET_TIMEOUT);
2023 @@ -645,7 +645,7 @@ static int dmc_tsc10_init(struct usbtouch_usb *usbtouch)
2024 }
2025
2026 /* start sending data */
2027 - ret = usb_control_msg(dev, usb_rcvctrlpipe (dev, 0),
2028 + ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
2029 TSC10_CMD_DATA1,
2030 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
2031 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
2032 diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c
2033 index 9b23843dcad4d..7ba1a94497f5d 100644
2034 --- a/drivers/ipack/carriers/tpci200.c
2035 +++ b/drivers/ipack/carriers/tpci200.c
2036 @@ -591,8 +591,11 @@ static int tpci200_pci_probe(struct pci_dev *pdev,
2037
2038 out_err_bus_register:
2039 tpci200_uninstall(tpci200);
2040 + /* tpci200->info->cfg_regs is unmapped in tpci200_uninstall */
2041 + tpci200->info->cfg_regs = NULL;
2042 out_err_install:
2043 - iounmap(tpci200->info->cfg_regs);
2044 + if (tpci200->info->cfg_regs)
2045 + iounmap(tpci200->info->cfg_regs);
2046 out_err_ioremap:
2047 pci_release_region(pdev, TPCI200_CFG_MEM_BAR);
2048 out_err_pci_request:
2049 diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c
2050 index ff48da61c94c8..89cf1d695a01c 100644
2051 --- a/drivers/isdn/hardware/mISDN/hfcpci.c
2052 +++ b/drivers/isdn/hardware/mISDN/hfcpci.c
2053 @@ -2352,7 +2352,7 @@ static void __exit
2054 HFC_cleanup(void)
2055 {
2056 if (timer_pending(&hfc_tl))
2057 - del_timer(&hfc_tl);
2058 + del_timer_sync(&hfc_tl);
2059
2060 pci_unregister_driver(&hfc_driver);
2061 }
2062 diff --git a/drivers/leds/leds-ktd2692.c b/drivers/leds/leds-ktd2692.c
2063 index 45296aaca9daa..02738b5b1dbf2 100644
2064 --- a/drivers/leds/leds-ktd2692.c
2065 +++ b/drivers/leds/leds-ktd2692.c
2066 @@ -259,6 +259,17 @@ static void ktd2692_setup(struct ktd2692_context *led)
2067 | KTD2692_REG_FLASH_CURRENT_BASE);
2068 }
2069
2070 +static void regulator_disable_action(void *_data)
2071 +{
2072 + struct device *dev = _data;
2073 + struct ktd2692_context *led = dev_get_drvdata(dev);
2074 + int ret;
2075 +
2076 + ret = regulator_disable(led->regulator);
2077 + if (ret)
2078 + dev_err(dev, "Failed to disable supply: %d\n", ret);
2079 +}
2080 +
2081 static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
2082 struct ktd2692_led_config_data *cfg)
2083 {
2084 @@ -289,8 +300,14 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
2085
2086 if (led->regulator) {
2087 ret = regulator_enable(led->regulator);
2088 - if (ret)
2089 + if (ret) {
2090 dev_err(dev, "Failed to enable supply: %d\n", ret);
2091 + } else {
2092 + ret = devm_add_action_or_reset(dev,
2093 + regulator_disable_action, dev);
2094 + if (ret)
2095 + return ret;
2096 + }
2097 }
2098
2099 child_node = of_get_next_available_child(np, NULL);
2100 @@ -380,17 +397,9 @@ static int ktd2692_probe(struct platform_device *pdev)
2101 static int ktd2692_remove(struct platform_device *pdev)
2102 {
2103 struct ktd2692_context *led = platform_get_drvdata(pdev);
2104 - int ret;
2105
2106 led_classdev_flash_unregister(&led->fled_cdev);
2107
2108 - if (led->regulator) {
2109 - ret = regulator_disable(led->regulator);
2110 - if (ret)
2111 - dev_err(&pdev->dev,
2112 - "Failed to disable supply: %d\n", ret);
2113 - }
2114 -
2115 mutex_destroy(&led->lock);
2116
2117 return 0;
2118 diff --git a/drivers/md/persistent-data/dm-btree-remove.c b/drivers/md/persistent-data/dm-btree-remove.c
2119 index eff04fa23dfad..9e4d1212f4c16 100644
2120 --- a/drivers/md/persistent-data/dm-btree-remove.c
2121 +++ b/drivers/md/persistent-data/dm-btree-remove.c
2122 @@ -549,7 +549,8 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root,
2123 delete_at(n, index);
2124 }
2125
2126 - *new_root = shadow_root(&spine);
2127 + if (!r)
2128 + *new_root = shadow_root(&spine);
2129 exit_shadow_spine(&spine);
2130
2131 return r;
2132 diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
2133 index bf4c5e2ccb6ff..e0acae7a3815d 100644
2134 --- a/drivers/md/persistent-data/dm-space-map-disk.c
2135 +++ b/drivers/md/persistent-data/dm-space-map-disk.c
2136 @@ -171,6 +171,14 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b)
2137 * Any block we allocate has to be free in both the old and current ll.
2138 */
2139 r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b);
2140 + if (r == -ENOSPC) {
2141 + /*
2142 + * There's no free block between smd->begin and the end of the metadata device.
2143 + * We search before smd->begin in case something has been freed.
2144 + */
2145 + r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, 0, smd->begin, b);
2146 + }
2147 +
2148 if (r)
2149 return r;
2150
2151 @@ -199,7 +207,6 @@ static int sm_disk_commit(struct dm_space_map *sm)
2152 return r;
2153
2154 memcpy(&smd->old_ll, &smd->ll, sizeof(smd->old_ll));
2155 - smd->begin = 0;
2156 smd->nr_allocated_this_transaction = 0;
2157
2158 r = sm_disk_get_nr_free(sm, &nr_free);
2159 diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
2160 index 967d8f2a731fb..62a4d7da9bd96 100644
2161 --- a/drivers/md/persistent-data/dm-space-map-metadata.c
2162 +++ b/drivers/md/persistent-data/dm-space-map-metadata.c
2163 @@ -451,6 +451,14 @@ static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b)
2164 * Any block we allocate has to be free in both the old and current ll.
2165 */
2166 r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);
2167 + if (r == -ENOSPC) {
2168 + /*
2169 + * There's no free block between smm->begin and the end of the metadata device.
2170 + * We search before smm->begin in case something has been freed.
2171 + */
2172 + r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, 0, smm->begin, b);
2173 + }
2174 +
2175 if (r)
2176 return r;
2177
2178 @@ -502,7 +510,6 @@ static int sm_metadata_commit(struct dm_space_map *sm)
2179 return r;
2180
2181 memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll));
2182 - smm->begin = 0;
2183 smm->allocated_this_transaction = 0;
2184
2185 return 0;
2186 diff --git a/drivers/media/common/siano/smscoreapi.c b/drivers/media/common/siano/smscoreapi.c
2187 index f3a42834d7d61..b10bd45da9c5b 100644
2188 --- a/drivers/media/common/siano/smscoreapi.c
2189 +++ b/drivers/media/common/siano/smscoreapi.c
2190 @@ -914,7 +914,7 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
2191 void *buffer, size_t size)
2192 {
2193 struct sms_firmware *firmware = (struct sms_firmware *) buffer;
2194 - struct sms_msg_data4 *msg;
2195 + struct sms_msg_data5 *msg;
2196 u32 mem_address, calc_checksum = 0;
2197 u32 i, *ptr;
2198 u8 *payload = firmware->payload;
2199 @@ -995,24 +995,20 @@ static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
2200 goto exit_fw_download;
2201
2202 if (coredev->mode == DEVICE_MODE_NONE) {
2203 - struct sms_msg_data *trigger_msg =
2204 - (struct sms_msg_data *) msg;
2205 -
2206 pr_debug("sending MSG_SMS_SWDOWNLOAD_TRIGGER_REQ\n");
2207 SMS_INIT_MSG(&msg->x_msg_header,
2208 MSG_SMS_SWDOWNLOAD_TRIGGER_REQ,
2209 - sizeof(struct sms_msg_hdr) +
2210 - sizeof(u32) * 5);
2211 + sizeof(*msg));
2212
2213 - trigger_msg->msg_data[0] = firmware->start_address;
2214 + msg->msg_data[0] = firmware->start_address;
2215 /* Entry point */
2216 - trigger_msg->msg_data[1] = 6; /* Priority */
2217 - trigger_msg->msg_data[2] = 0x200; /* Stack size */
2218 - trigger_msg->msg_data[3] = 0; /* Parameter */
2219 - trigger_msg->msg_data[4] = 4; /* Task ID */
2220 + msg->msg_data[1] = 6; /* Priority */
2221 + msg->msg_data[2] = 0x200; /* Stack size */
2222 + msg->msg_data[3] = 0; /* Parameter */
2223 + msg->msg_data[4] = 4; /* Task ID */
2224
2225 - rc = smscore_sendrequest_and_wait(coredev, trigger_msg,
2226 - trigger_msg->x_msg_header.msg_length,
2227 + rc = smscore_sendrequest_and_wait(coredev, msg,
2228 + msg->x_msg_header.msg_length,
2229 &coredev->trigger_done);
2230 } else {
2231 SMS_INIT_MSG(&msg->x_msg_header, MSG_SW_RELOAD_EXEC_REQ,
2232 diff --git a/drivers/media/common/siano/smscoreapi.h b/drivers/media/common/siano/smscoreapi.h
2233 index 4cc39e4a83182..55d02c27f1244 100644
2234 --- a/drivers/media/common/siano/smscoreapi.h
2235 +++ b/drivers/media/common/siano/smscoreapi.h
2236 @@ -636,9 +636,9 @@ struct sms_msg_data2 {
2237 u32 msg_data[2];
2238 };
2239
2240 -struct sms_msg_data4 {
2241 +struct sms_msg_data5 {
2242 struct sms_msg_hdr x_msg_header;
2243 - u32 msg_data[4];
2244 + u32 msg_data[5];
2245 };
2246
2247 struct sms_data_download {
2248 diff --git a/drivers/media/common/siano/smsdvb-main.c b/drivers/media/common/siano/smsdvb-main.c
2249 index 9d5eb8b6aede9..3a5b5f94398a1 100644
2250 --- a/drivers/media/common/siano/smsdvb-main.c
2251 +++ b/drivers/media/common/siano/smsdvb-main.c
2252 @@ -1187,6 +1187,10 @@ static int smsdvb_hotplug(struct smscore_device_t *coredev,
2253 return 0;
2254
2255 media_graph_error:
2256 + mutex_lock(&g_smsdvb_clientslock);
2257 + list_del(&client->entry);
2258 + mutex_unlock(&g_smsdvb_clientslock);
2259 +
2260 smsdvb_debugfs_release(client);
2261
2262 client_error:
2263 diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
2264 index 9914f69a4a02b..f133489af9b9f 100644
2265 --- a/drivers/media/dvb-core/dvb_net.c
2266 +++ b/drivers/media/dvb-core/dvb_net.c
2267 @@ -57,6 +57,7 @@
2268 #include <linux/module.h>
2269 #include <linux/kernel.h>
2270 #include <linux/netdevice.h>
2271 +#include <linux/nospec.h>
2272 #include <linux/etherdevice.h>
2273 #include <linux/dvb/net.h>
2274 #include <linux/uio.h>
2275 @@ -1350,14 +1351,20 @@ static int dvb_net_do_ioctl(struct file *file,
2276 struct net_device *netdev;
2277 struct dvb_net_priv *priv_data;
2278 struct dvb_net_if *dvbnetif = parg;
2279 + int if_num = dvbnetif->if_num;
2280
2281 - if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
2282 - !dvbnet->state[dvbnetif->if_num]) {
2283 + if (if_num >= DVB_NET_DEVICES_MAX) {
2284 ret = -EINVAL;
2285 goto ioctl_error;
2286 }
2287 + if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
2288
2289 - netdev = dvbnet->device[dvbnetif->if_num];
2290 + if (!dvbnet->state[if_num]) {
2291 + ret = -EINVAL;
2292 + goto ioctl_error;
2293 + }
2294 +
2295 + netdev = dvbnet->device[if_num];
2296
2297 priv_data = netdev_priv(netdev);
2298 dvbnetif->pid=priv_data->pid;
2299 @@ -1410,14 +1417,20 @@ static int dvb_net_do_ioctl(struct file *file,
2300 struct net_device *netdev;
2301 struct dvb_net_priv *priv_data;
2302 struct __dvb_net_if_old *dvbnetif = parg;
2303 + int if_num = dvbnetif->if_num;
2304 +
2305 + if (if_num >= DVB_NET_DEVICES_MAX) {
2306 + ret = -EINVAL;
2307 + goto ioctl_error;
2308 + }
2309 + if_num = array_index_nospec(if_num, DVB_NET_DEVICES_MAX);
2310
2311 - if (dvbnetif->if_num >= DVB_NET_DEVICES_MAX ||
2312 - !dvbnet->state[dvbnetif->if_num]) {
2313 + if (!dvbnet->state[if_num]) {
2314 ret = -EINVAL;
2315 goto ioctl_error;
2316 }
2317
2318 - netdev = dvbnet->device[dvbnetif->if_num];
2319 + netdev = dvbnet->device[if_num];
2320
2321 priv_data = netdev_priv(netdev);
2322 dvbnetif->pid=priv_data->pid;
2323 diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
2324 index 3844853ab0a04..9d55abfe070f0 100644
2325 --- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
2326 +++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
2327 @@ -1393,7 +1393,7 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)
2328 s5c73m3_gpio_deassert(state, STBY);
2329 usleep_range(100, 200);
2330
2331 - s5c73m3_gpio_deassert(state, RST);
2332 + s5c73m3_gpio_deassert(state, RSET);
2333 usleep_range(50, 100);
2334
2335 return 0;
2336 @@ -1408,7 +1408,7 @@ static int __s5c73m3_power_off(struct s5c73m3 *state)
2337 {
2338 int i, ret;
2339
2340 - if (s5c73m3_gpio_assert(state, RST))
2341 + if (s5c73m3_gpio_assert(state, RSET))
2342 usleep_range(10, 50);
2343
2344 if (s5c73m3_gpio_assert(state, STBY))
2345 @@ -1613,7 +1613,7 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
2346
2347 state->mclk_frequency = pdata->mclk_frequency;
2348 state->gpio[STBY] = pdata->gpio_stby;
2349 - state->gpio[RST] = pdata->gpio_reset;
2350 + state->gpio[RSET] = pdata->gpio_reset;
2351 return 0;
2352 }
2353
2354 diff --git a/drivers/media/i2c/s5c73m3/s5c73m3.h b/drivers/media/i2c/s5c73m3/s5c73m3.h
2355 index 653f68e7ea07b..e267b2522149a 100644
2356 --- a/drivers/media/i2c/s5c73m3/s5c73m3.h
2357 +++ b/drivers/media/i2c/s5c73m3/s5c73m3.h
2358 @@ -361,7 +361,7 @@ struct s5c73m3_ctrls {
2359
2360 enum s5c73m3_gpio_id {
2361 STBY,
2362 - RST,
2363 + RSET,
2364 GPIO_NUM,
2365 };
2366
2367 diff --git a/drivers/media/i2c/s5k4ecgx.c b/drivers/media/i2c/s5k4ecgx.c
2368 index 6ebcf254989a5..75fb13a33eab3 100644
2369 --- a/drivers/media/i2c/s5k4ecgx.c
2370 +++ b/drivers/media/i2c/s5k4ecgx.c
2371 @@ -177,7 +177,7 @@ static const char * const s5k4ecgx_supply_names[] = {
2372
2373 enum s5k4ecgx_gpio_id {
2374 STBY,
2375 - RST,
2376 + RSET,
2377 GPIO_NUM,
2378 };
2379
2380 @@ -482,7 +482,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)
2381 if (s5k4ecgx_gpio_set_value(priv, STBY, priv->gpio[STBY].level))
2382 usleep_range(30, 50);
2383
2384 - if (s5k4ecgx_gpio_set_value(priv, RST, priv->gpio[RST].level))
2385 + if (s5k4ecgx_gpio_set_value(priv, RSET, priv->gpio[RSET].level))
2386 usleep_range(30, 50);
2387
2388 return 0;
2389 @@ -490,7 +490,7 @@ static int __s5k4ecgx_power_on(struct s5k4ecgx *priv)
2390
2391 static int __s5k4ecgx_power_off(struct s5k4ecgx *priv)
2392 {
2393 - if (s5k4ecgx_gpio_set_value(priv, RST, !priv->gpio[RST].level))
2394 + if (s5k4ecgx_gpio_set_value(priv, RSET, !priv->gpio[RSET].level))
2395 usleep_range(30, 50);
2396
2397 if (s5k4ecgx_gpio_set_value(priv, STBY, !priv->gpio[STBY].level))
2398 @@ -878,7 +878,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,
2399 int ret;
2400
2401 priv->gpio[STBY].gpio = -EINVAL;
2402 - priv->gpio[RST].gpio = -EINVAL;
2403 + priv->gpio[RSET].gpio = -EINVAL;
2404
2405 ret = s5k4ecgx_config_gpio(gpio->gpio, gpio->level, "S5K4ECGX_STBY");
2406
2407 @@ -897,7 +897,7 @@ static int s5k4ecgx_config_gpios(struct s5k4ecgx *priv,
2408 s5k4ecgx_free_gpios(priv);
2409 return ret;
2410 }
2411 - priv->gpio[RST] = *gpio;
2412 + priv->gpio[RSET] = *gpio;
2413 if (gpio_is_valid(gpio->gpio))
2414 gpio_set_value(gpio->gpio, 0);
2415
2416 diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
2417 index db82ed05792ef..e8c820cb418b7 100644
2418 --- a/drivers/media/i2c/s5k5baf.c
2419 +++ b/drivers/media/i2c/s5k5baf.c
2420 @@ -238,7 +238,7 @@ struct s5k5baf_gpio {
2421
2422 enum s5k5baf_gpio_id {
2423 STBY,
2424 - RST,
2425 + RSET,
2426 NUM_GPIOS,
2427 };
2428
2429 @@ -973,7 +973,7 @@ static int s5k5baf_power_on(struct s5k5baf *state)
2430
2431 s5k5baf_gpio_deassert(state, STBY);
2432 usleep_range(50, 100);
2433 - s5k5baf_gpio_deassert(state, RST);
2434 + s5k5baf_gpio_deassert(state, RSET);
2435 return 0;
2436
2437 err_reg_dis:
2438 @@ -991,7 +991,7 @@ static int s5k5baf_power_off(struct s5k5baf *state)
2439 state->apply_cfg = 0;
2440 state->apply_crop = 0;
2441
2442 - s5k5baf_gpio_assert(state, RST);
2443 + s5k5baf_gpio_assert(state, RSET);
2444 s5k5baf_gpio_assert(state, STBY);
2445
2446 if (!IS_ERR(state->clock))
2447 diff --git a/drivers/media/i2c/s5k6aa.c b/drivers/media/i2c/s5k6aa.c
2448 index 4b615b4b0463d..4d92aac279dc3 100644
2449 --- a/drivers/media/i2c/s5k6aa.c
2450 +++ b/drivers/media/i2c/s5k6aa.c
2451 @@ -181,7 +181,7 @@ static const char * const s5k6aa_supply_names[] = {
2452
2453 enum s5k6aa_gpio_id {
2454 STBY,
2455 - RST,
2456 + RSET,
2457 GPIO_NUM,
2458 };
2459
2460 @@ -845,7 +845,7 @@ static int __s5k6aa_power_on(struct s5k6aa *s5k6aa)
2461 ret = s5k6aa->s_power(1);
2462 usleep_range(4000, 4000);
2463
2464 - if (s5k6aa_gpio_deassert(s5k6aa, RST))
2465 + if (s5k6aa_gpio_deassert(s5k6aa, RSET))
2466 msleep(20);
2467
2468 return ret;
2469 @@ -855,7 +855,7 @@ static int __s5k6aa_power_off(struct s5k6aa *s5k6aa)
2470 {
2471 int ret;
2472
2473 - if (s5k6aa_gpio_assert(s5k6aa, RST))
2474 + if (s5k6aa_gpio_assert(s5k6aa, RSET))
2475 usleep_range(100, 150);
2476
2477 if (s5k6aa->s_power) {
2478 @@ -1514,7 +1514,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,
2479 int ret;
2480
2481 s5k6aa->gpio[STBY].gpio = -EINVAL;
2482 - s5k6aa->gpio[RST].gpio = -EINVAL;
2483 + s5k6aa->gpio[RSET].gpio = -EINVAL;
2484
2485 gpio = &pdata->gpio_stby;
2486 if (gpio_is_valid(gpio->gpio)) {
2487 @@ -1537,7 +1537,7 @@ static int s5k6aa_configure_gpios(struct s5k6aa *s5k6aa,
2488 if (ret < 0)
2489 return ret;
2490
2491 - s5k6aa->gpio[RST] = *gpio;
2492 + s5k6aa->gpio[RSET] = *gpio;
2493 }
2494
2495 return 0;
2496 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
2497 index 3e47b432d0f4e..c799071be66fc 100644
2498 --- a/drivers/media/i2c/tc358743.c
2499 +++ b/drivers/media/i2c/tc358743.c
2500 @@ -1763,6 +1763,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
2501 bps_pr_lane = 2 * endpoint->link_frequencies[0];
2502 if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) {
2503 dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane);
2504 + ret = -EINVAL;
2505 goto disable_clk;
2506 }
2507
2508 diff --git a/drivers/media/pci/bt8xx/bt878.c b/drivers/media/pci/bt8xx/bt878.c
2509 index 90fcccc05b562..c678d7120727e 100644
2510 --- a/drivers/media/pci/bt8xx/bt878.c
2511 +++ b/drivers/media/pci/bt8xx/bt878.c
2512 @@ -494,6 +494,9 @@ static int bt878_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
2513 btwrite(0, BT878_AINT_MASK);
2514 bt878_num++;
2515
2516 + if (!bt->tasklet.func)
2517 + tasklet_disable(&bt->tasklet);
2518 +
2519 return 0;
2520
2521 fail2:
2522 diff --git a/drivers/media/pci/cobalt/cobalt-driver.c b/drivers/media/pci/cobalt/cobalt-driver.c
2523 index 979634000597f..17b717a1c7fa3 100644
2524 --- a/drivers/media/pci/cobalt/cobalt-driver.c
2525 +++ b/drivers/media/pci/cobalt/cobalt-driver.c
2526 @@ -689,6 +689,7 @@ static int cobalt_probe(struct pci_dev *pci_dev,
2527 return -ENOMEM;
2528 cobalt->pci_dev = pci_dev;
2529 cobalt->instance = i;
2530 + mutex_init(&cobalt->pci_lock);
2531
2532 retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev);
2533 if (retval) {
2534 diff --git a/drivers/media/pci/cobalt/cobalt-driver.h b/drivers/media/pci/cobalt/cobalt-driver.h
2535 index ed00dc9d93995..8f9454d30b95e 100644
2536 --- a/drivers/media/pci/cobalt/cobalt-driver.h
2537 +++ b/drivers/media/pci/cobalt/cobalt-driver.h
2538 @@ -262,6 +262,8 @@ struct cobalt {
2539 int instance;
2540 struct pci_dev *pci_dev;
2541 struct v4l2_device v4l2_dev;
2542 + /* serialize PCI access in cobalt_s_bit_sysctrl() */
2543 + struct mutex pci_lock;
2544
2545 void __iomem *bar0, *bar1;
2546
2547 @@ -333,10 +335,13 @@ static inline u32 cobalt_g_sysctrl(struct cobalt *cobalt)
2548 static inline void cobalt_s_bit_sysctrl(struct cobalt *cobalt,
2549 int bit, int val)
2550 {
2551 - u32 ctrl = cobalt_read_bar1(cobalt, COBALT_SYS_CTRL_BASE);
2552 + u32 ctrl;
2553
2554 + mutex_lock(&cobalt->pci_lock);
2555 + ctrl = cobalt_read_bar1(cobalt, COBALT_SYS_CTRL_BASE);
2556 cobalt_write_bar1(cobalt, COBALT_SYS_CTRL_BASE,
2557 (ctrl & ~(1UL << bit)) | (val << bit));
2558 + mutex_unlock(&cobalt->pci_lock);
2559 }
2560
2561 static inline u32 cobalt_g_sysstat(struct cobalt *cobalt)
2562 diff --git a/drivers/media/platform/s5p-g2d/g2d.c b/drivers/media/platform/s5p-g2d/g2d.c
2563 index 5f6ccf4921110..8f083f28dcf38 100644
2564 --- a/drivers/media/platform/s5p-g2d/g2d.c
2565 +++ b/drivers/media/platform/s5p-g2d/g2d.c
2566 @@ -283,6 +283,9 @@ static int g2d_release(struct file *file)
2567 struct g2d_dev *dev = video_drvdata(file);
2568 struct g2d_ctx *ctx = fh2ctx(file->private_data);
2569
2570 + mutex_lock(&dev->mutex);
2571 + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx);
2572 + mutex_unlock(&dev->mutex);
2573 v4l2_ctrl_handler_free(&ctx->ctrl_handler);
2574 v4l2_fh_del(&ctx->fh);
2575 v4l2_fh_exit(&ctx->fh);
2576 diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c
2577 index c4d97fb80aaec..1653892da9a5c 100644
2578 --- a/drivers/media/platform/sti/hva/hva-hw.c
2579 +++ b/drivers/media/platform/sti/hva/hva-hw.c
2580 @@ -127,8 +127,7 @@ static irqreturn_t hva_hw_its_irq_thread(int irq, void *arg)
2581 ctx_id = (hva->sts_reg & 0xFF00) >> 8;
2582 if (ctx_id >= HVA_MAX_INSTANCES) {
2583 dev_err(dev, "%s %s: bad context identifier: %d\n",
2584 - ctx->name, __func__, ctx_id);
2585 - ctx->hw_err = true;
2586 + HVA_PREFIX, __func__, ctx_id);
2587 goto out;
2588 }
2589
2590 diff --git a/drivers/media/usb/cpia2/cpia2.h b/drivers/media/usb/cpia2/cpia2.h
2591 index cdef677d57ecf..80a7af6482ae7 100644
2592 --- a/drivers/media/usb/cpia2/cpia2.h
2593 +++ b/drivers/media/usb/cpia2/cpia2.h
2594 @@ -442,6 +442,7 @@ int cpia2_send_command(struct camera_data *cam, struct cpia2_command *cmd);
2595 int cpia2_do_command(struct camera_data *cam,
2596 unsigned int command,
2597 unsigned char direction, unsigned char param);
2598 +void cpia2_deinit_camera_struct(struct camera_data *cam, struct usb_interface *intf);
2599 struct camera_data *cpia2_init_camera_struct(struct usb_interface *intf);
2600 int cpia2_init_camera(struct camera_data *cam);
2601 int cpia2_allocate_buffers(struct camera_data *cam);
2602 diff --git a/drivers/media/usb/cpia2/cpia2_core.c b/drivers/media/usb/cpia2/cpia2_core.c
2603 index 0310fd6ed1033..828f9689f4a11 100644
2604 --- a/drivers/media/usb/cpia2/cpia2_core.c
2605 +++ b/drivers/media/usb/cpia2/cpia2_core.c
2606 @@ -2158,6 +2158,18 @@ static void reset_camera_struct(struct camera_data *cam)
2607 cam->height = cam->params.roi.height;
2608 }
2609
2610 +/******************************************************************************
2611 + *
2612 + * cpia2_init_camera_struct
2613 + *
2614 + * Deinitialize camera struct
2615 + *****************************************************************************/
2616 +void cpia2_deinit_camera_struct(struct camera_data *cam, struct usb_interface *intf)
2617 +{
2618 + v4l2_device_unregister(&cam->v4l2_dev);
2619 + kfree(cam);
2620 +}
2621 +
2622 /******************************************************************************
2623 *
2624 * cpia2_init_camera_struct
2625 diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
2626 index 30e27844e0e99..4f4a130f17af3 100644
2627 --- a/drivers/media/usb/cpia2/cpia2_usb.c
2628 +++ b/drivers/media/usb/cpia2/cpia2_usb.c
2629 @@ -860,15 +860,13 @@ static int cpia2_usb_probe(struct usb_interface *intf,
2630 ret = set_alternate(cam, USBIF_CMDONLY);
2631 if (ret < 0) {
2632 ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
2633 - kfree(cam);
2634 - return ret;
2635 + goto alt_err;
2636 }
2637
2638
2639 if((ret = cpia2_init_camera(cam)) < 0) {
2640 ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
2641 - kfree(cam);
2642 - return ret;
2643 + goto alt_err;
2644 }
2645 LOG(" CPiA Version: %d.%02d (%d.%d)\n",
2646 cam->params.version.firmware_revision_hi,
2647 @@ -888,11 +886,14 @@ static int cpia2_usb_probe(struct usb_interface *intf,
2648 ret = cpia2_register_camera(cam);
2649 if (ret < 0) {
2650 ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
2651 - kfree(cam);
2652 - return ret;
2653 + goto alt_err;
2654 }
2655
2656 return 0;
2657 +
2658 +alt_err:
2659 + cpia2_deinit_camera_struct(cam, intf);
2660 + return ret;
2661 }
2662
2663 /******************************************************************************
2664 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
2665 index 2b7a1b569db0b..184a9b827d565 100644
2666 --- a/drivers/media/usb/dvb-usb/cxusb.c
2667 +++ b/drivers/media/usb/dvb-usb/cxusb.c
2668 @@ -1791,7 +1791,7 @@ static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
2669
2670 .size_of_priv = sizeof(struct cxusb_state),
2671
2672 - .num_adapters = 2,
2673 + .num_adapters = 1,
2674 .adapter = {
2675 {
2676 .num_frontends = 1,
2677 diff --git a/drivers/media/usb/dvb-usb/dtv5100.c b/drivers/media/usb/dvb-usb/dtv5100.c
2678 index c60fb54f445f5..66f34988fdf04 100644
2679 --- a/drivers/media/usb/dvb-usb/dtv5100.c
2680 +++ b/drivers/media/usb/dvb-usb/dtv5100.c
2681 @@ -39,6 +39,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
2682 u8 *wbuf, u16 wlen, u8 *rbuf, u16 rlen)
2683 {
2684 struct dtv5100_state *st = d->priv;
2685 + unsigned int pipe;
2686 u8 request;
2687 u8 type;
2688 u16 value;
2689 @@ -47,6 +48,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
2690 switch (wlen) {
2691 case 1:
2692 /* write { reg }, read { value } */
2693 + pipe = usb_rcvctrlpipe(d->udev, 0);
2694 request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_READ :
2695 DTV5100_TUNER_READ);
2696 type = USB_TYPE_VENDOR | USB_DIR_IN;
2697 @@ -54,6 +56,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
2698 break;
2699 case 2:
2700 /* write { reg, value } */
2701 + pipe = usb_sndctrlpipe(d->udev, 0);
2702 request = (addr == DTV5100_DEMOD_ADDR ? DTV5100_DEMOD_WRITE :
2703 DTV5100_TUNER_WRITE);
2704 type = USB_TYPE_VENDOR | USB_DIR_OUT;
2705 @@ -67,7 +70,7 @@ static int dtv5100_i2c_msg(struct dvb_usb_device *d, u8 addr,
2706
2707 memcpy(st->data, rbuf, rlen);
2708 msleep(1); /* avoid I2C errors */
2709 - return usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0), request,
2710 + return usb_control_msg(d->udev, pipe, request,
2711 type, value, index, st->data, rlen,
2712 DTV5100_USB_TIMEOUT);
2713 }
2714 @@ -154,7 +157,7 @@ static int dtv5100_probe(struct usb_interface *intf,
2715
2716 /* initialize non qt1010/zl10353 part? */
2717 for (i = 0; dtv5100_init[i].request; i++) {
2718 - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
2719 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
2720 dtv5100_init[i].request,
2721 USB_TYPE_VENDOR | USB_DIR_OUT,
2722 dtv5100_init[i].value,
2723 diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
2724 index 03322d2b2e829..efb5e553b7725 100644
2725 --- a/drivers/media/usb/gspca/sq905.c
2726 +++ b/drivers/media/usb/gspca/sq905.c
2727 @@ -130,7 +130,7 @@ static int sq905_command(struct gspca_dev *gspca_dev, u16 index)
2728 }
2729
2730 ret = usb_control_msg(gspca_dev->dev,
2731 - usb_sndctrlpipe(gspca_dev->dev, 0),
2732 + usb_rcvctrlpipe(gspca_dev->dev, 0),
2733 USB_REQ_SYNCH_FRAME, /* request */
2734 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
2735 SQ905_PING, 0, gspca_dev->usb_buf, 1,
2736 diff --git a/drivers/media/usb/gspca/sunplus.c b/drivers/media/usb/gspca/sunplus.c
2737 index cc3e1478c5a09..949915734d572 100644
2738 --- a/drivers/media/usb/gspca/sunplus.c
2739 +++ b/drivers/media/usb/gspca/sunplus.c
2740 @@ -255,6 +255,10 @@ static void reg_r(struct gspca_dev *gspca_dev,
2741 PERR("reg_r: buffer overflow\n");
2742 return;
2743 }
2744 + if (len == 0) {
2745 + PERR("reg_r: zero-length read\n");
2746 + return;
2747 + }
2748 if (gspca_dev->usb_err < 0)
2749 return;
2750 ret = usb_control_msg(gspca_dev->dev,
2751 @@ -263,7 +267,7 @@ static void reg_r(struct gspca_dev *gspca_dev,
2752 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
2753 0, /* value */
2754 index,
2755 - len ? gspca_dev->usb_buf : NULL, len,
2756 + gspca_dev->usb_buf, len,
2757 500);
2758 if (ret < 0) {
2759 pr_err("reg_r err %d\n", ret);
2760 @@ -739,7 +743,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
2761 case MegaImageVI:
2762 reg_w_riv(gspca_dev, 0xf0, 0, 0);
2763 spca504B_WaitCmdStatus(gspca_dev);
2764 - reg_r(gspca_dev, 0xf0, 4, 0);
2765 + reg_w_riv(gspca_dev, 0xf0, 4, 0);
2766 spca504B_WaitCmdStatus(gspca_dev);
2767 break;
2768 default:
2769 diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2770 index ff489645e0701..0cb8dd5852357 100644
2771 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2772 +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
2773 @@ -2722,9 +2722,8 @@ void pvr2_hdw_destroy(struct pvr2_hdw *hdw)
2774 pvr2_stream_destroy(hdw->vid_stream);
2775 hdw->vid_stream = NULL;
2776 }
2777 - pvr2_i2c_core_done(hdw);
2778 v4l2_device_unregister(&hdw->v4l2_dev);
2779 - pvr2_hdw_remove_usb_stuff(hdw);
2780 + pvr2_hdw_disconnect(hdw);
2781 mutex_lock(&pvr2_unit_mtx);
2782 do {
2783 if ((hdw->unit_number >= 0) &&
2784 @@ -2751,6 +2750,7 @@ void pvr2_hdw_disconnect(struct pvr2_hdw *hdw)
2785 {
2786 pvr2_trace(PVR2_TRACE_INIT,"pvr2_hdw_disconnect(hdw=%p)",hdw);
2787 LOCK_TAKE(hdw->big_lock);
2788 + pvr2_i2c_core_done(hdw);
2789 LOCK_TAKE(hdw->ctl_lock);
2790 pvr2_hdw_remove_usb_stuff(hdw);
2791 LOCK_GIVE(hdw->ctl_lock);
2792 diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
2793 index dcca723f71554..1d724e86f3780 100644
2794 --- a/drivers/media/usb/uvc/uvc_video.c
2795 +++ b/drivers/media/usb/uvc/uvc_video.c
2796 @@ -89,10 +89,37 @@ int uvc_query_ctrl(struct uvc_device *dev, __u8 query, __u8 unit,
2797 static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
2798 struct uvc_streaming_control *ctrl)
2799 {
2800 + static const struct usb_device_id elgato_cam_link_4k = {
2801 + USB_DEVICE(0x0fd9, 0x0066)
2802 + };
2803 struct uvc_format *format = NULL;
2804 struct uvc_frame *frame = NULL;
2805 unsigned int i;
2806
2807 + /*
2808 + * The response of the Elgato Cam Link 4K is incorrect: The second byte
2809 + * contains bFormatIndex (instead of being the second byte of bmHint).
2810 + * The first byte is always zero. The third byte is always 1.
2811 + *
2812 + * The UVC 1.5 class specification defines the first five bits in the
2813 + * bmHint bitfield. The remaining bits are reserved and should be zero.
2814 + * Therefore a valid bmHint will be less than 32.
2815 + *
2816 + * Latest Elgato Cam Link 4K firmware as of 2021-03-23 needs this fix.
2817 + * MCU: 20.02.19, FPGA: 67
2818 + */
2819 + if (usb_match_one_id(stream->dev->intf, &elgato_cam_link_4k) &&
2820 + ctrl->bmHint > 255) {
2821 + u8 corrected_format_index = ctrl->bmHint >> 8;
2822 +
2823 + /* uvc_dbg(stream->dev, VIDEO,
2824 + "Correct USB video probe response from {bmHint: 0x%04x, bFormatIndex: %u} to {bmHint: 0x%04x, bFormatIndex: %u}\n",
2825 + ctrl->bmHint, ctrl->bFormatIndex,
2826 + 1, corrected_format_index); */
2827 + ctrl->bmHint = 1;
2828 + ctrl->bFormatIndex = corrected_format_index;
2829 + }
2830 +
2831 for (i = 0; i < stream->nformats; ++i) {
2832 if (stream->format[i].index == ctrl->bFormatIndex) {
2833 format = &stream->format[i];
2834 diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c
2835 index c5513f55e64e0..05b9012f9902d 100644
2836 --- a/drivers/media/usb/zr364xx/zr364xx.c
2837 +++ b/drivers/media/usb/zr364xx/zr364xx.c
2838 @@ -1066,6 +1066,7 @@ static int zr364xx_start_readpipe(struct zr364xx_camera *cam)
2839 DBG("submitting URB %p\n", pipe_info->stream_urb);
2840 retval = usb_submit_urb(pipe_info->stream_urb, GFP_KERNEL);
2841 if (retval) {
2842 + usb_free_urb(pipe_info->stream_urb);
2843 printk(KERN_ERR KBUILD_MODNAME ": start read pipe failed\n");
2844 return retval;
2845 }
2846 diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
2847 index 0c5e690705861..d44b289205b4f 100644
2848 --- a/drivers/media/v4l2-core/v4l2-fh.c
2849 +++ b/drivers/media/v4l2-core/v4l2-fh.c
2850 @@ -109,6 +109,7 @@ int v4l2_fh_release(struct file *filp)
2851 v4l2_fh_del(fh);
2852 v4l2_fh_exit(fh);
2853 kfree(fh);
2854 + filp->private_data = NULL;
2855 }
2856 return 0;
2857 }
2858 diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
2859 index 1b182b117f9cf..38b945eb410f3 100644
2860 --- a/drivers/memory/fsl_ifc.c
2861 +++ b/drivers/memory/fsl_ifc.c
2862 @@ -109,7 +109,6 @@ static int fsl_ifc_ctrl_remove(struct platform_device *dev)
2863 iounmap(ctrl->gregs);
2864
2865 dev_set_drvdata(&dev->dev, NULL);
2866 - kfree(ctrl);
2867
2868 return 0;
2869 }
2870 @@ -221,7 +220,8 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
2871
2872 dev_info(&dev->dev, "Freescale Integrated Flash Controller\n");
2873
2874 - fsl_ifc_ctrl_dev = kzalloc(sizeof(*fsl_ifc_ctrl_dev), GFP_KERNEL);
2875 + fsl_ifc_ctrl_dev = devm_kzalloc(&dev->dev, sizeof(*fsl_ifc_ctrl_dev),
2876 + GFP_KERNEL);
2877 if (!fsl_ifc_ctrl_dev)
2878 return -ENOMEM;
2879
2880 @@ -231,8 +231,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
2881 fsl_ifc_ctrl_dev->gregs = of_iomap(dev->dev.of_node, 0);
2882 if (!fsl_ifc_ctrl_dev->gregs) {
2883 dev_err(&dev->dev, "failed to get memory region\n");
2884 - ret = -ENODEV;
2885 - goto err;
2886 + return -ENODEV;
2887 }
2888
2889 if (of_property_read_bool(dev->dev.of_node, "little-endian")) {
2890 @@ -308,6 +307,7 @@ err_irq:
2891 free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
2892 irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
2893 err:
2894 + iounmap(fsl_ifc_ctrl_dev->gregs);
2895 return ret;
2896 }
2897
2898 diff --git a/drivers/mfd/da9052-i2c.c b/drivers/mfd/da9052-i2c.c
2899 index 578e881067a58..4094f97ec7dc7 100644
2900 --- a/drivers/mfd/da9052-i2c.c
2901 +++ b/drivers/mfd/da9052-i2c.c
2902 @@ -118,6 +118,7 @@ static const struct i2c_device_id da9052_i2c_id[] = {
2903 {"da9053-bc", DA9053_BC},
2904 {}
2905 };
2906 +MODULE_DEVICE_TABLE(i2c, da9052_i2c_id);
2907
2908 #ifdef CONFIG_OF
2909 static const struct of_device_id dialog_dt_ids[] = {
2910 diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
2911 index 863c39a3353c9..d284df25c76ba 100644
2912 --- a/drivers/mfd/stmpe-i2c.c
2913 +++ b/drivers/mfd/stmpe-i2c.c
2914 @@ -109,7 +109,7 @@ static const struct i2c_device_id stmpe_i2c_id[] = {
2915 { "stmpe2403", STMPE2403 },
2916 { }
2917 };
2918 -MODULE_DEVICE_TABLE(i2c, stmpe_id);
2919 +MODULE_DEVICE_TABLE(i2c, stmpe_i2c_id);
2920
2921 static struct i2c_driver stmpe_i2c_driver = {
2922 .driver = {
2923 diff --git a/drivers/misc/ibmasm/module.c b/drivers/misc/ibmasm/module.c
2924 index 6b3bf9ab051db..706decef68a08 100644
2925 --- a/drivers/misc/ibmasm/module.c
2926 +++ b/drivers/misc/ibmasm/module.c
2927 @@ -123,7 +123,7 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
2928 result = ibmasm_init_remote_input_dev(sp);
2929 if (result) {
2930 dev_err(sp->dev, "Failed to initialize remote queue\n");
2931 - goto error_send_message;
2932 + goto error_init_remote;
2933 }
2934
2935 result = ibmasm_send_driver_vpd(sp);
2936 @@ -143,8 +143,9 @@ static int ibmasm_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
2937 return 0;
2938
2939 error_send_message:
2940 - disable_sp_interrupts(sp->base_address);
2941 ibmasm_free_remote_input_dev(sp);
2942 +error_init_remote:
2943 + disable_sp_interrupts(sp->base_address);
2944 free_irq(sp->irq, (void *)sp);
2945 error_request_irq:
2946 iounmap(sp->base_address);
2947 diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
2948 index b2c977d617c58..f0fa6a799f7ce 100644
2949 --- a/drivers/mmc/core/core.c
2950 +++ b/drivers/mmc/core/core.c
2951 @@ -1171,11 +1171,14 @@ int mmc_execute_tuning(struct mmc_card *card)
2952
2953 err = host->ops->execute_tuning(host, opcode);
2954
2955 - if (err)
2956 + if (err) {
2957 pr_err("%s: tuning execution failed: %d\n",
2958 mmc_hostname(host), err);
2959 - else
2960 + } else {
2961 + host->retune_now = 0;
2962 + host->need_retune = 0;
2963 mmc_retune_enable(host);
2964 + }
2965
2966 return err;
2967 }
2968 diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
2969 index 68b736547d817..0325083b10493 100644
2970 --- a/drivers/mmc/host/sdhci.c
2971 +++ b/drivers/mmc/host/sdhci.c
2972 @@ -1219,6 +1219,10 @@ static u16 sdhci_get_preset_value(struct sdhci_host *host)
2973 u16 preset = 0;
2974
2975 switch (host->timing) {
2976 + case MMC_TIMING_MMC_HS:
2977 + case MMC_TIMING_SD_HS:
2978 + preset = sdhci_readw(host, SDHCI_PRESET_FOR_HIGH_SPEED);
2979 + break;
2980 case MMC_TIMING_UHS_SDR12:
2981 preset = sdhci_readw(host, SDHCI_PRESET_FOR_SDR12);
2982 break;
2983 diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
2984 index 2570455b219a4..062db5f6ccac3 100644
2985 --- a/drivers/mmc/host/sdhci.h
2986 +++ b/drivers/mmc/host/sdhci.h
2987 @@ -237,6 +237,7 @@
2988
2989 /* 60-FB reserved */
2990
2991 +#define SDHCI_PRESET_FOR_HIGH_SPEED 0x64
2992 #define SDHCI_PRESET_FOR_SDR12 0x66
2993 #define SDHCI_PRESET_FOR_SDR25 0x68
2994 #define SDHCI_PRESET_FOR_SDR50 0x6A
2995 diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
2996 index 003aecc441223..ad0a467bb464a 100644
2997 --- a/drivers/mmc/host/usdhi6rol0.c
2998 +++ b/drivers/mmc/host/usdhi6rol0.c
2999 @@ -1809,6 +1809,7 @@ static int usdhi6_probe(struct platform_device *pdev)
3000
3001 version = usdhi6_read(host, USDHI6_VERSION);
3002 if ((version & 0xfff) != 0xa0d) {
3003 + ret = -EPERM;
3004 dev_err(dev, "Version not recognized %x\n", version);
3005 goto e_clk_off;
3006 }
3007 diff --git a/drivers/mmc/host/via-sdmmc.c b/drivers/mmc/host/via-sdmmc.c
3008 index b455e9cf95afc..a3472127bea31 100644
3009 --- a/drivers/mmc/host/via-sdmmc.c
3010 +++ b/drivers/mmc/host/via-sdmmc.c
3011 @@ -859,6 +859,9 @@ static void via_sdc_data_isr(struct via_crdr_mmc_host *host, u16 intmask)
3012 {
3013 BUG_ON(intmask == 0);
3014
3015 + if (!host->data)
3016 + return;
3017 +
3018 if (intmask & VIA_CRDR_SDSTS_DT)
3019 host->data->error = -ETIMEDOUT;
3020 else if (intmask & (VIA_CRDR_SDSTS_RC | VIA_CRDR_SDSTS_WC))
3021 diff --git a/drivers/mmc/host/vub300.c b/drivers/mmc/host/vub300.c
3022 index bb3e0d1dd3550..a3e4288e5391b 100644
3023 --- a/drivers/mmc/host/vub300.c
3024 +++ b/drivers/mmc/host/vub300.c
3025 @@ -2292,7 +2292,7 @@ static int vub300_probe(struct usb_interface *interface,
3026 if (retval < 0)
3027 goto error5;
3028 retval =
3029 - usb_control_msg(vub300->udev, usb_rcvctrlpipe(vub300->udev, 0),
3030 + usb_control_msg(vub300->udev, usb_sndctrlpipe(vub300->udev, 0),
3031 SET_ROM_WAIT_STATES,
3032 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
3033 firmware_rom_wait_states, 0x0000, NULL, 0, HZ);
3034 diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
3035 index d0846ae9e0e40..022a9b3c7d4e8 100644
3036 --- a/drivers/net/can/usb/ems_usb.c
3037 +++ b/drivers/net/can/usb/ems_usb.c
3038 @@ -1064,7 +1064,6 @@ static void ems_usb_disconnect(struct usb_interface *intf)
3039
3040 if (dev) {
3041 unregister_netdev(dev->netdev);
3042 - free_candev(dev->netdev);
3043
3044 unlink_all_urbs(dev);
3045
3046 @@ -1072,6 +1071,8 @@ static void ems_usb_disconnect(struct usb_interface *intf)
3047
3048 kfree(dev->intr_in_buffer);
3049 kfree(dev->tx_msg_buffer);
3050 +
3051 + free_candev(dev->netdev);
3052 }
3053 }
3054
3055 diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/aeroflex/greth.c
3056 index f8df8248035ec..31e02ca56572a 100644
3057 --- a/drivers/net/ethernet/aeroflex/greth.c
3058 +++ b/drivers/net/ethernet/aeroflex/greth.c
3059 @@ -1554,10 +1554,11 @@ static int greth_of_remove(struct platform_device *of_dev)
3060 mdiobus_unregister(greth->mdio);
3061
3062 unregister_netdev(ndev);
3063 - free_netdev(ndev);
3064
3065 of_iounmap(&of_dev->resource[0], greth->regs, resource_size(&of_dev->resource[0]));
3066
3067 + free_netdev(ndev);
3068 +
3069 return 0;
3070 }
3071
3072 diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
3073 index 223f35cc034cf..6de29f2a0a090 100644
3074 --- a/drivers/net/ethernet/ezchip/nps_enet.c
3075 +++ b/drivers/net/ethernet/ezchip/nps_enet.c
3076 @@ -624,7 +624,7 @@ static s32 nps_enet_probe(struct platform_device *pdev)
3077
3078 /* Get IRQ number */
3079 priv->irq = platform_get_irq(pdev, 0);
3080 - if (!priv->irq) {
3081 + if (priv->irq < 0) {
3082 dev_err(dev, "failed to retrieve <irq Rx-Tx> value from device tree\n");
3083 err = -ENODEV;
3084 goto out_netdev;
3085 @@ -659,8 +659,8 @@ static s32 nps_enet_remove(struct platform_device *pdev)
3086 struct nps_enet_priv *priv = netdev_priv(ndev);
3087
3088 unregister_netdev(ndev);
3089 - free_netdev(ndev);
3090 netif_napi_del(&priv->napi);
3091 + free_netdev(ndev);
3092
3093 return 0;
3094 }
3095 diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
3096 index 3692adb8902d1..6c70cba92df06 100644
3097 --- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
3098 +++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
3099 @@ -2656,10 +2656,8 @@ static int ehea_restart_qps(struct net_device *dev)
3100 u16 dummy16 = 0;
3101
3102 cb0 = (void *)get_zeroed_page(GFP_KERNEL);
3103 - if (!cb0) {
3104 - ret = -ENOMEM;
3105 - goto out;
3106 - }
3107 + if (!cb0)
3108 + return -ENOMEM;
3109
3110 for (i = 0; i < (port->num_def_qps); i++) {
3111 struct ehea_port_res *pr = &port->port_res[i];
3112 @@ -2679,6 +2677,7 @@ static int ehea_restart_qps(struct net_device *dev)
3113 cb0);
3114 if (hret != H_SUCCESS) {
3115 netdev_err(dev, "query_ehea_qp failed (1)\n");
3116 + ret = -EFAULT;
3117 goto out;
3118 }
3119
3120 @@ -2691,6 +2690,7 @@ static int ehea_restart_qps(struct net_device *dev)
3121 &dummy64, &dummy16, &dummy16);
3122 if (hret != H_SUCCESS) {
3123 netdev_err(dev, "modify_ehea_qp failed (1)\n");
3124 + ret = -EFAULT;
3125 goto out;
3126 }
3127
3128 @@ -2699,6 +2699,7 @@ static int ehea_restart_qps(struct net_device *dev)
3129 cb0);
3130 if (hret != H_SUCCESS) {
3131 netdev_err(dev, "query_ehea_qp failed (2)\n");
3132 + ret = -EFAULT;
3133 goto out;
3134 }
3135
3136 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
3137 index 93c29094ceff9..9035cb5fc70d3 100644
3138 --- a/drivers/net/ethernet/intel/e100.c
3139 +++ b/drivers/net/ethernet/intel/e100.c
3140 @@ -1423,7 +1423,7 @@ static int e100_phy_check_without_mii(struct nic *nic)
3141 u8 phy_type;
3142 int without_mii;
3143
3144 - phy_type = (nic->eeprom[eeprom_phy_iface] >> 8) & 0x0f;
3145 + phy_type = (le16_to_cpu(nic->eeprom[eeprom_phy_iface]) >> 8) & 0x0f;
3146
3147 switch (phy_type) {
3148 case NoSuchPhy: /* Non-MII PHY; UNTESTED! */
3149 @@ -1543,7 +1543,7 @@ static int e100_phy_init(struct nic *nic)
3150 mdio_write(netdev, nic->mii.phy_id, MII_BMCR, bmcr);
3151 } else if ((nic->mac >= mac_82550_D102) || ((nic->flags & ich) &&
3152 (mdio_read(netdev, nic->mii.phy_id, MII_TPISTATUS) & 0x8000) &&
3153 - (nic->eeprom[eeprom_cnfg_mdix] & eeprom_mdix_enabled))) {
3154 + (le16_to_cpu(nic->eeprom[eeprom_cnfg_mdix]) & eeprom_mdix_enabled))) {
3155 /* enable/disable MDI/MDI-X auto-switching. */
3156 mdio_write(netdev, nic->mii.phy_id, MII_NCONFIG,
3157 nic->mii.force_media ? 0 : NCONFIG_AUTO_SWITCH);
3158 @@ -2298,9 +2298,9 @@ static int e100_asf(struct nic *nic)
3159 {
3160 /* ASF can be enabled from eeprom */
3161 return (nic->pdev->device >= 0x1050) && (nic->pdev->device <= 0x1057) &&
3162 - (nic->eeprom[eeprom_config_asf] & eeprom_asf) &&
3163 - !(nic->eeprom[eeprom_config_asf] & eeprom_gcl) &&
3164 - ((nic->eeprom[eeprom_smbus_addr] & 0xFF) != 0xFE);
3165 + (le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_asf) &&
3166 + !(le16_to_cpu(nic->eeprom[eeprom_config_asf]) & eeprom_gcl) &&
3167 + ((le16_to_cpu(nic->eeprom[eeprom_smbus_addr]) & 0xFF) != 0xFE);
3168 }
3169
3170 static int e100_up(struct nic *nic)
3171 @@ -2952,7 +2952,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3172
3173 /* Wol magic packet can be enabled from eeprom */
3174 if ((nic->mac >= mac_82558_D101_A4) &&
3175 - (nic->eeprom[eeprom_id] & eeprom_id_wol)) {
3176 + (le16_to_cpu(nic->eeprom[eeprom_id]) & eeprom_id_wol)) {
3177 nic->flags |= wol_magic;
3178 device_set_wakeup_enable(&pdev->dev, true);
3179 }
3180 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
3181 index 0b1ee353f4150..832fffed4a1fa 100644
3182 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
3183 +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
3184 @@ -5478,6 +5478,8 @@ int i40e_vsi_open(struct i40e_vsi *vsi)
3185 dev_driver_string(&pf->pdev->dev),
3186 dev_name(&pf->pdev->dev));
3187 err = i40e_vsi_request_irq(vsi, int_name);
3188 + if (err)
3189 + goto err_setup_rx;
3190
3191 } else {
3192 err = -EINVAL;
3193 diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c
3194 index cb0102dd7f70f..d691c33dffc6b 100644
3195 --- a/drivers/net/ethernet/micrel/ks8842.c
3196 +++ b/drivers/net/ethernet/micrel/ks8842.c
3197 @@ -1150,6 +1150,10 @@ static int ks8842_probe(struct platform_device *pdev)
3198 unsigned i;
3199
3200 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
3201 + if (!iomem) {
3202 + dev_err(&pdev->dev, "Invalid resource\n");
3203 + return -EINVAL;
3204 + }
3205 if (!request_mem_region(iomem->start, resource_size(iomem), DRV_NAME))
3206 goto err_mem_region;
3207
3208 diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
3209 index 3cd87a41ac92c..cd59577a0c921 100644
3210 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
3211 +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
3212 @@ -124,7 +124,7 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid)
3213 {
3214 u8 *data = skb->data;
3215 unsigned int offset;
3216 - u16 *hi, *id;
3217 + u16 hi, id;
3218 u32 lo;
3219
3220 if (ptp_classify_raw(skb) == PTP_CLASS_NONE)
3221 @@ -135,14 +135,11 @@ static int pch_ptp_match(struct sk_buff *skb, u16 uid_hi, u32 uid_lo, u16 seqid)
3222 if (skb->len < offset + OFF_PTP_SEQUENCE_ID + sizeof(seqid))
3223 return 0;
3224
3225 - hi = (u16 *)(data + offset + OFF_PTP_SOURCE_UUID);
3226 - id = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
3227 + hi = get_unaligned_be16(data + offset + OFF_PTP_SOURCE_UUID + 0);
3228 + lo = get_unaligned_be32(data + offset + OFF_PTP_SOURCE_UUID + 2);
3229 + id = get_unaligned_be16(data + offset + OFF_PTP_SEQUENCE_ID);
3230
3231 - memcpy(&lo, &hi[1], sizeof(lo));
3232 -
3233 - return (uid_hi == *hi &&
3234 - uid_lo == lo &&
3235 - seqid == *id);
3236 + return (uid_hi == hi && uid_lo == lo && seqid == id);
3237 }
3238
3239 static void
3240 @@ -152,7 +149,6 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)
3241 struct pci_dev *pdev;
3242 u64 ns;
3243 u32 hi, lo, val;
3244 - u16 uid, seq;
3245
3246 if (!adapter->hwts_rx_en)
3247 return;
3248 @@ -168,10 +164,7 @@ pch_rx_timestamp(struct pch_gbe_adapter *adapter, struct sk_buff *skb)
3249 lo = pch_src_uuid_lo_read(pdev);
3250 hi = pch_src_uuid_hi_read(pdev);
3251
3252 - uid = hi & 0xffff;
3253 - seq = (hi >> 16) & 0xffff;
3254 -
3255 - if (!pch_ptp_match(skb, htons(uid), htonl(lo), htons(seq)))
3256 + if (!pch_ptp_match(skb, hi, lo, hi >> 16))
3257 goto out;
3258
3259 ns = pch_rx_snap_read(pdev);
3260 @@ -2617,9 +2610,13 @@ static int pch_gbe_probe(struct pci_dev *pdev,
3261 adapter->pdev = pdev;
3262 adapter->hw.back = adapter;
3263 adapter->hw.reg = pcim_iomap_table(pdev)[PCH_GBE_PCI_BAR];
3264 +
3265 adapter->pdata = (struct pch_gbe_privdata *)pci_id->driver_data;
3266 - if (adapter->pdata && adapter->pdata->platform_init)
3267 - adapter->pdata->platform_init(pdev);
3268 + if (adapter->pdata && adapter->pdata->platform_init) {
3269 + ret = adapter->pdata->platform_init(pdev);
3270 + if (ret)
3271 + goto err_free_netdev;
3272 + }
3273
3274 adapter->ptp_pdev = pci_get_bus_and_slot(adapter->pdev->bus->number,
3275 PCI_DEVFN(12, 4));
3276 @@ -2709,7 +2706,7 @@ err_free_netdev:
3277 */
3278 static int pch_gbe_minnow_platform_init(struct pci_dev *pdev)
3279 {
3280 - unsigned long flags = GPIOF_DIR_OUT | GPIOF_INIT_HIGH | GPIOF_EXPORT;
3281 + unsigned long flags = GPIOF_OUT_INIT_HIGH;
3282 unsigned gpio = MINNOW_PHY_RESET_GPIO;
3283 int ret;
3284
3285 diff --git a/drivers/net/ethernet/sfc/ef10_sriov.c b/drivers/net/ethernet/sfc/ef10_sriov.c
3286 index a949b9d27329e..bef23e19cbbd9 100644
3287 --- a/drivers/net/ethernet/sfc/ef10_sriov.c
3288 +++ b/drivers/net/ethernet/sfc/ef10_sriov.c
3289 @@ -405,12 +405,17 @@ fail1:
3290 return rc;
3291 }
3292
3293 +/* Disable SRIOV and remove VFs
3294 + * If some VFs are attached to a guest (using Xen, only) nothing is
3295 + * done if force=false, and vports are freed if force=true (for the non
3296 + * attachedc ones, only) but SRIOV is not disabled and VFs are not
3297 + * removed in either case.
3298 + */
3299 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
3300 {
3301 struct pci_dev *dev = efx->pci_dev;
3302 - unsigned int vfs_assigned = 0;
3303 -
3304 - vfs_assigned = pci_vfs_assigned(dev);
3305 + unsigned int vfs_assigned = pci_vfs_assigned(dev);
3306 + int rc = 0;
3307
3308 if (vfs_assigned && !force) {
3309 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; "
3310 @@ -420,10 +425,12 @@ static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
3311
3312 if (!vfs_assigned)
3313 pci_disable_sriov(dev);
3314 + else
3315 + rc = -EBUSY;
3316
3317 efx_ef10_sriov_free_vf_vswitching(efx);
3318 efx->vf_count = 0;
3319 - return 0;
3320 + return rc;
3321 }
3322
3323 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
3324 @@ -442,7 +449,6 @@ int efx_ef10_sriov_init(struct efx_nic *efx)
3325 void efx_ef10_sriov_fini(struct efx_nic *efx)
3326 {
3327 struct efx_ef10_nic_data *nic_data = efx->nic_data;
3328 - unsigned int i;
3329 int rc;
3330
3331 if (!nic_data->vf) {
3332 @@ -452,14 +458,7 @@ void efx_ef10_sriov_fini(struct efx_nic *efx)
3333 return;
3334 }
3335
3336 - /* Remove any VFs in the host */
3337 - for (i = 0; i < efx->vf_count; ++i) {
3338 - struct efx_nic *vf_efx = nic_data->vf[i].efx;
3339 -
3340 - if (vf_efx)
3341 - vf_efx->pci_dev->driver->remove(vf_efx->pci_dev);
3342 - }
3343 -
3344 + /* Disable SRIOV and remove any VFs in the host */
3345 rc = efx_ef10_pci_sriov_disable(efx, true);
3346 if (rc)
3347 netif_dbg(efx, drv, efx->net_dev,
3348 diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c
3349 index 3511d40ba3f11..440047a239f57 100644
3350 --- a/drivers/net/fjes/fjes_main.c
3351 +++ b/drivers/net/fjes/fjes_main.c
3352 @@ -1212,6 +1212,10 @@ static int fjes_probe(struct platform_device *plat_dev)
3353 adapter->interrupt_watch_enable = false;
3354
3355 res = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
3356 + if (!res) {
3357 + err = -EINVAL;
3358 + goto err_free_control_wq;
3359 + }
3360 hw->hw_res.start = res->start;
3361 hw->hw_res.size = resource_size(res);
3362 hw->hw_res.irq = platform_get_irq(plat_dev, 0);
3363 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
3364 index 088bb5870ac5b..0bfadec8b79c9 100644
3365 --- a/drivers/net/vxlan.c
3366 +++ b/drivers/net/vxlan.c
3367 @@ -1594,6 +1594,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb)
3368 struct neighbour *n;
3369 struct inet6_dev *in6_dev;
3370
3371 + rcu_read_lock();
3372 in6_dev = __in6_dev_get(dev);
3373 if (!in6_dev)
3374 goto out;
3375 @@ -1650,6 +1651,7 @@ static int neigh_reduce(struct net_device *dev, struct sk_buff *skb)
3376 }
3377
3378 out:
3379 + rcu_read_unlock();
3380 consume_skb(skb);
3381 return NETDEV_TX_OK;
3382 }
3383 diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
3384 index 564181bb0906a..314cac2ce0879 100644
3385 --- a/drivers/net/wireless/ath/ath10k/mac.c
3386 +++ b/drivers/net/wireless/ath/ath10k/mac.c
3387 @@ -4947,6 +4947,7 @@ static int ath10k_add_interface(struct ieee80211_hw *hw,
3388
3389 if (arvif->nohwcrypt &&
3390 !test_bit(ATH10K_FLAG_RAW_MODE, &ar->dev_flags)) {
3391 + ret = -EINVAL;
3392 ath10k_warn(ar, "cryptmode module param needed for sw crypto\n");
3393 goto err;
3394 }
3395 diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
3396 index 58af2fe5be3c1..454bf16d6b304 100644
3397 --- a/drivers/net/wireless/ath/ath9k/main.c
3398 +++ b/drivers/net/wireless/ath/ath9k/main.c
3399 @@ -302,6 +302,11 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan)
3400 hchan = ah->curchan;
3401 }
3402
3403 + if (!hchan) {
3404 + fastcc = false;
3405 + hchan = ath9k_cmn_get_channel(sc->hw, ah, &sc->cur_chan->chandef);
3406 + }
3407 +
3408 if (!ath_prepare_reset(sc))
3409 fastcc = false;
3410
3411 diff --git a/drivers/net/wireless/ath/carl9170/Kconfig b/drivers/net/wireless/ath/carl9170/Kconfig
3412 index 2e34baeaf7649..2b782db20fde4 100644
3413 --- a/drivers/net/wireless/ath/carl9170/Kconfig
3414 +++ b/drivers/net/wireless/ath/carl9170/Kconfig
3415 @@ -15,13 +15,11 @@ config CARL9170
3416
3417 config CARL9170_LEDS
3418 bool "SoftLED Support"
3419 - depends on CARL9170
3420 - select MAC80211_LEDS
3421 - select LEDS_CLASS
3422 - select NEW_LEDS
3423 default y
3424 + depends on CARL9170
3425 + depends on MAC80211_LEDS
3426 help
3427 - This option is necessary, if you want your device' LEDs to blink
3428 + This option is necessary, if you want your device's LEDs to blink.
3429
3430 Say Y, unless you need the LEDs for firmware debugging.
3431
3432 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
3433 index b820e80d4b4c2..8b56aa6274876 100644
3434 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
3435 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/mac80211_if.c
3436 @@ -1221,6 +1221,7 @@ static int brcms_bcma_probe(struct bcma_device *pdev)
3437 {
3438 struct brcms_info *wl;
3439 struct ieee80211_hw *hw;
3440 + int ret;
3441
3442 dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
3443 pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
3444 @@ -1245,11 +1246,16 @@ static int brcms_bcma_probe(struct bcma_device *pdev)
3445 wl = brcms_attach(pdev);
3446 if (!wl) {
3447 pr_err("%s: brcms_attach failed!\n", __func__);
3448 - return -ENODEV;
3449 + ret = -ENODEV;
3450 + goto err_free_ieee80211;
3451 }
3452 brcms_led_register(wl);
3453
3454 return 0;
3455 +
3456 +err_free_ieee80211:
3457 + ieee80211_free_hw(hw);
3458 + return ret;
3459 }
3460
3461 static int brcms_suspend(struct bcma_device *pdev)
3462 diff --git a/drivers/net/wireless/st/cw1200/cw1200_sdio.c b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
3463 index d3acc85932a56..de92107549eef 100644
3464 --- a/drivers/net/wireless/st/cw1200/cw1200_sdio.c
3465 +++ b/drivers/net/wireless/st/cw1200/cw1200_sdio.c
3466 @@ -62,6 +62,7 @@ static const struct sdio_device_id cw1200_sdio_ids[] = {
3467 { SDIO_DEVICE(SDIO_VENDOR_ID_STE, SDIO_DEVICE_ID_STE_CW1200) },
3468 { /* end: all zeroes */ },
3469 };
3470 +MODULE_DEVICE_TABLE(sdio, cw1200_sdio_ids);
3471
3472 /* hwbus_ops implemetation */
3473
3474 diff --git a/drivers/net/wireless/ti/wl1251/cmd.c b/drivers/net/wireless/ti/wl1251/cmd.c
3475 index ede31f048ef98..247f4310a38fe 100644
3476 --- a/drivers/net/wireless/ti/wl1251/cmd.c
3477 +++ b/drivers/net/wireless/ti/wl1251/cmd.c
3478 @@ -465,9 +465,12 @@ int wl1251_cmd_scan(struct wl1251 *wl, u8 *ssid, size_t ssid_len,
3479 cmd->channels[i].channel = channels[i]->hw_value;
3480 }
3481
3482 - cmd->params.ssid_len = ssid_len;
3483 - if (ssid)
3484 - memcpy(cmd->params.ssid, ssid, ssid_len);
3485 + if (ssid) {
3486 + int len = clamp_val(ssid_len, 0, IEEE80211_MAX_SSID_LEN);
3487 +
3488 + cmd->params.ssid_len = len;
3489 + memcpy(cmd->params.ssid, ssid, len);
3490 + }
3491
3492 ret = wl1251_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd));
3493 if (ret < 0) {
3494 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
3495 index 9bd635ec7827b..72991d3a55f10 100644
3496 --- a/drivers/net/wireless/ti/wl12xx/main.c
3497 +++ b/drivers/net/wireless/ti/wl12xx/main.c
3498 @@ -1516,6 +1516,13 @@ static int wl12xx_get_fuse_mac(struct wl1271 *wl)
3499 u32 mac1, mac2;
3500 int ret;
3501
3502 + /* Device may be in ELP from the bootloader or kexec */
3503 + ret = wlcore_write32(wl, WL12XX_WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
3504 + if (ret < 0)
3505 + goto out;
3506 +
3507 + usleep_range(500000, 700000);
3508 +
3509 ret = wlcore_set_partition(wl, &wl->ptable[PART_DRPW]);
3510 if (ret < 0)
3511 goto out;
3512 diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
3513 index e9360d5cbcbac..6a239c9bbf59b 100644
3514 --- a/drivers/of/fdt.c
3515 +++ b/drivers/of/fdt.c
3516 @@ -605,11 +605,11 @@ static int __init __reserved_mem_reserve_reg(unsigned long node,
3517
3518 if (size &&
3519 early_init_dt_reserve_memory_arch(base, size, nomap) == 0)
3520 - pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %ld MiB\n",
3521 - uname, &base, (unsigned long)size / SZ_1M);
3522 + pr_debug("Reserved memory: reserved region for node '%s': base %pa, size %lu MiB\n",
3523 + uname, &base, (unsigned long)(size / SZ_1M));
3524 else
3525 - pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %ld MiB\n",
3526 - uname, &base, (unsigned long)size / SZ_1M);
3527 + pr_info("Reserved memory: failed to reserve memory for node '%s': base %pa, size %lu MiB\n",
3528 + uname, &base, (unsigned long)(size / SZ_1M));
3529
3530 len -= t_len;
3531 if (first) {
3532 diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
3533 index f15bb936dfd84..fca446a13bbb2 100644
3534 --- a/drivers/of/of_reserved_mem.c
3535 +++ b/drivers/of/of_reserved_mem.c
3536 @@ -158,9 +158,9 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
3537 ret = early_init_dt_alloc_reserved_memory_arch(size,
3538 align, start, end, nomap, &base);
3539 if (ret == 0) {
3540 - pr_debug("allocated memory for '%s' node: base %pa, size %ld MiB\n",
3541 + pr_debug("allocated memory for '%s' node: base %pa, size %lu MiB\n",
3542 uname, &base,
3543 - (unsigned long)size / SZ_1M);
3544 + (unsigned long)(size / SZ_1M));
3545 break;
3546 }
3547 len -= t_len;
3548 @@ -170,8 +170,8 @@ static int __init __reserved_mem_alloc_size(unsigned long node,
3549 ret = early_init_dt_alloc_reserved_memory_arch(size, align,
3550 0, 0, nomap, &base);
3551 if (ret == 0)
3552 - pr_debug("allocated memory for '%s' node: base %pa, size %ld MiB\n",
3553 - uname, &base, (unsigned long)size / SZ_1M);
3554 + pr_debug("allocated memory for '%s' node: base %pa, size %lu MiB\n",
3555 + uname, &base, (unsigned long)(size / SZ_1M));
3556 }
3557
3558 if (base == 0) {
3559 diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
3560 index 51357377efbce..ac169cf0fa02b 100644
3561 --- a/drivers/pci/pci-label.c
3562 +++ b/drivers/pci/pci-label.c
3563 @@ -157,7 +157,7 @@ static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
3564 len = utf16s_to_utf8s((const wchar_t *)obj->buffer.pointer,
3565 obj->buffer.length,
3566 UTF16_LITTLE_ENDIAN,
3567 - buf, PAGE_SIZE);
3568 + buf, PAGE_SIZE - 1);
3569 buf[len] = '\n';
3570 }
3571
3572 diff --git a/drivers/phy/phy-dm816x-usb.c b/drivers/phy/phy-dm816x-usb.c
3573 index cbcce7cf0028e..2ed5fe20d7792 100644
3574 --- a/drivers/phy/phy-dm816x-usb.c
3575 +++ b/drivers/phy/phy-dm816x-usb.c
3576 @@ -246,19 +246,28 @@ static int dm816x_usb_phy_probe(struct platform_device *pdev)
3577
3578 pm_runtime_enable(phy->dev);
3579 generic_phy = devm_phy_create(phy->dev, NULL, &ops);
3580 - if (IS_ERR(generic_phy))
3581 - return PTR_ERR(generic_phy);
3582 + if (IS_ERR(generic_phy)) {
3583 + error = PTR_ERR(generic_phy);
3584 + goto clk_unprepare;
3585 + }
3586
3587 phy_set_drvdata(generic_phy, phy);
3588
3589 phy_provider = devm_of_phy_provider_register(phy->dev,
3590 of_phy_simple_xlate);
3591 - if (IS_ERR(phy_provider))
3592 - return PTR_ERR(phy_provider);
3593 + if (IS_ERR(phy_provider)) {
3594 + error = PTR_ERR(phy_provider);
3595 + goto clk_unprepare;
3596 + }
3597
3598 usb_add_phy_dev(&phy->phy);
3599
3600 return 0;
3601 +
3602 +clk_unprepare:
3603 + pm_runtime_disable(phy->dev);
3604 + clk_unprepare(phy->refclk);
3605 + return error;
3606 }
3607
3608 static int dm816x_usb_phy_remove(struct platform_device *pdev)
3609 diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
3610 index 1bb2493ad1d03..c762caba551f9 100644
3611 --- a/drivers/pinctrl/pinctrl-amd.c
3612 +++ b/drivers/pinctrl/pinctrl-amd.c
3613 @@ -896,6 +896,7 @@ static int amd_gpio_remove(struct platform_device *pdev)
3614 static const struct acpi_device_id amd_gpio_acpi_match[] = {
3615 { "AMD0030", 0 },
3616 { "AMDI0030", 0},
3617 + { "AMDI0031", 0},
3618 { },
3619 };
3620 MODULE_DEVICE_TABLE(acpi, amd_gpio_acpi_match);
3621 diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
3622 index f25278bb3e1a8..90b17cf74e9fd 100644
3623 --- a/drivers/platform/x86/toshiba_acpi.c
3624 +++ b/drivers/platform/x86/toshiba_acpi.c
3625 @@ -2866,6 +2866,7 @@ static int toshiba_acpi_setup_keyboard(struct toshiba_acpi_dev *dev)
3626
3627 if (!dev->info_supported && !dev->system_event_supported) {
3628 pr_warn("No hotkey query interface found\n");
3629 + error = -EINVAL;
3630 goto err_remove_filter;
3631 }
3632
3633 diff --git a/drivers/power/reset/gpio-poweroff.c b/drivers/power/reset/gpio-poweroff.c
3634 index be3d81ff51cc3..a44e3427fdeb0 100644
3635 --- a/drivers/power/reset/gpio-poweroff.c
3636 +++ b/drivers/power/reset/gpio-poweroff.c
3637 @@ -84,6 +84,7 @@ static const struct of_device_id of_gpio_poweroff_match[] = {
3638 { .compatible = "gpio-poweroff", },
3639 {},
3640 };
3641 +MODULE_DEVICE_TABLE(of, of_gpio_poweroff_match);
3642
3643 static struct platform_driver gpio_poweroff_driver = {
3644 .probe = gpio_poweroff_probe,
3645 diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
3646 index 0de9a958b29a5..b825e70a5196c 100644
3647 --- a/drivers/power/supply/Kconfig
3648 +++ b/drivers/power/supply/Kconfig
3649 @@ -490,7 +490,8 @@ config BATTERY_GOLDFISH
3650
3651 config BATTERY_RT5033
3652 tristate "RT5033 fuel gauge support"
3653 - depends on MFD_RT5033
3654 + depends on I2C
3655 + select REGMAP_I2C
3656 help
3657 This adds support for battery fuel gauge in Richtek RT5033 PMIC.
3658 The fuelgauge calculates and determines the battery state of charge
3659 diff --git a/drivers/power/supply/ab8500_btemp.c b/drivers/power/supply/ab8500_btemp.c
3660 index 6ffdc18f2599b..9f17d81767ea0 100644
3661 --- a/drivers/power/supply/ab8500_btemp.c
3662 +++ b/drivers/power/supply/ab8500_btemp.c
3663 @@ -1181,6 +1181,7 @@ static const struct of_device_id ab8500_btemp_match[] = {
3664 { .compatible = "stericsson,ab8500-btemp", },
3665 { },
3666 };
3667 +MODULE_DEVICE_TABLE(of, ab8500_btemp_match);
3668
3669 static struct platform_driver ab8500_btemp_driver = {
3670 .probe = ab8500_btemp_probe,
3671 diff --git a/drivers/power/supply/ab8500_charger.c b/drivers/power/supply/ab8500_charger.c
3672 index 48a11fd86a7f2..56b5023314334 100644
3673 --- a/drivers/power/supply/ab8500_charger.c
3674 +++ b/drivers/power/supply/ab8500_charger.c
3675 @@ -409,6 +409,14 @@ disable_otp:
3676 static void ab8500_power_supply_changed(struct ab8500_charger *di,
3677 struct power_supply *psy)
3678 {
3679 + /*
3680 + * This happens if we get notifications or interrupts and
3681 + * the platform has been configured not to support one or
3682 + * other type of charging.
3683 + */
3684 + if (!psy)
3685 + return;
3686 +
3687 if (di->autopower_cfg) {
3688 if (!di->usb.charger_connected &&
3689 !di->ac.charger_connected &&
3690 @@ -435,7 +443,15 @@ static void ab8500_charger_set_usb_connected(struct ab8500_charger *di,
3691 if (!connected)
3692 di->flags.vbus_drop_end = false;
3693
3694 - sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL, "present");
3695 + /*
3696 + * Sometimes the platform is configured not to support
3697 + * USB charging and no psy has been created, but we still
3698 + * will get these notifications.
3699 + */
3700 + if (di->usb_chg.psy) {
3701 + sysfs_notify(&di->usb_chg.psy->dev.kobj, NULL,
3702 + "present");
3703 + }
3704
3705 if (connected) {
3706 mutex_lock(&di->charger_attached_mutex);
3707 @@ -3736,6 +3752,7 @@ static const struct of_device_id ab8500_charger_match[] = {
3708 { .compatible = "stericsson,ab8500-charger", },
3709 { },
3710 };
3711 +MODULE_DEVICE_TABLE(of, ab8500_charger_match);
3712
3713 static struct platform_driver ab8500_charger_driver = {
3714 .probe = ab8500_charger_probe,
3715 diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
3716 index ea8c26a108f00..d6079e892e11f 100644
3717 --- a/drivers/power/supply/ab8500_fg.c
3718 +++ b/drivers/power/supply/ab8500_fg.c
3719 @@ -3229,6 +3229,7 @@ static const struct of_device_id ab8500_fg_match[] = {
3720 { .compatible = "stericsson,ab8500-fg", },
3721 { },
3722 };
3723 +MODULE_DEVICE_TABLE(of, ab8500_fg_match);
3724
3725 static struct platform_driver ab8500_fg_driver = {
3726 .probe = ab8500_fg_probe,
3727 diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
3728 index 13f23c00538b4..043836e6d347b 100644
3729 --- a/drivers/power/supply/charger-manager.c
3730 +++ b/drivers/power/supply/charger-manager.c
3731 @@ -1489,6 +1489,7 @@ static const struct of_device_id charger_manager_match[] = {
3732 },
3733 {},
3734 };
3735 +MODULE_DEVICE_TABLE(of, charger_manager_match);
3736
3737 static struct charger_desc *of_cm_parse_desc(struct device *dev)
3738 {
3739 diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
3740 index bcdd830484929..9310b85f3405e 100644
3741 --- a/drivers/power/supply/rt5033_battery.c
3742 +++ b/drivers/power/supply/rt5033_battery.c
3743 @@ -167,9 +167,16 @@ static const struct i2c_device_id rt5033_battery_id[] = {
3744 };
3745 MODULE_DEVICE_TABLE(i2c, rt5033_battery_id);
3746
3747 +static const struct of_device_id rt5033_battery_of_match[] = {
3748 + { .compatible = "richtek,rt5033-battery", },
3749 + { }
3750 +};
3751 +MODULE_DEVICE_TABLE(of, rt5033_battery_of_match);
3752 +
3753 static struct i2c_driver rt5033_battery_driver = {
3754 .driver = {
3755 .name = "rt5033-battery",
3756 + .of_match_table = rt5033_battery_of_match,
3757 },
3758 .probe = rt5033_battery_probe,
3759 .remove = rt5033_battery_remove,
3760 diff --git a/drivers/pwm/pwm-spear.c b/drivers/pwm/pwm-spear.c
3761 index 6c6b44fd3f438..2d11ac277de8d 100644
3762 --- a/drivers/pwm/pwm-spear.c
3763 +++ b/drivers/pwm/pwm-spear.c
3764 @@ -231,10 +231,6 @@ static int spear_pwm_probe(struct platform_device *pdev)
3765 static int spear_pwm_remove(struct platform_device *pdev)
3766 {
3767 struct spear_pwm_chip *pc = platform_get_drvdata(pdev);
3768 - int i;
3769 -
3770 - for (i = 0; i < NUM_PWM; i++)
3771 - pwm_disable(&pc->chip.pwms[i]);
3772
3773 /* clk was prepared in probe, hence unprepare it here */
3774 clk_unprepare(pc->clk);
3775 diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
3776 index 7e8906d6ab7a9..d76698ce6472e 100644
3777 --- a/drivers/pwm/pwm-tegra.c
3778 +++ b/drivers/pwm/pwm-tegra.c
3779 @@ -228,7 +228,6 @@ static int tegra_pwm_probe(struct platform_device *pdev)
3780 static int tegra_pwm_remove(struct platform_device *pdev)
3781 {
3782 struct tegra_pwm_chip *pc = platform_get_drvdata(pdev);
3783 - unsigned int i;
3784 int err;
3785
3786 if (WARN_ON(!pc))
3787 @@ -238,18 +237,6 @@ static int tegra_pwm_remove(struct platform_device *pdev)
3788 if (err < 0)
3789 return err;
3790
3791 - for (i = 0; i < pc->chip.npwm; i++) {
3792 - struct pwm_device *pwm = &pc->chip.pwms[i];
3793 -
3794 - if (!pwm_is_enabled(pwm))
3795 - if (clk_prepare_enable(pc->clk) < 0)
3796 - continue;
3797 -
3798 - pwm_writel(pc, i, 0);
3799 -
3800 - clk_disable_unprepare(pc->clk);
3801 - }
3802 -
3803 reset_control_assert(pc->rst);
3804 clk_disable_unprepare(pc->clk);
3805
3806 diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
3807 index 9ececfef42d67..bd91c95f73e0e 100644
3808 --- a/drivers/regulator/da9052-regulator.c
3809 +++ b/drivers/regulator/da9052-regulator.c
3810 @@ -258,7 +258,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
3811 case DA9052_ID_BUCK3:
3812 case DA9052_ID_LDO2:
3813 case DA9052_ID_LDO3:
3814 - ret = (new_sel - old_sel) * info->step_uV / 6250;
3815 + ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
3816 + 6250);
3817 break;
3818 }
3819
3820 diff --git a/drivers/reset/core.c b/drivers/reset/core.c
3821 index d0ebca301afc9..c15c898fe0dc0 100644
3822 --- a/drivers/reset/core.c
3823 +++ b/drivers/reset/core.c
3824 @@ -263,7 +263,10 @@ static struct reset_control *__reset_control_get_internal(
3825 if (!rstc)
3826 return ERR_PTR(-ENOMEM);
3827
3828 - try_module_get(rcdev->owner);
3829 + if (!try_module_get(rcdev->owner)) {
3830 + kfree(rstc);
3831 + return ERR_PTR(-ENODEV);
3832 + }
3833
3834 rstc->rcdev = rcdev;
3835 list_add(&rstc->list, &rcdev->reset_control_head);
3836 diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c
3837 index 31e7e23cc5be7..9396b69f75e8f 100644
3838 --- a/drivers/rtc/rtc-proc.c
3839 +++ b/drivers/rtc/rtc-proc.c
3840 @@ -26,8 +26,8 @@ static bool is_rtc_hctosys(struct rtc_device *rtc)
3841 int size;
3842 char name[NAME_SIZE];
3843
3844 - size = scnprintf(name, NAME_SIZE, "rtc%d", rtc->id);
3845 - if (size > NAME_SIZE)
3846 + size = snprintf(name, NAME_SIZE, "rtc%d", rtc->id);
3847 + if (size >= NAME_SIZE)
3848 return false;
3849
3850 return !strncmp(name, CONFIG_RTC_HCTOSYS_DEVICE, NAME_SIZE);
3851 diff --git a/drivers/s390/char/sclp_vt220.c b/drivers/s390/char/sclp_vt220.c
3852 index 68d6ee7ae504d..3e8b5906548f8 100644
3853 --- a/drivers/s390/char/sclp_vt220.c
3854 +++ b/drivers/s390/char/sclp_vt220.c
3855 @@ -34,8 +34,8 @@
3856 #define SCLP_VT220_MINOR 65
3857 #define SCLP_VT220_DRIVER_NAME "sclp_vt220"
3858 #define SCLP_VT220_DEVICE_NAME "ttysclp"
3859 -#define SCLP_VT220_CONSOLE_NAME "ttyS"
3860 -#define SCLP_VT220_CONSOLE_INDEX 1 /* console=ttyS1 */
3861 +#define SCLP_VT220_CONSOLE_NAME "ttysclp"
3862 +#define SCLP_VT220_CONSOLE_INDEX 0 /* console=ttysclp0 */
3863
3864 /* Representation of a single write request */
3865 struct sclp_vt220_request {
3866 diff --git a/drivers/s390/cio/chp.c b/drivers/s390/cio/chp.c
3867 index 876c7e6e3a992..6b8e7086c8078 100644
3868 --- a/drivers/s390/cio/chp.c
3869 +++ b/drivers/s390/cio/chp.c
3870 @@ -254,6 +254,9 @@ static ssize_t chp_status_write(struct device *dev,
3871 if (!num_args)
3872 return count;
3873
3874 + /* Wait until previous actions have settled. */
3875 + css_wait_for_slow_path();
3876 +
3877 if (!strncasecmp(cmd, "on", 2) || !strcmp(cmd, "1")) {
3878 mutex_lock(&cp->lock);
3879 error = s390_vary_chpid(cp->chpid, 1);
3880 diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
3881 index 67903c93328b0..6e695bc96b88e 100644
3882 --- a/drivers/s390/cio/chsc.c
3883 +++ b/drivers/s390/cio/chsc.c
3884 @@ -769,8 +769,6 @@ int chsc_chp_vary(struct chp_id chpid, int on)
3885 {
3886 struct channel_path *chp = chpid_to_chp(chpid);
3887
3888 - /* Wait until previous actions have settled. */
3889 - css_wait_for_slow_path();
3890 /*
3891 * Redo PathVerification on the devices the chpid connects to
3892 */
3893 diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c
3894 index 867b864f50479..4bca37d52bad8 100644
3895 --- a/drivers/scsi/FlashPoint.c
3896 +++ b/drivers/scsi/FlashPoint.c
3897 @@ -40,7 +40,7 @@ struct sccb_mgr_info {
3898 u16 si_per_targ_ultra_nego;
3899 u16 si_per_targ_no_disc;
3900 u16 si_per_targ_wide_nego;
3901 - u16 si_flags;
3902 + u16 si_mflags;
3903 unsigned char si_card_family;
3904 unsigned char si_bustype;
3905 unsigned char si_card_model[3];
3906 @@ -1070,22 +1070,22 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
3907 ScamFlg =
3908 (unsigned char)FPT_utilEERead(ioport, SCAM_CONFIG / 2);
3909
3910 - pCardInfo->si_flags = 0x0000;
3911 + pCardInfo->si_mflags = 0x0000;
3912
3913 if (i & 0x01)
3914 - pCardInfo->si_flags |= SCSI_PARITY_ENA;
3915 + pCardInfo->si_mflags |= SCSI_PARITY_ENA;
3916
3917 if (!(i & 0x02))
3918 - pCardInfo->si_flags |= SOFT_RESET;
3919 + pCardInfo->si_mflags |= SOFT_RESET;
3920
3921 if (i & 0x10)
3922 - pCardInfo->si_flags |= EXTENDED_TRANSLATION;
3923 + pCardInfo->si_mflags |= EXTENDED_TRANSLATION;
3924
3925 if (ScamFlg & SCAM_ENABLED)
3926 - pCardInfo->si_flags |= FLAG_SCAM_ENABLED;
3927 + pCardInfo->si_mflags |= FLAG_SCAM_ENABLED;
3928
3929 if (ScamFlg & SCAM_LEVEL2)
3930 - pCardInfo->si_flags |= FLAG_SCAM_LEVEL2;
3931 + pCardInfo->si_mflags |= FLAG_SCAM_LEVEL2;
3932
3933 j = (RD_HARPOON(ioport + hp_bm_ctrl) & ~SCSI_TERM_ENA_L);
3934 if (i & 0x04) {
3935 @@ -1101,7 +1101,7 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
3936
3937 if (!(RD_HARPOON(ioport + hp_page_ctrl) & NARROW_SCSI_CARD))
3938
3939 - pCardInfo->si_flags |= SUPPORT_16TAR_32LUN;
3940 + pCardInfo->si_mflags |= SUPPORT_16TAR_32LUN;
3941
3942 pCardInfo->si_card_family = HARPOON_FAMILY;
3943 pCardInfo->si_bustype = BUSTYPE_PCI;
3944 @@ -1137,15 +1137,15 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
3945
3946 if (pCardInfo->si_card_model[1] == '3') {
3947 if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
3948 - pCardInfo->si_flags |= LOW_BYTE_TERM;
3949 + pCardInfo->si_mflags |= LOW_BYTE_TERM;
3950 } else if (pCardInfo->si_card_model[2] == '0') {
3951 temp = RD_HARPOON(ioport + hp_xfer_pad);
3952 WR_HARPOON(ioport + hp_xfer_pad, (temp & ~BIT(4)));
3953 if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
3954 - pCardInfo->si_flags |= LOW_BYTE_TERM;
3955 + pCardInfo->si_mflags |= LOW_BYTE_TERM;
3956 WR_HARPOON(ioport + hp_xfer_pad, (temp | BIT(4)));
3957 if (RD_HARPOON(ioport + hp_ee_ctrl) & BIT(7))
3958 - pCardInfo->si_flags |= HIGH_BYTE_TERM;
3959 + pCardInfo->si_mflags |= HIGH_BYTE_TERM;
3960 WR_HARPOON(ioport + hp_xfer_pad, temp);
3961 } else {
3962 temp = RD_HARPOON(ioport + hp_ee_ctrl);
3963 @@ -1163,9 +1163,9 @@ static int FlashPoint_ProbeHostAdapter(struct sccb_mgr_info *pCardInfo)
3964 WR_HARPOON(ioport + hp_ee_ctrl, temp);
3965 WR_HARPOON(ioport + hp_xfer_pad, temp2);
3966 if (!(temp3 & BIT(7)))
3967 - pCardInfo->si_flags |= LOW_BYTE_TERM;
3968 + pCardInfo->si_mflags |= LOW_BYTE_TERM;
3969 if (!(temp3 & BIT(6)))
3970 - pCardInfo->si_flags |= HIGH_BYTE_TERM;
3971 + pCardInfo->si_mflags |= HIGH_BYTE_TERM;
3972 }
3973
3974 ARAM_ACCESS(ioport);
3975 @@ -1272,7 +1272,7 @@ static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info
3976 WR_HARPOON(ioport + hp_arb_id, pCardInfo->si_id);
3977 CurrCard->ourId = pCardInfo->si_id;
3978
3979 - i = (unsigned char)pCardInfo->si_flags;
3980 + i = (unsigned char)pCardInfo->si_mflags;
3981 if (i & SCSI_PARITY_ENA)
3982 WR_HARPOON(ioport + hp_portctrl_1, (HOST_MODE8 | CHK_SCSI_P));
3983
3984 @@ -1286,14 +1286,14 @@ static void *FlashPoint_HardwareResetHostAdapter(struct sccb_mgr_info
3985 j |= SCSI_TERM_ENA_H;
3986 WR_HARPOON(ioport + hp_ee_ctrl, j);
3987
3988 - if (!(pCardInfo->si_flags & SOFT_RESET)) {
3989 + if (!(pCardInfo->si_mflags & SOFT_RESET)) {
3990
3991 FPT_sresb(ioport, thisCard);
3992
3993 FPT_scini(thisCard, pCardInfo->si_id, 0);
3994 }
3995
3996 - if (pCardInfo->si_flags & POST_ALL_UNDERRRUNS)
3997 + if (pCardInfo->si_mflags & POST_ALL_UNDERRRUNS)
3998 CurrCard->globalFlags |= F_NO_FILTER;
3999
4000 if (pCurrNvRam) {
4001 diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
4002 index 741cc96379cb7..628bf2e6a526b 100644
4003 --- a/drivers/scsi/be2iscsi/be_main.c
4004 +++ b/drivers/scsi/be2iscsi/be_main.c
4005 @@ -5847,6 +5847,7 @@ hba_free:
4006 pci_disable_msix(phba->pcidev);
4007 pci_dev_put(phba->pcidev);
4008 iscsi_host_free(phba->shost);
4009 + pci_disable_pcie_error_reporting(pcidev);
4010 pci_set_drvdata(pcidev, NULL);
4011 disable_pci:
4012 pci_release_regions(pcidev);
4013 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
4014 index 604cf3385aae2..b6a9773326e30 100644
4015 --- a/drivers/scsi/hosts.c
4016 +++ b/drivers/scsi/hosts.c
4017 @@ -515,6 +515,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
4018 shost_printk(KERN_WARNING, shost,
4019 "error handler thread failed to spawn, error = %ld\n",
4020 PTR_ERR(shost->ehandler));
4021 + shost->ehandler = NULL;
4022 goto fail;
4023 }
4024
4025 diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
4026 index 50e2943c33377..30e954bb6c81e 100644
4027 --- a/drivers/scsi/libiscsi.c
4028 +++ b/drivers/scsi/libiscsi.c
4029 @@ -1384,7 +1384,6 @@ void iscsi_session_failure(struct iscsi_session *session,
4030 enum iscsi_err err)
4031 {
4032 struct iscsi_conn *conn;
4033 - struct device *dev;
4034
4035 spin_lock_bh(&session->frwd_lock);
4036 conn = session->leadconn;
4037 @@ -1393,10 +1392,8 @@ void iscsi_session_failure(struct iscsi_session *session,
4038 return;
4039 }
4040
4041 - dev = get_device(&conn->cls_conn->dev);
4042 + iscsi_get_conn(conn->cls_conn);
4043 spin_unlock_bh(&session->frwd_lock);
4044 - if (!dev)
4045 - return;
4046 /*
4047 * if the host is being removed bypass the connection
4048 * recovery initialization because we are going to kill
4049 @@ -1406,7 +1403,7 @@ void iscsi_session_failure(struct iscsi_session *session,
4050 iscsi_conn_error_event(conn->cls_conn, err);
4051 else
4052 iscsi_conn_failure(conn, err);
4053 - put_device(dev);
4054 + iscsi_put_conn(conn->cls_conn);
4055 }
4056 EXPORT_SYMBOL_GPL(iscsi_session_failure);
4057
4058 diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
4059 index 7d4a5bb916062..f17adfe1326b8 100644
4060 --- a/drivers/scsi/lpfc/lpfc_els.c
4061 +++ b/drivers/scsi/lpfc/lpfc_els.c
4062 @@ -1159,6 +1159,15 @@ stop_rr_fcf_flogi:
4063 phba->fcf.fcf_redisc_attempted = 0; /* reset */
4064 goto out;
4065 }
4066 + } else if (vport->port_state > LPFC_FLOGI &&
4067 + vport->fc_flag & FC_PT2PT) {
4068 + /*
4069 + * In a p2p topology, it is possible that discovery has
4070 + * already progressed, and this completion can be ignored.
4071 + * Recheck the indicated topology.
4072 + */
4073 + if (!sp->cmn.fPort)
4074 + goto out;
4075 }
4076
4077 flogifail:
4078 diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4079 index aa2078d7e23e2..58876b8a2e9f8 100644
4080 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4081 +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
4082 @@ -5199,8 +5199,10 @@ _scsih_expander_add(struct MPT3SAS_ADAPTER *ioc, u16 handle)
4083 handle, parent_handle, (unsigned long long)
4084 sas_expander->sas_address, sas_expander->num_phys);
4085
4086 - if (!sas_expander->num_phys)
4087 + if (!sas_expander->num_phys) {
4088 + rc = -1;
4089 goto out_fail;
4090 + }
4091 sas_expander->phy = kcalloc(sas_expander->num_phys,
4092 sizeof(struct _sas_phy), GFP_KERNEL);
4093 if (!sas_expander->phy) {
4094 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
4095 index 80341863caa5e..32522652d055b 100644
4096 --- a/drivers/scsi/scsi_lib.c
4097 +++ b/drivers/scsi/scsi_lib.c
4098 @@ -915,6 +915,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
4099 case 0x07: /* operation in progress */
4100 case 0x08: /* Long write in progress */
4101 case 0x09: /* self test in progress */
4102 + case 0x11: /* notify (enable spinup) required */
4103 case 0x14: /* space allocation in progress */
4104 action = ACTION_DELAYED_RETRY;
4105 break;
4106 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
4107 index 4f4d2d65a4a70..337aad0660fae 100644
4108 --- a/drivers/scsi/scsi_transport_iscsi.c
4109 +++ b/drivers/scsi/scsi_transport_iscsi.c
4110 @@ -2327,6 +2327,18 @@ int iscsi_destroy_conn(struct iscsi_cls_conn *conn)
4111 }
4112 EXPORT_SYMBOL_GPL(iscsi_destroy_conn);
4113
4114 +void iscsi_put_conn(struct iscsi_cls_conn *conn)
4115 +{
4116 + put_device(&conn->dev);
4117 +}
4118 +EXPORT_SYMBOL_GPL(iscsi_put_conn);
4119 +
4120 +void iscsi_get_conn(struct iscsi_cls_conn *conn)
4121 +{
4122 + get_device(&conn->dev);
4123 +}
4124 +EXPORT_SYMBOL_GPL(iscsi_get_conn);
4125 +
4126 /*
4127 * iscsi interface functions
4128 */
4129 diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
4130 index 7120083fe7610..cac38753d0cd3 100644
4131 --- a/drivers/spi/spi-loopback-test.c
4132 +++ b/drivers/spi/spi-loopback-test.c
4133 @@ -803,7 +803,7 @@ static int spi_test_run_iter(struct spi_device *spi,
4134 test.transfers[i].len = len;
4135 if (test.transfers[i].tx_buf)
4136 test.transfers[i].tx_buf += tx_off;
4137 - if (test.transfers[i].tx_buf)
4138 + if (test.transfers[i].rx_buf)
4139 test.transfers[i].rx_buf += rx_off;
4140 }
4141
4142 diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
4143 index 1eccdc4a45817..2eeb0fe2eed28 100644
4144 --- a/drivers/spi/spi-omap-100k.c
4145 +++ b/drivers/spi/spi-omap-100k.c
4146 @@ -251,7 +251,7 @@ static int omap1_spi100k_setup_transfer(struct spi_device *spi,
4147 else
4148 word_len = spi->bits_per_word;
4149
4150 - if (spi->bits_per_word > 32)
4151 + if (word_len > 32)
4152 return -EINVAL;
4153 cs->word_len = word_len;
4154
4155 diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
4156 index 17068e62e792d..8c3f5a00fd9e1 100644
4157 --- a/drivers/spi/spi-sun6i.c
4158 +++ b/drivers/spi/spi-sun6i.c
4159 @@ -251,6 +251,10 @@ static int sun6i_spi_transfer_one(struct spi_master *master,
4160 }
4161
4162 sun6i_spi_write(sspi, SUN6I_CLK_CTL_REG, reg);
4163 + /* Finally enable the bus - doing so before might raise SCK to HIGH */
4164 + reg = sun6i_spi_read(sspi, SUN6I_GBL_CTL_REG);
4165 + reg |= SUN6I_GBL_CTL_BUS_ENABLE;
4166 + sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG, reg);
4167
4168 /* Setup the transfer now... */
4169 if (sspi->tx_buf)
4170 @@ -334,7 +338,7 @@ static int sun6i_spi_runtime_resume(struct device *dev)
4171 }
4172
4173 sun6i_spi_write(sspi, SUN6I_GBL_CTL_REG,
4174 - SUN6I_GBL_CTL_BUS_ENABLE | SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP);
4175 + SUN6I_GBL_CTL_MASTER | SUN6I_GBL_CTL_TP);
4176
4177 return 0;
4178
4179 diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
4180 index fe707440f8c3b..9b24ebbba346d 100644
4181 --- a/drivers/spi/spi-topcliff-pch.c
4182 +++ b/drivers/spi/spi-topcliff-pch.c
4183 @@ -585,8 +585,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
4184 data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
4185 if (data->pkt_tx_buff != NULL) {
4186 data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
4187 - if (!data->pkt_rx_buff)
4188 + if (!data->pkt_rx_buff) {
4189 kfree(data->pkt_tx_buff);
4190 + data->pkt_tx_buff = NULL;
4191 + }
4192 }
4193
4194 if (!data->pkt_rx_buff) {
4195 diff --git a/drivers/ssb/sdio.c b/drivers/ssb/sdio.c
4196 index 2278e43614bd1..5e10514ef80c1 100644
4197 --- a/drivers/ssb/sdio.c
4198 +++ b/drivers/ssb/sdio.c
4199 @@ -411,7 +411,6 @@ static void ssb_sdio_block_write(struct ssb_device *dev, const void *buffer,
4200 sdio_claim_host(bus->host_sdio);
4201 if (unlikely(ssb_sdio_switch_core(bus, dev))) {
4202 error = -EIO;
4203 - memset((void *)buffer, 0xff, count);
4204 goto err_out;
4205 }
4206 offset |= bus->sdio_sbaddr & 0xffff;
4207 diff --git a/drivers/staging/gdm724x/gdm_lte.c b/drivers/staging/gdm724x/gdm_lte.c
4208 index e72dfa9699f3e..454e47424adea 100644
4209 --- a/drivers/staging/gdm724x/gdm_lte.c
4210 +++ b/drivers/staging/gdm724x/gdm_lte.c
4211 @@ -624,10 +624,12 @@ static void gdm_lte_netif_rx(struct net_device *dev, char *buf,
4212 * bytes (99,130,83,99 dec)
4213 */
4214 } __packed;
4215 - void *addr = buf + sizeof(struct iphdr) +
4216 - sizeof(struct udphdr) +
4217 - offsetof(struct dhcp_packet, chaddr);
4218 - ether_addr_copy(nic->dest_mac_addr, addr);
4219 + int offset = sizeof(struct iphdr) +
4220 + sizeof(struct udphdr) +
4221 + offsetof(struct dhcp_packet, chaddr);
4222 + if (offset + ETH_ALEN > len)
4223 + return;
4224 + ether_addr_copy(nic->dest_mac_addr, buf + offset);
4225 }
4226 }
4227
4228 @@ -689,6 +691,7 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
4229 struct multi_sdu *multi_sdu = (struct multi_sdu *)buf;
4230 struct sdu *sdu = NULL;
4231 u8 *data = (u8 *)multi_sdu->data;
4232 + int copied;
4233 u16 i = 0;
4234 u16 num_packet;
4235 u16 hci_len;
4236 @@ -702,6 +705,12 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
4237 multi_sdu->num_packet);
4238
4239 for (i = 0; i < num_packet; i++) {
4240 + copied = data - multi_sdu->data;
4241 + if (len < copied + sizeof(*sdu)) {
4242 + pr_err("rx prevent buffer overflow");
4243 + return;
4244 + }
4245 +
4246 sdu = (struct sdu *)data;
4247
4248 cmd_evt = gdm_dev16_to_cpu(phy_dev->
4249 @@ -715,7 +724,8 @@ static void gdm_lte_multi_sdu_pkt(struct phy_dev *phy_dev, char *buf, int len)
4250 pr_err("rx sdu wrong hci %04x\n", cmd_evt);
4251 return;
4252 }
4253 - if (hci_len < 12) {
4254 + if (hci_len < 12 ||
4255 + len < copied + sizeof(*sdu) + (hci_len - 12)) {
4256 pr_err("rx sdu invalid len %d\n", hci_len);
4257 return;
4258 }
4259 diff --git a/drivers/staging/media/s5p-cec/s5p_cec.c b/drivers/staging/media/s5p-cec/s5p_cec.c
4260 index 58d7562311360..bebd44d9bd51a 100644
4261 --- a/drivers/staging/media/s5p-cec/s5p_cec.c
4262 +++ b/drivers/staging/media/s5p-cec/s5p_cec.c
4263 @@ -54,7 +54,7 @@ static int s5p_cec_adap_enable(struct cec_adapter *adap, bool enable)
4264 } else {
4265 s5p_cec_mask_tx_interrupts(cec);
4266 s5p_cec_mask_rx_interrupts(cec);
4267 - pm_runtime_disable(cec->dev);
4268 + pm_runtime_put(cec->dev);
4269 }
4270
4271 return 0;
4272 diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
4273 index d6fd0e802ef51..37c7cea8c34f9 100644
4274 --- a/drivers/tty/nozomi.c
4275 +++ b/drivers/tty/nozomi.c
4276 @@ -1437,7 +1437,7 @@ static int nozomi_card_init(struct pci_dev *pdev,
4277 NOZOMI_NAME, dc);
4278 if (unlikely(ret)) {
4279 dev_err(&pdev->dev, "can't request irq %d\n", pdev->irq);
4280 - goto err_free_kfifo;
4281 + goto err_free_all_kfifo;
4282 }
4283
4284 DBG1("base_addr: %p", dc->base_addr);
4285 @@ -1475,12 +1475,15 @@ static int nozomi_card_init(struct pci_dev *pdev,
4286 return 0;
4287
4288 err_free_tty:
4289 - for (i = 0; i < MAX_PORT; ++i) {
4290 + for (i--; i >= 0; i--) {
4291 tty_unregister_device(ntty_driver, dc->index_start + i);
4292 tty_port_destroy(&dc->port[i].port);
4293 }
4294 + free_irq(pdev->irq, dc);
4295 +err_free_all_kfifo:
4296 + i = MAX_PORT;
4297 err_free_kfifo:
4298 - for (i = 0; i < MAX_PORT; i++)
4299 + for (i--; i >= PORT_MDM; i--)
4300 kfifo_free(&dc->port[i].fifo_ul);
4301 err_free_sbuf:
4302 kfree(dc->send_buf);
4303 diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
4304 index 8106353ce7aa0..3747991024d51 100644
4305 --- a/drivers/tty/serial/8250/serial_cs.c
4306 +++ b/drivers/tty/serial/8250/serial_cs.c
4307 @@ -305,6 +305,7 @@ static int serial_resume(struct pcmcia_device *link)
4308 static int serial_probe(struct pcmcia_device *link)
4309 {
4310 struct serial_info *info;
4311 + int ret;
4312
4313 dev_dbg(&link->dev, "serial_attach()\n");
4314
4315 @@ -319,7 +320,15 @@ static int serial_probe(struct pcmcia_device *link)
4316 if (do_sound)
4317 link->config_flags |= CONF_ENABLE_SPKR;
4318
4319 - return serial_config(link);
4320 + ret = serial_config(link);
4321 + if (ret)
4322 + goto free_info;
4323 +
4324 + return 0;
4325 +
4326 +free_info:
4327 + kfree(info);
4328 + return ret;
4329 }
4330
4331 static void serial_detach(struct pcmcia_device *link)
4332 @@ -779,6 +788,7 @@ static const struct pcmcia_device_id serial_ids[] = {
4333 PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e),
4334 PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a),
4335 PCMCIA_DEVICE_PROD_ID12("Option International", "V34bis GSM/PSTN Data/Fax Modem", 0x9d7cd6f5, 0x5cb8bf41),
4336 + PCMCIA_DEVICE_PROD_ID12("Option International", "GSM-Ready 56K/ISDN", 0x9d7cd6f5, 0xb23844aa),
4337 PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab),
4338 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f),
4339 PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "Dual RS-232 Serial Port PC Card", 0xc4420b35, 0x031a380d),
4340 @@ -806,7 +816,6 @@ static const struct pcmcia_device_id serial_ids[] = {
4341 PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "cis/COMpad4.cis"),
4342 PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "cis/COMpad2.cis"),
4343 PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "cis/RS-COM-2P.cis"),
4344 - PCMCIA_DEVICE_CIS_MANF_CARD(0x0013, 0x0000, "cis/GLOBETROTTER.cis"),
4345 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100 1.00.", 0x19ca78af, 0xf964f42b),
4346 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL100", 0x19ca78af, 0x71d98e83),
4347 PCMCIA_DEVICE_PROD_ID12("ELAN DIGITAL SYSTEMS LTD, c1997.", "SERIAL CARD: SL232 1.00.", 0x19ca78af, 0x69fb7490),
4348 diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
4349 index 5b6093dc3ff26..a4c1797e30d71 100644
4350 --- a/drivers/tty/serial/fsl_lpuart.c
4351 +++ b/drivers/tty/serial/fsl_lpuart.c
4352 @@ -1766,6 +1766,9 @@ lpuart32_console_get_options(struct lpuart_port *sport, int *baud,
4353
4354 bd = lpuart32_read(sport->port.membase + UARTBAUD);
4355 bd &= UARTBAUD_SBR_MASK;
4356 + if (!bd)
4357 + return;
4358 +
4359 sbr = bd;
4360 uartclk = clk_get_rate(sport->clk);
4361 /*
4362 diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
4363 index ea35f51442378..b4f528d26bf1a 100644
4364 --- a/drivers/tty/serial/sh-sci.c
4365 +++ b/drivers/tty/serial/sh-sci.c
4366 @@ -612,6 +612,14 @@ static void sci_stop_tx(struct uart_port *port)
4367 ctrl &= ~SCSCR_TIE;
4368
4369 serial_port_out(port, SCSCR, ctrl);
4370 +
4371 +#ifdef CONFIG_SERIAL_SH_SCI_DMA
4372 + if (to_sci_port(port)->chan_tx &&
4373 + !dma_submit_error(to_sci_port(port)->cookie_tx)) {
4374 + dmaengine_terminate_async(to_sci_port(port)->chan_tx);
4375 + to_sci_port(port)->cookie_tx = -EINVAL;
4376 + }
4377 +#endif
4378 }
4379
4380 static void sci_start_rx(struct uart_port *port)
4381 diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
4382 index a70d2341ada63..23df1549eb0d8 100644
4383 --- a/drivers/usb/class/cdc-acm.c
4384 +++ b/drivers/usb/class/cdc-acm.c
4385 @@ -1894,6 +1894,11 @@ static const struct usb_device_id acm_ids[] = {
4386 .driver_info = IGNORE_DEVICE,
4387 },
4388
4389 + /* Exclude Heimann Sensor GmbH USB appset demo */
4390 + { USB_DEVICE(0x32a7, 0x0000),
4391 + .driver_info = IGNORE_DEVICE,
4392 + },
4393 +
4394 /* control interfaces without any protocol set */
4395 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM,
4396 USB_CDC_PROTO_NONE) },
4397 diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c
4398 index 5abc27f12a418..b8fcc202e0a35 100644
4399 --- a/drivers/usb/gadget/function/f_eem.c
4400 +++ b/drivers/usb/gadget/function/f_eem.c
4401 @@ -34,6 +34,11 @@ struct f_eem {
4402 u8 ctrl_id;
4403 };
4404
4405 +struct in_context {
4406 + struct sk_buff *skb;
4407 + struct usb_ep *ep;
4408 +};
4409 +
4410 static inline struct f_eem *func_to_eem(struct usb_function *f)
4411 {
4412 return container_of(f, struct f_eem, port.func);
4413 @@ -327,9 +332,12 @@ fail:
4414
4415 static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req)
4416 {
4417 - struct sk_buff *skb = (struct sk_buff *)req->context;
4418 + struct in_context *ctx = req->context;
4419
4420 - dev_kfree_skb_any(skb);
4421 + dev_kfree_skb_any(ctx->skb);
4422 + kfree(req->buf);
4423 + usb_ep_free_request(ctx->ep, req);
4424 + kfree(ctx);
4425 }
4426
4427 /*
4428 @@ -417,7 +425,9 @@ static int eem_unwrap(struct gether *port,
4429 * b15: bmType (0 == data, 1 == command)
4430 */
4431 if (header & BIT(15)) {
4432 - struct usb_request *req = cdev->req;
4433 + struct usb_request *req;
4434 + struct in_context *ctx;
4435 + struct usb_ep *ep;
4436 u16 bmEEMCmd;
4437
4438 /* EEM command packet format:
4439 @@ -446,11 +456,36 @@ static int eem_unwrap(struct gether *port,
4440 skb_trim(skb2, len);
4441 put_unaligned_le16(BIT(15) | BIT(11) | len,
4442 skb_push(skb2, 2));
4443 +
4444 + ep = port->in_ep;
4445 + req = usb_ep_alloc_request(ep, GFP_ATOMIC);
4446 + if (!req) {
4447 + dev_kfree_skb_any(skb2);
4448 + goto next;
4449 + }
4450 +
4451 + req->buf = kmalloc(skb2->len, GFP_KERNEL);
4452 + if (!req->buf) {
4453 + usb_ep_free_request(ep, req);
4454 + dev_kfree_skb_any(skb2);
4455 + goto next;
4456 + }
4457 +
4458 + ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
4459 + if (!ctx) {
4460 + kfree(req->buf);
4461 + usb_ep_free_request(ep, req);
4462 + dev_kfree_skb_any(skb2);
4463 + goto next;
4464 + }
4465 + ctx->skb = skb2;
4466 + ctx->ep = ep;
4467 +
4468 skb_copy_bits(skb2, 0, req->buf, skb2->len);
4469 req->length = skb2->len;
4470 req->complete = eem_cmd_complete;
4471 req->zero = 1;
4472 - req->context = skb2;
4473 + req->context = ctx;
4474 if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
4475 DBG(cdev, "echo response queue fail\n");
4476 break;
4477 diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
4478 index 42e5677d932d8..dd415b1589b5c 100644
4479 --- a/drivers/usb/gadget/function/f_hid.c
4480 +++ b/drivers/usb/gadget/function/f_hid.c
4481 @@ -91,7 +91,7 @@ static struct usb_interface_descriptor hidg_interface_desc = {
4482 static struct hid_descriptor hidg_desc = {
4483 .bLength = sizeof hidg_desc,
4484 .bDescriptorType = HID_DT_HID,
4485 - .bcdHID = 0x0101,
4486 + .bcdHID = cpu_to_le16(0x0101),
4487 .bCountryCode = 0x00,
4488 .bNumDescriptors = 0x1,
4489 /*.desc[0].bDescriptorType = DYNAMIC */
4490 diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
4491 index a71a884f79fc7..cccbb948821b2 100644
4492 --- a/drivers/usb/gadget/legacy/hid.c
4493 +++ b/drivers/usb/gadget/legacy/hid.c
4494 @@ -175,8 +175,10 @@ static int hid_bind(struct usb_composite_dev *cdev)
4495 struct usb_descriptor_header *usb_desc;
4496
4497 usb_desc = usb_otg_descriptor_alloc(gadget);
4498 - if (!usb_desc)
4499 + if (!usb_desc) {
4500 + status = -ENOMEM;
4501 goto put;
4502 + }
4503 usb_otg_descriptor_init(gadget, usb_desc);
4504 otg_desc[0] = usb_desc;
4505 otg_desc[1] = NULL;
4506 diff --git a/drivers/video/backlight/lm3630a_bl.c b/drivers/video/backlight/lm3630a_bl.c
4507 index 1771220b2437f..90a24b9752405 100644
4508 --- a/drivers/video/backlight/lm3630a_bl.c
4509 +++ b/drivers/video/backlight/lm3630a_bl.c
4510 @@ -183,7 +183,7 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
4511 if ((pwm_ctrl & LM3630A_PWM_BANK_A) != 0) {
4512 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
4513 bl->props.max_brightness);
4514 - return bl->props.brightness;
4515 + return 0;
4516 }
4517
4518 /* disable sleep */
4519 @@ -203,8 +203,8 @@ static int lm3630a_bank_a_update_status(struct backlight_device *bl)
4520 return 0;
4521
4522 out_i2c_err:
4523 - dev_err(pchip->dev, "i2c failed to access\n");
4524 - return bl->props.brightness;
4525 + dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
4526 + return ret;
4527 }
4528
4529 static int lm3630a_bank_a_get_brightness(struct backlight_device *bl)
4530 @@ -260,7 +260,7 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
4531 if ((pwm_ctrl & LM3630A_PWM_BANK_B) != 0) {
4532 lm3630a_pwm_ctrl(pchip, bl->props.brightness,
4533 bl->props.max_brightness);
4534 - return bl->props.brightness;
4535 + return 0;
4536 }
4537
4538 /* disable sleep */
4539 @@ -280,8 +280,8 @@ static int lm3630a_bank_b_update_status(struct backlight_device *bl)
4540 return 0;
4541
4542 out_i2c_err:
4543 - dev_err(pchip->dev, "i2c failed to access REG_CTRL\n");
4544 - return bl->props.brightness;
4545 + dev_err(pchip->dev, "i2c failed to access (%pe)\n", ERR_PTR(ret));
4546 + return ret;
4547 }
4548
4549 static int lm3630a_bank_b_get_brightness(struct backlight_device *bl)
4550 diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
4551 index f5ad8023c2e6a..1c47e6345b57e 100644
4552 --- a/drivers/watchdog/aspeed_wdt.c
4553 +++ b/drivers/watchdog/aspeed_wdt.c
4554 @@ -100,7 +100,7 @@ static int aspeed_wdt_set_timeout(struct watchdog_device *wdd,
4555
4556 wdd->timeout = timeout;
4557
4558 - actual = min(timeout, wdd->max_hw_heartbeat_ms * 1000);
4559 + actual = min(timeout, wdd->max_hw_heartbeat_ms / 1000);
4560
4561 writel(actual * WDT_RATE_1MHZ, wdt->base + WDT_RELOAD_VALUE);
4562 writel(WDT_RESTART_MAGIC, wdt->base + WDT_RESTART);
4563 diff --git a/drivers/watchdog/lpc18xx_wdt.c b/drivers/watchdog/lpc18xx_wdt.c
4564 index fd171e6caa167..1b63d1d85aa0e 100644
4565 --- a/drivers/watchdog/lpc18xx_wdt.c
4566 +++ b/drivers/watchdog/lpc18xx_wdt.c
4567 @@ -300,7 +300,7 @@ static int lpc18xx_wdt_remove(struct platform_device *pdev)
4568 struct lpc18xx_wdt_dev *lpc18xx_wdt = platform_get_drvdata(pdev);
4569
4570 dev_warn(&pdev->dev, "I quit now, hardware will probably reboot!\n");
4571 - del_timer(&lpc18xx_wdt->timer);
4572 + del_timer_sync(&lpc18xx_wdt->timer);
4573
4574 watchdog_unregister_device(&lpc18xx_wdt->wdt_dev);
4575 clk_disable_unprepare(lpc18xx_wdt->wdt_clk);
4576 diff --git a/drivers/watchdog/sbc60xxwdt.c b/drivers/watchdog/sbc60xxwdt.c
4577 index 2eef58a0cf059..152db059d5aa1 100644
4578 --- a/drivers/watchdog/sbc60xxwdt.c
4579 +++ b/drivers/watchdog/sbc60xxwdt.c
4580 @@ -152,7 +152,7 @@ static void wdt_startup(void)
4581 static void wdt_turnoff(void)
4582 {
4583 /* Stop the timer */
4584 - del_timer(&timer);
4585 + del_timer_sync(&timer);
4586 inb_p(wdt_stop);
4587 pr_info("Watchdog timer is now disabled...\n");
4588 }
4589 diff --git a/drivers/watchdog/sc520_wdt.c b/drivers/watchdog/sc520_wdt.c
4590 index 1cfd3f6a13d5f..08500db8324f3 100644
4591 --- a/drivers/watchdog/sc520_wdt.c
4592 +++ b/drivers/watchdog/sc520_wdt.c
4593 @@ -190,7 +190,7 @@ static int wdt_startup(void)
4594 static int wdt_turnoff(void)
4595 {
4596 /* Stop the timer */
4597 - del_timer(&timer);
4598 + del_timer_sync(&timer);
4599
4600 /* Stop the watchdog */
4601 wdt_config(0);
4602 diff --git a/drivers/watchdog/w83877f_wdt.c b/drivers/watchdog/w83877f_wdt.c
4603 index f0483c75ed324..4b52cf321747e 100644
4604 --- a/drivers/watchdog/w83877f_wdt.c
4605 +++ b/drivers/watchdog/w83877f_wdt.c
4606 @@ -170,7 +170,7 @@ static void wdt_startup(void)
4607 static void wdt_turnoff(void)
4608 {
4609 /* Stop the timer */
4610 - del_timer(&timer);
4611 + del_timer_sync(&timer);
4612
4613 wdt_change(WDT_DISABLE);
4614
4615 diff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig
4616 index 80e9c18ea64f6..fd6b67c40d9dd 100644
4617 --- a/fs/btrfs/Kconfig
4618 +++ b/fs/btrfs/Kconfig
4619 @@ -9,6 +9,8 @@ config BTRFS_FS
4620 select RAID6_PQ
4621 select XOR_BLOCKS
4622 select SRCU
4623 + depends on !PPC_256K_PAGES # powerpc
4624 + depends on !PAGE_SIZE_256KB # hexagon
4625
4626 help
4627 Btrfs is a general purpose copy-on-write filesystem with extents,
4628 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
4629 index 4d8f8a8c9c908..29e75fba53765 100644
4630 --- a/fs/btrfs/delayed-inode.c
4631 +++ b/fs/btrfs/delayed-inode.c
4632 @@ -1076,6 +1076,14 @@ err_out:
4633 btrfs_delayed_inode_release_metadata(root, node);
4634 btrfs_release_delayed_inode(node);
4635
4636 + /*
4637 + * If we fail to update the delayed inode we need to abort the
4638 + * transaction, because we could leave the inode with the improper
4639 + * counts behind.
4640 + */
4641 + if (ret && ret != -ENOENT)
4642 + btrfs_abort_transaction(trans, ret);
4643 +
4644 return ret;
4645
4646 search:
4647 diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
4648 index 31df020634cdd..d0fbe49420fc1 100644
4649 --- a/fs/btrfs/transaction.c
4650 +++ b/fs/btrfs/transaction.c
4651 @@ -1287,8 +1287,10 @@ int btrfs_defrag_root(struct btrfs_root *root)
4652
4653 while (1) {
4654 trans = btrfs_start_transaction(root, 0);
4655 - if (IS_ERR(trans))
4656 - return PTR_ERR(trans);
4657 + if (IS_ERR(trans)) {
4658 + ret = PTR_ERR(trans);
4659 + break;
4660 + }
4661
4662 ret = btrfs_defrag_leaves(trans, root);
4663
4664 diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
4665 index 36aa6d8cdff71..9791de2dc7734 100644
4666 --- a/fs/ceph/addr.c
4667 +++ b/fs/ceph/addr.c
4668 @@ -72,10 +72,6 @@ static int ceph_set_page_dirty(struct page *page)
4669 struct inode *inode;
4670 struct ceph_inode_info *ci;
4671 struct ceph_snap_context *snapc;
4672 - int ret;
4673 -
4674 - if (unlikely(!mapping))
4675 - return !TestSetPageDirty(page);
4676
4677 if (PageDirty(page)) {
4678 dout("%p set_page_dirty %p idx %lu -- already dirty\n",
4679 @@ -121,11 +117,7 @@ static int ceph_set_page_dirty(struct page *page)
4680 page->private = (unsigned long)snapc;
4681 SetPagePrivate(page);
4682
4683 - ret = __set_page_dirty_nobuffers(page);
4684 - WARN_ON(!PageLocked(page));
4685 - WARN_ON(!page->mapping);
4686 -
4687 - return ret;
4688 + return __set_page_dirty_nobuffers(page);
4689 }
4690
4691 /*
4692 diff --git a/fs/configfs/file.c b/fs/configfs/file.c
4693 index 896e90dc91936..71f665eb03160 100644
4694 --- a/fs/configfs/file.c
4695 +++ b/fs/configfs/file.c
4696 @@ -496,13 +496,13 @@ static int configfs_release_bin_file(struct inode *inode, struct file *file)
4697 buffer->bin_buffer_size);
4698 }
4699 up_read(&frag->frag_sem);
4700 - /* vfree on NULL is safe */
4701 - vfree(buffer->bin_buffer);
4702 - buffer->bin_buffer = NULL;
4703 - buffer->bin_buffer_size = 0;
4704 - buffer->needs_read_fill = 1;
4705 }
4706
4707 + vfree(buffer->bin_buffer);
4708 + buffer->bin_buffer = NULL;
4709 + buffer->bin_buffer_size = 0;
4710 + buffer->needs_read_fill = 1;
4711 +
4712 configfs_release(inode, file);
4713 return 0;
4714 }
4715 diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
4716 index e14bb7b67e9c2..5136ea1959347 100644
4717 --- a/fs/crypto/fname.c
4718 +++ b/fs/crypto/fname.c
4719 @@ -294,12 +294,8 @@ int fscrypt_fname_disk_to_usr(struct inode *inode,
4720 oname->name);
4721 return 0;
4722 }
4723 - if (hash) {
4724 - memcpy(buf, &hash, 4);
4725 - memcpy(buf + 4, &minor_hash, 4);
4726 - } else {
4727 - memset(buf, 0, 8);
4728 - }
4729 + memcpy(buf, &hash, 4);
4730 + memcpy(buf + 4, &minor_hash, 4);
4731 memcpy(buf + 8, iname->name + ((iname->len - 17) & ~15), 16);
4732 oname->name[0] = '_';
4733 oname->len = 1 + digest_encode(buf, 24, oname->name + 1);
4734 diff --git a/fs/dlm/config.c b/fs/dlm/config.c
4735 index 6def89d2209d3..10d25b7830bfa 100644
4736 --- a/fs/dlm/config.c
4737 +++ b/fs/dlm/config.c
4738 @@ -80,6 +80,9 @@ struct dlm_cluster {
4739 unsigned int cl_new_rsb_count;
4740 unsigned int cl_recover_callbacks;
4741 char cl_cluster_name[DLM_LOCKSPACE_LEN];
4742 +
4743 + struct dlm_spaces *sps;
4744 + struct dlm_comms *cms;
4745 };
4746
4747 static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
4748 @@ -356,6 +359,9 @@ static struct config_group *make_cluster(struct config_group *g,
4749 if (!cl || !sps || !cms)
4750 goto fail;
4751
4752 + cl->sps = sps;
4753 + cl->cms = cms;
4754 +
4755 config_group_init_type_name(&cl->group, name, &cluster_type);
4756 config_group_init_type_name(&sps->ss_group, "spaces", &spaces_type);
4757 config_group_init_type_name(&cms->cs_group, "comms", &comms_type);
4758 @@ -405,6 +411,9 @@ static void drop_cluster(struct config_group *g, struct config_item *i)
4759 static void release_cluster(struct config_item *i)
4760 {
4761 struct dlm_cluster *cl = config_item_to_cluster(i);
4762 +
4763 + kfree(cl->sps);
4764 + kfree(cl->cms);
4765 kfree(cl);
4766 }
4767
4768 diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c
4769 index 609998de533e8..0d8aaf9c61be6 100644
4770 --- a/fs/dlm/lowcomms.c
4771 +++ b/fs/dlm/lowcomms.c
4772 @@ -599,7 +599,7 @@ static void close_connection(struct connection *con, bool and_other,
4773 }
4774 if (con->othercon && and_other) {
4775 /* Will only re-enter once. */
4776 - close_connection(con->othercon, false, true, true);
4777 + close_connection(con->othercon, false, tx, rx);
4778 }
4779 if (con->rx_page) {
4780 __free_page(con->rx_page);
4781 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
4782 index e2f31aee67c28..d195f41071d8c 100644
4783 --- a/fs/ext4/extents.c
4784 +++ b/fs/ext4/extents.c
4785 @@ -870,6 +870,7 @@ int ext4_ext_tree_init(handle_t *handle, struct inode *inode)
4786 eh->eh_entries = 0;
4787 eh->eh_magic = EXT4_EXT_MAGIC;
4788 eh->eh_max = cpu_to_le16(ext4_ext_space_root(inode, 0));
4789 + eh->eh_generation = 0;
4790 ext4_mark_inode_dirty(handle, inode);
4791 return 0;
4792 }
4793 @@ -1126,6 +1127,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
4794 neh->eh_max = cpu_to_le16(ext4_ext_space_block(inode, 0));
4795 neh->eh_magic = EXT4_EXT_MAGIC;
4796 neh->eh_depth = 0;
4797 + neh->eh_generation = 0;
4798
4799 /* move remainder of path[depth] to the new leaf */
4800 if (unlikely(path[depth].p_hdr->eh_entries !=
4801 @@ -1203,6 +1205,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
4802 neh->eh_magic = EXT4_EXT_MAGIC;
4803 neh->eh_max = cpu_to_le16(ext4_ext_space_block_idx(inode, 0));
4804 neh->eh_depth = cpu_to_le16(depth - i);
4805 + neh->eh_generation = 0;
4806 fidx = EXT_FIRST_INDEX(neh);
4807 fidx->ei_block = border;
4808 ext4_idx_store_pblock(fidx, oldblock);
4809 diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
4810 index 37e059202cd2f..ce0f58c84b0ad 100644
4811 --- a/fs/ext4/extents_status.c
4812 +++ b/fs/ext4/extents_status.c
4813 @@ -1080,11 +1080,9 @@ static unsigned long ext4_es_scan(struct shrinker *shrink,
4814 ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
4815 trace_ext4_es_shrink_scan_enter(sbi->s_sb, nr_to_scan, ret);
4816
4817 - if (!nr_to_scan)
4818 - return ret;
4819 -
4820 nr_shrunk = __es_shrink(sbi, nr_to_scan, NULL);
4821
4822 + ret = percpu_counter_read_positive(&sbi->s_es_stats.es_stats_shk_cnt);
4823 trace_ext4_es_shrink_scan_exit(sbi->s_sb, nr_shrunk, ret);
4824 return nr_shrunk;
4825 }
4826 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
4827 index 11ebd274b7c00..4966c6d24ad2c 100644
4828 --- a/fs/ext4/ialloc.c
4829 +++ b/fs/ext4/ialloc.c
4830 @@ -405,7 +405,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
4831 *
4832 * We always try to spread first-level directories.
4833 *
4834 - * If there are blockgroups with both free inodes and free blocks counts
4835 + * If there are blockgroups with both free inodes and free clusters counts
4836 * not worse than average we return one with smallest directory count.
4837 * Otherwise we simply return a random group.
4838 *
4839 @@ -414,7 +414,7 @@ static void get_orlov_stats(struct super_block *sb, ext4_group_t g,
4840 * It's OK to put directory into a group unless
4841 * it has too many directories already (max_dirs) or
4842 * it has too few free inodes left (min_inodes) or
4843 - * it has too few free blocks left (min_blocks) or
4844 + * it has too few free clusters left (min_clusters) or
4845 * Parent's group is preferred, if it doesn't satisfy these
4846 * conditions we search cyclically through the rest. If none
4847 * of the groups look good we just look for a group with more
4848 @@ -430,7 +430,7 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
4849 ext4_group_t real_ngroups = ext4_get_groups_count(sb);
4850 int inodes_per_group = EXT4_INODES_PER_GROUP(sb);
4851 unsigned int freei, avefreei, grp_free;
4852 - ext4_fsblk_t freeb, avefreec;
4853 + ext4_fsblk_t freec, avefreec;
4854 unsigned int ndirs;
4855 int max_dirs, min_inodes;
4856 ext4_grpblk_t min_clusters;
4857 @@ -449,9 +449,8 @@ static int find_group_orlov(struct super_block *sb, struct inode *parent,
4858
4859 freei = percpu_counter_read_positive(&sbi->s_freeinodes_counter);
4860 avefreei = freei / ngroups;
4861 - freeb = EXT4_C2B(sbi,
4862 - percpu_counter_read_positive(&sbi->s_freeclusters_counter));
4863 - avefreec = freeb;
4864 + freec = percpu_counter_read_positive(&sbi->s_freeclusters_counter);
4865 + avefreec = freec;
4866 do_div(avefreec, ngroups);
4867 ndirs = percpu_counter_read_positive(&sbi->s_dirs_counter);
4868
4869 diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
4870 index 2de656ecc48bb..e7815bebaeb85 100644
4871 --- a/fs/fs-writeback.c
4872 +++ b/fs/fs-writeback.c
4873 @@ -512,9 +512,14 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
4874 /* find and pin the new wb */
4875 rcu_read_lock();
4876 memcg_css = css_from_id(new_wb_id, &memory_cgrp_subsys);
4877 - if (memcg_css)
4878 - isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
4879 + if (memcg_css && !css_tryget(memcg_css))
4880 + memcg_css = NULL;
4881 rcu_read_unlock();
4882 + if (!memcg_css)
4883 + goto out_free;
4884 +
4885 + isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
4886 + css_put(memcg_css);
4887 if (!isw->new_wb)
4888 goto out_free;
4889
4890 @@ -2088,28 +2093,6 @@ int dirtytime_interval_handler(struct ctl_table *table, int write,
4891 return ret;
4892 }
4893
4894 -static noinline void block_dump___mark_inode_dirty(struct inode *inode)
4895 -{
4896 - if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev")) {
4897 - struct dentry *dentry;
4898 - const char *name = "?";
4899 -
4900 - dentry = d_find_alias(inode);
4901 - if (dentry) {
4902 - spin_lock(&dentry->d_lock);
4903 - name = (const char *) dentry->d_name.name;
4904 - }
4905 - printk(KERN_DEBUG
4906 - "%s(%d): dirtied inode %lu (%s) on %s\n",
4907 - current->comm, task_pid_nr(current), inode->i_ino,
4908 - name, inode->i_sb->s_id);
4909 - if (dentry) {
4910 - spin_unlock(&dentry->d_lock);
4911 - dput(dentry);
4912 - }
4913 - }
4914 -}
4915 -
4916 /**
4917 * __mark_inode_dirty - internal function
4918 * @inode: inode to mark
4919 @@ -2168,9 +2151,6 @@ void __mark_inode_dirty(struct inode *inode, int flags)
4920 (dirtytime && (inode->i_state & I_DIRTY_INODE)))
4921 return;
4922
4923 - if (unlikely(block_dump))
4924 - block_dump___mark_inode_dirty(inode);
4925 -
4926 spin_lock(&inode->i_lock);
4927 if (dirtytime && (inode->i_state & I_DIRTY_INODE))
4928 goto out_unlock_inode;
4929 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
4930 index 33c90e24f91aa..d21e41735805d 100644
4931 --- a/fs/fuse/dev.c
4932 +++ b/fs/fuse/dev.c
4933 @@ -1298,6 +1298,15 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
4934 goto restart;
4935 }
4936 spin_lock(&fpq->lock);
4937 + /*
4938 + * Must not put request on fpq->io queue after having been shut down by
4939 + * fuse_abort_conn()
4940 + */
4941 + if (!fpq->connected) {
4942 + req->out.h.error = err = -ECONNABORTED;
4943 + goto out_end;
4944 +
4945 + }
4946 list_add(&req->list, &fpq->io);
4947 spin_unlock(&fpq->lock);
4948 cs->req = req;
4949 @@ -1874,7 +1883,7 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
4950 }
4951
4952 err = -EINVAL;
4953 - if (oh.error <= -1000 || oh.error > 0)
4954 + if (oh.error <= -512 || oh.error > 0)
4955 goto err_finish;
4956
4957 spin_lock(&fpq->lock);
4958 diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
4959 index 054cc761b426f..87b41edc800d0 100644
4960 --- a/fs/jfs/inode.c
4961 +++ b/fs/jfs/inode.c
4962 @@ -161,7 +161,8 @@ void jfs_evict_inode(struct inode *inode)
4963 if (test_cflag(COMMIT_Freewmap, inode))
4964 jfs_free_zero_link(inode);
4965
4966 - diFree(inode);
4967 + if (JFS_SBI(inode->i_sb)->ipimap)
4968 + diFree(inode);
4969
4970 /*
4971 * Free the inode from the quota allocation.
4972 diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
4973 index a21ea8b3e5fa6..12555c4eeb2b6 100644
4974 --- a/fs/jfs/jfs_logmgr.c
4975 +++ b/fs/jfs/jfs_logmgr.c
4976 @@ -1338,6 +1338,7 @@ int lmLogInit(struct jfs_log * log)
4977 } else {
4978 if (memcmp(logsuper->uuid, log->uuid, 16)) {
4979 jfs_warn("wrong uuid on JFS log device");
4980 + rc = -EINVAL;
4981 goto errout20;
4982 }
4983 log->size = le32_to_cpu(logsuper->size);
4984 diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
4985 index dc925b531f326..41bda33b630f2 100644
4986 --- a/fs/nfs/nfs3proc.c
4987 +++ b/fs/nfs/nfs3proc.c
4988 @@ -363,7 +363,7 @@ nfs3_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
4989 break;
4990
4991 case NFS3_CREATE_UNCHECKED:
4992 - goto out;
4993 + goto out_release_acls;
4994 }
4995 nfs_fattr_init(data->res.dir_attr);
4996 nfs_fattr_init(data->res.fattr);
4997 @@ -708,7 +708,7 @@ nfs3_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
4998 break;
4999 default:
5000 status = -EINVAL;
5001 - goto out;
5002 + goto out_release_acls;
5003 }
5004
5005 status = nfs3_do_create(dir, dentry, data);
5006 diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
5007 index a4fa548785d60..8cd134750ebb0 100644
5008 --- a/fs/ntfs/inode.c
5009 +++ b/fs/ntfs/inode.c
5010 @@ -502,7 +502,7 @@ err_corrupt_attr:
5011 }
5012 file_name_attr = (FILE_NAME_ATTR*)((u8*)attr +
5013 le16_to_cpu(attr->data.resident.value_offset));
5014 - p2 = (u8*)attr + le32_to_cpu(attr->data.resident.value_length);
5015 + p2 = (u8 *)file_name_attr + le32_to_cpu(attr->data.resident.value_length);
5016 if (p2 < (u8*)attr || p2 > p)
5017 goto err_corrupt_attr;
5018 /* This attribute is ok, but is it in the $Extend directory? */
5019 diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
5020 index 2cabbcf2f28ee..5571268b681c8 100644
5021 --- a/fs/ocfs2/filecheck.c
5022 +++ b/fs/ocfs2/filecheck.c
5023 @@ -431,11 +431,7 @@ static ssize_t ocfs2_filecheck_show(struct kobject *kobj,
5024 ret = snprintf(buf + total, remain, "%lu\t\t%u\t%s\n",
5025 p->fe_ino, p->fe_done,
5026 ocfs2_filecheck_error(p->fe_status));
5027 - if (ret < 0) {
5028 - total = ret;
5029 - break;
5030 - }
5031 - if (ret == remain) {
5032 + if (ret >= remain) {
5033 /* snprintf() didn't fit */
5034 total = -E2BIG;
5035 break;
5036 diff --git a/fs/ocfs2/stackglue.c b/fs/ocfs2/stackglue.c
5037 index 52c07346bea3f..03e1c6cd6f3c8 100644
5038 --- a/fs/ocfs2/stackglue.c
5039 +++ b/fs/ocfs2/stackglue.c
5040 @@ -510,11 +510,7 @@ static ssize_t ocfs2_loaded_cluster_plugins_show(struct kobject *kobj,
5041 list_for_each_entry(p, &ocfs2_stack_list, sp_list) {
5042 ret = snprintf(buf, remain, "%s\n",
5043 p->sp_name);
5044 - if (ret < 0) {
5045 - total = ret;
5046 - break;
5047 - }
5048 - if (ret == remain) {
5049 + if (ret >= remain) {
5050 /* snprintf() didn't fit */
5051 total = -E2BIG;
5052 break;
5053 @@ -541,7 +537,7 @@ static ssize_t ocfs2_active_cluster_plugin_show(struct kobject *kobj,
5054 if (active_stack) {
5055 ret = snprintf(buf, PAGE_SIZE, "%s\n",
5056 active_stack->sp_name);
5057 - if (ret == PAGE_SIZE)
5058 + if (ret >= PAGE_SIZE)
5059 ret = -E2BIG;
5060 }
5061 spin_unlock(&ocfs2_stack_lock);
5062 diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
5063 index 6e35ef6521b4e..8972ebc87016b 100644
5064 --- a/fs/orangefs/super.c
5065 +++ b/fs/orangefs/super.c
5066 @@ -185,7 +185,7 @@ static int orangefs_statfs(struct dentry *dentry, struct kstatfs *buf)
5067 buf->f_bavail = (sector_t) new_op->downcall.resp.statfs.blocks_avail;
5068 buf->f_files = (sector_t) new_op->downcall.resp.statfs.files_total;
5069 buf->f_ffree = (sector_t) new_op->downcall.resp.statfs.files_avail;
5070 - buf->f_frsize = sb->s_blocksize;
5071 + buf->f_frsize = 0;
5072
5073 out_op_release:
5074 op_release(new_op);
5075 diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
5076 index 2a5c4813c47d3..94871f611fa8e 100644
5077 --- a/fs/reiserfs/journal.c
5078 +++ b/fs/reiserfs/journal.c
5079 @@ -2766,6 +2766,20 @@ int journal_init(struct super_block *sb, const char *j_dev_name,
5080 goto free_and_return;
5081 }
5082
5083 + /*
5084 + * Sanity check to see if journal first block is correct.
5085 + * If journal first block is invalid it can cause
5086 + * zeroing important superblock members.
5087 + */
5088 + if (!SB_ONDISK_JOURNAL_DEVICE(sb) &&
5089 + SB_ONDISK_JOURNAL_1st_BLOCK(sb) < SB_JOURNAL_1st_RESERVED_BLOCK(sb)) {
5090 + reiserfs_warning(sb, "journal-1393",
5091 + "journal 1st super block is invalid: 1st reserved block %d, but actual 1st block is %d",
5092 + SB_JOURNAL_1st_RESERVED_BLOCK(sb),
5093 + SB_ONDISK_JOURNAL_1st_BLOCK(sb));
5094 + goto free_and_return;
5095 + }
5096 +
5097 if (journal_init_dev(sb, journal, j_dev_name) != 0) {
5098 reiserfs_warning(sb, "sh-462",
5099 "unable to initialize journal device");
5100 diff --git a/fs/seq_file.c b/fs/seq_file.c
5101 index 368bfb92b115c..3ade39e02bb73 100644
5102 --- a/fs/seq_file.c
5103 +++ b/fs/seq_file.c
5104 @@ -28,6 +28,9 @@ static void *seq_buf_alloc(unsigned long size)
5105 void *buf;
5106 gfp_t gfp = GFP_KERNEL;
5107
5108 + if (unlikely(size > MAX_RW_COUNT))
5109 + return NULL;
5110 +
5111 /*
5112 * For high order allocations, use __GFP_NORETRY to avoid oom-killing -
5113 * it's better to fall back to vmalloc() than to kill things. For small
5114 diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
5115 index 87ab02e2d6661..56eed54633cf2 100644
5116 --- a/fs/ubifs/dir.c
5117 +++ b/fs/ubifs/dir.c
5118 @@ -1144,7 +1144,10 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
5119 return err;
5120 }
5121
5122 + spin_lock(&whiteout->i_lock);
5123 whiteout->i_state |= I_LINKABLE;
5124 + spin_unlock(&whiteout->i_lock);
5125 +
5126 whiteout_ui = ubifs_inode(whiteout);
5127 whiteout_ui->data = dev;
5128 whiteout_ui->data_len = ubifs_encode_dev(dev, MKDEV(0, 0));
5129 @@ -1239,7 +1242,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
5130
5131 inc_nlink(whiteout);
5132 mark_inode_dirty(whiteout);
5133 +
5134 + spin_lock(&whiteout->i_lock);
5135 whiteout->i_state &= ~I_LINKABLE;
5136 + spin_unlock(&whiteout->i_lock);
5137 +
5138 iput(whiteout);
5139 }
5140
5141 diff --git a/fs/udf/namei.c b/fs/udf/namei.c
5142 index 348b922d1b6a5..bfa53dead8c8a 100644
5143 --- a/fs/udf/namei.c
5144 +++ b/fs/udf/namei.c
5145 @@ -956,6 +956,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
5146 iinfo->i_location.partitionReferenceNum,
5147 0);
5148 epos.bh = udf_tgetblk(sb, block);
5149 + if (unlikely(!epos.bh)) {
5150 + err = -ENOMEM;
5151 + goto out_no_entry;
5152 + }
5153 lock_buffer(epos.bh);
5154 memset(epos.bh->b_data, 0x00, bsize);
5155 set_buffer_uptodate(epos.bh);
5156 diff --git a/include/crypto/internal/hash.h b/include/crypto/internal/hash.h
5157 index 5203560f992e4..000c049a75f7c 100644
5158 --- a/include/crypto/internal/hash.h
5159 +++ b/include/crypto/internal/hash.h
5160 @@ -80,13 +80,7 @@ int ahash_register_instance(struct crypto_template *tmpl,
5161 struct ahash_instance *inst);
5162 void ahash_free_instance(struct crypto_instance *inst);
5163
5164 -int shash_no_setkey(struct crypto_shash *tfm, const u8 *key,
5165 - unsigned int keylen);
5166 -
5167 -static inline bool crypto_shash_alg_has_setkey(struct shash_alg *alg)
5168 -{
5169 - return alg->setkey != shash_no_setkey;
5170 -}
5171 +bool crypto_shash_alg_has_setkey(struct shash_alg *alg);
5172
5173 bool crypto_hash_alg_has_setkey(struct hash_alg_common *halg);
5174
5175 diff --git a/include/linux/mfd/abx500/ux500_chargalg.h b/include/linux/mfd/abx500/ux500_chargalg.h
5176 index 67703f23e7ba2..821a3b9bc16e1 100644
5177 --- a/include/linux/mfd/abx500/ux500_chargalg.h
5178 +++ b/include/linux/mfd/abx500/ux500_chargalg.h
5179 @@ -15,7 +15,7 @@
5180 * - POWER_SUPPLY_TYPE_USB,
5181 * because only them store as drv_data pointer to struct ux500_charger.
5182 */
5183 -#define psy_to_ux500_charger(x) power_supply_get_drvdata(psy)
5184 +#define psy_to_ux500_charger(x) power_supply_get_drvdata(x)
5185
5186 /* Forward declaration */
5187 struct ux500_charger;
5188 diff --git a/include/linux/prandom.h b/include/linux/prandom.h
5189 index cc1e71334e53c..e20339c78a84c 100644
5190 --- a/include/linux/prandom.h
5191 +++ b/include/linux/prandom.h
5192 @@ -93,7 +93,7 @@ static inline u32 __seed(u32 x, u32 m)
5193 */
5194 static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
5195 {
5196 - u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
5197 + u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL;
5198
5199 state->s1 = __seed(i, 2U);
5200 state->s2 = __seed(i, 8U);
5201 diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
5202 index 6183d20a01fbe..e673c7c9c5fbc 100644
5203 --- a/include/scsi/scsi_transport_iscsi.h
5204 +++ b/include/scsi/scsi_transport_iscsi.h
5205 @@ -437,6 +437,8 @@ extern void iscsi_free_session(struct iscsi_cls_session *session);
5206 extern int iscsi_destroy_session(struct iscsi_cls_session *session);
5207 extern struct iscsi_cls_conn *iscsi_create_conn(struct iscsi_cls_session *sess,
5208 int dd_size, uint32_t cid);
5209 +extern void iscsi_put_conn(struct iscsi_cls_conn *conn);
5210 +extern void iscsi_get_conn(struct iscsi_cls_conn *conn);
5211 extern int iscsi_destroy_conn(struct iscsi_cls_conn *conn);
5212 extern void iscsi_unblock_session(struct iscsi_cls_session *session);
5213 extern void iscsi_block_session(struct iscsi_cls_session *session);
5214 diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
5215 index 766e5ccad60ae..57a9341c67e45 100644
5216 --- a/kernel/trace/trace_events_hist.c
5217 +++ b/kernel/trace/trace_events_hist.c
5218 @@ -374,7 +374,9 @@ static struct hist_field *create_hist_field(struct ftrace_event_field *field,
5219 if (WARN_ON_ONCE(!field))
5220 goto out;
5221
5222 - if (is_string_field(field)) {
5223 + /* Pointers to strings are just pointers and dangerous to dereference */
5224 + if (is_string_field(field) &&
5225 + (field->filter_type != FILTER_PTR_STRING)) {
5226 flags |= HIST_FIELD_FL_STRING;
5227
5228 if (field->filter_type == FILTER_STATIC_STRING)
5229 @@ -863,8 +865,6 @@ static inline void add_to_key(char *compound_key, void *key,
5230 field = key_field->field;
5231 if (field->filter_type == FILTER_DYN_STRING)
5232 size = *(u32 *)(rec + field->offset) >> 16;
5233 - else if (field->filter_type == FILTER_PTR_STRING)
5234 - size = strlen(key);
5235 else if (field->filter_type == FILTER_STATIC_STRING)
5236 size = field->size;
5237
5238 diff --git a/lib/decompress_unlz4.c b/lib/decompress_unlz4.c
5239 index 036fc882cd725..f1449244fdd40 100644
5240 --- a/lib/decompress_unlz4.c
5241 +++ b/lib/decompress_unlz4.c
5242 @@ -115,6 +115,9 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
5243 error("data corrupted");
5244 goto exit_2;
5245 }
5246 + } else if (size < 4) {
5247 + /* empty or end-of-file */
5248 + goto exit_3;
5249 }
5250
5251 chunksize = get_unaligned_le32(inp);
5252 @@ -128,6 +131,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
5253 continue;
5254 }
5255
5256 + if (!fill && chunksize == 0) {
5257 + /* empty or end-of-file */
5258 + goto exit_3;
5259 + }
5260
5261 if (posp)
5262 *posp += 4;
5263 @@ -184,6 +191,7 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
5264 }
5265 }
5266
5267 +exit_3:
5268 ret = 0;
5269 exit_2:
5270 if (!input)
5271 diff --git a/lib/iov_iter.c b/lib/iov_iter.c
5272 index a75ea633b5c46..07d735b2eccf7 100644
5273 --- a/lib/iov_iter.c
5274 +++ b/lib/iov_iter.c
5275 @@ -394,7 +394,7 @@ int iov_iter_fault_in_readable(struct iov_iter *i, size_t bytes)
5276 int err;
5277 struct iovec v;
5278
5279 - if (!(i->type & (ITER_BVEC|ITER_KVEC))) {
5280 + if (iter_is_iovec(i)) {
5281 iterate_iovec(i, bytes, v, iov, skip, ({
5282 err = fault_in_pages_readable(v.iov_base, v.iov_len);
5283 if (unlikely(err))
5284 diff --git a/lib/seq_buf.c b/lib/seq_buf.c
5285 index 5954f9fb6675a..b3ec487c97282 100644
5286 --- a/lib/seq_buf.c
5287 +++ b/lib/seq_buf.c
5288 @@ -227,8 +227,10 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
5289
5290 WARN_ON(s->size == 0);
5291
5292 + BUILD_BUG_ON(MAX_MEMHEX_BYTES * 2 >= HEX_CHARS);
5293 +
5294 while (len) {
5295 - start_len = min(len, HEX_CHARS - 1);
5296 + start_len = min(len, MAX_MEMHEX_BYTES);
5297 #ifdef __BIG_ENDIAN
5298 for (i = 0, j = 0; i < start_len; i++) {
5299 #else
5300 @@ -241,12 +243,14 @@ int seq_buf_putmem_hex(struct seq_buf *s, const void *mem,
5301 break;
5302
5303 /* j increments twice per loop */
5304 - len -= j / 2;
5305 hex[j++] = ' ';
5306
5307 seq_buf_putmem(s, hex, j);
5308 if (seq_buf_has_overflowed(s))
5309 return -1;
5310 +
5311 + len -= start_len;
5312 + data += start_len;
5313 }
5314 return 0;
5315 }
5316 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
5317 index 177ca028b9868..91f33bb43f178 100644
5318 --- a/mm/huge_memory.c
5319 +++ b/mm/huge_memory.c
5320 @@ -1369,7 +1369,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
5321 * If other processes are mapping this page, we couldn't discard
5322 * the page unless they all do MADV_FREE so let's skip the page.
5323 */
5324 - if (page_mapcount(page) != 1)
5325 + if (total_mapcount(page) != 1)
5326 goto out;
5327
5328 if (!trylock_page(page))
5329 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
5330 index 839c534bdcdb9..50b9a0bbe5dff 100644
5331 --- a/net/bluetooth/hci_core.c
5332 +++ b/net/bluetooth/hci_core.c
5333 @@ -1533,14 +1533,6 @@ int hci_dev_do_close(struct hci_dev *hdev)
5334
5335 BT_DBG("%s %p", hdev->name, hdev);
5336
5337 - if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
5338 - !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
5339 - test_bit(HCI_UP, &hdev->flags)) {
5340 - /* Execute vendor specific shutdown routine */
5341 - if (hdev->shutdown)
5342 - hdev->shutdown(hdev);
5343 - }
5344 -
5345 cancel_delayed_work(&hdev->power_off);
5346
5347 hci_request_cancel_all(hdev);
5348 @@ -1608,6 +1600,14 @@ int hci_dev_do_close(struct hci_dev *hdev)
5349 clear_bit(HCI_INIT, &hdev->flags);
5350 }
5351
5352 + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
5353 + !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
5354 + test_bit(HCI_UP, &hdev->flags)) {
5355 + /* Execute vendor specific shutdown routine */
5356 + if (hdev->shutdown)
5357 + hdev->shutdown(hdev);
5358 + }
5359 +
5360 /* flush cmd work */
5361 flush_work(&hdev->cmd_work);
5362
5363 diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
5364 index bca1408f815ff..7aef6d23bc771 100644
5365 --- a/net/bluetooth/mgmt.c
5366 +++ b/net/bluetooth/mgmt.c
5367 @@ -219,12 +219,15 @@ static u8 mgmt_status_table[] = {
5368 MGMT_STATUS_TIMEOUT, /* Instant Passed */
5369 MGMT_STATUS_NOT_SUPPORTED, /* Pairing Not Supported */
5370 MGMT_STATUS_FAILED, /* Transaction Collision */
5371 + MGMT_STATUS_FAILED, /* Reserved for future use */
5372 MGMT_STATUS_INVALID_PARAMS, /* Unacceptable Parameter */
5373 MGMT_STATUS_REJECTED, /* QoS Rejected */
5374 MGMT_STATUS_NOT_SUPPORTED, /* Classification Not Supported */
5375 MGMT_STATUS_REJECTED, /* Insufficient Security */
5376 MGMT_STATUS_INVALID_PARAMS, /* Parameter Out Of Range */
5377 + MGMT_STATUS_FAILED, /* Reserved for future use */
5378 MGMT_STATUS_BUSY, /* Role Switch Pending */
5379 + MGMT_STATUS_FAILED, /* Reserved for future use */
5380 MGMT_STATUS_FAILED, /* Slot Violation */
5381 MGMT_STATUS_FAILED, /* Role Switch Failed */
5382 MGMT_STATUS_INVALID_PARAMS, /* EIR Too Large */
5383 @@ -6087,6 +6090,9 @@ static bool tlv_data_is_valid(struct hci_dev *hdev, u32 adv_flags, u8 *data,
5384 for (i = 0, cur_len = 0; i < len; i += (cur_len + 1)) {
5385 cur_len = data[i];
5386
5387 + if (!cur_len)
5388 + continue;
5389 +
5390 if (data[i + 1] == EIR_FLAGS &&
5391 (!is_adv_data || flags_managed(adv_flags)))
5392 return false;
5393 diff --git a/net/can/bcm.c b/net/can/bcm.c
5394 index 65fa0ac2fb47d..369326715b9c6 100644
5395 --- a/net/can/bcm.c
5396 +++ b/net/can/bcm.c
5397 @@ -839,6 +839,7 @@ static int bcm_delete_rx_op(struct list_head *ops, struct bcm_msg_head *mh,
5398 bcm_rx_handler, op);
5399
5400 list_del(&op->list);
5401 + synchronize_rcu();
5402 bcm_remove_op(op);
5403 return 1; /* done */
5404 }
5405 @@ -1589,9 +1590,13 @@ static int bcm_release(struct socket *sock)
5406 REGMASK(op->can_id),
5407 bcm_rx_handler, op);
5408
5409 - bcm_remove_op(op);
5410 }
5411
5412 + synchronize_rcu();
5413 +
5414 + list_for_each_entry_safe(op, next, &bo->rx_ops, list)
5415 + bcm_remove_op(op);
5416 +
5417 /* remove procfs entry */
5418 if (proc_dir && bo->bcm_proc_read)
5419 remove_proc_entry(bo->procname, proc_dir);
5420 diff --git a/net/can/gw.c b/net/can/gw.c
5421 index 81650affa3faa..1867000f8a650 100644
5422 --- a/net/can/gw.c
5423 +++ b/net/can/gw.c
5424 @@ -497,6 +497,7 @@ static int cgw_notifier(struct notifier_block *nb,
5425 if (gwj->src.dev == dev || gwj->dst.dev == dev) {
5426 hlist_del(&gwj->list);
5427 cgw_unregister_filter(gwj);
5428 + synchronize_rcu();
5429 kmem_cache_free(cgw_cache, gwj);
5430 }
5431 }
5432 @@ -941,6 +942,7 @@ static void cgw_remove_all_jobs(void)
5433 hlist_for_each_entry_safe(gwj, nx, &cgw_list, list) {
5434 hlist_del(&gwj->list);
5435 cgw_unregister_filter(gwj);
5436 + synchronize_rcu();
5437 kmem_cache_free(cgw_cache, gwj);
5438 }
5439 }
5440 @@ -1008,6 +1010,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
5441
5442 hlist_del(&gwj->list);
5443 cgw_unregister_filter(gwj);
5444 + synchronize_rcu();
5445 kmem_cache_free(cgw_cache, gwj);
5446 err = 0;
5447 break;
5448 diff --git a/net/core/dev.c b/net/core/dev.c
5449 index 5b69a9a41dd50..47468fc5d0c9d 100644
5450 --- a/net/core/dev.c
5451 +++ b/net/core/dev.c
5452 @@ -4998,11 +4998,18 @@ EXPORT_SYMBOL(__napi_schedule);
5453 * __napi_schedule_irqoff - schedule for receive
5454 * @n: entry to schedule
5455 *
5456 - * Variant of __napi_schedule() assuming hard irqs are masked
5457 + * Variant of __napi_schedule() assuming hard irqs are masked.
5458 + *
5459 + * On PREEMPT_RT enabled kernels this maps to __napi_schedule()
5460 + * because the interrupt disabled assumption might not be true
5461 + * due to force-threaded interrupts and spinlock substitution.
5462 */
5463 void __napi_schedule_irqoff(struct napi_struct *n)
5464 {
5465 - ____napi_schedule(this_cpu_ptr(&softnet_data), n);
5466 + if (!IS_ENABLED(CONFIG_PREEMPT_RT))
5467 + ____napi_schedule(this_cpu_ptr(&softnet_data), n);
5468 + else
5469 + __napi_schedule(n);
5470 }
5471 EXPORT_SYMBOL(__napi_schedule_irqoff);
5472
5473 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
5474 index 6a6d01cb1acec..9c25e8b093065 100644
5475 --- a/net/ipv6/output_core.c
5476 +++ b/net/ipv6/output_core.c
5477 @@ -14,29 +14,11 @@ static u32 __ipv6_select_ident(struct net *net,
5478 const struct in6_addr *dst,
5479 const struct in6_addr *src)
5480 {
5481 - const struct {
5482 - struct in6_addr dst;
5483 - struct in6_addr src;
5484 - } __aligned(SIPHASH_ALIGNMENT) combined = {
5485 - .dst = *dst,
5486 - .src = *src,
5487 - };
5488 - u32 hash, id;
5489 -
5490 - /* Note the following code is not safe, but this is okay. */
5491 - if (unlikely(siphash_key_is_zero(&net->ipv4.ip_id_key)))
5492 - get_random_bytes(&net->ipv4.ip_id_key,
5493 - sizeof(net->ipv4.ip_id_key));
5494 -
5495 - hash = siphash(&combined, sizeof(combined), &net->ipv4.ip_id_key);
5496 -
5497 - /* Treat id of 0 as unset and if we get 0 back from ip_idents_reserve,
5498 - * set the hight order instead thus minimizing possible future
5499 - * collisions.
5500 - */
5501 - id = ip_idents_reserve(hash, 1);
5502 - if (unlikely(!id))
5503 - id = 1 << 31;
5504 + u32 id;
5505 +
5506 + do {
5507 + id = prandom_u32();
5508 + } while (!id);
5509
5510 return id;
5511 }
5512 diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
5513 index 3a069cb188b72..b40e71a5d7957 100644
5514 --- a/net/mac80211/rx.c
5515 +++ b/net/mac80211/rx.c
5516 @@ -2380,7 +2380,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
5517 #endif
5518
5519 if (skb) {
5520 - struct ethhdr *ehdr = (void *)skb_mac_header(skb);
5521 + struct ethhdr *ehdr = (struct ethhdr *)skb->data;
5522
5523 /* deliver to local stack */
5524 skb->protocol = eth_type_trans(skb, dev);
5525 diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
5526 index 47beb3abcc9da..e2c815ee06d0e 100644
5527 --- a/net/netfilter/nft_exthdr.c
5528 +++ b/net/netfilter/nft_exthdr.c
5529 @@ -34,6 +34,9 @@ static void nft_exthdr_eval(const struct nft_expr *expr,
5530 unsigned int offset = 0;
5531 int err;
5532
5533 + if (pkt->skb->protocol != htons(ETH_P_IPV6))
5534 + goto err;
5535 +
5536 err = ipv6_find_hdr(pkt->skb, &offset, priv->type, NULL, NULL);
5537 if (err < 0)
5538 goto err;
5539 diff --git a/net/netlabel/netlabel_mgmt.c b/net/netlabel/netlabel_mgmt.c
5540 index f85d0e07af2dd..9be851ce97c2b 100644
5541 --- a/net/netlabel/netlabel_mgmt.c
5542 +++ b/net/netlabel/netlabel_mgmt.c
5543 @@ -96,6 +96,7 @@ static const struct nla_policy netlbl_mgmt_genl_policy[NLBL_MGMT_A_MAX + 1] = {
5544 static int netlbl_mgmt_add_common(struct genl_info *info,
5545 struct netlbl_audit *audit_info)
5546 {
5547 + void *pmap = NULL;
5548 int ret_val = -EINVAL;
5549 struct netlbl_domaddr_map *addrmap = NULL;
5550 struct cipso_v4_doi *cipsov4 = NULL;
5551 @@ -195,6 +196,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
5552 ret_val = -ENOMEM;
5553 goto add_free_addrmap;
5554 }
5555 + pmap = map;
5556 map->list.addr = addr->s_addr & mask->s_addr;
5557 map->list.mask = mask->s_addr;
5558 map->list.valid = 1;
5559 @@ -203,10 +205,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
5560 map->def.cipso = cipsov4;
5561
5562 ret_val = netlbl_af4list_add(&map->list, &addrmap->list4);
5563 - if (ret_val != 0) {
5564 - kfree(map);
5565 - goto add_free_addrmap;
5566 - }
5567 + if (ret_val != 0)
5568 + goto add_free_map;
5569
5570 entry->family = AF_INET;
5571 entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
5572 @@ -243,6 +243,7 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
5573 ret_val = -ENOMEM;
5574 goto add_free_addrmap;
5575 }
5576 + pmap = map;
5577 map->list.addr = *addr;
5578 map->list.addr.s6_addr32[0] &= mask->s6_addr32[0];
5579 map->list.addr.s6_addr32[1] &= mask->s6_addr32[1];
5580 @@ -255,10 +256,8 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
5581 map->def.calipso = calipso;
5582
5583 ret_val = netlbl_af6list_add(&map->list, &addrmap->list6);
5584 - if (ret_val != 0) {
5585 - kfree(map);
5586 - goto add_free_addrmap;
5587 - }
5588 + if (ret_val != 0)
5589 + goto add_free_map;
5590
5591 entry->family = AF_INET6;
5592 entry->def.type = NETLBL_NLTYPE_ADDRSELECT;
5593 @@ -268,10 +267,12 @@ static int netlbl_mgmt_add_common(struct genl_info *info,
5594
5595 ret_val = netlbl_domhsh_add(entry, audit_info);
5596 if (ret_val != 0)
5597 - goto add_free_addrmap;
5598 + goto add_free_map;
5599
5600 return 0;
5601
5602 +add_free_map:
5603 + kfree(pmap);
5604 add_free_addrmap:
5605 kfree(addrmap);
5606 add_doi_put_def:
5607 diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
5608 index 70ee78d8f8fb8..7aafb402e5c77 100644
5609 --- a/net/sched/cls_tcindex.c
5610 +++ b/net/sched/cls_tcindex.c
5611 @@ -247,7 +247,7 @@ static int tcindex_alloc_perfect_hash(struct tcindex_data *cp)
5612 int i, err = 0;
5613
5614 cp->perfect = kcalloc(cp->hash, sizeof(struct tcindex_filter_result),
5615 - GFP_KERNEL);
5616 + GFP_KERNEL | __GFP_NOWARN);
5617 if (!cp->perfect)
5618 return -ENOMEM;
5619
5620 diff --git a/net/sctp/input.c b/net/sctp/input.c
5621 index 12d821ea8a1f6..8f4574c4aa6ca 100644
5622 --- a/net/sctp/input.c
5623 +++ b/net/sctp/input.c
5624 @@ -1165,7 +1165,7 @@ static struct sctp_association *__sctp_rcv_walk_lookup(struct net *net,
5625
5626 ch = (sctp_chunkhdr_t *) ch_end;
5627 chunk_num++;
5628 - } while (ch_end < skb_tail_pointer(skb));
5629 + } while (ch_end + sizeof(*ch) < skb_tail_pointer(skb));
5630
5631 return asoc;
5632 }
5633 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
5634 index 0ef65822fdd34..00d95fefdc6fd 100644
5635 --- a/net/sunrpc/sched.c
5636 +++ b/net/sunrpc/sched.c
5637 @@ -486,11 +486,21 @@ static struct rpc_task *__rpc_find_next_queued_priority(struct rpc_wait_queue *q
5638 struct list_head *q;
5639 struct rpc_task *task;
5640
5641 + /*
5642 + * Service the privileged queue.
5643 + */
5644 + q = &queue->tasks[RPC_NR_PRIORITY - 1];
5645 + if (queue->maxpriority > RPC_PRIORITY_PRIVILEGED && !list_empty(q)) {
5646 + task = list_first_entry(q, struct rpc_task, u.tk_wait.list);
5647 + goto out;
5648 + }
5649 +
5650 /*
5651 * Service a batch of tasks from a single owner.
5652 */
5653 q = &queue->tasks[queue->priority];
5654 - if (!list_empty(q) && --queue->nr) {
5655 + if (!list_empty(q) && queue->nr) {
5656 + queue->nr--;
5657 task = list_first_entry(q, struct rpc_task, u.tk_wait.list);
5658 goto out;
5659 }
5660 diff --git a/net/wireless/wext-spy.c b/net/wireless/wext-spy.c
5661 index 33bef22e44e95..b379a03716539 100644
5662 --- a/net/wireless/wext-spy.c
5663 +++ b/net/wireless/wext-spy.c
5664 @@ -120,8 +120,8 @@ int iw_handler_set_thrspy(struct net_device * dev,
5665 return -EOPNOTSUPP;
5666
5667 /* Just do it */
5668 - memcpy(&(spydata->spy_thr_low), &(threshold->low),
5669 - 2 * sizeof(struct iw_quality));
5670 + spydata->spy_thr_low = threshold->low;
5671 + spydata->spy_thr_high = threshold->high;
5672
5673 /* Clear flag */
5674 memset(spydata->spy_thr_under, '\0', sizeof(spydata->spy_thr_under));
5675 @@ -147,8 +147,8 @@ int iw_handler_get_thrspy(struct net_device * dev,
5676 return -EOPNOTSUPP;
5677
5678 /* Just do it */
5679 - memcpy(&(threshold->low), &(spydata->spy_thr_low),
5680 - 2 * sizeof(struct iw_quality));
5681 + threshold->low = spydata->spy_thr_low;
5682 + threshold->high = spydata->spy_thr_high;
5683
5684 return 0;
5685 }
5686 @@ -173,10 +173,10 @@ static void iw_send_thrspy_event(struct net_device * dev,
5687 memcpy(threshold.addr.sa_data, address, ETH_ALEN);
5688 threshold.addr.sa_family = ARPHRD_ETHER;
5689 /* Copy stats */
5690 - memcpy(&(threshold.qual), wstats, sizeof(struct iw_quality));
5691 + threshold.qual = *wstats;
5692 /* Copy also thresholds */
5693 - memcpy(&(threshold.low), &(spydata->spy_thr_low),
5694 - 2 * sizeof(struct iw_quality));
5695 + threshold.low = spydata->spy_thr_low;
5696 + threshold.high = spydata->spy_thr_high;
5697
5698 /* Send event to user space */
5699 wireless_send_event(dev, SIOCGIWTHRSPY, &wrqu, (char *) &threshold);
5700 diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
5701 index feb24ca530f27..48139e1a0ac91 100644
5702 --- a/net/xfrm/xfrm_user.c
5703 +++ b/net/xfrm/xfrm_user.c
5704 @@ -566,6 +566,20 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
5705
5706 copy_from_user_state(x, p);
5707
5708 + if (attrs[XFRMA_ENCAP]) {
5709 + x->encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]),
5710 + sizeof(*x->encap), GFP_KERNEL);
5711 + if (x->encap == NULL)
5712 + goto error;
5713 + }
5714 +
5715 + if (attrs[XFRMA_COADDR]) {
5716 + x->coaddr = kmemdup(nla_data(attrs[XFRMA_COADDR]),
5717 + sizeof(*x->coaddr), GFP_KERNEL);
5718 + if (x->coaddr == NULL)
5719 + goto error;
5720 + }
5721 +
5722 if (attrs[XFRMA_SA_EXTRA_FLAGS])
5723 x->props.extra_flags = nla_get_u32(attrs[XFRMA_SA_EXTRA_FLAGS]);
5724
5725 @@ -586,23 +600,9 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
5726 attrs[XFRMA_ALG_COMP])))
5727 goto error;
5728
5729 - if (attrs[XFRMA_ENCAP]) {
5730 - x->encap = kmemdup(nla_data(attrs[XFRMA_ENCAP]),
5731 - sizeof(*x->encap), GFP_KERNEL);
5732 - if (x->encap == NULL)
5733 - goto error;
5734 - }
5735 -
5736 if (attrs[XFRMA_TFCPAD])
5737 x->tfcpad = nla_get_u32(attrs[XFRMA_TFCPAD]);
5738
5739 - if (attrs[XFRMA_COADDR]) {
5740 - x->coaddr = kmemdup(nla_data(attrs[XFRMA_COADDR]),
5741 - sizeof(*x->coaddr), GFP_KERNEL);
5742 - if (x->coaddr == NULL)
5743 - goto error;
5744 - }
5745 -
5746 xfrm_mark_get(attrs, &x->mark);
5747
5748 err = __xfrm_init_state(x, false);
5749 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
5750 index f3c473791b698..a16c72c2a9675 100644
5751 --- a/security/selinux/avc.c
5752 +++ b/security/selinux/avc.c
5753 @@ -348,26 +348,27 @@ static struct avc_xperms_decision_node
5754 struct avc_xperms_decision_node *xpd_node;
5755 struct extended_perms_decision *xpd;
5756
5757 - xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep, GFP_NOWAIT);
5758 + xpd_node = kmem_cache_zalloc(avc_xperms_decision_cachep,
5759 + GFP_NOWAIT | __GFP_NOWARN);
5760 if (!xpd_node)
5761 return NULL;
5762
5763 xpd = &xpd_node->xpd;
5764 if (which & XPERMS_ALLOWED) {
5765 xpd->allowed = kmem_cache_zalloc(avc_xperms_data_cachep,
5766 - GFP_NOWAIT);
5767 + GFP_NOWAIT | __GFP_NOWARN);
5768 if (!xpd->allowed)
5769 goto error;
5770 }
5771 if (which & XPERMS_AUDITALLOW) {
5772 xpd->auditallow = kmem_cache_zalloc(avc_xperms_data_cachep,
5773 - GFP_NOWAIT);
5774 + GFP_NOWAIT | __GFP_NOWARN);
5775 if (!xpd->auditallow)
5776 goto error;
5777 }
5778 if (which & XPERMS_DONTAUDIT) {
5779 xpd->dontaudit = kmem_cache_zalloc(avc_xperms_data_cachep,
5780 - GFP_NOWAIT);
5781 + GFP_NOWAIT | __GFP_NOWARN);
5782 if (!xpd->dontaudit)
5783 goto error;
5784 }
5785 @@ -395,7 +396,7 @@ static struct avc_xperms_node *avc_xperms_alloc(void)
5786 {
5787 struct avc_xperms_node *xp_node;
5788
5789 - xp_node = kmem_cache_zalloc(avc_xperms_cachep, GFP_NOWAIT);
5790 + xp_node = kmem_cache_zalloc(avc_xperms_cachep, GFP_NOWAIT | __GFP_NOWARN);
5791 if (!xp_node)
5792 return xp_node;
5793 INIT_LIST_HEAD(&xp_node->xpd_head);
5794 @@ -548,7 +549,7 @@ static struct avc_node *avc_alloc_node(void)
5795 {
5796 struct avc_node *node;
5797
5798 - node = kmem_cache_zalloc(avc_node_cachep, GFP_NOWAIT);
5799 + node = kmem_cache_zalloc(avc_node_cachep, GFP_NOWAIT | __GFP_NOWARN);
5800 if (!node)
5801 goto out;
5802
5803 diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
5804 index 04a53cdb409fa..966d30bf2e388 100644
5805 --- a/security/smack/smackfs.c
5806 +++ b/security/smack/smackfs.c
5807 @@ -878,6 +878,8 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
5808 if (format == SMK_FIXED24_FMT &&
5809 (count < SMK_CIPSOMIN || count > SMK_CIPSOMAX))
5810 return -EINVAL;
5811 + if (count > PAGE_SIZE)
5812 + return -EINVAL;
5813
5814 data = memdup_user_nul(buf, count);
5815 if (IS_ERR(data))
5816 diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
5817 index f7b8dcb578157..82894330cae1e 100644
5818 --- a/sound/firewire/Kconfig
5819 +++ b/sound/firewire/Kconfig
5820 @@ -36,7 +36,7 @@ config SND_OXFW
5821 * Mackie(Loud) Onyx-i series (former models)
5822 * Mackie(Loud) Onyx Satellite
5823 * Mackie(Loud) Tapco Link.Firewire
5824 - * Mackie(Loud) d.4 pro
5825 + * Mackie(Loud) d.2 pro/d.4 pro (built-in FireWire card with OXFW971 ASIC)
5826 * Mackie(Loud) U.420/U.420d
5827 * TASCAM FireOne
5828 * Stanton Controllers & Systems 1 Deck/Mixer
5829 @@ -82,7 +82,7 @@ config SND_BEBOB
5830 * PreSonus FIREBOX/FIREPOD/FP10/Inspire1394
5831 * BridgeCo RDAudio1/Audio5
5832 * Mackie Onyx 1220/1620/1640 (FireWire I/O Card)
5833 - * Mackie d.2 (FireWire Option) and d.2 Pro
5834 + * Mackie d.2 (optional FireWire card with DM1000 ASIC)
5835 * Stanton FinalScratch 2 (ScratchAmp)
5836 * Tascam IF-FW/DM
5837 * Behringer XENIX UFX 1204/1604
5838 @@ -108,6 +108,7 @@ config SND_BEBOB
5839 * M-Audio Ozonic/NRV10/ProfireLightBridge
5840 * M-Audio FireWire 1814/ProjectMix IO
5841 * Digidesign Mbox 2 Pro
5842 + * ToneWeal FW66
5843
5844 To compile this driver as a module, choose M here: the module
5845 will be called snd-bebob.
5846 diff --git a/sound/firewire/bebob/bebob.c b/sound/firewire/bebob/bebob.c
5847 index 9d620a7c283f4..4bb2cbe73f201 100644
5848 --- a/sound/firewire/bebob/bebob.c
5849 +++ b/sound/firewire/bebob/bebob.c
5850 @@ -60,6 +60,7 @@ static DECLARE_BITMAP(devices_used, SNDRV_CARDS);
5851 #define VEN_MAUDIO1 0x00000d6c
5852 #define VEN_MAUDIO2 0x000007f5
5853 #define VEN_DIGIDESIGN 0x00a07e
5854 +#define OUI_SHOUYO 0x002327
5855
5856 #define MODEL_FOCUSRITE_SAFFIRE_BOTH 0x00000000
5857 #define MODEL_MAUDIO_AUDIOPHILE_BOTH 0x00010060
5858 @@ -414,7 +415,7 @@ static const struct ieee1394_device_id bebob_id_table[] = {
5859 SND_BEBOB_DEV_ENTRY(VEN_BRIDGECO, 0x00010049, &spec_normal),
5860 /* Mackie, Onyx 1220/1620/1640 (Firewire I/O Card) */
5861 SND_BEBOB_DEV_ENTRY(VEN_MACKIE2, 0x00010065, &spec_normal),
5862 - // Mackie, d.2 (Firewire option card) and d.2 Pro (the card is built-in).
5863 + // Mackie, d.2 (optional Firewire card with DM1000).
5864 SND_BEBOB_DEV_ENTRY(VEN_MACKIE1, 0x00010067, &spec_normal),
5865 /* Stanton, ScratchAmp */
5866 SND_BEBOB_DEV_ENTRY(VEN_STANTON, 0x00000001, &spec_normal),
5867 @@ -513,6 +514,8 @@ static const struct ieee1394_device_id bebob_id_table[] = {
5868 &maudio_special_spec),
5869 /* Digidesign Mbox 2 Pro */
5870 SND_BEBOB_DEV_ENTRY(VEN_DIGIDESIGN, 0x0000a9, &spec_normal),
5871 + // Toneweal FW66.
5872 + SND_BEBOB_DEV_ENTRY(OUI_SHOUYO, 0x020002, &spec_normal),
5873 /* IDs are unknown but able to be supported */
5874 /* Apogee, Mini-ME Firewire */
5875 /* Apogee, Mini-DAC Firewire */
5876 diff --git a/sound/firewire/oxfw/oxfw.c b/sound/firewire/oxfw/oxfw.c
5877 index 44ecf2f5f65fd..e2932ac9d4879 100644
5878 --- a/sound/firewire/oxfw/oxfw.c
5879 +++ b/sound/firewire/oxfw/oxfw.c
5880 @@ -405,7 +405,7 @@ static const struct ieee1394_device_id oxfw_id_table[] = {
5881 * Onyx-i series (former models): 0x081216
5882 * Mackie Onyx Satellite: 0x00200f
5883 * Tapco LINK.firewire 4x6: 0x000460
5884 - * d.4 pro: Unknown
5885 + * d.2 pro/d.4 pro (built-in card): Unknown
5886 * U.420: Unknown
5887 * U.420d: Unknown
5888 */
5889 diff --git a/sound/isa/cmi8330.c b/sound/isa/cmi8330.c
5890 index dfedfd85f2054..463906882b95c 100644
5891 --- a/sound/isa/cmi8330.c
5892 +++ b/sound/isa/cmi8330.c
5893 @@ -564,7 +564,7 @@ static int snd_cmi8330_probe(struct snd_card *card, int dev)
5894 }
5895 if (acard->sb->hardware != SB_HW_16) {
5896 snd_printk(KERN_ERR PFX "SB16 not found during probe\n");
5897 - return err;
5898 + return -ENODEV;
5899 }
5900
5901 snd_wss_out(acard->wss, CS4231_MISC_INFO, 0x40); /* switch on MODE2 */
5902 diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
5903 index 2cc068be7d3be..90fa57ad14c04 100644
5904 --- a/sound/isa/sb/sb16_csp.c
5905 +++ b/sound/isa/sb/sb16_csp.c
5906 @@ -1086,10 +1086,14 @@ static void snd_sb_qsound_destroy(struct snd_sb_csp * p)
5907 card = p->chip->card;
5908
5909 down_write(&card->controls_rwsem);
5910 - if (p->qsound_switch)
5911 + if (p->qsound_switch) {
5912 snd_ctl_remove(card, p->qsound_switch);
5913 - if (p->qsound_space)
5914 + p->qsound_switch = NULL;
5915 + }
5916 + if (p->qsound_space) {
5917 snd_ctl_remove(card, p->qsound_space);
5918 + p->qsound_space = NULL;
5919 + }
5920 up_write(&card->controls_rwsem);
5921
5922 /* cancel pending transfer of QSound parameters */
5923 diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
5924 index e85fb04ec7be6..b567c4bdae000 100644
5925 --- a/sound/pci/hda/hda_tegra.c
5926 +++ b/sound/pci/hda/hda_tegra.c
5927 @@ -363,6 +363,9 @@ static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev)
5928 unsigned short gcap;
5929 int irq_id = platform_get_irq(pdev, 0);
5930
5931 + if (irq_id < 0)
5932 + return irq_id;
5933 +
5934 err = hda_tegra_init_chip(chip, pdev);
5935 if (err)
5936 return err;
5937 diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
5938 index 33c6be9fb388e..7c70ba5e2540d 100644
5939 --- a/sound/ppc/powermac.c
5940 +++ b/sound/ppc/powermac.c
5941 @@ -90,7 +90,11 @@ static int snd_pmac_probe(struct platform_device *devptr)
5942 sprintf(card->shortname, "PowerMac %s", name_ext);
5943 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
5944 card->shortname, chip->device_id, chip->subframe);
5945 - if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0)
5946 + err = snd_pmac_tumbler_init(chip);
5947 + if (err < 0)
5948 + goto __error;
5949 + err = snd_pmac_tumbler_post_init();
5950 + if (err < 0)
5951 goto __error;
5952 break;
5953 case PMAC_AWACS:
5954 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
5955 index 168559b5e9f32..0344d44231675 100644
5956 --- a/sound/soc/soc-core.c
5957 +++ b/sound/soc/soc-core.c
5958 @@ -3644,7 +3644,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
5959 if (!routes) {
5960 dev_err(card->dev,
5961 "ASoC: Could not allocate DAPM route table\n");
5962 - return -EINVAL;
5963 + return -ENOMEM;
5964 }
5965
5966 for (i = 0; i < num_routes; i++) {
5967 diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c
5968 index deb597f7c302b..f40657da4db2b 100644
5969 --- a/sound/soc/tegra/tegra_alc5632.c
5970 +++ b/sound/soc/tegra/tegra_alc5632.c
5971 @@ -149,6 +149,7 @@ static struct snd_soc_dai_link tegra_alc5632_dai = {
5972
5973 static struct snd_soc_card snd_soc_tegra_alc5632 = {
5974 .name = "tegra-alc5632",
5975 + .driver_name = "tegra",
5976 .owner = THIS_MODULE,
5977 .remove = tegra_alc5632_card_remove,
5978 .dai_link = &tegra_alc5632_dai,
5979 diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c
5980 index 902da36581d1b..f4f238924c764 100644
5981 --- a/sound/soc/tegra/tegra_max98090.c
5982 +++ b/sound/soc/tegra/tegra_max98090.c
5983 @@ -205,6 +205,7 @@ static struct snd_soc_dai_link tegra_max98090_dai = {
5984
5985 static struct snd_soc_card snd_soc_tegra_max98090 = {
5986 .name = "tegra-max98090",
5987 + .driver_name = "tegra",
5988 .owner = THIS_MODULE,
5989 .remove = tegra_max98090_card_remove,
5990 .dai_link = &tegra_max98090_dai,
5991 diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c
5992 index e5ef4e9c4ac59..3088c6f401e38 100644
5993 --- a/sound/soc/tegra/tegra_rt5640.c
5994 +++ b/sound/soc/tegra/tegra_rt5640.c
5995 @@ -150,6 +150,7 @@ static struct snd_soc_dai_link tegra_rt5640_dai = {
5996
5997 static struct snd_soc_card snd_soc_tegra_rt5640 = {
5998 .name = "tegra-rt5640",
5999 + .driver_name = "tegra",
6000 .owner = THIS_MODULE,
6001 .remove = tegra_rt5640_card_remove,
6002 .dai_link = &tegra_rt5640_dai,
6003 diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c
6004 index 1470873ecde68..451e7254e87b6 100644
6005 --- a/sound/soc/tegra/tegra_rt5677.c
6006 +++ b/sound/soc/tegra/tegra_rt5677.c
6007 @@ -198,6 +198,7 @@ static struct snd_soc_dai_link tegra_rt5677_dai = {
6008
6009 static struct snd_soc_card snd_soc_tegra_rt5677 = {
6010 .name = "tegra-rt5677",
6011 + .driver_name = "tegra",
6012 .owner = THIS_MODULE,
6013 .remove = tegra_rt5677_card_remove,
6014 .dai_link = &tegra_rt5677_dai,
6015 diff --git a/sound/soc/tegra/tegra_sgtl5000.c b/sound/soc/tegra/tegra_sgtl5000.c
6016 index 863e04809a6b8..8755a9528d925 100644
6017 --- a/sound/soc/tegra/tegra_sgtl5000.c
6018 +++ b/sound/soc/tegra/tegra_sgtl5000.c
6019 @@ -103,6 +103,7 @@ static struct snd_soc_dai_link tegra_sgtl5000_dai = {
6020
6021 static struct snd_soc_card snd_soc_tegra_sgtl5000 = {
6022 .name = "tegra-sgtl5000",
6023 + .driver_name = "tegra",
6024 .owner = THIS_MODULE,
6025 .dai_link = &tegra_sgtl5000_dai,
6026 .num_links = 1,
6027 diff --git a/sound/soc/tegra/tegra_wm8753.c b/sound/soc/tegra/tegra_wm8753.c
6028 index f0cd01dbfc380..633d26c4811b8 100644
6029 --- a/sound/soc/tegra/tegra_wm8753.c
6030 +++ b/sound/soc/tegra/tegra_wm8753.c
6031 @@ -110,6 +110,7 @@ static struct snd_soc_dai_link tegra_wm8753_dai = {
6032
6033 static struct snd_soc_card snd_soc_tegra_wm8753 = {
6034 .name = "tegra-wm8753",
6035 + .driver_name = "tegra",
6036 .owner = THIS_MODULE,
6037 .dai_link = &tegra_wm8753_dai,
6038 .num_links = 1,
6039 diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c
6040 index e485278e027a2..20a3ca03ac30d 100644
6041 --- a/sound/soc/tegra/tegra_wm8903.c
6042 +++ b/sound/soc/tegra/tegra_wm8903.c
6043 @@ -228,6 +228,7 @@ static struct snd_soc_dai_link tegra_wm8903_dai = {
6044
6045 static struct snd_soc_card snd_soc_tegra_wm8903 = {
6046 .name = "tegra-wm8903",
6047 + .driver_name = "tegra",
6048 .owner = THIS_MODULE,
6049 .dai_link = &tegra_wm8903_dai,
6050 .num_links = 1,
6051 diff --git a/sound/soc/tegra/tegra_wm9712.c b/sound/soc/tegra/tegra_wm9712.c
6052 index 6492f8143ff1f..e5bebb473d95e 100644
6053 --- a/sound/soc/tegra/tegra_wm9712.c
6054 +++ b/sound/soc/tegra/tegra_wm9712.c
6055 @@ -59,6 +59,7 @@ static struct snd_soc_dai_link tegra_wm9712_dai = {
6056
6057 static struct snd_soc_card snd_soc_tegra_wm9712 = {
6058 .name = "tegra-wm9712",
6059 + .driver_name = "tegra",
6060 .owner = THIS_MODULE,
6061 .dai_link = &tegra_wm9712_dai,
6062 .num_links = 1,
6063 diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c
6064 index 2cea203c4f5f1..90a770968f348 100644
6065 --- a/sound/soc/tegra/trimslice.c
6066 +++ b/sound/soc/tegra/trimslice.c
6067 @@ -103,6 +103,7 @@ static struct snd_soc_dai_link trimslice_tlv320aic23_dai = {
6068
6069 static struct snd_soc_card snd_soc_trimslice = {
6070 .name = "tegra-trimslice",
6071 + .driver_name = "tegra",
6072 .owner = THIS_MODULE,
6073 .dai_link = &trimslice_tlv320aic23_dai,
6074 .num_links = 1,
6075 diff --git a/sound/usb/format.c b/sound/usb/format.c
6076 index 06190e3fd9194..56b5baee65528 100644
6077 --- a/sound/usb/format.c
6078 +++ b/sound/usb/format.c
6079 @@ -189,9 +189,11 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
6080 continue;
6081 /* C-Media CM6501 mislabels its 96 kHz altsetting */
6082 /* Terratec Aureon 7.1 USB C-Media 6206, too */
6083 + /* Ozone Z90 USB C-Media, too */
6084 if (rate == 48000 && nr_rates == 1 &&
6085 (chip->usb_id == USB_ID(0x0d8c, 0x0201) ||
6086 chip->usb_id == USB_ID(0x0d8c, 0x0102) ||
6087 + chip->usb_id == USB_ID(0x0d8c, 0x0078) ||
6088 chip->usb_id == USB_ID(0x0ccd, 0x00b1)) &&
6089 fp->altsetting == 5 && fp->maxpacksize == 392)
6090 rate = 96000;
6091 diff --git a/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c b/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
6092 index 8341d7778d5ed..87630d44fb4c7 100644
6093 --- a/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
6094 +++ b/tools/testing/selftests/powerpc/pmu/ebb/no_handler_test.c
6095 @@ -50,8 +50,6 @@ static int no_handler_test(void)
6096
6097 event_close(&event);
6098
6099 - dump_ebb_state();
6100 -
6101 /* The real test is that we never took an EBB at 0x0 */
6102
6103 return 0;
6104 diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c
6105 index 5338e668b5e65..d78736845b8ec 100644
6106 --- a/tools/testing/selftests/x86/protection_keys.c
6107 +++ b/tools/testing/selftests/x86/protection_keys.c
6108 @@ -609,7 +609,6 @@ int alloc_random_pkey(void)
6109 int nr_alloced = 0;
6110 int random_index;
6111 memset(alloced_pkeys, 0, sizeof(alloced_pkeys));
6112 - srand((unsigned int)time(NULL));
6113
6114 /* allocate every possible key and make a note of which ones we got */
6115 max_nr_pkey_allocs = NR_PKEYS;
6116 @@ -1387,6 +1386,8 @@ int main(void)
6117 {
6118 int nr_iterations = 22;
6119
6120 + srand((unsigned int)time(NULL));
6121 +
6122 setup_handlers();
6123
6124 printf("has pku: %d\n", cpu_has_pku());