Magellan Linux

Annotation of /trunk/kernel-alx-legacy/patches-4.9/0368-4.9.269-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3670 - (hide annotations) (download)
Mon Oct 24 14:07:47 2022 UTC (19 months, 3 weeks ago) by niro
File size: 202660 byte(s)
-linux-4.9.269
1 niro 3670 diff --git a/Makefile b/Makefile
2     index 642365d416be1..94436a50dc9fb 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 9
8     -SUBLEVEL = 268
9     +SUBLEVEL = 269
10     EXTRAVERSION =
11     NAME = Roaring Lionus
12    
13     diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
14     index 85d9ea4a0accc..37ad245cf9899 100644
15     --- a/arch/arc/kernel/entry.S
16     +++ b/arch/arc/kernel/entry.S
17     @@ -169,7 +169,7 @@ tracesys:
18    
19     ; Do the Sys Call as we normally would.
20     ; Validate the Sys Call number
21     - cmp r8, NR_syscalls
22     + cmp r8, NR_syscalls - 1
23     mov.hi r0, -ENOSYS
24     bhi tracesys_exit
25    
26     @@ -252,7 +252,7 @@ ENTRY(EV_Trap)
27     ;============ Normal syscall case
28    
29     ; syscall num shd not exceed the total system calls avail
30     - cmp r8, NR_syscalls
31     + cmp r8, NR_syscalls - 1
32     mov.hi r0, -ENOSYS
33     bhi .Lret_from_system_call
34    
35     diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
36     index a97a785ccc6ba..f0906d67a1070 100644
37     --- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
38     +++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
39     @@ -134,7 +134,7 @@
40     compatible = "maxim,max77686";
41     reg = <0x09>;
42     interrupt-parent = <&gpx3>;
43     - interrupts = <2 IRQ_TYPE_NONE>;
44     + interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
45     pinctrl-names = "default";
46     pinctrl-0 = <&max77686_irq>;
47     wakeup-source;
48     diff --git a/arch/arm/boot/dts/exynos5250-snow-common.dtsi b/arch/arm/boot/dts/exynos5250-snow-common.dtsi
49     index d5d51916bb742..b24a77781e75e 100644
50     --- a/arch/arm/boot/dts/exynos5250-snow-common.dtsi
51     +++ b/arch/arm/boot/dts/exynos5250-snow-common.dtsi
52     @@ -280,7 +280,7 @@
53     max77686: max77686@09 {
54     compatible = "maxim,max77686";
55     interrupt-parent = <&gpx3>;
56     - interrupts = <2 IRQ_TYPE_NONE>;
57     + interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
58     pinctrl-names = "default";
59     pinctrl-0 = <&max77686_irq>;
60     wakeup-source;
61     diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
62     index 671dbc28e5d46..59e04e2d9d9db 100644
63     --- a/arch/arm/kernel/hw_breakpoint.c
64     +++ b/arch/arm/kernel/hw_breakpoint.c
65     @@ -891,7 +891,7 @@ static void breakpoint_handler(unsigned long unknown, struct pt_regs *regs)
66     info->trigger = addr;
67     pr_debug("breakpoint fired: address = 0x%x\n", addr);
68     perf_bp_event(bp, regs);
69     - if (!bp->overflow_handler)
70     + if (is_default_overflow_handler(bp))
71     enable_single_step(bp, addr);
72     goto unlock;
73     }
74     diff --git a/arch/arm64/boot/dts/mediatek/mt8173.dtsi b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
75     index b307d6b6357ec..ad34be46c3618 100644
76     --- a/arch/arm64/boot/dts/mediatek/mt8173.dtsi
77     +++ b/arch/arm64/boot/dts/mediatek/mt8173.dtsi
78     @@ -914,7 +914,7 @@
79     <&mmsys CLK_MM_DSI1_DIGITAL>,
80     <&mipi_tx1>;
81     clock-names = "engine", "digital", "hs";
82     - phy = <&mipi_tx1>;
83     + phys = <&mipi_tx1>;
84     phy-names = "dphy";
85     status = "disabled";
86     };
87     diff --git a/arch/arm64/kernel/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S
88     index beca249bc2f39..b3e6c4d5b75c8 100644
89     --- a/arch/arm64/kernel/vdso/vdso.lds.S
90     +++ b/arch/arm64/kernel/vdso/vdso.lds.S
91     @@ -39,6 +39,13 @@ SECTIONS
92     .gnu.version_d : { *(.gnu.version_d) }
93     .gnu.version_r : { *(.gnu.version_r) }
94    
95     + /*
96     + * Discard .note.gnu.property sections which are unused and have
97     + * different alignment requirement from vDSO note sections.
98     + */
99     + /DISCARD/ : {
100     + *(.note.GNU-stack .note.gnu.property)
101     + }
102     .note : { *(.note.*) } :text :note
103    
104     . = ALIGN(16);
105     @@ -59,7 +66,6 @@ SECTIONS
106     PROVIDE(end = .);
107    
108     /DISCARD/ : {
109     - *(.note.GNU-stack)
110     *(.data .data.* .gnu.linkonce.d.* .sdata*)
111     *(.bss .sbss .dynbss .dynsbss)
112     }
113     diff --git a/arch/mips/include/asm/div64.h b/arch/mips/include/asm/div64.h
114     index dc5ea57364408..ceece76fc971a 100644
115     --- a/arch/mips/include/asm/div64.h
116     +++ b/arch/mips/include/asm/div64.h
117     @@ -1,5 +1,5 @@
118     /*
119     - * Copyright (C) 2000, 2004 Maciej W. Rozycki
120     + * Copyright (C) 2000, 2004, 2021 Maciej W. Rozycki
121     * Copyright (C) 2003, 07 Ralf Baechle (ralf@linux-mips.org)
122     *
123     * This file is subject to the terms and conditions of the GNU General Public
124     @@ -9,25 +9,18 @@
125     #ifndef __ASM_DIV64_H
126     #define __ASM_DIV64_H
127    
128     -#include <asm-generic/div64.h>
129     -
130     -#if BITS_PER_LONG == 64
131     +#include <asm/bitsperlong.h>
132    
133     -#include <linux/types.h>
134     +#if BITS_PER_LONG == 32
135    
136     /*
137     * No traps on overflows for any of these...
138     */
139    
140     -#define __div64_32(n, base) \
141     -({ \
142     +#define do_div64_32(res, high, low, base) ({ \
143     unsigned long __cf, __tmp, __tmp2, __i; \
144     unsigned long __quot32, __mod32; \
145     - unsigned long __high, __low; \
146     - unsigned long long __n; \
147     \
148     - __high = *__n >> 32; \
149     - __low = __n; \
150     __asm__( \
151     " .set push \n" \
152     " .set noat \n" \
153     @@ -51,18 +44,48 @@
154     " subu %0, %0, %z6 \n" \
155     " addiu %2, %2, 1 \n" \
156     "3: \n" \
157     - " bnez %4, 0b\n\t" \
158     - " srl %5, %1, 0x1f\n\t" \
159     + " bnez %4, 0b \n" \
160     + " srl %5, %1, 0x1f \n" \
161     " .set pop" \
162     : "=&r" (__mod32), "=&r" (__tmp), \
163     "=&r" (__quot32), "=&r" (__cf), \
164     "=&r" (__i), "=&r" (__tmp2) \
165     - : "Jr" (base), "0" (__high), "1" (__low)); \
166     + : "Jr" (base), "0" (high), "1" (low)); \
167     \
168     - (__n) = __quot32; \
169     + (res) = __quot32; \
170     __mod32; \
171     })
172    
173     -#endif /* BITS_PER_LONG == 64 */
174     +#define __div64_32(n, base) ({ \
175     + unsigned long __upper, __low, __high, __radix; \
176     + unsigned long long __quot; \
177     + unsigned long long __div; \
178     + unsigned long __mod; \
179     + \
180     + __div = (*n); \
181     + __radix = (base); \
182     + \
183     + __high = __div >> 32; \
184     + __low = __div; \
185     + \
186     + if (__high < __radix) { \
187     + __upper = __high; \
188     + __high = 0; \
189     + } else { \
190     + __upper = __high % __radix; \
191     + __high /= __radix; \
192     + } \
193     + \
194     + __mod = do_div64_32(__low, __upper, __low, __radix); \
195     + \
196     + __quot = __high; \
197     + __quot = __quot << 32 | __low; \
198     + (*n) = __quot; \
199     + __mod; \
200     +})
201     +
202     +#endif /* BITS_PER_LONG == 32 */
203     +
204     +#include <asm-generic/div64.h>
205    
206     #endif /* __ASM_DIV64_H */
207     diff --git a/arch/mips/pci/pci-legacy.c b/arch/mips/pci/pci-legacy.c
208     index 2d6886f09ba35..009b840ee5ef0 100644
209     --- a/arch/mips/pci/pci-legacy.c
210     +++ b/arch/mips/pci/pci-legacy.c
211     @@ -158,8 +158,13 @@ void pci_load_of_ranges(struct pci_controller *hose, struct device_node *node)
212     res = hose->mem_resource;
213     break;
214     }
215     - if (res != NULL)
216     - of_pci_range_to_resource(&range, node, res);
217     + if (res != NULL) {
218     + res->name = node->full_name;
219     + res->flags = range.flags;
220     + res->start = range.cpu_addr;
221     + res->end = range.cpu_addr + range.size - 1;
222     + res->parent = res->child = res->sibling = NULL;
223     + }
224     }
225     }
226    
227     diff --git a/arch/powerpc/Kconfig.debug b/arch/powerpc/Kconfig.debug
228     index 63292f64b25a3..f66326339bc81 100644
229     --- a/arch/powerpc/Kconfig.debug
230     +++ b/arch/powerpc/Kconfig.debug
231     @@ -348,6 +348,7 @@ config PPC_EARLY_DEBUG_CPM_ADDR
232     config FAIL_IOMMU
233     bool "Fault-injection capability for IOMMU"
234     depends on FAULT_INJECTION
235     + depends on PCI || IBMVIO
236     help
237     Provide fault-injection capability for IOMMU. Each device can
238     be selectively enabled via the fail_iommu property.
239     diff --git a/arch/powerpc/include/uapi/asm/errno.h b/arch/powerpc/include/uapi/asm/errno.h
240     index e8b6b5f7de7c4..5e8f42ff797fb 100644
241     --- a/arch/powerpc/include/uapi/asm/errno.h
242     +++ b/arch/powerpc/include/uapi/asm/errno.h
243     @@ -1,6 +1,7 @@
244     #ifndef _ASM_POWERPC_ERRNO_H
245     #define _ASM_POWERPC_ERRNO_H
246    
247     +#undef EDEADLOCK
248     #include <asm-generic/errno.h>
249    
250     #undef EDEADLOCK
251     diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
252     index a7f229e598926..90d1f2bfb0071 100644
253     --- a/arch/powerpc/kernel/eeh.c
254     +++ b/arch/powerpc/kernel/eeh.c
255     @@ -366,14 +366,11 @@ static inline unsigned long eeh_token_to_phys(unsigned long token)
256     pa = pte_pfn(*ptep);
257    
258     /* On radix we can do hugepage mappings for io, so handle that */
259     - if (hugepage_shift) {
260     - pa <<= hugepage_shift;
261     - pa |= token & ((1ul << hugepage_shift) - 1);
262     - } else {
263     - pa <<= PAGE_SHIFT;
264     - pa |= token & (PAGE_SIZE - 1);
265     - }
266     + if (!hugepage_shift)
267     + hugepage_shift = PAGE_SHIFT;
268    
269     + pa <<= PAGE_SHIFT;
270     + pa |= token & ((1ul << hugepage_shift) - 1);
271     return pa;
272     }
273    
274     diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
275     index 9bfdd2510fd5e..2cf900d165273 100644
276     --- a/arch/powerpc/kernel/iommu.c
277     +++ b/arch/powerpc/kernel/iommu.c
278     @@ -1021,7 +1021,7 @@ int iommu_take_ownership(struct iommu_table *tbl)
279    
280     spin_lock_irqsave(&tbl->large_pool.lock, flags);
281     for (i = 0; i < tbl->nr_pools; i++)
282     - spin_lock(&tbl->pools[i].lock);
283     + spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock);
284    
285     if (tbl->it_offset == 0)
286     clear_bit(0, tbl->it_map);
287     @@ -1050,7 +1050,7 @@ void iommu_release_ownership(struct iommu_table *tbl)
288    
289     spin_lock_irqsave(&tbl->large_pool.lock, flags);
290     for (i = 0; i < tbl->nr_pools; i++)
291     - spin_lock(&tbl->pools[i].lock);
292     + spin_lock_nest_lock(&tbl->pools[i].lock, &tbl->large_pool.lock);
293    
294     memset(tbl->it_map, 0, sz);
295    
296     diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
297     index b868f07c4246c..11b4ecec04eeb 100644
298     --- a/arch/powerpc/kernel/prom.c
299     +++ b/arch/powerpc/kernel/prom.c
300     @@ -262,7 +262,7 @@ static struct feature_property {
301     };
302    
303     #if defined(CONFIG_44x) && defined(CONFIG_PPC_FPU)
304     -static inline void identical_pvr_fixup(unsigned long node)
305     +static __init void identical_pvr_fixup(unsigned long node)
306     {
307     unsigned int pvr;
308     const char *model = of_get_flat_dt_prop(node, "model", NULL);
309     diff --git a/arch/powerpc/lib/feature-fixups.c b/arch/powerpc/lib/feature-fixups.c
310     index 446810e37b0cc..777a90e251cc2 100644
311     --- a/arch/powerpc/lib/feature-fixups.c
312     +++ b/arch/powerpc/lib/feature-fixups.c
313     @@ -17,6 +17,7 @@
314     #include <linux/kernel.h>
315     #include <linux/string.h>
316     #include <linux/init.h>
317     +#include <linux/stop_machine.h>
318     #include <asm/cputable.h>
319     #include <asm/code-patching.h>
320     #include <asm/page.h>
321     @@ -282,8 +283,9 @@ void do_uaccess_flush_fixups(enum l1d_flush_type types)
322     : "unknown");
323     }
324    
325     -void do_entry_flush_fixups(enum l1d_flush_type types)
326     +static int __do_entry_flush_fixups(void *data)
327     {
328     + enum l1d_flush_type types = *(enum l1d_flush_type *)data;
329     unsigned int instrs[3], *dest;
330     long *start, *end;
331     int i;
332     @@ -334,6 +336,19 @@ void do_entry_flush_fixups(enum l1d_flush_type types)
333     : "ori type" :
334     (types & L1D_FLUSH_MTTRIG) ? "mttrig type"
335     : "unknown");
336     +
337     + return 0;
338     +}
339     +
340     +void do_entry_flush_fixups(enum l1d_flush_type types)
341     +{
342     + /*
343     + * The call to the fallback flush can not be safely patched in/out while
344     + * other CPUs are executing it. So call __do_entry_flush_fixups() on one
345     + * CPU while all other CPUs spin in the stop machine core with interrupts
346     + * hard disabled.
347     + */
348     + stop_machine(__do_entry_flush_fixups, &types, NULL);
349     }
350    
351     void do_rfi_flush_fixups(enum l1d_flush_type types)
352     diff --git a/arch/powerpc/perf/isa207-common.c b/arch/powerpc/perf/isa207-common.c
353     index 7592a6491a9a2..2d3557406424e 100644
354     --- a/arch/powerpc/perf/isa207-common.c
355     +++ b/arch/powerpc/perf/isa207-common.c
356     @@ -139,8 +139,8 @@ ebb_bhrb:
357     * EBB events are pinned & exclusive, so this should never actually
358     * hit, but we leave it as a fallback in case.
359     */
360     - mask |= CNST_EBB_VAL(ebb);
361     - value |= CNST_EBB_MASK;
362     + mask |= CNST_EBB_MASK;
363     + value |= CNST_EBB_VAL(ebb);
364    
365     *maskp = mask;
366     *valp = value;
367     diff --git a/arch/powerpc/platforms/52xx/lite5200_sleep.S b/arch/powerpc/platforms/52xx/lite5200_sleep.S
368     index 08ab6fefcf7a6..5f44e92234137 100644
369     --- a/arch/powerpc/platforms/52xx/lite5200_sleep.S
370     +++ b/arch/powerpc/platforms/52xx/lite5200_sleep.S
371     @@ -180,7 +180,7 @@ sram_code:
372     udelay: /* r11 - tb_ticks_per_usec, r12 - usecs, overwrites r13 */
373     mullw r12, r12, r11
374     mftb r13 /* start */
375     - addi r12, r13, r12 /* end */
376     + add r12, r13, r12 /* end */
377     1:
378     mftb r13 /* current */
379     cmp cr0, r13, r12
380     diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c
381     index 7a2beedb97403..a7d9dd0298507 100644
382     --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c
383     +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c
384     @@ -92,9 +92,6 @@ static void rtas_stop_self(void)
385    
386     BUG_ON(rtas_stop_self_token == RTAS_UNKNOWN_SERVICE);
387    
388     - printk("cpu %u (hwid %u) Ready to die...\n",
389     - smp_processor_id(), hard_smp_processor_id());
390     -
391     rtas_call_unlocked(&args, rtas_stop_self_token, 0, 1, NULL);
392    
393     panic("Alas, I survived.\n");
394     diff --git a/arch/powerpc/platforms/pseries/pci_dlpar.c b/arch/powerpc/platforms/pseries/pci_dlpar.c
395     index 547fd13e4f8e8..35d035d68dce0 100644
396     --- a/arch/powerpc/platforms/pseries/pci_dlpar.c
397     +++ b/arch/powerpc/platforms/pseries/pci_dlpar.c
398     @@ -66,6 +66,7 @@ EXPORT_SYMBOL_GPL(init_phb_dynamic);
399     int remove_phb_dynamic(struct pci_controller *phb)
400     {
401     struct pci_bus *b = phb->bus;
402     + struct pci_host_bridge *host_bridge = to_pci_host_bridge(b->bridge);
403     struct resource *res;
404     int rc, i;
405    
406     @@ -92,7 +93,8 @@ int remove_phb_dynamic(struct pci_controller *phb)
407     /* Remove the PCI bus and unregister the bridge device from sysfs */
408     phb->bus = NULL;
409     pci_remove_bus(b);
410     - device_unregister(b->bridge);
411     + host_bridge->bus = NULL;
412     + device_unregister(&host_bridge->dev);
413    
414     /* Now release the IO resource */
415     if (res->flags & IORESOURCE_IO)
416     diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
417     index f9dca1aed9a4b..17b3e82415f89 100644
418     --- a/arch/s390/kernel/dis.c
419     +++ b/arch/s390/kernel/dis.c
420     @@ -2026,7 +2026,7 @@ void show_code(struct pt_regs *regs)
421    
422     void print_fn_code(unsigned char *code, unsigned long len)
423     {
424     - char buffer[64], *ptr;
425     + char buffer[128], *ptr;
426     int opsize, i;
427    
428     while (len) {
429     diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
430     index 4fdbcf958cd5a..558e5258dfff9 100644
431     --- a/arch/um/kernel/dyn.lds.S
432     +++ b/arch/um/kernel/dyn.lds.S
433     @@ -6,6 +6,12 @@ OUTPUT_ARCH(ELF_ARCH)
434     ENTRY(_start)
435     jiffies = jiffies_64;
436    
437     +VERSION {
438     + {
439     + local: *;
440     + };
441     +}
442     +
443     SECTIONS
444     {
445     PROVIDE (__executable_start = START);
446     diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
447     index 1840f55ed0420..f544b8c13c2e9 100644
448     --- a/arch/um/kernel/uml.lds.S
449     +++ b/arch/um/kernel/uml.lds.S
450     @@ -6,6 +6,12 @@ OUTPUT_ARCH(ELF_ARCH)
451     ENTRY(_start)
452     jiffies = jiffies_64;
453    
454     +VERSION {
455     + {
456     + local: *;
457     + };
458     +}
459     +
460     SECTIONS
461     {
462     /* This must contain the right address - not quite the default ELF one.*/
463     diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
464     index 80636caee07cc..3ce5b5bd1dc45 100644
465     --- a/arch/x86/Kconfig
466     +++ b/arch/x86/Kconfig
467     @@ -495,6 +495,7 @@ config X86_UV
468     depends on X86_EXTENDED_PLATFORM
469     depends on NUMA
470     depends on EFI
471     + depends on KEXEC_CORE
472     depends on X86_X2APIC
473     depends on PCI
474     ---help---
475     diff --git a/arch/x86/Makefile b/arch/x86/Makefile
476     index 9ebbd4892557e..0bc35e3e6c5cd 100644
477     --- a/arch/x86/Makefile
478     +++ b/arch/x86/Makefile
479     @@ -40,6 +40,7 @@ REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding
480     REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector)
481     REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -Wno-address-of-packed-member)
482     REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), $(cc_stack_align4))
483     +REALMODE_CFLAGS += $(CLANG_FLAGS)
484     export REALMODE_CFLAGS
485    
486     # BITS is used as extension for files which are available in a 32 bit
487     diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c
488     index b28200dea715c..2bbf3fba80972 100644
489     --- a/arch/x86/events/amd/iommu.c
490     +++ b/arch/x86/events/amd/iommu.c
491     @@ -80,12 +80,12 @@ static struct attribute_group amd_iommu_format_group = {
492     * sysfs events attributes
493     *---------------------------------------------*/
494     struct amd_iommu_event_desc {
495     - struct kobj_attribute attr;
496     + struct device_attribute attr;
497     const char *event;
498     };
499    
500     -static ssize_t _iommu_event_show(struct kobject *kobj,
501     - struct kobj_attribute *attr, char *buf)
502     +static ssize_t _iommu_event_show(struct device *dev,
503     + struct device_attribute *attr, char *buf)
504     {
505     struct amd_iommu_event_desc *event =
506     container_of(attr, struct amd_iommu_event_desc, attr);
507     diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
508     index 98fb3a7240371..b945f362771fa 100644
509     --- a/arch/x86/kvm/x86.c
510     +++ b/arch/x86/kvm/x86.c
511     @@ -6268,6 +6268,7 @@ void kvm_arch_exit(void)
512     cpuhp_remove_state_nocalls(CPUHP_AP_X86_KVM_CLK_ONLINE);
513     #ifdef CONFIG_X86_64
514     pvclock_gtod_unregister_notifier(&pvclock_gtod_notifier);
515     + cancel_work_sync(&pvclock_gtod_work);
516     #endif
517     kvm_x86_ops = NULL;
518     kvm_mmu_module_exit();
519     diff --git a/arch/x86/lib/msr-smp.c b/arch/x86/lib/msr-smp.c
520     index ce68b6a9d7d1e..e28c106a7c0ce 100644
521     --- a/arch/x86/lib/msr-smp.c
522     +++ b/arch/x86/lib/msr-smp.c
523     @@ -239,7 +239,7 @@ static void __wrmsr_safe_regs_on_cpu(void *info)
524     rv->err = wrmsr_safe_regs(rv->regs);
525     }
526    
527     -int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
528     +int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])
529     {
530     int err;
531     struct msr_regs_info rv;
532     @@ -252,7 +252,7 @@ int rdmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
533     }
534     EXPORT_SYMBOL(rdmsr_safe_regs_on_cpu);
535    
536     -int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 *regs)
537     +int wrmsr_safe_regs_on_cpu(unsigned int cpu, u32 regs[8])
538     {
539     int err;
540     struct msr_regs_info rv;
541     diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
542     index 435bd0ffc8c02..ea4c7c93a9209 100644
543     --- a/drivers/acpi/custom_method.c
544     +++ b/drivers/acpi/custom_method.c
545     @@ -37,6 +37,8 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
546     sizeof(struct acpi_table_header)))
547     return -EFAULT;
548     uncopied_bytes = max_size = table.length;
549     + /* make sure the buf is not allocated */
550     + kfree(buf);
551     buf = kzalloc(max_size, GFP_KERNEL);
552     if (!buf)
553     return -ENOMEM;
554     @@ -50,6 +52,7 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
555     (*ppos + count < count) ||
556     (count > uncopied_bytes)) {
557     kfree(buf);
558     + buf = NULL;
559     return -EINVAL;
560     }
561    
562     @@ -71,7 +74,6 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
563     add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
564     }
565    
566     - kfree(buf);
567     return count;
568     }
569    
570     diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
571     index d749fe20fbfc5..89ce7b14a1660 100644
572     --- a/drivers/acpi/scan.c
573     +++ b/drivers/acpi/scan.c
574     @@ -704,6 +704,7 @@ int acpi_device_add(struct acpi_device *device,
575    
576     result = acpi_device_set_name(device, acpi_device_bus_id);
577     if (result) {
578     + kfree_const(acpi_device_bus_id->bus_id);
579     kfree(acpi_device_bus_id);
580     goto err_unlock;
581     }
582     diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
583     index 0b80502bc1c51..bfa2e5eec2635 100644
584     --- a/drivers/ata/libahci_platform.c
585     +++ b/drivers/ata/libahci_platform.c
586     @@ -518,11 +518,13 @@ int ahci_platform_init_host(struct platform_device *pdev,
587     int i, irq, n_ports, rc;
588    
589     irq = platform_get_irq(pdev, 0);
590     - if (irq <= 0) {
591     + if (irq < 0) {
592     if (irq != -EPROBE_DEFER)
593     dev_err(dev, "no irq\n");
594     return irq;
595     }
596     + if (!irq)
597     + return -EINVAL;
598    
599     hpriv->irq = irq;
600    
601     diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
602     index b4d54771c9fe0..623199fab8fe0 100644
603     --- a/drivers/ata/pata_arasan_cf.c
604     +++ b/drivers/ata/pata_arasan_cf.c
605     @@ -819,12 +819,19 @@ static int arasan_cf_probe(struct platform_device *pdev)
606     else
607     quirk = CF_BROKEN_UDMA; /* as it is on spear1340 */
608    
609     - /* if irq is 0, support only PIO */
610     - acdev->irq = platform_get_irq(pdev, 0);
611     - if (acdev->irq)
612     + /*
613     + * If there's an error getting IRQ (or we do get IRQ0),
614     + * support only PIO
615     + */
616     + ret = platform_get_irq(pdev, 0);
617     + if (ret > 0) {
618     + acdev->irq = ret;
619     irq_handler = arasan_cf_interrupt;
620     - else
621     + } else if (ret == -EPROBE_DEFER) {
622     + return ret;
623     + } else {
624     quirk |= CF_BROKEN_MWDMA | CF_BROKEN_UDMA;
625     + }
626    
627     acdev->pbase = res->start;
628     acdev->vbase = devm_ioremap_nocache(&pdev->dev, res->start,
629     diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
630     index abda441835122..fb8d1f68f36f7 100644
631     --- a/drivers/ata/pata_ixp4xx_cf.c
632     +++ b/drivers/ata/pata_ixp4xx_cf.c
633     @@ -169,8 +169,12 @@ static int ixp4xx_pata_probe(struct platform_device *pdev)
634     return -ENOMEM;
635    
636     irq = platform_get_irq(pdev, 0);
637     - if (irq)
638     + if (irq > 0)
639     irq_set_irq_type(irq, IRQ_TYPE_EDGE_RISING);
640     + else if (irq < 0)
641     + return irq;
642     + else
643     + return -EINVAL;
644    
645     /* Setup expansion bus chip selects */
646     *data->cs0_cfg = data->cs0_bits;
647     diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
648     index 513ef298dd960..ded3a66049d2c 100644
649     --- a/drivers/ata/sata_mv.c
650     +++ b/drivers/ata/sata_mv.c
651     @@ -4112,6 +4112,10 @@ static int mv_platform_probe(struct platform_device *pdev)
652     n_ports = mv_platform_data->n_ports;
653     irq = platform_get_irq(pdev, 0);
654     }
655     + if (irq < 0)
656     + return irq;
657     + if (!irq)
658     + return -EINVAL;
659    
660     host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
661     hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL);
662     diff --git a/drivers/bus/qcom-ebi2.c b/drivers/bus/qcom-ebi2.c
663     index a6444244c4111..bfb67aa00becc 100644
664     --- a/drivers/bus/qcom-ebi2.c
665     +++ b/drivers/bus/qcom-ebi2.c
666     @@ -357,8 +357,10 @@ static int qcom_ebi2_probe(struct platform_device *pdev)
667    
668     /* Figure out the chipselect */
669     ret = of_property_read_u32(child, "reg", &csindex);
670     - if (ret)
671     + if (ret) {
672     + of_node_put(child);
673     return ret;
674     + }
675    
676     if (csindex > 5) {
677     dev_err(dev,
678     diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
679     index 774748497aced..e56ac5adb5fcc 100644
680     --- a/drivers/char/ttyprintk.c
681     +++ b/drivers/char/ttyprintk.c
682     @@ -159,12 +159,23 @@ static int tpk_ioctl(struct tty_struct *tty,
683     return 0;
684     }
685    
686     +/*
687     + * TTY operations hangup function.
688     + */
689     +static void tpk_hangup(struct tty_struct *tty)
690     +{
691     + struct ttyprintk_port *tpkp = tty->driver_data;
692     +
693     + tty_port_hangup(&tpkp->port);
694     +}
695     +
696     static const struct tty_operations ttyprintk_ops = {
697     .open = tpk_open,
698     .close = tpk_close,
699     .write = tpk_write,
700     .write_room = tpk_write_room,
701     .ioctl = tpk_ioctl,
702     + .hangup = tpk_hangup,
703     };
704    
705     static const struct tty_port_operations null_ops = { };
706     diff --git a/drivers/clk/samsung/clk-exynos7.c b/drivers/clk/samsung/clk-exynos7.c
707     index bbfa57b4e0176..17dfd4f130cae 100644
708     --- a/drivers/clk/samsung/clk-exynos7.c
709     +++ b/drivers/clk/samsung/clk-exynos7.c
710     @@ -541,8 +541,13 @@ static const struct samsung_gate_clock top1_gate_clks[] __initconst = {
711     GATE(CLK_ACLK_FSYS0_200, "aclk_fsys0_200", "dout_aclk_fsys0_200",
712     ENABLE_ACLK_TOP13, 28, CLK_SET_RATE_PARENT |
713     CLK_IS_CRITICAL, 0),
714     + /*
715     + * This clock is required for the CMU_FSYS1 registers access, keep it
716     + * enabled permanently until proper runtime PM support is added.
717     + */
718     GATE(CLK_ACLK_FSYS1_200, "aclk_fsys1_200", "dout_aclk_fsys1_200",
719     - ENABLE_ACLK_TOP13, 24, CLK_SET_RATE_PARENT, 0),
720     + ENABLE_ACLK_TOP13, 24, CLK_SET_RATE_PARENT |
721     + CLK_IS_CRITICAL, 0),
722    
723     GATE(CLK_SCLK_PHY_FSYS1_26M, "sclk_phy_fsys1_26m",
724     "dout_sclk_phy_fsys1_26m", ENABLE_SCLK_TOP1_FSYS11,
725     diff --git a/drivers/clk/socfpga/clk-gate-a10.c b/drivers/clk/socfpga/clk-gate-a10.c
726     index c2d5727481671..7913dbedba89b 100644
727     --- a/drivers/clk/socfpga/clk-gate-a10.c
728     +++ b/drivers/clk/socfpga/clk-gate-a10.c
729     @@ -157,6 +157,7 @@ static void __init __socfpga_gate_init(struct device_node *node,
730     if (IS_ERR(socfpga_clk->sys_mgr_base_addr)) {
731     pr_err("%s: failed to find altr,sys-mgr regmap!\n",
732     __func__);
733     + kfree(socfpga_clk);
734     return;
735     }
736     }
737     diff --git a/drivers/clk/uniphier/clk-uniphier-mux.c b/drivers/clk/uniphier/clk-uniphier-mux.c
738     index 2c243a894f3b9..3a52ab968ac24 100644
739     --- a/drivers/clk/uniphier/clk-uniphier-mux.c
740     +++ b/drivers/clk/uniphier/clk-uniphier-mux.c
741     @@ -40,10 +40,10 @@ static int uniphier_clk_mux_set_parent(struct clk_hw *hw, u8 index)
742     static u8 uniphier_clk_mux_get_parent(struct clk_hw *hw)
743     {
744     struct uniphier_clk_mux *mux = to_uniphier_clk_mux(hw);
745     - int num_parents = clk_hw_get_num_parents(hw);
746     + unsigned int num_parents = clk_hw_get_num_parents(hw);
747     int ret;
748     unsigned int val;
749     - u8 i;
750     + unsigned int i;
751    
752     ret = regmap_read(mux->regmap, mux->reg, &val);
753     if (ret)
754     diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c b/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c
755     index 0dd8d2dc2ec1b..26931325dfa26 100644
756     --- a/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c
757     +++ b/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c
758     @@ -238,12 +238,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
759     if (ret)
760     goto out_err_free_reg;
761    
762     - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
763     -
764     ret = adf_dev_init(accel_dev);
765     if (ret)
766     goto out_err_dev_shutdown;
767    
768     + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
769     +
770     ret = adf_dev_start(accel_dev);
771     if (ret)
772     goto out_err_dev_stop;
773     diff --git a/drivers/crypto/qat/qat_c62xvf/adf_drv.c b/drivers/crypto/qat/qat_c62xvf/adf_drv.c
774     index cd9e63468b189..722a06aac9faa 100644
775     --- a/drivers/crypto/qat/qat_c62xvf/adf_drv.c
776     +++ b/drivers/crypto/qat/qat_c62xvf/adf_drv.c
777     @@ -238,12 +238,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
778     if (ret)
779     goto out_err_free_reg;
780    
781     - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
782     -
783     ret = adf_dev_init(accel_dev);
784     if (ret)
785     goto out_err_dev_shutdown;
786    
787     + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
788     +
789     ret = adf_dev_start(accel_dev);
790     if (ret)
791     goto out_err_dev_stop;
792     diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
793     index 06d49017a52b7..2c0be14309cfa 100644
794     --- a/drivers/crypto/qat/qat_common/adf_isr.c
795     +++ b/drivers/crypto/qat/qat_common/adf_isr.c
796     @@ -330,19 +330,32 @@ int adf_isr_resource_alloc(struct adf_accel_dev *accel_dev)
797    
798     ret = adf_isr_alloc_msix_entry_table(accel_dev);
799     if (ret)
800     - return ret;
801     - if (adf_enable_msix(accel_dev))
802     goto err_out;
803    
804     - if (adf_setup_bh(accel_dev))
805     - goto err_out;
806     + ret = adf_enable_msix(accel_dev);
807     + if (ret)
808     + goto err_free_msix_table;
809    
810     - if (adf_request_irqs(accel_dev))
811     - goto err_out;
812     + ret = adf_setup_bh(accel_dev);
813     + if (ret)
814     + goto err_disable_msix;
815     +
816     + ret = adf_request_irqs(accel_dev);
817     + if (ret)
818     + goto err_cleanup_bh;
819    
820     return 0;
821     +
822     +err_cleanup_bh:
823     + adf_cleanup_bh(accel_dev);
824     +
825     +err_disable_msix:
826     + adf_disable_msix(&accel_dev->accel_pci_dev);
827     +
828     +err_free_msix_table:
829     + adf_isr_free_msix_entry_table(accel_dev);
830     +
831     err_out:
832     - adf_isr_resource_free(accel_dev);
833     - return -EFAULT;
834     + return ret;
835     }
836     EXPORT_SYMBOL_GPL(adf_isr_resource_alloc);
837     diff --git a/drivers/crypto/qat/qat_common/adf_transport.c b/drivers/crypto/qat/qat_common/adf_transport.c
838     index 57d2622728a57..4c0067f8c079f 100644
839     --- a/drivers/crypto/qat/qat_common/adf_transport.c
840     +++ b/drivers/crypto/qat/qat_common/adf_transport.c
841     @@ -197,6 +197,7 @@ static int adf_init_ring(struct adf_etr_ring_data *ring)
842     dev_err(&GET_DEV(accel_dev), "Ring address not aligned\n");
843     dma_free_coherent(&GET_DEV(accel_dev), ring_size_bytes,
844     ring->base_addr, ring->dma_addr);
845     + ring->base_addr = NULL;
846     return -EFAULT;
847     }
848    
849     diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
850     index bf99e11a3403d..4c1217ba83ae8 100644
851     --- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
852     +++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
853     @@ -304,17 +304,26 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev)
854     goto err_out;
855    
856     if (adf_setup_pf2vf_bh(accel_dev))
857     - goto err_out;
858     + goto err_disable_msi;
859    
860     if (adf_setup_bh(accel_dev))
861     - goto err_out;
862     + goto err_cleanup_pf2vf_bh;
863    
864     if (adf_request_msi_irq(accel_dev))
865     - goto err_out;
866     + goto err_cleanup_bh;
867    
868     return 0;
869     +
870     +err_cleanup_bh:
871     + adf_cleanup_bh(accel_dev);
872     +
873     +err_cleanup_pf2vf_bh:
874     + adf_cleanup_pf2vf_bh(accel_dev);
875     +
876     +err_disable_msi:
877     + adf_disable_msi(accel_dev);
878     +
879     err_out:
880     - adf_vf_isr_resource_free(accel_dev);
881     return -EFAULT;
882     }
883     EXPORT_SYMBOL_GPL(adf_vf_isr_resource_alloc);
884     diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c b/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c
885     index 15de9cbed3bf8..cc3f5171a5233 100644
886     --- a/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c
887     +++ b/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c
888     @@ -238,12 +238,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
889     if (ret)
890     goto out_err_free_reg;
891    
892     - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
893     -
894     ret = adf_dev_init(accel_dev);
895     if (ret)
896     goto out_err_dev_shutdown;
897    
898     + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
899     +
900     ret = adf_dev_start(accel_dev);
901     if (ret)
902     goto out_err_dev_stop;
903     diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
904     index 4c0b6df8b5ddb..1d06d99b8bd92 100644
905     --- a/drivers/extcon/extcon-arizona.c
906     +++ b/drivers/extcon/extcon-arizona.c
907     @@ -601,7 +601,7 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
908     struct arizona *arizona = info->arizona;
909     int id_gpio = arizona->pdata.hpdet_id_gpio;
910     unsigned int report = EXTCON_JACK_HEADPHONE;
911     - int ret, reading;
912     + int ret, reading, state;
913     bool mic = false;
914    
915     mutex_lock(&info->lock);
916     @@ -614,12 +614,11 @@ static irqreturn_t arizona_hpdet_irq(int irq, void *data)
917     }
918    
919     /* If the cable was removed while measuring ignore the result */
920     - ret = extcon_get_state(info->edev, EXTCON_MECHANICAL);
921     - if (ret < 0) {
922     - dev_err(arizona->dev, "Failed to check cable state: %d\n",
923     - ret);
924     + state = extcon_get_state(info->edev, EXTCON_MECHANICAL);
925     + if (state < 0) {
926     + dev_err(arizona->dev, "Failed to check cable state: %d\n", state);
927     goto out;
928     - } else if (!ret) {
929     + } else if (!state) {
930     dev_dbg(arizona->dev, "Ignoring HPDET for removed cable\n");
931     goto done;
932     }
933     @@ -672,7 +671,7 @@ done:
934     ARIZONA_ACCDET_MODE_MASK, ARIZONA_ACCDET_MODE_MIC);
935    
936     /* If we have a mic then reenable MICDET */
937     - if (mic || info->mic)
938     + if (state && (mic || info->mic))
939     arizona_start_mic(info);
940    
941     if (info->hpdet_active) {
942     @@ -680,7 +679,9 @@ done:
943     info->hpdet_active = false;
944     }
945    
946     - info->hpdet_done = true;
947     + /* Do not set hp_det done when the cable has been unplugged */
948     + if (state)
949     + info->hpdet_done = true;
950    
951     out:
952     mutex_unlock(&info->lock);
953     diff --git a/drivers/firmware/Kconfig b/drivers/firmware/Kconfig
954     index 854df538ae01e..1fc29fca27c89 100644
955     --- a/drivers/firmware/Kconfig
956     +++ b/drivers/firmware/Kconfig
957     @@ -194,6 +194,7 @@ config FW_CFG_SYSFS_CMDLINE
958     config QCOM_SCM
959     bool
960     depends on ARM || ARM64
961     + depends on HAVE_ARM_SMCCC
962     select RESET_CONTROLLER
963    
964     config QCOM_SCM_32
965     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
966     index 80c60a62d39ef..7271e3f32d82e 100644
967     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
968     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
969     @@ -652,7 +652,7 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_tt *ttm)
970     DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
971    
972     /* double check that we don't free the table twice */
973     - if (!ttm->sg->sgl)
974     + if (!ttm->sg || !ttm->sg->sgl)
975     return;
976    
977     /* free the sg table and pages again */
978     diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cmd_encoder.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cmd_encoder.c
979     index c627ab6d00617..8ac54b9dcd392 100644
980     --- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cmd_encoder.c
981     +++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_cmd_encoder.c
982     @@ -128,9 +128,17 @@ static int pingpong_tearcheck_setup(struct drm_encoder *encoder,
983     | MDP5_PP_SYNC_CONFIG_VSYNC_IN_EN;
984     cfg |= MDP5_PP_SYNC_CONFIG_VSYNC_COUNT(vclks_line);
985    
986     + /*
987     + * Tearcheck emits a blanking signal every vclks_line * vtotal * 2 ticks on
988     + * the vsync_clk equating to roughly half the desired panel refresh rate.
989     + * This is only necessary as stability fallback if interrupts from the
990     + * panel arrive too late or not at all, but is currently used by default
991     + * because these panel interrupts are not wired up yet.
992     + */
993     mdp5_write(mdp5_kms, REG_MDP5_PP_SYNC_CONFIG_VSYNC(pp_id), cfg);
994     mdp5_write(mdp5_kms,
995     - REG_MDP5_PP_SYNC_CONFIG_HEIGHT(pp_id), 0xfff0);
996     + REG_MDP5_PP_SYNC_CONFIG_HEIGHT(pp_id), (2 * mode->vtotal));
997     +
998     mdp5_write(mdp5_kms,
999     REG_MDP5_PP_VSYNC_INIT_VAL(pp_id), mode->vdisplay);
1000     mdp5_write(mdp5_kms, REG_MDP5_PP_RD_PTR_IRQ(pp_id), mode->vdisplay + 1);
1001     diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
1002     index 5df3ec73021b5..0bfbced3862e6 100644
1003     --- a/drivers/gpu/drm/radeon/radeon_atombios.c
1004     +++ b/drivers/gpu/drm/radeon/radeon_atombios.c
1005     @@ -2259,10 +2259,10 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev)
1006     rdev->pm.default_power_state_index = state_index - 1;
1007     rdev->pm.power_state[state_index - 1].default_clock_mode =
1008     &rdev->pm.power_state[state_index - 1].clock_info[0];
1009     - rdev->pm.power_state[state_index].flags &=
1010     + rdev->pm.power_state[state_index - 1].flags &=
1011     ~RADEON_PM_STATE_SINGLE_DISPLAY_ONLY;
1012     - rdev->pm.power_state[state_index].misc = 0;
1013     - rdev->pm.power_state[state_index].misc2 = 0;
1014     + rdev->pm.power_state[state_index - 1].misc = 0;
1015     + rdev->pm.power_state[state_index - 1].misc2 = 0;
1016     }
1017     return state_index;
1018     }
1019     diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
1020     index 96d2a564d9a3c..61000e3b2e793 100644
1021     --- a/drivers/gpu/drm/radeon/radeon_kms.c
1022     +++ b/drivers/gpu/drm/radeon/radeon_kms.c
1023     @@ -506,6 +506,7 @@ static int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file
1024     *value = rdev->config.si.backend_enable_mask;
1025     } else {
1026     DRM_DEBUG_KMS("BACKEND_ENABLED_MASK is si+ only!\n");
1027     + return -EINVAL;
1028     }
1029     break;
1030     case RADEON_INFO_MAX_SCLK:
1031     diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
1032     index c4a53fc648e95..1f641870d860d 100644
1033     --- a/drivers/hid/hid-ids.h
1034     +++ b/drivers/hid/hid-ids.h
1035     @@ -816,6 +816,7 @@
1036     #define USB_DEVICE_ID_ORTEK_WKB2000 0x2000
1037    
1038     #define USB_VENDOR_ID_PLANTRONICS 0x047f
1039     +#define USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3220_SERIES 0xc056
1040    
1041     #define USB_VENDOR_ID_PANASONIC 0x04da
1042     #define USB_DEVICE_ID_PANABOARD_UBT780 0x1044
1043     diff --git a/drivers/hid/hid-plantronics.c b/drivers/hid/hid-plantronics.c
1044     index 584b10d3fc3d8..460711c1124ac 100644
1045     --- a/drivers/hid/hid-plantronics.c
1046     +++ b/drivers/hid/hid-plantronics.c
1047     @@ -16,6 +16,7 @@
1048    
1049     #include <linux/hid.h>
1050     #include <linux/module.h>
1051     +#include <linux/jiffies.h>
1052    
1053     #define PLT_HID_1_0_PAGE 0xffa00000
1054     #define PLT_HID_2_0_PAGE 0xffa20000
1055     @@ -39,6 +40,16 @@
1056     #define PLT_ALLOW_CONSUMER (field->application == HID_CP_CONSUMERCONTROL && \
1057     (usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER)
1058    
1059     +#define PLT_QUIRK_DOUBLE_VOLUME_KEYS BIT(0)
1060     +
1061     +#define PLT_DOUBLE_KEY_TIMEOUT 5 /* ms */
1062     +
1063     +struct plt_drv_data {
1064     + unsigned long device_type;
1065     + unsigned long last_volume_key_ts;
1066     + u32 quirks;
1067     +};
1068     +
1069     static int plantronics_input_mapping(struct hid_device *hdev,
1070     struct hid_input *hi,
1071     struct hid_field *field,
1072     @@ -46,7 +57,8 @@ static int plantronics_input_mapping(struct hid_device *hdev,
1073     unsigned long **bit, int *max)
1074     {
1075     unsigned short mapped_key;
1076     - unsigned long plt_type = (unsigned long)hid_get_drvdata(hdev);
1077     + struct plt_drv_data *drv_data = hid_get_drvdata(hdev);
1078     + unsigned long plt_type = drv_data->device_type;
1079    
1080     /* special case for PTT products */
1081     if (field->application == HID_GD_JOYSTICK)
1082     @@ -108,6 +120,30 @@ mapped:
1083     return 1;
1084     }
1085    
1086     +static int plantronics_event(struct hid_device *hdev, struct hid_field *field,
1087     + struct hid_usage *usage, __s32 value)
1088     +{
1089     + struct plt_drv_data *drv_data = hid_get_drvdata(hdev);
1090     +
1091     + if (drv_data->quirks & PLT_QUIRK_DOUBLE_VOLUME_KEYS) {
1092     + unsigned long prev_ts, cur_ts;
1093     +
1094     + /* Usages are filtered in plantronics_usages. */
1095     +
1096     + if (!value) /* Handle key presses only. */
1097     + return 0;
1098     +
1099     + prev_ts = drv_data->last_volume_key_ts;
1100     + cur_ts = jiffies;
1101     + if (jiffies_to_msecs(cur_ts - prev_ts) <= PLT_DOUBLE_KEY_TIMEOUT)
1102     + return 1; /* Ignore the repeated key. */
1103     +
1104     + drv_data->last_volume_key_ts = cur_ts;
1105     + }
1106     +
1107     + return 0;
1108     +}
1109     +
1110     static unsigned long plantronics_device_type(struct hid_device *hdev)
1111     {
1112     unsigned i, col_page;
1113     @@ -136,15 +172,24 @@ exit:
1114     static int plantronics_probe(struct hid_device *hdev,
1115     const struct hid_device_id *id)
1116     {
1117     + struct plt_drv_data *drv_data;
1118     int ret;
1119    
1120     + drv_data = devm_kzalloc(&hdev->dev, sizeof(*drv_data), GFP_KERNEL);
1121     + if (!drv_data)
1122     + return -ENOMEM;
1123     +
1124     ret = hid_parse(hdev);
1125     if (ret) {
1126     hid_err(hdev, "parse failed\n");
1127     goto err;
1128     }
1129    
1130     - hid_set_drvdata(hdev, (void *)plantronics_device_type(hdev));
1131     + drv_data->device_type = plantronics_device_type(hdev);
1132     + drv_data->quirks = id->driver_data;
1133     + drv_data->last_volume_key_ts = jiffies - msecs_to_jiffies(PLT_DOUBLE_KEY_TIMEOUT);
1134     +
1135     + hid_set_drvdata(hdev, drv_data);
1136    
1137     ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT |
1138     HID_CONNECT_HIDINPUT_FORCE | HID_CONNECT_HIDDEV_FORCE);
1139     @@ -156,15 +201,26 @@ err:
1140     }
1141    
1142     static const struct hid_device_id plantronics_devices[] = {
1143     + { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS,
1144     + USB_DEVICE_ID_PLANTRONICS_BLACKWIRE_3220_SERIES),
1145     + .driver_data = PLT_QUIRK_DOUBLE_VOLUME_KEYS },
1146     { HID_USB_DEVICE(USB_VENDOR_ID_PLANTRONICS, HID_ANY_ID) },
1147     { }
1148     };
1149     MODULE_DEVICE_TABLE(hid, plantronics_devices);
1150    
1151     +static const struct hid_usage_id plantronics_usages[] = {
1152     + { HID_CP_VOLUMEUP, EV_KEY, HID_ANY_ID },
1153     + { HID_CP_VOLUMEDOWN, EV_KEY, HID_ANY_ID },
1154     + { HID_TERMINATOR, HID_TERMINATOR, HID_TERMINATOR }
1155     +};
1156     +
1157     static struct hid_driver plantronics_driver = {
1158     .name = "plantronics",
1159     .id_table = plantronics_devices,
1160     + .usage_table = plantronics_usages,
1161     .input_mapping = plantronics_input_mapping,
1162     + .event = plantronics_event,
1163     .probe = plantronics_probe,
1164     };
1165     module_hid_driver(plantronics_driver);
1166     diff --git a/drivers/hsi/hsi_core.c b/drivers/hsi/hsi_core.c
1167     index c2a2a9795b0ba..e9d63b966caff 100644
1168     --- a/drivers/hsi/hsi_core.c
1169     +++ b/drivers/hsi/hsi_core.c
1170     @@ -223,8 +223,6 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
1171     if (err)
1172     goto err;
1173    
1174     - dev_set_name(&cl->device, "%s", name);
1175     -
1176     err = hsi_of_property_parse_mode(client, "hsi-mode", &mode);
1177     if (err) {
1178     err = hsi_of_property_parse_mode(client, "hsi-rx-mode",
1179     @@ -307,6 +305,7 @@ static void hsi_add_client_from_dt(struct hsi_port *port,
1180     cl->device.release = hsi_client_release;
1181     cl->device.of_node = client;
1182    
1183     + dev_set_name(&cl->device, "%s", name);
1184     if (device_register(&cl->device) < 0) {
1185     pr_err("hsi: failed to register client: %s\n", name);
1186     put_device(&cl->device);
1187     diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c
1188     index 7bf5e2fe17516..60c122b355ea5 100644
1189     --- a/drivers/hv/channel_mgmt.c
1190     +++ b/drivers/hv/channel_mgmt.c
1191     @@ -675,6 +675,12 @@ static void init_vp_index(struct vmbus_channel *channel, u16 dev_type)
1192     channel->target_vp = hv_context.vp_index[cur_cpu];
1193     }
1194    
1195     +#define UNLOAD_DELAY_UNIT_MS 10 /* 10 milliseconds */
1196     +#define UNLOAD_WAIT_MS (100*1000) /* 100 seconds */
1197     +#define UNLOAD_WAIT_LOOPS (UNLOAD_WAIT_MS/UNLOAD_DELAY_UNIT_MS)
1198     +#define UNLOAD_MSG_MS (5*1000) /* Every 5 seconds */
1199     +#define UNLOAD_MSG_LOOPS (UNLOAD_MSG_MS/UNLOAD_DELAY_UNIT_MS)
1200     +
1201     static void vmbus_wait_for_unload(void)
1202     {
1203     int cpu;
1204     @@ -692,12 +698,17 @@ static void vmbus_wait_for_unload(void)
1205     * vmbus_connection.unload_event. If not, the last thing we can do is
1206     * read message pages for all CPUs directly.
1207     *
1208     - * Wait no more than 10 seconds so that the panic path can't get
1209     - * hung forever in case the response message isn't seen.
1210     + * Wait up to 100 seconds since an Azure host must writeback any dirty
1211     + * data in its disk cache before the VMbus UNLOAD request will
1212     + * complete. This flushing has been empirically observed to take up
1213     + * to 50 seconds in cases with a lot of dirty data, so allow additional
1214     + * leeway and for inaccuracies in mdelay(). But eventually time out so
1215     + * that the panic path can't get hung forever in case the response
1216     + * message isn't seen.
1217     */
1218     - for (i = 0; i < 1000; i++) {
1219     + for (i = 1; i <= UNLOAD_WAIT_LOOPS; i++) {
1220     if (completion_done(&vmbus_connection.unload_event))
1221     - break;
1222     + goto completed;
1223    
1224     for_each_online_cpu(cpu) {
1225     page_addr = hv_context.synic_message_page[cpu];
1226     @@ -717,9 +728,18 @@ static void vmbus_wait_for_unload(void)
1227     vmbus_signal_eom(msg, message_type);
1228     }
1229    
1230     - mdelay(10);
1231     + /*
1232     + * Give a notice periodically so someone watching the
1233     + * serial output won't think it is completely hung.
1234     + */
1235     + if (!(i % UNLOAD_MSG_LOOPS))
1236     + pr_notice("Waiting for VMBus UNLOAD to complete\n");
1237     +
1238     + mdelay(UNLOAD_DELAY_UNIT_MS);
1239     }
1240     + pr_err("Continuing even though VMBus UNLOAD did not complete\n");
1241    
1242     +completed:
1243     /*
1244     * We're crashing and already got the UNLOAD_RESPONSE, cleanup all
1245     * maybe-pending messages on all CPUs to be able to receive new
1246     diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
1247     index 98a4cb5d49938..9c236c88bc7b9 100644
1248     --- a/drivers/hwtracing/intel_th/gth.c
1249     +++ b/drivers/hwtracing/intel_th/gth.c
1250     @@ -485,7 +485,7 @@ static void intel_th_gth_disable(struct intel_th_device *thdev,
1251     output->active = false;
1252    
1253     for_each_set_bit(master, gth->output[output->port].master,
1254     - TH_CONFIGURABLE_MASTERS) {
1255     + TH_CONFIGURABLE_MASTERS + 1) {
1256     gth_master_set(gth, master, -1);
1257     }
1258     spin_unlock(&gth->gth_lock);
1259     @@ -605,7 +605,7 @@ static void intel_th_gth_unassign(struct intel_th_device *thdev,
1260     othdev->output.port = -1;
1261     othdev->output.active = false;
1262     gth->output[port].output = NULL;
1263     - for (master = 0; master <= TH_CONFIGURABLE_MASTERS; master++)
1264     + for (master = 0; master < TH_CONFIGURABLE_MASTERS + 1; master++)
1265     if (gth->master[master] == port)
1266     gth->master[master] = -1;
1267     spin_unlock(&gth->gth_lock);
1268     diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
1269     index 45d6771fac8ce..23ee1a4236545 100644
1270     --- a/drivers/i2c/busses/i2c-cadence.c
1271     +++ b/drivers/i2c/busses/i2c-cadence.c
1272     @@ -908,7 +908,10 @@ static int cdns_i2c_probe(struct platform_device *pdev)
1273     if (IS_ERR(id->membase))
1274     return PTR_ERR(id->membase);
1275    
1276     - id->irq = platform_get_irq(pdev, 0);
1277     + ret = platform_get_irq(pdev, 0);
1278     + if (ret < 0)
1279     + return ret;
1280     + id->irq = ret;
1281    
1282     id->adap.owner = THIS_MODULE;
1283     id->adap.dev.of_node = pdev->dev.of_node;
1284     diff --git a/drivers/i2c/busses/i2c-emev2.c b/drivers/i2c/busses/i2c-emev2.c
1285     index 0218ba6eb26ab..ad33c1e3a30fe 100644
1286     --- a/drivers/i2c/busses/i2c-emev2.c
1287     +++ b/drivers/i2c/busses/i2c-emev2.c
1288     @@ -398,7 +398,10 @@ static int em_i2c_probe(struct platform_device *pdev)
1289    
1290     em_i2c_reset(&priv->adap);
1291    
1292     - priv->irq = platform_get_irq(pdev, 0);
1293     + ret = platform_get_irq(pdev, 0);
1294     + if (ret < 0)
1295     + goto err_clk;
1296     + priv->irq = ret;
1297     ret = devm_request_irq(&pdev->dev, priv->irq, em_i2c_irq_handler, 0,
1298     "em_i2c", priv);
1299     if (ret)
1300     diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c
1301     index 41ca9ff7b5da7..4dd800c0db14a 100644
1302     --- a/drivers/i2c/busses/i2c-jz4780.c
1303     +++ b/drivers/i2c/busses/i2c-jz4780.c
1304     @@ -760,7 +760,10 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
1305    
1306     jz4780_i2c_writew(i2c, JZ4780_I2C_INTM, 0x0);
1307    
1308     - i2c->irq = platform_get_irq(pdev, 0);
1309     + ret = platform_get_irq(pdev, 0);
1310     + if (ret < 0)
1311     + goto err;
1312     + i2c->irq = ret;
1313     ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
1314     dev_name(&pdev->dev), i2c);
1315     if (ret)
1316     diff --git a/drivers/i2c/busses/i2c-sh7760.c b/drivers/i2c/busses/i2c-sh7760.c
1317     index c2005c789d2b0..319d1fa617c88 100644
1318     --- a/drivers/i2c/busses/i2c-sh7760.c
1319     +++ b/drivers/i2c/busses/i2c-sh7760.c
1320     @@ -471,7 +471,10 @@ static int sh7760_i2c_probe(struct platform_device *pdev)
1321     goto out2;
1322     }
1323    
1324     - id->irq = platform_get_irq(pdev, 0);
1325     + ret = platform_get_irq(pdev, 0);
1326     + if (ret < 0)
1327     + goto out3;
1328     + id->irq = ret;
1329    
1330     id->adap.nr = pdev->id;
1331     id->adap.algo = &sh7760_i2c_algo;
1332     diff --git a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1333     index 3141c3c161bb4..46e969a3a9b7e 100644
1334     --- a/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1335     +++ b/drivers/iio/proximity/pulsedlight-lidar-lite-v2.c
1336     @@ -166,6 +166,7 @@ static int lidar_get_measurement(struct lidar_data *data, u16 *reg)
1337     ret = lidar_write_control(data, LIDAR_REG_CONTROL_ACQUIRE);
1338     if (ret < 0) {
1339     dev_err(&client->dev, "cannot send start measurement command");
1340     + pm_runtime_put_noidle(&client->dev);
1341     return ret;
1342     }
1343    
1344     diff --git a/drivers/infiniband/hw/i40iw/i40iw_pble.c b/drivers/infiniband/hw/i40iw/i40iw_pble.c
1345     index 85993dc44f6e6..3fbf7a3b00de9 100644
1346     --- a/drivers/infiniband/hw/i40iw/i40iw_pble.c
1347     +++ b/drivers/infiniband/hw/i40iw/i40iw_pble.c
1348     @@ -399,12 +399,9 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev,
1349     i40iw_debug(dev, I40IW_DEBUG_PBLE, "next_fpm_addr = %llx chunk_size[%u] = 0x%x\n",
1350     pble_rsrc->next_fpm_addr, chunk->size, chunk->size);
1351     pble_rsrc->unallocated_pble -= (chunk->size >> 3);
1352     - list_add(&chunk->list, &pble_rsrc->pinfo.clist);
1353     sd_reg_val = (sd_entry_type == I40IW_SD_TYPE_PAGED) ?
1354     sd_entry->u.pd_table.pd_page_addr.pa : sd_entry->u.bp.addr.pa;
1355     - if (sd_entry->valid)
1356     - return 0;
1357     - if (dev->is_pf) {
1358     + if (dev->is_pf && !sd_entry->valid) {
1359     ret_code = i40iw_hmc_sd_one(dev, hmc_info->hmc_fn_id,
1360     sd_reg_val, idx->sd_idx,
1361     sd_entry->entry_type, true);
1362     @@ -415,6 +412,7 @@ static enum i40iw_status_code add_pble_pool(struct i40iw_sc_dev *dev,
1363     }
1364    
1365     sd_entry->valid = true;
1366     + list_add(&chunk->list, &pble_rsrc->pinfo.clist);
1367     return 0;
1368     error:
1369     kfree(chunk);
1370     diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c
1371     index 867772878c0c8..3350c0190c4ac 100644
1372     --- a/drivers/input/touchscreen/silead.c
1373     +++ b/drivers/input/touchscreen/silead.c
1374     @@ -28,6 +28,7 @@
1375     #include <linux/input/mt.h>
1376     #include <linux/input/touchscreen.h>
1377     #include <linux/pm.h>
1378     +#include <linux/pm_runtime.h>
1379     #include <linux/irq.h>
1380    
1381     #include <asm/unaligned.h>
1382     @@ -317,10 +318,8 @@ static int silead_ts_get_id(struct i2c_client *client)
1383    
1384     error = i2c_smbus_read_i2c_block_data(client, SILEAD_REG_ID,
1385     sizeof(chip_id), (u8 *)&chip_id);
1386     - if (error < 0) {
1387     - dev_err(&client->dev, "Chip ID read error %d\n", error);
1388     + if (error < 0)
1389     return error;
1390     - }
1391    
1392     data->chip_id = le32_to_cpu(chip_id);
1393     dev_info(&client->dev, "Silead chip ID: 0x%8X", data->chip_id);
1394     @@ -333,12 +332,49 @@ static int silead_ts_setup(struct i2c_client *client)
1395     int error;
1396     u32 status;
1397    
1398     + /*
1399     + * Some buggy BIOS-es bring up the chip in a stuck state where it
1400     + * blocks the I2C bus. The following steps are necessary to
1401     + * unstuck the chip / bus:
1402     + * 1. Turn off the Silead chip.
1403     + * 2. Try to do an I2C transfer with the chip, this will fail in
1404     + * response to which the I2C-bus-driver will call:
1405     + * i2c_recover_bus() which will unstuck the I2C-bus. Note the
1406     + * unstuck-ing of the I2C bus only works if we first drop the
1407     + * chip off the bus by turning it off.
1408     + * 3. Turn the chip back on.
1409     + *
1410     + * On the x86/ACPI systems were this problem is seen, step 1. and
1411     + * 3. require making ACPI calls and dealing with ACPI Power
1412     + * Resources. The workaround below runtime-suspends the chip to
1413     + * turn it off, leaving it up to the ACPI subsystem to deal with
1414     + * this.
1415     + */
1416     +
1417     + if (device_property_read_bool(&client->dev,
1418     + "silead,stuck-controller-bug")) {
1419     + pm_runtime_set_active(&client->dev);
1420     + pm_runtime_enable(&client->dev);
1421     + pm_runtime_allow(&client->dev);
1422     +
1423     + pm_runtime_suspend(&client->dev);
1424     +
1425     + dev_warn(&client->dev, FW_BUG "Stuck I2C bus: please ignore the next 'controller timed out' error\n");
1426     + silead_ts_get_id(client);
1427     +
1428     + /* The forbid will also resume the device */
1429     + pm_runtime_forbid(&client->dev);
1430     + pm_runtime_disable(&client->dev);
1431     + }
1432     +
1433     silead_ts_set_power(client, SILEAD_POWER_OFF);
1434     silead_ts_set_power(client, SILEAD_POWER_ON);
1435    
1436     error = silead_ts_get_id(client);
1437     - if (error)
1438     + if (error) {
1439     + dev_err(&client->dev, "Chip ID read error %d\n", error);
1440     return error;
1441     + }
1442    
1443     error = silead_ts_init(client);
1444     if (error)
1445     diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
1446     index d15347de415a6..9de62c3b8bf9f 100644
1447     --- a/drivers/isdn/capi/kcapi.c
1448     +++ b/drivers/isdn/capi/kcapi.c
1449     @@ -845,7 +845,7 @@ EXPORT_SYMBOL(capi20_put_message);
1450     * Return value: CAPI result code
1451     */
1452    
1453     -u16 capi20_get_manufacturer(u32 contr, u8 *buf)
1454     +u16 capi20_get_manufacturer(u32 contr, u8 buf[CAPI_MANUFACTURER_LEN])
1455     {
1456     struct capi_ctr *ctr;
1457     u16 ret;
1458     @@ -915,7 +915,7 @@ EXPORT_SYMBOL(capi20_get_version);
1459     * Return value: CAPI result code
1460     */
1461    
1462     -u16 capi20_get_serial(u32 contr, u8 *serial)
1463     +u16 capi20_get_serial(u32 contr, u8 serial[CAPI_SERIAL_LEN])
1464     {
1465     struct capi_ctr *ctr;
1466     u16 ret;
1467     diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
1468     index 836a2808c0c71..eb2659a123108 100644
1469     --- a/drivers/md/dm-ioctl.c
1470     +++ b/drivers/md/dm-ioctl.c
1471     @@ -524,7 +524,7 @@ static int list_devices(struct dm_ioctl *param, size_t param_size)
1472     * Grab our output buffer.
1473     */
1474     nl = get_result_buffer(param, param_size, &len);
1475     - if (len < needed) {
1476     + if (len < needed || len < sizeof(nl->dev)) {
1477     param->flags |= DM_BUFFER_FULL_FLAG;
1478     goto out;
1479     }
1480     diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
1481     index ba7c4c685db39..dcde657e08252 100644
1482     --- a/drivers/md/dm-rq.c
1483     +++ b/drivers/md/dm-rq.c
1484     @@ -1009,6 +1009,7 @@ out_tag_set:
1485     blk_mq_free_tag_set(md->tag_set);
1486     out_kfree_tag_set:
1487     kfree(md->tag_set);
1488     + md->tag_set = NULL;
1489    
1490     return err;
1491     }
1492     @@ -1018,6 +1019,7 @@ void dm_mq_cleanup_mapped_device(struct mapped_device *md)
1493     if (md->tag_set) {
1494     blk_mq_free_tag_set(md->tag_set);
1495     kfree(md->tag_set);
1496     + md->tag_set = NULL;
1497     }
1498     }
1499    
1500     diff --git a/drivers/md/md.c b/drivers/md/md.c
1501     index 0bfb77f8503d2..98c72dd56a2d4 100644
1502     --- a/drivers/md/md.c
1503     +++ b/drivers/md/md.c
1504     @@ -508,6 +508,17 @@ void mddev_init(struct mddev *mddev)
1505     }
1506     EXPORT_SYMBOL_GPL(mddev_init);
1507    
1508     +static struct mddev *mddev_find_locked(dev_t unit)
1509     +{
1510     + struct mddev *mddev;
1511     +
1512     + list_for_each_entry(mddev, &all_mddevs, all_mddevs)
1513     + if (mddev->unit == unit)
1514     + return mddev;
1515     +
1516     + return NULL;
1517     +}
1518     +
1519     static struct mddev *mddev_find(dev_t unit)
1520     {
1521     struct mddev *mddev, *new = NULL;
1522     @@ -519,13 +530,13 @@ static struct mddev *mddev_find(dev_t unit)
1523     spin_lock(&all_mddevs_lock);
1524    
1525     if (unit) {
1526     - list_for_each_entry(mddev, &all_mddevs, all_mddevs)
1527     - if (mddev->unit == unit) {
1528     - mddev_get(mddev);
1529     - spin_unlock(&all_mddevs_lock);
1530     - kfree(new);
1531     - return mddev;
1532     - }
1533     + mddev = mddev_find_locked(unit);
1534     + if (mddev) {
1535     + mddev_get(mddev);
1536     + spin_unlock(&all_mddevs_lock);
1537     + kfree(new);
1538     + return mddev;
1539     + }
1540    
1541     if (new) {
1542     list_add(&new->all_mddevs, &all_mddevs);
1543     @@ -551,12 +562,7 @@ static struct mddev *mddev_find(dev_t unit)
1544     return NULL;
1545     }
1546    
1547     - is_free = 1;
1548     - list_for_each_entry(mddev, &all_mddevs, all_mddevs)
1549     - if (mddev->unit == dev) {
1550     - is_free = 0;
1551     - break;
1552     - }
1553     + is_free = !mddev_find_locked(dev);
1554     }
1555     new->unit = dev;
1556     new->md_minor = MINOR(dev);
1557     @@ -7106,8 +7112,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
1558     /* Wait until bdev->bd_disk is definitely gone */
1559     if (work_pending(&mddev->del_work))
1560     flush_workqueue(md_misc_wq);
1561     - /* Then retry the open from the top */
1562     - return -ERESTARTSYS;
1563     + return -EBUSY;
1564     }
1565     BUG_ON(mddev != bdev->bd_disk->private_data);
1566    
1567     @@ -8462,11 +8467,11 @@ void md_check_recovery(struct mddev *mddev)
1568     }
1569    
1570     if (mddev_is_clustered(mddev)) {
1571     - struct md_rdev *rdev;
1572     + struct md_rdev *rdev, *tmp;
1573     /* kick the device if another node issued a
1574     * remove disk.
1575     */
1576     - rdev_for_each(rdev, mddev) {
1577     + rdev_for_each_safe(rdev, tmp, mddev) {
1578     if (test_and_clear_bit(ClusterRemove, &rdev->flags) &&
1579     rdev->raid_disk < 0)
1580     md_kick_rdev_from_array(rdev);
1581     @@ -8775,12 +8780,12 @@ err_wq:
1582     static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
1583     {
1584     struct mdp_superblock_1 *sb = page_address(rdev->sb_page);
1585     - struct md_rdev *rdev2;
1586     + struct md_rdev *rdev2, *tmp;
1587     int role, ret;
1588     char b[BDEVNAME_SIZE];
1589    
1590     /* Check for change of roles in the active devices */
1591     - rdev_for_each(rdev2, mddev) {
1592     + rdev_for_each_safe(rdev2, tmp, mddev) {
1593     if (test_bit(Faulty, &rdev2->flags))
1594     continue;
1595    
1596     diff --git a/drivers/md/persistent-data/dm-btree-internal.h b/drivers/md/persistent-data/dm-btree-internal.h
1597     index a240990a7f333..5673f8eb5f88f 100644
1598     --- a/drivers/md/persistent-data/dm-btree-internal.h
1599     +++ b/drivers/md/persistent-data/dm-btree-internal.h
1600     @@ -34,12 +34,12 @@ struct node_header {
1601     __le32 max_entries;
1602     __le32 value_size;
1603     __le32 padding;
1604     -} __packed;
1605     +} __attribute__((packed, aligned(8)));
1606    
1607     struct btree_node {
1608     struct node_header header;
1609     __le64 keys[0];
1610     -} __packed;
1611     +} __attribute__((packed, aligned(8)));
1612    
1613    
1614     /*
1615     diff --git a/drivers/md/persistent-data/dm-space-map-common.c b/drivers/md/persistent-data/dm-space-map-common.c
1616     index 22729fd92a1b9..ca09ad2a639c4 100644
1617     --- a/drivers/md/persistent-data/dm-space-map-common.c
1618     +++ b/drivers/md/persistent-data/dm-space-map-common.c
1619     @@ -337,6 +337,8 @@ int sm_ll_find_free_block(struct ll_disk *ll, dm_block_t begin,
1620     */
1621     begin = do_div(index_begin, ll->entries_per_block);
1622     end = do_div(end, ll->entries_per_block);
1623     + if (end == 0)
1624     + end = ll->entries_per_block;
1625    
1626     for (i = index_begin; i < index_end; i++, begin = 0) {
1627     struct dm_block *blk;
1628     diff --git a/drivers/md/persistent-data/dm-space-map-common.h b/drivers/md/persistent-data/dm-space-map-common.h
1629     index 8de63ce39bdd5..87e17909ef521 100644
1630     --- a/drivers/md/persistent-data/dm-space-map-common.h
1631     +++ b/drivers/md/persistent-data/dm-space-map-common.h
1632     @@ -33,7 +33,7 @@ struct disk_index_entry {
1633     __le64 blocknr;
1634     __le32 nr_free;
1635     __le32 none_free_before;
1636     -} __packed;
1637     +} __attribute__ ((packed, aligned(8)));
1638    
1639    
1640     #define MAX_METADATA_BITMAPS 255
1641     @@ -43,7 +43,7 @@ struct disk_metadata_index {
1642     __le64 blocknr;
1643    
1644     struct disk_index_entry index[MAX_METADATA_BITMAPS];
1645     -} __packed;
1646     +} __attribute__ ((packed, aligned(8)));
1647    
1648     struct ll_disk;
1649    
1650     @@ -86,7 +86,7 @@ struct disk_sm_root {
1651     __le64 nr_allocated;
1652     __le64 bitmap_root;
1653     __le64 ref_count_root;
1654     -} __packed;
1655     +} __attribute__ ((packed, aligned(8)));
1656    
1657     #define ENTRIES_PER_BYTE 4
1658    
1659     @@ -94,7 +94,7 @@ struct disk_bitmap_header {
1660     __le32 csum;
1661     __le32 not_used;
1662     __le64 blocknr;
1663     -} __packed;
1664     +} __attribute__ ((packed, aligned(8)));
1665    
1666     enum allocation_event {
1667     SM_NONE,
1668     diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
1669     index a1cc1c1e53182..fb1284051d054 100644
1670     --- a/drivers/media/dvb-core/dvbdev.c
1671     +++ b/drivers/media/dvb-core/dvbdev.c
1672     @@ -216,6 +216,7 @@ static void dvb_media_device_free(struct dvb_device *dvbdev)
1673    
1674     if (dvbdev->adapter->conn) {
1675     media_device_unregister_entity(dvbdev->adapter->conn);
1676     + kfree(dvbdev->adapter->conn);
1677     dvbdev->adapter->conn = NULL;
1678     kfree(dvbdev->adapter->conn_pads);
1679     dvbdev->adapter->conn_pads = NULL;
1680     diff --git a/drivers/media/i2c/adv7511-v4l2.c b/drivers/media/i2c/adv7511-v4l2.c
1681     index b87c9e7ff146f..e81c4cca50c63 100644
1682     --- a/drivers/media/i2c/adv7511-v4l2.c
1683     +++ b/drivers/media/i2c/adv7511-v4l2.c
1684     @@ -1976,7 +1976,7 @@ static int adv7511_remove(struct i2c_client *client)
1685    
1686     adv7511_set_isr(sd, false);
1687     adv7511_init_setup(sd);
1688     - cancel_delayed_work(&state->edid_handler);
1689     + cancel_delayed_work_sync(&state->edid_handler);
1690     i2c_unregister_device(state->i2c_edid);
1691     if (state->i2c_cec)
1692     i2c_unregister_device(state->i2c_cec);
1693     diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c
1694     index ce6f93074ae0d..56b8b7bf759e5 100644
1695     --- a/drivers/media/i2c/adv7604.c
1696     +++ b/drivers/media/i2c/adv7604.c
1697     @@ -3541,7 +3541,7 @@ static int adv76xx_remove(struct i2c_client *client)
1698     io_write(sd, 0x6e, 0);
1699     io_write(sd, 0x73, 0);
1700    
1701     - cancel_delayed_work(&state->delayed_work_enable_hotplug);
1702     + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
1703     v4l2_async_unregister_subdev(sd);
1704     media_entity_cleanup(&sd->entity);
1705     adv76xx_unregister_clients(to_state(sd));
1706     diff --git a/drivers/media/i2c/adv7842.c b/drivers/media/i2c/adv7842.c
1707     index cf3b42c9417e7..d7af4fbcb84b3 100644
1708     --- a/drivers/media/i2c/adv7842.c
1709     +++ b/drivers/media/i2c/adv7842.c
1710     @@ -3598,7 +3598,7 @@ static int adv7842_remove(struct i2c_client *client)
1711     struct adv7842_state *state = to_state(sd);
1712    
1713     adv7842_irq_enable(sd, false);
1714     - cancel_delayed_work(&state->delayed_work_enable_hotplug);
1715     + cancel_delayed_work_sync(&state->delayed_work_enable_hotplug);
1716     v4l2_device_unregister_subdev(sd);
1717     media_entity_cleanup(&sd->entity);
1718     adv7842_unregister_clients(sd);
1719     diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
1720     index 32a353d162e79..f2e6fbfa019fd 100644
1721     --- a/drivers/media/pci/saa7164/saa7164-encoder.c
1722     +++ b/drivers/media/pci/saa7164/saa7164-encoder.c
1723     @@ -1030,7 +1030,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1724     "(errno = %d), NO PCI configuration\n",
1725     __func__, result);
1726     result = -ENOMEM;
1727     - goto failed;
1728     + goto fail_pci;
1729     }
1730    
1731     /* Establish encoder defaults here */
1732     @@ -1084,7 +1084,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1733     100000, ENCODER_DEF_BITRATE);
1734     if (hdl->error) {
1735     result = hdl->error;
1736     - goto failed;
1737     + goto fail_hdl;
1738     }
1739    
1740     port->std = V4L2_STD_NTSC_M;
1741     @@ -1102,7 +1102,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1742     printk(KERN_INFO "%s: can't allocate mpeg device\n",
1743     dev->name);
1744     result = -ENOMEM;
1745     - goto failed;
1746     + goto fail_hdl;
1747     }
1748    
1749     port->v4l_device->ctrl_handler = hdl;
1750     @@ -1113,10 +1113,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
1751     if (result < 0) {
1752     printk(KERN_INFO "%s: can't register mpeg device\n",
1753     dev->name);
1754     - /* TODO: We're going to leak here if we don't dealloc
1755     - The buffers above. The unreg function can't deal wit it.
1756     - */
1757     - goto failed;
1758     + goto fail_reg;
1759     }
1760    
1761     printk(KERN_INFO "%s: registered device video%d [mpeg]\n",
1762     @@ -1138,9 +1135,14 @@ int saa7164_encoder_register(struct saa7164_port *port)
1763    
1764     saa7164_api_set_encoder(port);
1765     saa7164_api_get_encoder(port);
1766     + return 0;
1767    
1768     - result = 0;
1769     -failed:
1770     +fail_reg:
1771     + video_device_release(port->v4l_device);
1772     + port->v4l_device = NULL;
1773     +fail_hdl:
1774     + v4l2_ctrl_handler_free(hdl);
1775     +fail_pci:
1776     return result;
1777     }
1778    
1779     diff --git a/drivers/media/platform/vivid/vivid-vid-out.c b/drivers/media/platform/vivid/vivid-vid-out.c
1780     index 8fed2fbe91a98..f78caf72cb3e4 100644
1781     --- a/drivers/media/platform/vivid/vivid-vid-out.c
1782     +++ b/drivers/media/platform/vivid/vivid-vid-out.c
1783     @@ -1003,7 +1003,7 @@ int vivid_vid_out_s_fbuf(struct file *file, void *fh,
1784     return -EINVAL;
1785     }
1786     dev->fbuf_out_flags &= ~(chroma_flags | alpha_flags);
1787     - dev->fbuf_out_flags = a->flags & (chroma_flags | alpha_flags);
1788     + dev->fbuf_out_flags |= a->flags & (chroma_flags | alpha_flags);
1789     return 0;
1790     }
1791    
1792     diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
1793     index 63165d324fffd..7d3e50d94d86a 100644
1794     --- a/drivers/media/rc/ite-cir.c
1795     +++ b/drivers/media/rc/ite-cir.c
1796     @@ -292,8 +292,14 @@ static irqreturn_t ite_cir_isr(int irq, void *data)
1797     /* read the interrupt flags */
1798     iflags = dev->params.get_irq_causes(dev);
1799    
1800     + /* Check for RX overflow */
1801     + if (iflags & ITE_IRQ_RX_FIFO_OVERRUN) {
1802     + dev_warn(&dev->rdev->dev, "receive overflow\n");
1803     + ir_raw_event_reset(dev->rdev);
1804     + }
1805     +
1806     /* check for the receive interrupt */
1807     - if (iflags & (ITE_IRQ_RX_FIFO | ITE_IRQ_RX_FIFO_OVERRUN)) {
1808     + if (iflags & ITE_IRQ_RX_FIFO) {
1809     /* read the FIFO bytes */
1810     rx_bytes =
1811     dev->params.get_rx_bytes(dev, rx_buf,
1812     diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
1813     index 9f3e0fd4cad9f..d4443f9c9fa37 100644
1814     --- a/drivers/media/tuners/m88rs6000t.c
1815     +++ b/drivers/media/tuners/m88rs6000t.c
1816     @@ -534,7 +534,7 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
1817     PGA2_cri = PGA2_GC >> 2;
1818     PGA2_crf = PGA2_GC & 0x03;
1819    
1820     - for (i = 0; i <= RF_GC; i++)
1821     + for (i = 0; i <= RF_GC && i < ARRAY_SIZE(RFGS); i++)
1822     RFG += RFGS[i];
1823    
1824     if (RF_GC == 0)
1825     @@ -546,12 +546,12 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
1826     if (RF_GC == 3)
1827     RFG += 100;
1828    
1829     - for (i = 0; i <= IF_GC; i++)
1830     + for (i = 0; i <= IF_GC && i < ARRAY_SIZE(IFGS); i++)
1831     IFG += IFGS[i];
1832    
1833     TIAG = TIA_GC * TIA_GS;
1834    
1835     - for (i = 0; i <= BB_GC; i++)
1836     + for (i = 0; i <= BB_GC && i < ARRAY_SIZE(BBGS); i++)
1837     BBG += BBGS[i];
1838    
1839     PGA2G = PGA2_cri * PGA2_cri_GS + PGA2_crf * PGA2_crf_GS;
1840     diff --git a/drivers/media/usb/dvb-usb/dvb-usb-init.c b/drivers/media/usb/dvb-usb/dvb-usb-init.c
1841     index b3413404f91a5..690c1e06fbfac 100644
1842     --- a/drivers/media/usb/dvb-usb/dvb-usb-init.c
1843     +++ b/drivers/media/usb/dvb-usb/dvb-usb-init.c
1844     @@ -82,11 +82,17 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
1845     }
1846     }
1847    
1848     - if ((ret = dvb_usb_adapter_stream_init(adap)) ||
1849     - (ret = dvb_usb_adapter_dvb_init(adap, adapter_nrs)) ||
1850     - (ret = dvb_usb_adapter_frontend_init(adap))) {
1851     + ret = dvb_usb_adapter_stream_init(adap);
1852     + if (ret)
1853     return ret;
1854     - }
1855     +
1856     + ret = dvb_usb_adapter_dvb_init(adap, adapter_nrs);
1857     + if (ret)
1858     + goto dvb_init_err;
1859     +
1860     + ret = dvb_usb_adapter_frontend_init(adap);
1861     + if (ret)
1862     + goto frontend_init_err;
1863    
1864     /* use exclusive FE lock if there is multiple shared FEs */
1865     if (adap->fe_adap[1].fe)
1866     @@ -106,6 +112,12 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d, short *adapter_nrs)
1867     }
1868    
1869     return 0;
1870     +
1871     +frontend_init_err:
1872     + dvb_usb_adapter_dvb_exit(adap);
1873     +dvb_init_err:
1874     + dvb_usb_adapter_stream_exit(adap);
1875     + return ret;
1876     }
1877    
1878     static int dvb_usb_adapter_exit(struct dvb_usb_device *d)
1879     diff --git a/drivers/media/usb/dvb-usb/dvb-usb.h b/drivers/media/usb/dvb-usb/dvb-usb.h
1880     index 107255b08b2b1..704d57e3ea1c1 100644
1881     --- a/drivers/media/usb/dvb-usb/dvb-usb.h
1882     +++ b/drivers/media/usb/dvb-usb/dvb-usb.h
1883     @@ -471,7 +471,8 @@ extern int dvb_usb_generic_rw(struct dvb_usb_device *, u8 *, u16, u8 *, u16,int)
1884     extern int dvb_usb_generic_write(struct dvb_usb_device *, u8 *, u16);
1885    
1886     /* commonly used remote control parsing */
1887     -extern int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *, u8[], u32 *, int *);
1888     +int dvb_usb_nec_rc_key_to_event(struct dvb_usb_device *d, u8 keybuf[5],
1889     + u32 *event, int *state);
1890    
1891     /* commonly used firmware download types and function */
1892     struct hexline {
1893     diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
1894     index b0aea48907b71..7e259be472522 100644
1895     --- a/drivers/media/usb/em28xx/em28xx-dvb.c
1896     +++ b/drivers/media/usb/em28xx/em28xx-dvb.c
1897     @@ -1967,6 +1967,7 @@ ret:
1898     return result;
1899    
1900     out_free:
1901     + em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
1902     kfree(dvb);
1903     dev->dvb = NULL;
1904     goto ret;
1905     diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c
1906     index d239075a6a65f..79f1e8904e30f 100644
1907     --- a/drivers/media/usb/gspca/gspca.c
1908     +++ b/drivers/media/usb/gspca/gspca.c
1909     @@ -2146,6 +2146,8 @@ out:
1910     #endif
1911     v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler);
1912     v4l2_device_unregister(&gspca_dev->v4l2_dev);
1913     + if (sd_desc->probe_error)
1914     + sd_desc->probe_error(gspca_dev);
1915     kfree(gspca_dev->usb_buf);
1916     kfree(gspca_dev);
1917     return ret;
1918     diff --git a/drivers/media/usb/gspca/gspca.h b/drivers/media/usb/gspca/gspca.h
1919     index d39adf90303b9..bec8fccc2c949 100644
1920     --- a/drivers/media/usb/gspca/gspca.h
1921     +++ b/drivers/media/usb/gspca/gspca.h
1922     @@ -101,6 +101,7 @@ struct sd_desc {
1923     cam_cf_op config; /* called on probe */
1924     cam_op init; /* called on probe and resume */
1925     cam_op init_controls; /* called on probe */
1926     + cam_v_op probe_error; /* called if probe failed, do cleanup here */
1927     cam_op start; /* called on stream on after URBs creation */
1928     cam_pkt_op pkt_scan;
1929     /* optional operations */
1930     diff --git a/drivers/media/usb/gspca/sq905.c b/drivers/media/usb/gspca/sq905.c
1931     index a7ae0ec9fa919..03322d2b2e829 100644
1932     --- a/drivers/media/usb/gspca/sq905.c
1933     +++ b/drivers/media/usb/gspca/sq905.c
1934     @@ -172,7 +172,7 @@ static int
1935     sq905_read_data(struct gspca_dev *gspca_dev, u8 *data, int size, int need_lock)
1936     {
1937     int ret;
1938     - int act_len;
1939     + int act_len = 0;
1940    
1941     gspca_dev->usb_buf[0] = '\0';
1942     if (need_lock)
1943     diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
1944     index 7d255529ed4c1..40d4c99debb88 100644
1945     --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
1946     +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
1947     @@ -541,12 +541,21 @@ static int sd_int_pkt_scan(struct gspca_dev *gspca_dev,
1948     static int stv06xx_config(struct gspca_dev *gspca_dev,
1949     const struct usb_device_id *id);
1950    
1951     +static void stv06xx_probe_error(struct gspca_dev *gspca_dev)
1952     +{
1953     + struct sd *sd = (struct sd *)gspca_dev;
1954     +
1955     + kfree(sd->sensor_priv);
1956     + sd->sensor_priv = NULL;
1957     +}
1958     +
1959     /* sub-driver description */
1960     static const struct sd_desc sd_desc = {
1961     .name = MODULE_NAME,
1962     .config = stv06xx_config,
1963     .init = stv06xx_init,
1964     .init_controls = stv06xx_init_controls,
1965     + .probe_error = stv06xx_probe_error,
1966     .start = stv06xx_start,
1967     .stopN = stv06xx_stopN,
1968     .pkt_scan = stv06xx_pkt_scan,
1969     diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
1970     index a9d47c06f80f3..4af2f5b231dd4 100644
1971     --- a/drivers/memory/omap-gpmc.c
1972     +++ b/drivers/memory/omap-gpmc.c
1973     @@ -1028,8 +1028,8 @@ EXPORT_SYMBOL(gpmc_cs_request);
1974    
1975     void gpmc_cs_free(int cs)
1976     {
1977     - struct gpmc_cs_data *gpmc = &gpmc_cs[cs];
1978     - struct resource *res = &gpmc->mem;
1979     + struct gpmc_cs_data *gpmc;
1980     + struct resource *res;
1981    
1982     spin_lock(&gpmc_mem_lock);
1983     if (cs >= gpmc_cs_num || cs < 0 || !gpmc_cs_reserved(cs)) {
1984     @@ -1038,6 +1038,9 @@ void gpmc_cs_free(int cs)
1985     spin_unlock(&gpmc_mem_lock);
1986     return;
1987     }
1988     + gpmc = &gpmc_cs[cs];
1989     + res = &gpmc->mem;
1990     +
1991     gpmc_cs_disable_mem(cs);
1992     if (res->flags)
1993     release_resource(res);
1994     diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
1995     index fc8cb855c6e66..e4249ce2c42f4 100644
1996     --- a/drivers/misc/kgdbts.c
1997     +++ b/drivers/misc/kgdbts.c
1998     @@ -105,19 +105,19 @@
1999     #include <linux/module.h>
2000     #include <asm/sections.h>
2001    
2002     -#define v1printk(a...) do { \
2003     - if (verbose) \
2004     - printk(KERN_INFO a); \
2005     - } while (0)
2006     -#define v2printk(a...) do { \
2007     - if (verbose > 1) \
2008     - printk(KERN_INFO a); \
2009     - touch_nmi_watchdog(); \
2010     - } while (0)
2011     -#define eprintk(a...) do { \
2012     - printk(KERN_ERR a); \
2013     - WARN_ON(1); \
2014     - } while (0)
2015     +#define v1printk(a...) do { \
2016     + if (verbose) \
2017     + printk(KERN_INFO a); \
2018     +} while (0)
2019     +#define v2printk(a...) do { \
2020     + if (verbose > 1) \
2021     + printk(KERN_INFO a); \
2022     + touch_nmi_watchdog(); \
2023     +} while (0)
2024     +#define eprintk(a...) do { \
2025     + printk(KERN_ERR a); \
2026     + WARN_ON(1); \
2027     +} while (0)
2028     #define MAX_CONFIG_LEN 40
2029    
2030     static struct kgdb_io kgdbts_io_ops;
2031     diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
2032     index fb8705fc3aca7..205dc5d40ce61 100644
2033     --- a/drivers/misc/lis3lv02d/lis3lv02d.c
2034     +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
2035     @@ -220,7 +220,7 @@ static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000};
2036     static int lis3_3dlh_rates[4] = {50, 100, 400, 1000};
2037    
2038     /* ODR is Output Data Rate */
2039     -static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
2040     +static int lis3lv02d_get_odr_index(struct lis3lv02d *lis3)
2041     {
2042     u8 ctrl;
2043     int shift;
2044     @@ -228,15 +228,23 @@ static int lis3lv02d_get_odr(struct lis3lv02d *lis3)
2045     lis3->read(lis3, CTRL_REG1, &ctrl);
2046     ctrl &= lis3->odr_mask;
2047     shift = ffs(lis3->odr_mask) - 1;
2048     - return lis3->odrs[(ctrl >> shift)];
2049     + return (ctrl >> shift);
2050     }
2051    
2052     static int lis3lv02d_get_pwron_wait(struct lis3lv02d *lis3)
2053     {
2054     - int div = lis3lv02d_get_odr(lis3);
2055     + int odr_idx = lis3lv02d_get_odr_index(lis3);
2056     + int div = lis3->odrs[odr_idx];
2057    
2058     - if (WARN_ONCE(div == 0, "device returned spurious data"))
2059     + if (div == 0) {
2060     + if (odr_idx == 0) {
2061     + /* Power-down mode, not sampling no need to sleep */
2062     + return 0;
2063     + }
2064     +
2065     + dev_err(&lis3->pdev->dev, "Error unknown odrs-index: %d\n", odr_idx);
2066     return -ENXIO;
2067     + }
2068    
2069     /* LIS3 power on delay is quite long */
2070     msleep(lis3->pwron_delay / div);
2071     @@ -819,9 +827,12 @@ static ssize_t lis3lv02d_rate_show(struct device *dev,
2072     struct device_attribute *attr, char *buf)
2073     {
2074     struct lis3lv02d *lis3 = dev_get_drvdata(dev);
2075     + int odr_idx;
2076    
2077     lis3lv02d_sysfs_poweron(lis3);
2078     - return sprintf(buf, "%d\n", lis3lv02d_get_odr(lis3));
2079     +
2080     + odr_idx = lis3lv02d_get_odr_index(lis3);
2081     + return sprintf(buf, "%d\n", lis3->odrs[odr_idx]);
2082     }
2083    
2084     static ssize_t lis3lv02d_rate_set(struct device *dev,
2085     diff --git a/drivers/misc/vmw_vmci/vmci_doorbell.c b/drivers/misc/vmw_vmci/vmci_doorbell.c
2086     index f005206d9033b..4581210349d29 100644
2087     --- a/drivers/misc/vmw_vmci/vmci_doorbell.c
2088     +++ b/drivers/misc/vmw_vmci/vmci_doorbell.c
2089     @@ -334,7 +334,7 @@ int vmci_dbell_host_context_notify(u32 src_cid, struct vmci_handle handle)
2090     bool vmci_dbell_register_notification_bitmap(u32 bitmap_ppn)
2091     {
2092     int result;
2093     - struct vmci_notify_bm_set_msg bitmap_set_msg;
2094     + struct vmci_notify_bm_set_msg bitmap_set_msg = { };
2095    
2096     bitmap_set_msg.hdr.dst = vmci_make_handle(VMCI_HYPERVISOR_CONTEXT_ID,
2097     VMCI_SET_NOTIFY_BITMAP);
2098     diff --git a/drivers/misc/vmw_vmci/vmci_guest.c b/drivers/misc/vmw_vmci/vmci_guest.c
2099     index 189b325197488..9ac3659a55377 100644
2100     --- a/drivers/misc/vmw_vmci/vmci_guest.c
2101     +++ b/drivers/misc/vmw_vmci/vmci_guest.c
2102     @@ -172,7 +172,7 @@ static int vmci_check_host_caps(struct pci_dev *pdev)
2103     VMCI_UTIL_NUM_RESOURCES * sizeof(u32);
2104     struct vmci_datagram *check_msg;
2105    
2106     - check_msg = kmalloc(msg_size, GFP_KERNEL);
2107     + check_msg = kzalloc(msg_size, GFP_KERNEL);
2108     if (!check_msg) {
2109     dev_err(&pdev->dev, "%s: Insufficient memory\n", __func__);
2110     return -ENOMEM;
2111     diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
2112     index cff5829790c9e..b2c977d617c58 100644
2113     --- a/drivers/mmc/core/core.c
2114     +++ b/drivers/mmc/core/core.c
2115     @@ -1691,7 +1691,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr)
2116    
2117     err = mmc_wait_for_cmd(host, &cmd, 0);
2118     if (err)
2119     - return err;
2120     + goto power_cycle;
2121    
2122     if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR))
2123     return -EIO;
2124     diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
2125     index 7f654c714fffc..bb17027c283e9 100644
2126     --- a/drivers/mmc/core/sd.c
2127     +++ b/drivers/mmc/core/sd.c
2128     @@ -136,6 +136,9 @@ static int mmc_decode_csd(struct mmc_card *card)
2129     csd->erase_size = UNSTUFF_BITS(resp, 39, 7) + 1;
2130     csd->erase_size <<= csd->write_blkbits - 9;
2131     }
2132     +
2133     + if (UNSTUFF_BITS(resp, 13, 1))
2134     + mmc_card_set_readonly(card);
2135     break;
2136     case 1:
2137     /*
2138     @@ -170,6 +173,9 @@ static int mmc_decode_csd(struct mmc_card *card)
2139     csd->write_blkbits = 9;
2140     csd->write_partial = 0;
2141     csd->erase_size = 1;
2142     +
2143     + if (UNSTUFF_BITS(resp, 13, 1))
2144     + mmc_card_set_readonly(card);
2145     break;
2146     default:
2147     pr_err("%s: unrecognised CSD structure version %d\n",
2148     diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
2149     index 331183548bc58..b43b8edc18ec8 100644
2150     --- a/drivers/mtd/mtdchar.c
2151     +++ b/drivers/mtd/mtdchar.c
2152     @@ -689,16 +689,12 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
2153     case MEMGETINFO:
2154     case MEMREADOOB:
2155     case MEMREADOOB64:
2156     - case MEMLOCK:
2157     - case MEMUNLOCK:
2158     case MEMISLOCKED:
2159     case MEMGETOOBSEL:
2160     case MEMGETBADBLOCK:
2161     - case MEMSETBADBLOCK:
2162     case OTPSELECT:
2163     case OTPGETREGIONCOUNT:
2164     case OTPGETREGIONINFO:
2165     - case OTPLOCK:
2166     case ECCGETLAYOUT:
2167     case ECCGETSTATS:
2168     case MTDFILEMODE:
2169     @@ -709,9 +705,13 @@ static int mtdchar_ioctl(struct file *file, u_int cmd, u_long arg)
2170     /* "dangerous" commands */
2171     case MEMERASE:
2172     case MEMERASE64:
2173     + case MEMLOCK:
2174     + case MEMUNLOCK:
2175     + case MEMSETBADBLOCK:
2176     case MEMWRITEOOB:
2177     case MEMWRITEOOB64:
2178     case MEMWRITE:
2179     + case OTPLOCK:
2180     if (!(file->f_mode & FMODE_WRITE))
2181     return -EPERM;
2182     break;
2183     diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2184     index f4a99e91c2500..c43bd945d93a3 100644
2185     --- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2186     +++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
2187     @@ -2020,7 +2020,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
2188     this->bch_geometry.auxiliary_size = 128;
2189     ret = gpmi_alloc_dma_buffer(this);
2190     if (ret)
2191     - goto err_out;
2192     + return ret;
2193    
2194     ret = nand_scan_ident(mtd, GPMI_IS_MX6(this) ? 2 : 1, NULL);
2195     if (ret)
2196     diff --git a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
2197     index 03d79d95ab75f..d7e0d2ce15c11 100644
2198     --- a/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
2199     +++ b/drivers/net/ethernet/cavium/liquidio/cn23xx_pf_regs.h
2200     @@ -526,7 +526,7 @@
2201     #define CN23XX_BAR1_INDEX_OFFSET 3
2202    
2203     #define CN23XX_PEM_BAR1_INDEX_REG(port, idx) \
2204     - (CN23XX_PEM_BAR1_INDEX_START + ((port) << CN23XX_PEM_OFFSET) + \
2205     + (CN23XX_PEM_BAR1_INDEX_START + (((u64)port) << CN23XX_PEM_OFFSET) + \
2206     ((idx) << CN23XX_BAR1_INDEX_OFFSET))
2207    
2208     /*############################ DPI #########################*/
2209     diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
2210     index 747ef08829763..8f3d544bec0c9 100644
2211     --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
2212     +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c
2213     @@ -537,7 +537,7 @@ static void nicvf_rcv_queue_config(struct nicvf *nic, struct queue_set *qs,
2214     mbx.rq.msg = NIC_MBOX_MSG_RQ_CFG;
2215     mbx.rq.qs_num = qs->vnic_id;
2216     mbx.rq.rq_num = qidx;
2217     - mbx.rq.cfg = (rq->caching << 26) | (rq->cq_qs << 19) |
2218     + mbx.rq.cfg = ((u64)rq->caching << 26) | (rq->cq_qs << 19) |
2219     (rq->cq_idx << 16) | (rq->cont_rbdr_qs << 9) |
2220     (rq->cont_qs_rbdr_idx << 8) |
2221     (rq->start_rbdr_qs << 1) | (rq->start_qs_rbdr_idx);
2222     diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
2223     index c150521647172..becfb54421cc2 100644
2224     --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
2225     +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
2226     @@ -2446,7 +2446,7 @@ do { \
2227     seq_printf(seq, "%-12s", s); \
2228     for (i = 0; i < n; ++i) \
2229     seq_printf(seq, " %16" fmt_spec, v); \
2230     - seq_putc(seq, '\n'); \
2231     + seq_putc(seq, '\n'); \
2232     } while (0)
2233     #define S(s, v) S3("s", s, v)
2234     #define T3(fmt_spec, s, v) S3(fmt_spec, s, tx[i].v)
2235     diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2236     index d10c8a8156bc2..5b072bf80783a 100644
2237     --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2238     +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
2239     @@ -964,7 +964,7 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
2240     skb->protocol = eth_type_trans(skb, netdev);
2241    
2242     if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX &&
2243     - RX_DMA_VID(trxd.rxd3))
2244     + (trxd.rxd2 & RX_DMA_VTAG))
2245     __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q),
2246     RX_DMA_VID(trxd.rxd3));
2247     napi_gro_receive(napi, skb);
2248     diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
2249     index 99b1c8e9f16f9..2e7ccd8261c33 100644
2250     --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
2251     +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
2252     @@ -272,6 +272,7 @@
2253     #define RX_DMA_DONE BIT(31)
2254     #define RX_DMA_PLEN0(_x) (((_x) & 0x3fff) << 16)
2255     #define RX_DMA_GET_PLEN0(_x) (((_x) >> 16) & 0x3fff)
2256     +#define RX_DMA_VTAG BIT(15)
2257    
2258     /* QDMA descriptor rxd3 */
2259     #define RX_DMA_VID(_x) ((_x) & 0xfff)
2260     diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
2261     index 9d223ff650711..882f2b7ec6d1f 100644
2262     --- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c
2263     +++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c
2264     @@ -1504,6 +1504,7 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
2265     {
2266     struct emac_tpd tpd;
2267     u32 prod_idx;
2268     + int len;
2269    
2270     memset(&tpd, 0, sizeof(tpd));
2271    
2272     @@ -1523,9 +1524,10 @@ int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue *tx_q,
2273     if (skb_network_offset(skb) != ETH_HLEN)
2274     TPD_TYP_SET(&tpd, 1);
2275    
2276     + len = skb->len;
2277     emac_tx_fill_tpd(adpt, tx_q, skb, &tpd);
2278    
2279     - netdev_sent_queue(adpt->netdev, skb->len);
2280     + netdev_sent_queue(adpt->netdev, len);
2281    
2282     /* Make sure the are enough free descriptors to hold one
2283     * maximum-sized SKB. We need one desc for each fragment,
2284     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2285     index 1924788d28da0..f4ff43a1b5ba0 100644
2286     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2287     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
2288     @@ -363,6 +363,8 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
2289     plat_dat->bsp_priv = gmac;
2290     plat_dat->fix_mac_speed = ipq806x_gmac_fix_mac_speed;
2291     plat_dat->multicast_filter_bins = 0;
2292     + plat_dat->tx_fifo_size = 8192;
2293     + plat_dat->rx_fifo_size = 8192;
2294    
2295     err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
2296     if (err)
2297     diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
2298     index 413cf14dbacd3..8b7596fef42a6 100644
2299     --- a/drivers/net/ethernet/ti/davinci_emac.c
2300     +++ b/drivers/net/ethernet/ti/davinci_emac.c
2301     @@ -183,11 +183,11 @@ static const char emac_version_string[] = "TI DaVinci EMAC Linux v6.1";
2302     /* EMAC mac_status register */
2303     #define EMAC_MACSTATUS_TXERRCODE_MASK (0xF00000)
2304     #define EMAC_MACSTATUS_TXERRCODE_SHIFT (20)
2305     -#define EMAC_MACSTATUS_TXERRCH_MASK (0x7)
2306     +#define EMAC_MACSTATUS_TXERRCH_MASK (0x70000)
2307     #define EMAC_MACSTATUS_TXERRCH_SHIFT (16)
2308     #define EMAC_MACSTATUS_RXERRCODE_MASK (0xF000)
2309     #define EMAC_MACSTATUS_RXERRCODE_SHIFT (12)
2310     -#define EMAC_MACSTATUS_RXERRCH_MASK (0x7)
2311     +#define EMAC_MACSTATUS_RXERRCH_MASK (0x700)
2312     #define EMAC_MACSTATUS_RXERRCH_SHIFT (8)
2313    
2314     /* EMAC RX register masks */
2315     diff --git a/drivers/net/fddi/Kconfig b/drivers/net/fddi/Kconfig
2316     index 3a424c864f4db..ecebeeb9b2a02 100644
2317     --- a/drivers/net/fddi/Kconfig
2318     +++ b/drivers/net/fddi/Kconfig
2319     @@ -28,17 +28,20 @@ config DEFXX
2320    
2321     config DEFXX_MMIO
2322     bool
2323     - prompt "Use MMIO instead of PIO" if PCI || EISA
2324     + prompt "Use MMIO instead of IOP" if PCI || EISA
2325     depends on DEFXX
2326     - default n if PCI || EISA
2327     + default n if EISA
2328     default y
2329     ---help---
2330     This instructs the driver to use EISA or PCI memory-mapped I/O
2331     - (MMIO) as appropriate instead of programmed I/O ports (PIO).
2332     + (MMIO) as appropriate instead of programmed I/O ports (IOP).
2333     Enabling this gives an improvement in processing time in parts
2334     - of the driver, but it may cause problems with EISA (DEFEA)
2335     - adapters. TURBOchannel does not have the concept of I/O ports,
2336     - so MMIO is always used for these (DEFTA) adapters.
2337     + of the driver, but it requires a memory window to be configured
2338     + for EISA (DEFEA) adapters that may not always be available.
2339     + Conversely some PCIe host bridges do not support IOP, so MMIO
2340     + may be required to access PCI (DEFPA) adapters on downstream PCI
2341     + buses with some systems. TURBOchannel does not have the concept
2342     + of I/O ports, so MMIO is always used for these (DEFTA) adapters.
2343    
2344     If unsure, say N.
2345    
2346     diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
2347     index b0de8ecd7fe8e..bdcf4aa34566b 100644
2348     --- a/drivers/net/fddi/defxx.c
2349     +++ b/drivers/net/fddi/defxx.c
2350     @@ -495,6 +495,25 @@ static const struct net_device_ops dfx_netdev_ops = {
2351     .ndo_set_mac_address = dfx_ctl_set_mac_address,
2352     };
2353    
2354     +static void dfx_register_res_alloc_err(const char *print_name, bool mmio,
2355     + bool eisa)
2356     +{
2357     + pr_err("%s: Cannot use %s, no address set, aborting\n",
2358     + print_name, mmio ? "MMIO" : "I/O");
2359     + pr_err("%s: Recompile driver with \"CONFIG_DEFXX_MMIO=%c\"\n",
2360     + print_name, mmio ? 'n' : 'y');
2361     + if (eisa && mmio)
2362     + pr_err("%s: Or run ECU and set adapter's MMIO location\n",
2363     + print_name);
2364     +}
2365     +
2366     +static void dfx_register_res_err(const char *print_name, bool mmio,
2367     + unsigned long start, unsigned long len)
2368     +{
2369     + pr_err("%s: Cannot reserve %s resource 0x%lx @ 0x%lx, aborting\n",
2370     + print_name, mmio ? "MMIO" : "I/O", len, start);
2371     +}
2372     +
2373     /*
2374     * ================
2375     * = dfx_register =
2376     @@ -568,15 +587,12 @@ static int dfx_register(struct device *bdev)
2377     dev_set_drvdata(bdev, dev);
2378    
2379     dfx_get_bars(bdev, bar_start, bar_len);
2380     - if (dfx_bus_eisa && dfx_use_mmio && bar_start[0] == 0) {
2381     - pr_err("%s: Cannot use MMIO, no address set, aborting\n",
2382     - print_name);
2383     - pr_err("%s: Run ECU and set adapter's MMIO location\n",
2384     - print_name);
2385     - pr_err("%s: Or recompile driver with \"CONFIG_DEFXX_MMIO=n\""
2386     - "\n", print_name);
2387     + if (bar_len[0] == 0 ||
2388     + (dfx_bus_eisa && dfx_use_mmio && bar_start[0] == 0)) {
2389     + dfx_register_res_alloc_err(print_name, dfx_use_mmio,
2390     + dfx_bus_eisa);
2391     err = -ENXIO;
2392     - goto err_out;
2393     + goto err_out_disable;
2394     }
2395    
2396     if (dfx_use_mmio)
2397     @@ -585,18 +601,16 @@ static int dfx_register(struct device *bdev)
2398     else
2399     region = request_region(bar_start[0], bar_len[0], print_name);
2400     if (!region) {
2401     - pr_err("%s: Cannot reserve %s resource 0x%lx @ 0x%lx, "
2402     - "aborting\n", dfx_use_mmio ? "MMIO" : "I/O", print_name,
2403     - (long)bar_len[0], (long)bar_start[0]);
2404     + dfx_register_res_err(print_name, dfx_use_mmio,
2405     + bar_start[0], bar_len[0]);
2406     err = -EBUSY;
2407     goto err_out_disable;
2408     }
2409     if (bar_start[1] != 0) {
2410     region = request_region(bar_start[1], bar_len[1], print_name);
2411     if (!region) {
2412     - pr_err("%s: Cannot reserve I/O resource "
2413     - "0x%lx @ 0x%lx, aborting\n", print_name,
2414     - (long)bar_len[1], (long)bar_start[1]);
2415     + dfx_register_res_err(print_name, 0,
2416     + bar_start[1], bar_len[1]);
2417     err = -EBUSY;
2418     goto err_out_csr_region;
2419     }
2420     @@ -604,9 +618,8 @@ static int dfx_register(struct device *bdev)
2421     if (bar_start[2] != 0) {
2422     region = request_region(bar_start[2], bar_len[2], print_name);
2423     if (!region) {
2424     - pr_err("%s: Cannot reserve I/O resource "
2425     - "0x%lx @ 0x%lx, aborting\n", print_name,
2426     - (long)bar_len[2], (long)bar_start[2]);
2427     + dfx_register_res_err(print_name, 0,
2428     + bar_start[2], bar_len[2]);
2429     err = -EBUSY;
2430     goto err_out_bh_region;
2431     }
2432     diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
2433     index 0434ecf677122..412a36f27de6d 100644
2434     --- a/drivers/net/usb/ax88179_178a.c
2435     +++ b/drivers/net/usb/ax88179_178a.c
2436     @@ -307,12 +307,12 @@ static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
2437     int ret;
2438    
2439     if (2 == size) {
2440     - u16 buf;
2441     + u16 buf = 0;
2442     ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0);
2443     le16_to_cpus(&buf);
2444     *((u16 *)data) = buf;
2445     } else if (4 == size) {
2446     - u32 buf;
2447     + u32 buf = 0;
2448     ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0);
2449     le32_to_cpus(&buf);
2450     *((u32 *)data) = buf;
2451     diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
2452     index 666bbacb8cb49..24daa1d0e9c58 100644
2453     --- a/drivers/net/wan/lapbether.c
2454     +++ b/drivers/net/wan/lapbether.c
2455     @@ -56,6 +56,8 @@ struct lapbethdev {
2456     struct list_head node;
2457     struct net_device *ethdev; /* link to ethernet device */
2458     struct net_device *axdev; /* lapbeth device (lapb#) */
2459     + bool up;
2460     + spinlock_t up_lock; /* Protects "up" */
2461     };
2462    
2463     static LIST_HEAD(lapbeth_devices);
2464     @@ -103,8 +105,9 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
2465     rcu_read_lock();
2466     lapbeth = lapbeth_get_x25_dev(dev);
2467     if (!lapbeth)
2468     - goto drop_unlock;
2469     - if (!netif_running(lapbeth->axdev))
2470     + goto drop_unlock_rcu;
2471     + spin_lock_bh(&lapbeth->up_lock);
2472     + if (!lapbeth->up)
2473     goto drop_unlock;
2474    
2475     len = skb->data[0] + skb->data[1] * 256;
2476     @@ -119,11 +122,14 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe
2477     goto drop_unlock;
2478     }
2479     out:
2480     + spin_unlock_bh(&lapbeth->up_lock);
2481     rcu_read_unlock();
2482     return 0;
2483     drop_unlock:
2484     kfree_skb(skb);
2485     goto out;
2486     +drop_unlock_rcu:
2487     + rcu_read_unlock();
2488     drop:
2489     kfree_skb(skb);
2490     return 0;
2491     @@ -151,13 +157,11 @@ static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb)
2492     static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
2493     struct net_device *dev)
2494     {
2495     + struct lapbethdev *lapbeth = netdev_priv(dev);
2496     int err;
2497    
2498     - /*
2499     - * Just to be *really* sure not to send anything if the interface
2500     - * is down, the ethernet device may have gone.
2501     - */
2502     - if (!netif_running(dev))
2503     + spin_lock_bh(&lapbeth->up_lock);
2504     + if (!lapbeth->up)
2505     goto drop;
2506    
2507     /* There should be a pseudo header of 1 byte added by upper layers.
2508     @@ -188,6 +192,7 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
2509     goto drop;
2510     }
2511     out:
2512     + spin_unlock_bh(&lapbeth->up_lock);
2513     return NETDEV_TX_OK;
2514     drop:
2515     kfree_skb(skb);
2516     @@ -279,6 +284,7 @@ static const struct lapb_register_struct lapbeth_callbacks = {
2517     */
2518     static int lapbeth_open(struct net_device *dev)
2519     {
2520     + struct lapbethdev *lapbeth = netdev_priv(dev);
2521     int err;
2522    
2523     if ((err = lapb_register(dev, &lapbeth_callbacks)) != LAPB_OK) {
2524     @@ -286,13 +292,22 @@ static int lapbeth_open(struct net_device *dev)
2525     return -ENODEV;
2526     }
2527    
2528     + spin_lock_bh(&lapbeth->up_lock);
2529     + lapbeth->up = true;
2530     + spin_unlock_bh(&lapbeth->up_lock);
2531     +
2532     return 0;
2533     }
2534    
2535     static int lapbeth_close(struct net_device *dev)
2536     {
2537     + struct lapbethdev *lapbeth = netdev_priv(dev);
2538     int err;
2539    
2540     + spin_lock_bh(&lapbeth->up_lock);
2541     + lapbeth->up = false;
2542     + spin_unlock_bh(&lapbeth->up_lock);
2543     +
2544     if ((err = lapb_unregister(dev)) != LAPB_OK)
2545     pr_err("lapb_unregister error: %d\n", err);
2546    
2547     @@ -350,6 +365,9 @@ static int lapbeth_new_device(struct net_device *dev)
2548     dev_hold(dev);
2549     lapbeth->ethdev = dev;
2550    
2551     + lapbeth->up = false;
2552     + spin_lock_init(&lapbeth->up_lock);
2553     +
2554     rc = -EIO;
2555     if (register_netdevice(ndev))
2556     goto fail;
2557     diff --git a/drivers/net/wimax/i2400m/op-rfkill.c b/drivers/net/wimax/i2400m/op-rfkill.c
2558     index dc6fe93ce71f6..e8473047b2d1e 100644
2559     --- a/drivers/net/wimax/i2400m/op-rfkill.c
2560     +++ b/drivers/net/wimax/i2400m/op-rfkill.c
2561     @@ -101,7 +101,7 @@ int i2400m_op_rfkill_sw_toggle(struct wimax_dev *wimax_dev,
2562     if (cmd == NULL)
2563     goto error_alloc;
2564     cmd->hdr.type = cpu_to_le16(I2400M_MT_CMD_RF_CONTROL);
2565     - cmd->hdr.length = sizeof(cmd->sw_rf);
2566     + cmd->hdr.length = cpu_to_le16(sizeof(cmd->sw_rf));
2567     cmd->hdr.version = cpu_to_le16(I2400M_L3L4_VERSION);
2568     cmd->sw_rf.hdr.type = cpu_to_le16(I2400M_TLV_RF_OPERATION);
2569     cmd->sw_rf.hdr.length = cpu_to_le16(sizeof(cmd->sw_rf.status));
2570     diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
2571     index 15a0036dcc6ee..09d737f3461b2 100644
2572     --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
2573     +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
2574     @@ -246,7 +246,7 @@ static unsigned int ath9k_regread(void *hw_priv, u32 reg_offset)
2575     if (unlikely(r)) {
2576     ath_dbg(common, WMI, "REGISTER READ FAILED: (0x%04x, %d)\n",
2577     reg_offset, r);
2578     - return -EIO;
2579     + return -1;
2580     }
2581    
2582     return be32_to_cpu(val);
2583     diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
2584     index e7fca78cdd964..9d664398a41b2 100644
2585     --- a/drivers/net/wireless/ath/ath9k/hw.c
2586     +++ b/drivers/net/wireless/ath/ath9k/hw.c
2587     @@ -285,7 +285,7 @@ static bool ath9k_hw_read_revisions(struct ath_hw *ah)
2588    
2589     srev = REG_READ(ah, AR_SREV);
2590    
2591     - if (srev == -EIO) {
2592     + if (srev == -1) {
2593     ath_err(ath9k_hw_common(ah),
2594     "Failed to read SREV register");
2595     return false;
2596     diff --git a/drivers/net/wireless/intel/ipw2x00/libipw_wx.c b/drivers/net/wireless/intel/ipw2x00/libipw_wx.c
2597     index dd29f46d086b2..028b37ba9425d 100644
2598     --- a/drivers/net/wireless/intel/ipw2x00/libipw_wx.c
2599     +++ b/drivers/net/wireless/intel/ipw2x00/libipw_wx.c
2600     @@ -649,8 +649,10 @@ int libipw_wx_set_encodeext(struct libipw_device *ieee,
2601     }
2602    
2603     if (ext->alg != IW_ENCODE_ALG_NONE) {
2604     - memcpy(sec.keys[idx], ext->key, ext->key_len);
2605     - sec.key_sizes[idx] = ext->key_len;
2606     + int key_len = clamp_val(ext->key_len, 0, SCM_KEY_LEN);
2607     +
2608     + memcpy(sec.keys[idx], ext->key, key_len);
2609     + sec.key_sizes[idx] = key_len;
2610     sec.flags |= (1 << idx);
2611     if (ext->alg == IW_ENCODE_ALG_WEP) {
2612     sec.encode_alg[idx] = SEC_ALG_WEP;
2613     diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
2614     index ff564198d2cef..24948b28e3e70 100644
2615     --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
2616     +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c
2617     @@ -1510,6 +1510,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
2618     u32 cmd_pos;
2619     const u8 *cmddata[IWL_MAX_CMD_TBS_PER_TFD];
2620     u16 cmdlen[IWL_MAX_CMD_TBS_PER_TFD];
2621     + unsigned long flags2;
2622    
2623     if (WARN(!trans->wide_cmd_header &&
2624     group_id > IWL_ALWAYS_LONG_GROUP,
2625     @@ -1593,10 +1594,10 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
2626     goto free_dup_buf;
2627     }
2628    
2629     - spin_lock_bh(&txq->lock);
2630     + spin_lock_irqsave(&txq->lock, flags2);
2631    
2632     if (iwl_queue_space(txq) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) {
2633     - spin_unlock_bh(&txq->lock);
2634     + spin_unlock_irqrestore(&txq->lock, flags2);
2635    
2636     IWL_ERR(trans, "No space in command queue\n");
2637     iwl_op_mode_cmd_queue_full(trans->op_mode);
2638     @@ -1757,7 +1758,7 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans,
2639     spin_unlock_irqrestore(&trans_pcie->reg_lock, flags);
2640    
2641     out:
2642     - spin_unlock_bh(&txq->lock);
2643     + spin_unlock_irqrestore(&txq->lock, flags2);
2644     free_dup_buf:
2645     if (idx < 0)
2646     kfree(dup_buf);
2647     diff --git a/drivers/net/wireless/marvell/mwl8k.c b/drivers/net/wireless/marvell/mwl8k.c
2648     index b1b400b59d864..66cd38d4f199b 100644
2649     --- a/drivers/net/wireless/marvell/mwl8k.c
2650     +++ b/drivers/net/wireless/marvell/mwl8k.c
2651     @@ -1459,6 +1459,7 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
2652     txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL);
2653     if (txq->skb == NULL) {
2654     pci_free_consistent(priv->pdev, size, txq->txd, txq->txd_dma);
2655     + txq->txd = NULL;
2656     return -ENOMEM;
2657     }
2658    
2659     diff --git a/drivers/net/wireless/mediatek/mt7601u/eeprom.c b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
2660     index da6faea092d6b..80d0f64205f8a 100644
2661     --- a/drivers/net/wireless/mediatek/mt7601u/eeprom.c
2662     +++ b/drivers/net/wireless/mediatek/mt7601u/eeprom.c
2663     @@ -106,7 +106,7 @@ mt7601u_has_tssi(struct mt7601u_dev *dev, u8 *eeprom)
2664     {
2665     u16 nic_conf1 = get_unaligned_le16(eeprom + MT_EE_NIC_CONF_1);
2666    
2667     - return ~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN);
2668     + return (u16)~nic_conf1 && (nic_conf1 & MT_EE_NIC_CONF_1_TX_ALC_EN);
2669     }
2670    
2671     static void
2672     diff --git a/drivers/net/wireless/wl3501.h b/drivers/net/wireless/wl3501.h
2673     index 3fbfd19818f1a..ca2021bcac14f 100644
2674     --- a/drivers/net/wireless/wl3501.h
2675     +++ b/drivers/net/wireless/wl3501.h
2676     @@ -378,16 +378,7 @@ struct wl3501_get_confirm {
2677     u8 mib_value[100];
2678     };
2679    
2680     -struct wl3501_join_req {
2681     - u16 next_blk;
2682     - u8 sig_id;
2683     - u8 reserved;
2684     - struct iw_mgmt_data_rset operational_rset;
2685     - u16 reserved2;
2686     - u16 timeout;
2687     - u16 probe_delay;
2688     - u8 timestamp[8];
2689     - u8 local_time[8];
2690     +struct wl3501_req {
2691     u16 beacon_period;
2692     u16 dtim_period;
2693     u16 cap_info;
2694     @@ -400,6 +391,19 @@ struct wl3501_join_req {
2695     struct iw_mgmt_data_rset bss_basic_rset;
2696     };
2697    
2698     +struct wl3501_join_req {
2699     + u16 next_blk;
2700     + u8 sig_id;
2701     + u8 reserved;
2702     + struct iw_mgmt_data_rset operational_rset;
2703     + u16 reserved2;
2704     + u16 timeout;
2705     + u16 probe_delay;
2706     + u8 timestamp[8];
2707     + u8 local_time[8];
2708     + struct wl3501_req req;
2709     +};
2710     +
2711     struct wl3501_join_confirm {
2712     u16 next_blk;
2713     u8 sig_id;
2714     @@ -442,16 +446,7 @@ struct wl3501_scan_confirm {
2715     u16 status;
2716     char timestamp[8];
2717     char localtime[8];
2718     - u16 beacon_period;
2719     - u16 dtim_period;
2720     - u16 cap_info;
2721     - u8 bss_type;
2722     - u8 bssid[ETH_ALEN];
2723     - struct iw_mgmt_essid_pset ssid;
2724     - struct iw_mgmt_ds_pset ds_pset;
2725     - struct iw_mgmt_cf_pset cf_pset;
2726     - struct iw_mgmt_ibss_pset ibss_pset;
2727     - struct iw_mgmt_data_rset bss_basic_rset;
2728     + struct wl3501_req req;
2729     u8 rssi;
2730     };
2731    
2732     @@ -470,8 +465,10 @@ struct wl3501_md_req {
2733     u16 size;
2734     u8 pri;
2735     u8 service_class;
2736     - u8 daddr[ETH_ALEN];
2737     - u8 saddr[ETH_ALEN];
2738     + struct {
2739     + u8 daddr[ETH_ALEN];
2740     + u8 saddr[ETH_ALEN];
2741     + } addr;
2742     };
2743    
2744     struct wl3501_md_ind {
2745     @@ -483,8 +480,10 @@ struct wl3501_md_ind {
2746     u8 reception;
2747     u8 pri;
2748     u8 service_class;
2749     - u8 daddr[ETH_ALEN];
2750     - u8 saddr[ETH_ALEN];
2751     + struct {
2752     + u8 daddr[ETH_ALEN];
2753     + u8 saddr[ETH_ALEN];
2754     + } addr;
2755     };
2756    
2757     struct wl3501_md_confirm {
2758     diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
2759     index 932f3f81e8cf3..959844a108615 100644
2760     --- a/drivers/net/wireless/wl3501_cs.c
2761     +++ b/drivers/net/wireless/wl3501_cs.c
2762     @@ -468,6 +468,7 @@ static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len)
2763     struct wl3501_md_req sig = {
2764     .sig_id = WL3501_SIG_MD_REQ,
2765     };
2766     + size_t sig_addr_len = sizeof(sig.addr);
2767     u8 *pdata = (char *)data;
2768     int rc = -EIO;
2769    
2770     @@ -483,9 +484,9 @@ static int wl3501_send_pkt(struct wl3501_card *this, u8 *data, u16 len)
2771     goto out;
2772     }
2773     rc = 0;
2774     - memcpy(&sig.daddr[0], pdata, 12);
2775     - pktlen = len - 12;
2776     - pdata += 12;
2777     + memcpy(&sig.addr, pdata, sig_addr_len);
2778     + pktlen = len - sig_addr_len;
2779     + pdata += sig_addr_len;
2780     sig.data = bf;
2781     if (((*pdata) * 256 + (*(pdata + 1))) > 1500) {
2782     u8 addr4[ETH_ALEN] = {
2783     @@ -588,7 +589,7 @@ static int wl3501_mgmt_join(struct wl3501_card *this, u16 stas)
2784     struct wl3501_join_req sig = {
2785     .sig_id = WL3501_SIG_JOIN_REQ,
2786     .timeout = 10,
2787     - .ds_pset = {
2788     + .req.ds_pset = {
2789     .el = {
2790     .id = IW_MGMT_INFO_ELEMENT_DS_PARAMETER_SET,
2791     .len = 1,
2792     @@ -597,7 +598,7 @@ static int wl3501_mgmt_join(struct wl3501_card *this, u16 stas)
2793     },
2794     };
2795    
2796     - memcpy(&sig.beacon_period, &this->bss_set[stas].beacon_period, 72);
2797     + memcpy(&sig.req, &this->bss_set[stas].req, sizeof(sig.req));
2798     return wl3501_esbq_exec(this, &sig, sizeof(sig));
2799     }
2800    
2801     @@ -665,35 +666,37 @@ static void wl3501_mgmt_scan_confirm(struct wl3501_card *this, u16 addr)
2802     if (sig.status == WL3501_STATUS_SUCCESS) {
2803     pr_debug("success");
2804     if ((this->net_type == IW_MODE_INFRA &&
2805     - (sig.cap_info & WL3501_MGMT_CAPABILITY_ESS)) ||
2806     + (sig.req.cap_info & WL3501_MGMT_CAPABILITY_ESS)) ||
2807     (this->net_type == IW_MODE_ADHOC &&
2808     - (sig.cap_info & WL3501_MGMT_CAPABILITY_IBSS)) ||
2809     + (sig.req.cap_info & WL3501_MGMT_CAPABILITY_IBSS)) ||
2810     this->net_type == IW_MODE_AUTO) {
2811     if (!this->essid.el.len)
2812     matchflag = 1;
2813     else if (this->essid.el.len == 3 &&
2814     !memcmp(this->essid.essid, "ANY", 3))
2815     matchflag = 1;
2816     - else if (this->essid.el.len != sig.ssid.el.len)
2817     + else if (this->essid.el.len != sig.req.ssid.el.len)
2818     matchflag = 0;
2819     - else if (memcmp(this->essid.essid, sig.ssid.essid,
2820     + else if (memcmp(this->essid.essid, sig.req.ssid.essid,
2821     this->essid.el.len))
2822     matchflag = 0;
2823     else
2824     matchflag = 1;
2825     if (matchflag) {
2826     for (i = 0; i < this->bss_cnt; i++) {
2827     - if (ether_addr_equal_unaligned(this->bss_set[i].bssid, sig.bssid)) {
2828     + if (ether_addr_equal_unaligned(this->bss_set[i].req.bssid,
2829     + sig.req.bssid)) {
2830     matchflag = 0;
2831     break;
2832     }
2833     }
2834     }
2835     if (matchflag && (i < 20)) {
2836     - memcpy(&this->bss_set[i].beacon_period,
2837     - &sig.beacon_period, 73);
2838     + memcpy(&this->bss_set[i].req,
2839     + &sig.req, sizeof(sig.req));
2840     this->bss_cnt++;
2841     this->rssi = sig.rssi;
2842     + this->bss_set[i].rssi = sig.rssi;
2843     }
2844     }
2845     } else if (sig.status == WL3501_STATUS_TIMEOUT) {
2846     @@ -885,19 +888,19 @@ static void wl3501_mgmt_join_confirm(struct net_device *dev, u16 addr)
2847     if (this->join_sta_bss < this->bss_cnt) {
2848     const int i = this->join_sta_bss;
2849     memcpy(this->bssid,
2850     - this->bss_set[i].bssid, ETH_ALEN);
2851     - this->chan = this->bss_set[i].ds_pset.chan;
2852     + this->bss_set[i].req.bssid, ETH_ALEN);
2853     + this->chan = this->bss_set[i].req.ds_pset.chan;
2854     iw_copy_mgmt_info_element(&this->keep_essid.el,
2855     - &this->bss_set[i].ssid.el);
2856     + &this->bss_set[i].req.ssid.el);
2857     wl3501_mgmt_auth(this);
2858     }
2859     } else {
2860     const int i = this->join_sta_bss;
2861    
2862     - memcpy(&this->bssid, &this->bss_set[i].bssid, ETH_ALEN);
2863     - this->chan = this->bss_set[i].ds_pset.chan;
2864     + memcpy(&this->bssid, &this->bss_set[i].req.bssid, ETH_ALEN);
2865     + this->chan = this->bss_set[i].req.ds_pset.chan;
2866     iw_copy_mgmt_info_element(&this->keep_essid.el,
2867     - &this->bss_set[i].ssid.el);
2868     + &this->bss_set[i].req.ssid.el);
2869     wl3501_online(dev);
2870     }
2871     } else {
2872     @@ -979,7 +982,8 @@ static inline void wl3501_md_ind_interrupt(struct net_device *dev,
2873     } else {
2874     skb->dev = dev;
2875     skb_reserve(skb, 2); /* IP headers on 16 bytes boundaries */
2876     - skb_copy_to_linear_data(skb, (unsigned char *)&sig.daddr, 12);
2877     + skb_copy_to_linear_data(skb, (unsigned char *)&sig.addr,
2878     + sizeof(sig.addr));
2879     wl3501_receive(this, skb->data, pkt_len);
2880     skb_put(skb, pkt_len);
2881     skb->protocol = eth_type_trans(skb, dev);
2882     @@ -1574,30 +1578,30 @@ static int wl3501_get_scan(struct net_device *dev, struct iw_request_info *info,
2883     for (i = 0; i < this->bss_cnt; ++i) {
2884     iwe.cmd = SIOCGIWAP;
2885     iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
2886     - memcpy(iwe.u.ap_addr.sa_data, this->bss_set[i].bssid, ETH_ALEN);
2887     + memcpy(iwe.u.ap_addr.sa_data, this->bss_set[i].req.bssid, ETH_ALEN);
2888     current_ev = iwe_stream_add_event(info, current_ev,
2889     extra + IW_SCAN_MAX_DATA,
2890     &iwe, IW_EV_ADDR_LEN);
2891     iwe.cmd = SIOCGIWESSID;
2892     iwe.u.data.flags = 1;
2893     - iwe.u.data.length = this->bss_set[i].ssid.el.len;
2894     + iwe.u.data.length = this->bss_set[i].req.ssid.el.len;
2895     current_ev = iwe_stream_add_point(info, current_ev,
2896     extra + IW_SCAN_MAX_DATA,
2897     &iwe,
2898     - this->bss_set[i].ssid.essid);
2899     + this->bss_set[i].req.ssid.essid);
2900     iwe.cmd = SIOCGIWMODE;
2901     - iwe.u.mode = this->bss_set[i].bss_type;
2902     + iwe.u.mode = this->bss_set[i].req.bss_type;
2903     current_ev = iwe_stream_add_event(info, current_ev,
2904     extra + IW_SCAN_MAX_DATA,
2905     &iwe, IW_EV_UINT_LEN);
2906     iwe.cmd = SIOCGIWFREQ;
2907     - iwe.u.freq.m = this->bss_set[i].ds_pset.chan;
2908     + iwe.u.freq.m = this->bss_set[i].req.ds_pset.chan;
2909     iwe.u.freq.e = 0;
2910     current_ev = iwe_stream_add_event(info, current_ev,
2911     extra + IW_SCAN_MAX_DATA,
2912     &iwe, IW_EV_FREQ_LEN);
2913     iwe.cmd = SIOCGIWENCODE;
2914     - if (this->bss_set[i].cap_info & WL3501_MGMT_CAPABILITY_PRIVACY)
2915     + if (this->bss_set[i].req.cap_info & WL3501_MGMT_CAPABILITY_PRIVACY)
2916     iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
2917     else
2918     iwe.u.data.flags = IW_ENCODE_DISABLED;
2919     diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
2920     index d9c55830b2b26..6c495664d2cb7 100644
2921     --- a/drivers/nfc/pn533/pn533.c
2922     +++ b/drivers/nfc/pn533/pn533.c
2923     @@ -678,6 +678,9 @@ static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a,
2924     if (PN533_TYPE_A_SEL_CASCADE(type_a->sel_res) != 0)
2925     return false;
2926    
2927     + if (type_a->nfcid_len > NFC_NFCID1_MAXSIZE)
2928     + return false;
2929     +
2930     return true;
2931     }
2932    
2933     diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
2934     index 9054b8f218a78..e9360d5cbcbac 100644
2935     --- a/drivers/of/fdt.c
2936     +++ b/drivers/of/fdt.c
2937     @@ -1158,16 +1158,8 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
2938     int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base,
2939     phys_addr_t size, bool nomap)
2940     {
2941     - if (nomap) {
2942     - /*
2943     - * If the memory is already reserved (by another region), we
2944     - * should not allow it to be marked nomap.
2945     - */
2946     - if (memblock_is_region_reserved(base, size))
2947     - return -EBUSY;
2948     -
2949     - return memblock_mark_nomap(base, size);
2950     - }
2951     + if (nomap)
2952     + return memblock_remove(base, size);
2953     return memblock_reserve(base, size);
2954     }
2955    
2956     diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
2957     index 7f2b9ef185e44..f154b05f467ff 100644
2958     --- a/drivers/pci/hotplug/acpiphp_glue.c
2959     +++ b/drivers/pci/hotplug/acpiphp_glue.c
2960     @@ -538,6 +538,7 @@ static void enable_slot(struct acpiphp_slot *slot)
2961     slot->flags &= (~SLOT_ENABLED);
2962     continue;
2963     }
2964     + pci_dev_put(dev);
2965     }
2966     }
2967    
2968     diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2969     index e09653c73ab4b..acd89fa9820c4 100644
2970     --- a/drivers/pci/pci.c
2971     +++ b/drivers/pci/pci.c
2972     @@ -1378,20 +1378,10 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
2973     int err;
2974     int i, bars = 0;
2975    
2976     - /*
2977     - * Power state could be unknown at this point, either due to a fresh
2978     - * boot or a device removal call. So get the current power state
2979     - * so that things like MSI message writing will behave as expected
2980     - * (e.g. if the device really is in D0 at enable time).
2981     - */
2982     - if (dev->pm_cap) {
2983     - u16 pmcsr;
2984     - pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
2985     - dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
2986     - }
2987     -
2988     - if (atomic_inc_return(&dev->enable_cnt) > 1)
2989     + if (atomic_inc_return(&dev->enable_cnt) > 1) {
2990     + pci_update_current_state(dev, dev->current_state);
2991     return 0; /* already enabled */
2992     + }
2993    
2994     bridge = pci_upstream_bridge(dev);
2995     if (bridge)
2996     diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
2997     index 19658873b4c11..ddf5ba63b1958 100644
2998     --- a/drivers/pci/probe.c
2999     +++ b/drivers/pci/probe.c
3000     @@ -1694,6 +1694,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)
3001     pci_set_of_node(dev);
3002    
3003     if (pci_setup_device(dev)) {
3004     + pci_release_of_node(dev);
3005     pci_bus_put(dev->bus);
3006     kfree(dev);
3007     return NULL;
3008     diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c
3009     index ddb530ee2255c..9d57695e1f21f 100644
3010     --- a/drivers/phy/phy-twl4030-usb.c
3011     +++ b/drivers/phy/phy-twl4030-usb.c
3012     @@ -798,7 +798,7 @@ static int twl4030_usb_remove(struct platform_device *pdev)
3013    
3014     usb_remove_phy(&twl->phy);
3015     pm_runtime_get_sync(twl->dev);
3016     - cancel_delayed_work(&twl->id_workaround_work);
3017     + cancel_delayed_work_sync(&twl->id_workaround_work);
3018     device_remove_file(twl->dev, &dev_attr_vbus);
3019    
3020     /* set transceiver mode to power on defaults */
3021     diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
3022     index 379f9633f78e1..84bfecded84d9 100644
3023     --- a/drivers/platform/x86/thinkpad_acpi.c
3024     +++ b/drivers/platform/x86/thinkpad_acpi.c
3025     @@ -6044,6 +6044,7 @@ enum thermal_access_mode {
3026     enum { /* TPACPI_THERMAL_TPEC_* */
3027     TP_EC_THERMAL_TMP0 = 0x78, /* ACPI EC regs TMP 0..7 */
3028     TP_EC_THERMAL_TMP8 = 0xC0, /* ACPI EC regs TMP 8..15 */
3029     + TP_EC_FUNCREV = 0xEF, /* ACPI EC Functional revision */
3030     TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
3031    
3032     TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
3033     @@ -6242,7 +6243,7 @@ static const struct attribute_group thermal_temp_input8_group = {
3034    
3035     static int __init thermal_init(struct ibm_init_struct *iibm)
3036     {
3037     - u8 t, ta1, ta2;
3038     + u8 t, ta1, ta2, ver = 0;
3039     int i;
3040     int acpi_tmp7;
3041     int res;
3042     @@ -6257,7 +6258,14 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
3043     * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
3044     * non-implemented, thermal sensors return 0x80 when
3045     * not available
3046     + * The above rule is unfortunately flawed. This has been seen with
3047     + * 0xC2 (power supply ID) causing thermal control problems.
3048     + * The EC version can be determined by offset 0xEF and at least for
3049     + * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7
3050     + * are not thermal registers.
3051     */
3052     + if (!acpi_ec_read(TP_EC_FUNCREV, &ver))
3053     + pr_warn("Thinkpad ACPI EC unable to access EC version\n");
3054    
3055     ta1 = ta2 = 0;
3056     for (i = 0; i < 8; i++) {
3057     @@ -6267,11 +6275,13 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
3058     ta1 = 0;
3059     break;
3060     }
3061     - if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
3062     - ta2 |= t;
3063     - } else {
3064     - ta1 = 0;
3065     - break;
3066     + if (ver < 3) {
3067     + if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
3068     + ta2 |= t;
3069     + } else {
3070     + ta1 = 0;
3071     + break;
3072     + }
3073     }
3074     }
3075     if (ta1 == 0) {
3076     @@ -6287,9 +6297,12 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
3077     thermal_read_mode = TPACPI_THERMAL_NONE;
3078     }
3079     } else {
3080     - thermal_read_mode =
3081     - (ta2 != 0) ?
3082     - TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
3083     + if (ver >= 3)
3084     + thermal_read_mode = TPACPI_THERMAL_TPEC_8;
3085     + else
3086     + thermal_read_mode =
3087     + (ta2 != 0) ?
3088     + TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
3089     }
3090     } else if (acpi_tmp7) {
3091     if (tpacpi_is_ibm() &&
3092     diff --git a/drivers/power/supply/generic-adc-battery.c b/drivers/power/supply/generic-adc-battery.c
3093     index f627b39f64bf2..b77fd751945d5 100644
3094     --- a/drivers/power/supply/generic-adc-battery.c
3095     +++ b/drivers/power/supply/generic-adc-battery.c
3096     @@ -384,7 +384,7 @@ static int gab_remove(struct platform_device *pdev)
3097     }
3098    
3099     kfree(adc_bat->psy_desc.properties);
3100     - cancel_delayed_work(&adc_bat->bat_work);
3101     + cancel_delayed_work_sync(&adc_bat->bat_work);
3102     return 0;
3103     }
3104    
3105     diff --git a/drivers/power/supply/lp8788-charger.c b/drivers/power/supply/lp8788-charger.c
3106     index c3075ea011b64..e800beff1f8f3 100644
3107     --- a/drivers/power/supply/lp8788-charger.c
3108     +++ b/drivers/power/supply/lp8788-charger.c
3109     @@ -532,7 +532,7 @@ static int lp8788_set_irqs(struct platform_device *pdev,
3110    
3111     ret = request_threaded_irq(virq, NULL,
3112     lp8788_charger_irq_thread,
3113     - 0, name, pchg);
3114     + IRQF_ONESHOT, name, pchg);
3115     if (ret)
3116     break;
3117     }
3118     diff --git a/drivers/power/supply/pm2301_charger.c b/drivers/power/supply/pm2301_charger.c
3119     index 78561b6884fc7..9ef218d76aa9c 100644
3120     --- a/drivers/power/supply/pm2301_charger.c
3121     +++ b/drivers/power/supply/pm2301_charger.c
3122     @@ -1098,7 +1098,7 @@ static int pm2xxx_wall_charger_probe(struct i2c_client *i2c_client,
3123     ret = request_threaded_irq(gpio_to_irq(pm2->pdata->gpio_irq_number),
3124     NULL,
3125     pm2xxx_charger_irq[0].isr,
3126     - pm2->pdata->irq_type,
3127     + pm2->pdata->irq_type | IRQF_ONESHOT,
3128     pm2xxx_charger_irq[0].name, pm2);
3129    
3130     if (ret != 0) {
3131     diff --git a/drivers/power/supply/s3c_adc_battery.c b/drivers/power/supply/s3c_adc_battery.c
3132     index 0ffe5cd3abf62..06b412c43aa72 100644
3133     --- a/drivers/power/supply/s3c_adc_battery.c
3134     +++ b/drivers/power/supply/s3c_adc_battery.c
3135     @@ -392,7 +392,7 @@ static int s3c_adc_bat_remove(struct platform_device *pdev)
3136     gpio_free(pdata->gpio_charge_finished);
3137     }
3138    
3139     - cancel_delayed_work(&bat_work);
3140     + cancel_delayed_work_sync(&bat_work);
3141    
3142     if (pdata->exit)
3143     pdata->exit();
3144     diff --git a/drivers/power/supply/tps65090-charger.c b/drivers/power/supply/tps65090-charger.c
3145     index 1b4b5e09538e1..297bf58f0d4fb 100644
3146     --- a/drivers/power/supply/tps65090-charger.c
3147     +++ b/drivers/power/supply/tps65090-charger.c
3148     @@ -311,7 +311,7 @@ static int tps65090_charger_probe(struct platform_device *pdev)
3149    
3150     if (irq != -ENXIO) {
3151     ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
3152     - tps65090_charger_isr, 0, "tps65090-charger", cdata);
3153     + tps65090_charger_isr, IRQF_ONESHOT, "tps65090-charger", cdata);
3154     if (ret) {
3155     dev_err(cdata->dev,
3156     "Unable to register irq %d err %d\n", irq,
3157     diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
3158     index 9fd019f9b88c4..a6b4eb61b4bb4 100644
3159     --- a/drivers/power/supply/tps65217_charger.c
3160     +++ b/drivers/power/supply/tps65217_charger.c
3161     @@ -238,7 +238,7 @@ static int tps65217_charger_probe(struct platform_device *pdev)
3162     if (irq != -ENXIO) {
3163     ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
3164     tps65217_charger_irq,
3165     - 0, "tps65217-charger",
3166     + IRQF_ONESHOT, "tps65217-charger",
3167     charger);
3168     if (ret) {
3169     dev_err(charger->dev,
3170     diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
3171     index 2bc3dc6244a5e..dce8852762350 100644
3172     --- a/drivers/scsi/device_handler/scsi_dh_alua.c
3173     +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
3174     @@ -564,10 +564,11 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
3175     * even though it shouldn't according to T10.
3176     * The retry without rtpg_ext_hdr_req set
3177     * handles this.
3178     + * Note: some arrays return a sense key of ILLEGAL_REQUEST
3179     + * with ASC 00h if they don't support the extended header.
3180     */
3181     if (!(pg->flags & ALUA_RTPG_EXT_HDR_UNSUPP) &&
3182     - sense_hdr.sense_key == ILLEGAL_REQUEST &&
3183     - sense_hdr.asc == 0x24 && sense_hdr.ascq == 0) {
3184     + sense_hdr.sense_key == ILLEGAL_REQUEST) {
3185     pg->flags |= ALUA_RTPG_EXT_HDR_UNSUPP;
3186     goto retry;
3187     }
3188     diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
3189     index 9aaa74e349ccb..65f0dbfc3a45d 100644
3190     --- a/drivers/scsi/jazz_esp.c
3191     +++ b/drivers/scsi/jazz_esp.c
3192     @@ -170,7 +170,9 @@ static int esp_jazz_probe(struct platform_device *dev)
3193     if (!esp->command_block)
3194     goto fail_unmap_regs;
3195    
3196     - host->irq = platform_get_irq(dev, 0);
3197     + host->irq = err = platform_get_irq(dev, 0);
3198     + if (err < 0)
3199     + goto fail_unmap_command_block;
3200     err = request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp);
3201     if (err < 0)
3202     goto fail_unmap_command_block;
3203     diff --git a/drivers/scsi/libfc/fc_lport.c b/drivers/scsi/libfc/fc_lport.c
3204     index ae93f45f9cd8d..a36817fb0673a 100644
3205     --- a/drivers/scsi/libfc/fc_lport.c
3206     +++ b/drivers/scsi/libfc/fc_lport.c
3207     @@ -1751,7 +1751,7 @@ void fc_lport_flogi_resp(struct fc_seq *sp, struct fc_frame *fp,
3208    
3209     if (mfs < FC_SP_MIN_MAX_PAYLOAD || mfs > FC_SP_MAX_MAX_PAYLOAD) {
3210     FC_LPORT_DBG(lport, "FLOGI bad mfs:%hu response, "
3211     - "lport->mfs:%hu\n", mfs, lport->mfs);
3212     + "lport->mfs:%u\n", mfs, lport->mfs);
3213     fc_lport_error(lport, fp);
3214     goto out;
3215     }
3216     diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
3217     index fefef2884d590..30b5f65b29d15 100644
3218     --- a/drivers/scsi/lpfc/lpfc_nportdisc.c
3219     +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
3220     @@ -1606,8 +1606,6 @@ lpfc_cmpl_reglogin_reglogin_issue(struct lpfc_vport *vport,
3221     ndlp->nlp_last_elscmd = ELS_CMD_PLOGI;
3222    
3223     lpfc_issue_els_logo(vport, ndlp, 0);
3224     - ndlp->nlp_prev_state = NLP_STE_REG_LOGIN_ISSUE;
3225     - lpfc_nlp_set_state(vport, ndlp, NLP_STE_NPR_NODE);
3226     return ndlp->nlp_state;
3227     }
3228    
3229     diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
3230     index 08c76c361e8dc..0e7915ecb85a5 100644
3231     --- a/drivers/scsi/lpfc/lpfc_sli.c
3232     +++ b/drivers/scsi/lpfc/lpfc_sli.c
3233     @@ -15252,7 +15252,6 @@ lpfc_sli4_seq_abort_rsp_cmpl(struct lpfc_hba *phba,
3234     if (cmd_iocbq) {
3235     ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1;
3236     lpfc_nlp_put(ndlp);
3237     - lpfc_nlp_not_used(ndlp);
3238     lpfc_sli_release_iocbq(phba, cmd_iocbq);
3239     }
3240    
3241     diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
3242     index 33f4181ba9f76..591e2e89ae9f8 100644
3243     --- a/drivers/scsi/qla2xxx/qla_attr.c
3244     +++ b/drivers/scsi/qla2xxx/qla_attr.c
3245     @@ -1909,6 +1909,8 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
3246     vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
3247    
3248     if (IS_FWI2_CAPABLE(ha)) {
3249     + int rval;
3250     +
3251     stats = dma_alloc_coherent(&ha->pdev->dev,
3252     sizeof(*stats), &stats_dma, GFP_KERNEL);
3253     if (!stats) {
3254     @@ -1918,7 +1920,11 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
3255     }
3256    
3257     /* reset firmware statistics */
3258     - qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
3259     + rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
3260     + if (rval != QLA_SUCCESS)
3261     + ql_log(ql_log_warn, vha, 0x70de,
3262     + "Resetting ISP statistics failed: rval = %d\n",
3263     + rval);
3264    
3265     dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
3266     stats, stats_dma);
3267     diff --git a/drivers/scsi/sni_53c710.c b/drivers/scsi/sni_53c710.c
3268     index b0f5220ae23a8..fad68cb028d6b 100644
3269     --- a/drivers/scsi/sni_53c710.c
3270     +++ b/drivers/scsi/sni_53c710.c
3271     @@ -71,6 +71,7 @@ static int snirm710_probe(struct platform_device *dev)
3272     struct NCR_700_Host_Parameters *hostdata;
3273     struct Scsi_Host *host;
3274     struct resource *res;
3275     + int rc;
3276    
3277     res = platform_get_resource(dev, IORESOURCE_MEM, 0);
3278     if (!res)
3279     @@ -96,7 +97,9 @@ static int snirm710_probe(struct platform_device *dev)
3280     goto out_kfree;
3281     host->this_id = 7;
3282     host->base = base;
3283     - host->irq = platform_get_irq(dev, 0);
3284     + host->irq = rc = platform_get_irq(dev, 0);
3285     + if (rc < 0)
3286     + goto out_put_host;
3287     if(request_irq(host->irq, NCR_700_intr, IRQF_SHARED, "snirm710", host)) {
3288     printk(KERN_ERR "snirm710: request_irq failed!\n");
3289     goto out_put_host;
3290     diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
3291     index d50c5ed8f428c..167ae2d29e47b 100644
3292     --- a/drivers/scsi/sun3x_esp.c
3293     +++ b/drivers/scsi/sun3x_esp.c
3294     @@ -233,7 +233,9 @@ static int esp_sun3x_probe(struct platform_device *dev)
3295     if (!esp->command_block)
3296     goto fail_unmap_regs_dma;
3297    
3298     - host->irq = platform_get_irq(dev, 0);
3299     + host->irq = err = platform_get_irq(dev, 0);
3300     + if (err < 0)
3301     + goto fail_unmap_command_block;
3302     err = request_irq(host->irq, scsi_esp_intr, IRQF_SHARED,
3303     "SUN3X ESP", esp);
3304     if (err < 0)
3305     diff --git a/drivers/spi/spi-dln2.c b/drivers/spi/spi-dln2.c
3306     index b62a99caacc06..a41adea486182 100644
3307     --- a/drivers/spi/spi-dln2.c
3308     +++ b/drivers/spi/spi-dln2.c
3309     @@ -783,7 +783,7 @@ exit_free_master:
3310    
3311     static int dln2_spi_remove(struct platform_device *pdev)
3312     {
3313     - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
3314     + struct spi_master *master = platform_get_drvdata(pdev);
3315     struct dln2_spi *dln2 = spi_master_get_devdata(master);
3316    
3317     pm_runtime_disable(&pdev->dev);
3318     diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
3319     index 76a8425be227b..1eccdc4a45817 100644
3320     --- a/drivers/spi/spi-omap-100k.c
3321     +++ b/drivers/spi/spi-omap-100k.c
3322     @@ -435,7 +435,7 @@ err:
3323    
3324     static int omap1_spi100k_remove(struct platform_device *pdev)
3325     {
3326     - struct spi_master *master = spi_master_get(platform_get_drvdata(pdev));
3327     + struct spi_master *master = platform_get_drvdata(pdev);
3328     struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3329    
3330     pm_runtime_disable(&pdev->dev);
3331     @@ -449,7 +449,7 @@ static int omap1_spi100k_remove(struct platform_device *pdev)
3332     #ifdef CONFIG_PM
3333     static int omap1_spi100k_runtime_suspend(struct device *dev)
3334     {
3335     - struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
3336     + struct spi_master *master = dev_get_drvdata(dev);
3337     struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3338    
3339     clk_disable_unprepare(spi100k->ick);
3340     @@ -460,7 +460,7 @@ static int omap1_spi100k_runtime_suspend(struct device *dev)
3341    
3342     static int omap1_spi100k_runtime_resume(struct device *dev)
3343     {
3344     - struct spi_master *master = spi_master_get(dev_get_drvdata(dev));
3345     + struct spi_master *master = dev_get_drvdata(dev);
3346     struct omap1_spi100k *spi100k = spi_master_get_devdata(master);
3347     int ret;
3348    
3349     diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
3350     index 9ef9cbfd8926d..c35c9b766a001 100644
3351     --- a/drivers/staging/greybus/uart.c
3352     +++ b/drivers/staging/greybus/uart.c
3353     @@ -661,8 +661,6 @@ static int set_serial_info(struct gb_tty *gb_tty,
3354     if ((close_delay != gb_tty->port.close_delay) ||
3355     (closing_wait != gb_tty->port.closing_wait))
3356     retval = -EPERM;
3357     - else
3358     - retval = -EOPNOTSUPP;
3359     } else {
3360     gb_tty->port.close_delay = close_delay;
3361     gb_tty->port.closing_wait = closing_wait;
3362     diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c
3363     index c26c99fd4a24a..1e10fe204d3bd 100644
3364     --- a/drivers/staging/media/omap4iss/iss.c
3365     +++ b/drivers/staging/media/omap4iss/iss.c
3366     @@ -1244,8 +1244,10 @@ static int iss_probe(struct platform_device *pdev)
3367     if (ret < 0)
3368     goto error;
3369    
3370     - if (!omap4iss_get(iss))
3371     + if (!omap4iss_get(iss)) {
3372     + ret = -EINVAL;
3373     goto error;
3374     + }
3375    
3376     ret = iss_reset(iss);
3377     if (ret < 0)
3378     diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
3379     index fa4c47c7d2166..53b77c8ae328a 100644
3380     --- a/drivers/staging/rtl8192u/r8192U_core.c
3381     +++ b/drivers/staging/rtl8192u/r8192U_core.c
3382     @@ -3420,7 +3420,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
3383     u32 *TotalRxDataNum)
3384     {
3385     u16 SlotIndex;
3386     - u8 i;
3387     + u16 i;
3388    
3389     *TotalRxBcnNum = 0;
3390     *TotalRxDataNum = 0;
3391     diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
3392     index 079db0bd39174..089ba39f76a23 100644
3393     --- a/drivers/target/target_core_pscsi.c
3394     +++ b/drivers/target/target_core_pscsi.c
3395     @@ -629,8 +629,9 @@ static void pscsi_transport_complete(struct se_cmd *cmd, struct scatterlist *sg,
3396     unsigned char *buf;
3397    
3398     buf = transport_kmap_data_sg(cmd);
3399     - if (!buf)
3400     + if (!buf) {
3401     ; /* XXX: TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE */
3402     + }
3403    
3404     if (cdb[0] == MODE_SENSE_10) {
3405     if (!(buf[3] & 0x80))
3406     diff --git a/drivers/thermal/fair_share.c b/drivers/thermal/fair_share.c
3407     index 68bd1b5691185..da01b128c9a21 100644
3408     --- a/drivers/thermal/fair_share.c
3409     +++ b/drivers/thermal/fair_share.c
3410     @@ -93,6 +93,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
3411     int total_instance = 0;
3412     int cur_trip_level = get_trip_level(tz);
3413    
3414     + mutex_lock(&tz->lock);
3415     +
3416     list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
3417     if (instance->trip != trip)
3418     continue;
3419     @@ -121,6 +123,8 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
3420     mutex_unlock(&instance->cdev->lock);
3421     thermal_cdev_update(cdev);
3422     }
3423     +
3424     + mutex_unlock(&tz->lock);
3425     return 0;
3426     }
3427    
3428     diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
3429     index ea8b591dd46f4..f325019887b23 100644
3430     --- a/drivers/tty/serial/stm32-usart.c
3431     +++ b/drivers/tty/serial/stm32-usart.c
3432     @@ -476,8 +476,9 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
3433     unsigned int baud;
3434     u32 usartdiv, mantissa, fraction, oversampling;
3435     tcflag_t cflag = termios->c_cflag;
3436     - u32 cr1, cr2, cr3;
3437     + u32 cr1, cr2, cr3, isr;
3438     unsigned long flags;
3439     + int ret;
3440    
3441     if (!stm32_port->hw_flow_control)
3442     cflag &= ~CRTSCTS;
3443     @@ -486,6 +487,15 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios,
3444    
3445     spin_lock_irqsave(&port->lock, flags);
3446    
3447     + ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr,
3448     + isr,
3449     + (isr & USART_SR_TC),
3450     + 10, 100000);
3451     +
3452     + /* Send the TC error message only when ISR_TC is not set. */
3453     + if (ret)
3454     + dev_err(port->dev, "Transmission is not complete\n");
3455     +
3456     /* Stop serial port and reset value */
3457     writel_relaxed(0, port->membase + ofs->cr1);
3458    
3459     diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
3460     index 7b4aca20cb299..e16a74b68cd0f 100644
3461     --- a/drivers/tty/tty_io.c
3462     +++ b/drivers/tty/tty_io.c
3463     @@ -2791,14 +2791,14 @@ out:
3464     * @p: pointer to result
3465     *
3466     * Obtain the modem status bits from the tty driver if the feature
3467     - * is supported. Return -EINVAL if it is not available.
3468     + * is supported. Return -ENOTTY if it is not available.
3469     *
3470     * Locking: none (up to the driver)
3471     */
3472    
3473     static int tty_tiocmget(struct tty_struct *tty, int __user *p)
3474     {
3475     - int retval = -EINVAL;
3476     + int retval = -ENOTTY;
3477    
3478     if (tty->ops->tiocmget) {
3479     retval = tty->ops->tiocmget(tty);
3480     @@ -2816,7 +2816,7 @@ static int tty_tiocmget(struct tty_struct *tty, int __user *p)
3481     * @p: pointer to desired bits
3482     *
3483     * Set the modem status bits from the tty driver if the feature
3484     - * is supported. Return -EINVAL if it is not available.
3485     + * is supported. Return -ENOTTY if it is not available.
3486     *
3487     * Locking: none (up to the driver)
3488     */
3489     @@ -2828,7 +2828,7 @@ static int tty_tiocmset(struct tty_struct *tty, unsigned int cmd,
3490     unsigned int set, clear, val;
3491    
3492     if (tty->ops->tiocmset == NULL)
3493     - return -EINVAL;
3494     + return -ENOTTY;
3495    
3496     retval = get_user(val, p);
3497     if (retval)
3498     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
3499     index 97b5b021a2200..a70d2341ada63 100644
3500     --- a/drivers/usb/class/cdc-acm.c
3501     +++ b/drivers/usb/class/cdc-acm.c
3502     @@ -870,8 +870,6 @@ static int set_serial_info(struct acm *acm,
3503     if ((new_serial.close_delay != old_close_delay) ||
3504     (new_serial.closing_wait != old_closing_wait))
3505     retval = -EPERM;
3506     - else
3507     - retval = -EOPNOTSUPP;
3508     } else {
3509     acm->port.close_delay = close_delay;
3510     acm->port.closing_wait = closing_wait;
3511     diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3512     index 238dfe0f6e80a..df9fd9b95f22c 100644
3513     --- a/drivers/usb/core/hub.c
3514     +++ b/drivers/usb/core/hub.c
3515     @@ -3486,9 +3486,6 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3516     * sequence.
3517     */
3518     status = hub_port_status(hub, port1, &portstatus, &portchange);
3519     -
3520     - /* TRSMRCY = 10 msec */
3521     - msleep(10);
3522     }
3523    
3524     SuspendCleared:
3525     @@ -3503,6 +3500,9 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
3526     usb_clear_port_feature(hub->hdev, port1,
3527     USB_PORT_FEAT_C_SUSPEND);
3528     }
3529     +
3530     + /* TRSMRCY = 10 msec */
3531     + msleep(10);
3532     }
3533    
3534     if (udev->persist_enabled)
3535     diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
3536     index cd43e11d74f34..3dfd584a1ef3d 100644
3537     --- a/drivers/usb/core/quirks.c
3538     +++ b/drivers/usb/core/quirks.c
3539     @@ -245,6 +245,7 @@ static const struct usb_device_id usb_quirk_list[] = {
3540    
3541     /* Realtek hub in Dell WD19 (Type-C) */
3542     { USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM },
3543     + { USB_DEVICE(0x0bda, 0x5487), .driver_info = USB_QUIRK_RESET_RESUME },
3544    
3545     /* Generic RTL8153 based ethernet adapters */
3546     { USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM },
3547     @@ -264,6 +265,9 @@ static const struct usb_device_id usb_quirk_list[] = {
3548     { USB_DEVICE(0x1532, 0x0116), .driver_info =
3549     USB_QUIRK_LINEAR_UFRAME_INTR_BINTERVAL },
3550    
3551     + /* Lenovo ThinkPad USB-C Dock Gen2 Ethernet (RTL8153 GigE) */
3552     + { USB_DEVICE(0x17ef, 0xa387), .driver_info = USB_QUIRK_NO_LPM },
3553     +
3554     /* BUILDWIN Photo Frame */
3555     { USB_DEVICE(0x1908, 0x1315), .driver_info =
3556     USB_QUIRK_HONOR_BNUMINTERFACES },
3557     diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
3558     index 0f45a2f165e5d..1bb8b1e22ed35 100644
3559     --- a/drivers/usb/dwc2/core.h
3560     +++ b/drivers/usb/dwc2/core.h
3561     @@ -164,6 +164,7 @@ struct dwc2_hsotg_req;
3562     * @lock: State lock to protect contents of endpoint.
3563     * @dir_in: Set to true if this endpoint is of the IN direction, which
3564     * means that it is sending data to the Host.
3565     + * @map_dir: Set to the value of dir_in when the DMA buffer is mapped.
3566     * @index: The index for the endpoint registers.
3567     * @mc: Multi Count - number of transactions per microframe
3568     * @interval - Interval for periodic endpoints, in frames or microframes.
3569     @@ -207,6 +208,7 @@ struct dwc2_hsotg_ep {
3570     unsigned short fifo_index;
3571    
3572     unsigned char dir_in;
3573     + unsigned char map_dir;
3574     unsigned char index;
3575     unsigned char mc;
3576     u16 interval;
3577     diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
3578     index 6bde5db1490a1..e7ad3ae4ea6bd 100644
3579     --- a/drivers/usb/dwc2/gadget.c
3580     +++ b/drivers/usb/dwc2/gadget.c
3581     @@ -308,7 +308,7 @@ static void dwc2_hsotg_unmap_dma(struct dwc2_hsotg *hsotg,
3582     if (hs_req->req.length == 0)
3583     return;
3584    
3585     - usb_gadget_unmap_request(&hsotg->gadget, req, hs_ep->dir_in);
3586     + usb_gadget_unmap_request(&hsotg->gadget, req, hs_ep->map_dir);
3587     }
3588    
3589     /**
3590     @@ -745,6 +745,7 @@ static int dwc2_hsotg_map_dma(struct dwc2_hsotg *hsotg,
3591     if (hs_req->req.length == 0)
3592     return 0;
3593    
3594     + hs_ep->map_dir = hs_ep->dir_in;
3595     ret = usb_gadget_map_request(&hsotg->gadget, req, hs_ep->dir_in);
3596     if (ret)
3597     goto dma_error;
3598     diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
3599     index e0fb7b3723c53..cca51553e0fb0 100644
3600     --- a/drivers/usb/dwc3/gadget.c
3601     +++ b/drivers/usb/dwc3/gadget.c
3602     @@ -2409,6 +2409,15 @@ static void dwc3_gadget_reset_interrupt(struct dwc3 *dwc)
3603    
3604     dwc->connected = true;
3605    
3606     + /*
3607     + * Ideally, dwc3_reset_gadget() would trigger the function
3608     + * drivers to stop any active transfers through ep disable.
3609     + * However, for functions which defer ep disable, such as mass
3610     + * storage, we will need to rely on the call to stop active
3611     + * transfers here, and avoid allowing of request queuing.
3612     + */
3613     + dwc->connected = false;
3614     +
3615     /*
3616     * WORKAROUND: DWC3 revisions <1.88a have an issue which
3617     * would cause a missing Disconnect Event if there's a
3618     diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c
3619     index 17a6077b89a49..9b9d31eb6037f 100644
3620     --- a/drivers/usb/gadget/config.c
3621     +++ b/drivers/usb/gadget/config.c
3622     @@ -198,9 +198,13 @@ EXPORT_SYMBOL_GPL(usb_assign_descriptors);
3623     void usb_free_all_descriptors(struct usb_function *f)
3624     {
3625     usb_free_descriptors(f->fs_descriptors);
3626     + f->fs_descriptors = NULL;
3627     usb_free_descriptors(f->hs_descriptors);
3628     + f->hs_descriptors = NULL;
3629     usb_free_descriptors(f->ss_descriptors);
3630     + f->ss_descriptors = NULL;
3631     usb_free_descriptors(f->ssp_descriptors);
3632     + f->ssp_descriptors = NULL;
3633     }
3634     EXPORT_SYMBOL_GPL(usb_free_all_descriptors);
3635    
3636     diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
3637     index 26fcbb92c4ba7..bcb2daf81b05d 100644
3638     --- a/drivers/usb/gadget/function/f_fs.c
3639     +++ b/drivers/usb/gadget/function/f_fs.c
3640     @@ -2543,6 +2543,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
3641    
3642     do { /* lang_count > 0 so we can use do-while */
3643     unsigned needed = needed_count;
3644     + u32 str_per_lang = str_count;
3645    
3646     if (unlikely(len < 3))
3647     goto error_free;
3648     @@ -2578,7 +2579,7 @@ static int __ffs_data_got_strings(struct ffs_data *ffs,
3649    
3650     data += length + 1;
3651     len -= length + 1;
3652     - } while (--str_count);
3653     + } while (--str_per_lang);
3654    
3655     s->id = 0; /* terminator */
3656     s->s = NULL;
3657     diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c
3658     index f8a1881609a2c..89da34ef7b3fe 100644
3659     --- a/drivers/usb/gadget/function/f_uvc.c
3660     +++ b/drivers/usb/gadget/function/f_uvc.c
3661     @@ -625,7 +625,12 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f)
3662    
3663     uvc_hs_streaming_ep.wMaxPacketSize =
3664     cpu_to_le16(max_packet_size | ((max_packet_mult - 1) << 11));
3665     - uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
3666     +
3667     + /* A high-bandwidth endpoint must specify a bInterval value of 1 */
3668     + if (max_packet_mult > 1)
3669     + uvc_hs_streaming_ep.bInterval = 1;
3670     + else
3671     + uvc_hs_streaming_ep.bInterval = opts->streaming_interval;
3672    
3673     uvc_ss_streaming_ep.wMaxPacketSize = cpu_to_le16(max_packet_size);
3674     uvc_ss_streaming_ep.bInterval = opts->streaming_interval;
3675     diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
3676     index 9fdb567a09be6..8b16f0200d59b 100644
3677     --- a/drivers/usb/gadget/udc/dummy_hcd.c
3678     +++ b/drivers/usb/gadget/udc/dummy_hcd.c
3679     @@ -918,6 +918,21 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value)
3680     spin_lock_irqsave(&dum->lock, flags);
3681     dum->pullup = (value != 0);
3682     set_link_state(dum_hcd);
3683     + if (value == 0) {
3684     + /*
3685     + * Emulate synchronize_irq(): wait for callbacks to finish.
3686     + * This seems to be the best place to emulate the call to
3687     + * synchronize_irq() that's in usb_gadget_remove_driver().
3688     + * Doing it in dummy_udc_stop() would be too late since it
3689     + * is called after the unbind callback and unbind shouldn't
3690     + * be invoked until all the other callbacks are finished.
3691     + */
3692     + while (dum->callback_usage > 0) {
3693     + spin_unlock_irqrestore(&dum->lock, flags);
3694     + usleep_range(1000, 2000);
3695     + spin_lock_irqsave(&dum->lock, flags);
3696     + }
3697     + }
3698     spin_unlock_irqrestore(&dum->lock, flags);
3699    
3700     usb_hcd_poll_rh_status(dummy_hcd_to_hcd(dum_hcd));
3701     @@ -998,14 +1013,6 @@ static int dummy_udc_stop(struct usb_gadget *g)
3702     spin_lock_irq(&dum->lock);
3703     dum->ints_enabled = 0;
3704     stop_activity(dum);
3705     -
3706     - /* emulate synchronize_irq(): wait for callbacks to finish */
3707     - while (dum->callback_usage > 0) {
3708     - spin_unlock_irq(&dum->lock);
3709     - usleep_range(1000, 2000);
3710     - spin_lock_irq(&dum->lock);
3711     - }
3712     -
3713     dum->driver = NULL;
3714     spin_unlock_irq(&dum->lock);
3715    
3716     diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
3717     index 76e991557116a..9e102ba9cf66a 100644
3718     --- a/drivers/usb/gadget/udc/fotg210-udc.c
3719     +++ b/drivers/usb/gadget/udc/fotg210-udc.c
3720     @@ -340,15 +340,16 @@ static void fotg210_start_dma(struct fotg210_ep *ep,
3721     } else {
3722     buffer = req->req.buf + req->req.actual;
3723     length = ioread32(ep->fotg210->reg +
3724     - FOTG210_FIBCR(ep->epnum - 1));
3725     - length &= FIBCR_BCFX;
3726     + FOTG210_FIBCR(ep->epnum - 1)) & FIBCR_BCFX;
3727     + if (length > req->req.length - req->req.actual)
3728     + length = req->req.length - req->req.actual;
3729     }
3730     } else {
3731     buffer = req->req.buf + req->req.actual;
3732     if (req->req.length - req->req.actual > ep->ep.maxpacket)
3733     length = ep->ep.maxpacket;
3734     else
3735     - length = req->req.length;
3736     + length = req->req.length - req->req.actual;
3737     }
3738    
3739     d = dma_map_single(NULL, buffer, length,
3740     @@ -385,8 +386,7 @@ static void fotg210_ep0_queue(struct fotg210_ep *ep,
3741     }
3742     if (ep->dir_in) { /* if IN */
3743     fotg210_start_dma(ep, req);
3744     - if ((req->req.length == req->req.actual) ||
3745     - (req->req.actual < ep->ep.maxpacket))
3746     + if (req->req.length == req->req.actual)
3747     fotg210_done(ep, req, 0);
3748     } else { /* OUT */
3749     u32 value = ioread32(ep->fotg210->reg + FOTG210_DMISGR0);
3750     @@ -827,7 +827,7 @@ static void fotg210_ep0in(struct fotg210_udc *fotg210)
3751     if (req->req.length)
3752     fotg210_start_dma(ep, req);
3753    
3754     - if ((req->req.length - req->req.actual) < ep->ep.maxpacket)
3755     + if (req->req.actual == req->req.length)
3756     fotg210_done(ep, req, 0);
3757     } else {
3758     fotg210_set_cxdone(fotg210);
3759     @@ -856,12 +856,16 @@ static void fotg210_out_fifo_handler(struct fotg210_ep *ep)
3760     {
3761     struct fotg210_request *req = list_entry(ep->queue.next,
3762     struct fotg210_request, queue);
3763     + int disgr1 = ioread32(ep->fotg210->reg + FOTG210_DISGR1);
3764    
3765     fotg210_start_dma(ep, req);
3766    
3767     - /* finish out transfer */
3768     + /* Complete the request when it's full or a short packet arrived.
3769     + * Like other drivers, short_not_ok isn't handled.
3770     + */
3771     +
3772     if (req->req.length == req->req.actual ||
3773     - req->req.actual < ep->ep.maxpacket)
3774     + (disgr1 & DISGR1_SPK_INT(ep->epnum - 1)))
3775     fotg210_done(ep, req, 0);
3776     }
3777    
3778     @@ -1034,6 +1038,12 @@ static void fotg210_init(struct fotg210_udc *fotg210)
3779     value &= ~DMCR_GLINT_EN;
3780     iowrite32(value, fotg210->reg + FOTG210_DMCR);
3781    
3782     + /* enable only grp2 irqs we handle */
3783     + iowrite32(~(DISGR2_DMA_ERROR | DISGR2_RX0BYTE_INT | DISGR2_TX0BYTE_INT
3784     + | DISGR2_ISO_SEQ_ABORT_INT | DISGR2_ISO_SEQ_ERR_INT
3785     + | DISGR2_RESM_INT | DISGR2_SUSP_INT | DISGR2_USBRST_INT),
3786     + fotg210->reg + FOTG210_DMISGR2);
3787     +
3788     /* disable all fifo interrupt */
3789     iowrite32(~(u32)0, fotg210->reg + FOTG210_DMISGR1);
3790    
3791     diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c
3792     index 8a365aad66fe2..18ce19162804b 100644
3793     --- a/drivers/usb/gadget/udc/pch_udc.c
3794     +++ b/drivers/usb/gadget/udc/pch_udc.c
3795     @@ -604,18 +604,22 @@ static void pch_udc_reconnect(struct pch_udc_dev *dev)
3796     static inline void pch_udc_vbus_session(struct pch_udc_dev *dev,
3797     int is_active)
3798     {
3799     + unsigned long iflags;
3800     +
3801     + spin_lock_irqsave(&dev->lock, iflags);
3802     if (is_active) {
3803     pch_udc_reconnect(dev);
3804     dev->vbus_session = 1;
3805     } else {
3806     if (dev->driver && dev->driver->disconnect) {
3807     - spin_lock(&dev->lock);
3808     + spin_unlock_irqrestore(&dev->lock, iflags);
3809     dev->driver->disconnect(&dev->gadget);
3810     - spin_unlock(&dev->lock);
3811     + spin_lock_irqsave(&dev->lock, iflags);
3812     }
3813     pch_udc_set_disconnect(dev);
3814     dev->vbus_session = 0;
3815     }
3816     + spin_unlock_irqrestore(&dev->lock, iflags);
3817     }
3818    
3819     /**
3820     @@ -1172,20 +1176,25 @@ static int pch_udc_pcd_selfpowered(struct usb_gadget *gadget, int value)
3821     static int pch_udc_pcd_pullup(struct usb_gadget *gadget, int is_on)
3822     {
3823     struct pch_udc_dev *dev;
3824     + unsigned long iflags;
3825    
3826     if (!gadget)
3827     return -EINVAL;
3828     +
3829     dev = container_of(gadget, struct pch_udc_dev, gadget);
3830     +
3831     + spin_lock_irqsave(&dev->lock, iflags);
3832     if (is_on) {
3833     pch_udc_reconnect(dev);
3834     } else {
3835     if (dev->driver && dev->driver->disconnect) {
3836     - spin_lock(&dev->lock);
3837     + spin_unlock_irqrestore(&dev->lock, iflags);
3838     dev->driver->disconnect(&dev->gadget);
3839     - spin_unlock(&dev->lock);
3840     + spin_lock_irqsave(&dev->lock, iflags);
3841     }
3842     pch_udc_set_disconnect(dev);
3843     }
3844     + spin_unlock_irqrestore(&dev->lock, iflags);
3845    
3846     return 0;
3847     }
3848     @@ -1777,7 +1786,7 @@ static struct usb_request *pch_udc_alloc_request(struct usb_ep *usbep,
3849     }
3850     /* prevent from using desc. - set HOST BUSY */
3851     dma_desc->status |= PCH_UDC_BS_HST_BSY;
3852     - dma_desc->dataptr = cpu_to_le32(DMA_ADDR_INVALID);
3853     + dma_desc->dataptr = lower_32_bits(DMA_ADDR_INVALID);
3854     req->td_data = dma_desc;
3855     req->td_data_last = dma_desc;
3856     req->chain_len = 1;
3857     @@ -2320,6 +2329,21 @@ static void pch_udc_svc_data_out(struct pch_udc_dev *dev, int ep_num)
3858     pch_udc_set_dma(dev, DMA_DIR_RX);
3859     }
3860    
3861     +static int pch_udc_gadget_setup(struct pch_udc_dev *dev)
3862     + __must_hold(&dev->lock)
3863     +{
3864     + int rc;
3865     +
3866     + /* In some cases we can get an interrupt before driver gets setup */
3867     + if (!dev->driver)
3868     + return -ESHUTDOWN;
3869     +
3870     + spin_unlock(&dev->lock);
3871     + rc = dev->driver->setup(&dev->gadget, &dev->setup_data);
3872     + spin_lock(&dev->lock);
3873     + return rc;
3874     +}
3875     +
3876     /**
3877     * pch_udc_svc_control_in() - Handle Control IN endpoint interrupts
3878     * @dev: Reference to the device structure
3879     @@ -2391,15 +2415,12 @@ static void pch_udc_svc_control_out(struct pch_udc_dev *dev)
3880     dev->gadget.ep0 = &dev->ep[UDC_EP0IN_IDX].ep;
3881     else /* OUT */
3882     dev->gadget.ep0 = &ep->ep;
3883     - spin_lock(&dev->lock);
3884     /* If Mass storage Reset */
3885     if ((dev->setup_data.bRequestType == 0x21) &&
3886     (dev->setup_data.bRequest == 0xFF))
3887     dev->prot_stall = 0;
3888     /* call gadget with setup data received */
3889     - setup_supported = dev->driver->setup(&dev->gadget,
3890     - &dev->setup_data);
3891     - spin_unlock(&dev->lock);
3892     + setup_supported = pch_udc_gadget_setup(dev);
3893    
3894     if (dev->setup_data.bRequestType & USB_DIR_IN) {
3895     ep->td_data->status = (ep->td_data->status &
3896     @@ -2647,9 +2668,7 @@ static void pch_udc_svc_intf_interrupt(struct pch_udc_dev *dev)
3897     dev->ep[i].halted = 0;
3898     }
3899     dev->stall = 0;
3900     - spin_unlock(&dev->lock);
3901     - dev->driver->setup(&dev->gadget, &dev->setup_data);
3902     - spin_lock(&dev->lock);
3903     + pch_udc_gadget_setup(dev);
3904     }
3905    
3906     /**
3907     @@ -2684,9 +2703,7 @@ static void pch_udc_svc_cfg_interrupt(struct pch_udc_dev *dev)
3908     dev->stall = 0;
3909    
3910     /* call gadget zero with setup data received */
3911     - spin_unlock(&dev->lock);
3912     - dev->driver->setup(&dev->gadget, &dev->setup_data);
3913     - spin_lock(&dev->lock);
3914     + pch_udc_gadget_setup(dev);
3915     }
3916    
3917     /**
3918     @@ -2960,7 +2977,7 @@ static int init_dma_pools(struct pch_udc_dev *dev)
3919     dev->dma_addr = dma_map_single(&dev->pdev->dev, ep0out_buf,
3920     UDC_EP0OUT_BUFF_SIZE * 4,
3921     DMA_FROM_DEVICE);
3922     - return 0;
3923     + return dma_mapping_error(&dev->pdev->dev, dev->dma_addr);
3924     }
3925    
3926     static int pch_udc_start(struct usb_gadget *g,
3927     diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
3928     index 230e3248f3860..80503c3604ca5 100644
3929     --- a/drivers/usb/gadget/udc/r8a66597-udc.c
3930     +++ b/drivers/usb/gadget/udc/r8a66597-udc.c
3931     @@ -1855,6 +1855,8 @@ static int r8a66597_probe(struct platform_device *pdev)
3932     return PTR_ERR(reg);
3933    
3934     ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
3935     + if (!ires)
3936     + return -EINVAL;
3937     irq = ires->start;
3938     irq_trigger = ires->flags & IRQF_TRIGGER_MASK;
3939    
3940     diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
3941     index 72853020a5426..15249e664b89e 100644
3942     --- a/drivers/usb/host/fotg210-hcd.c
3943     +++ b/drivers/usb/host/fotg210-hcd.c
3944     @@ -5599,7 +5599,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
3945     struct usb_hcd *hcd;
3946     struct resource *res;
3947     int irq;
3948     - int retval = -ENODEV;
3949     + int retval;
3950     struct fotg210_hcd *fotg210;
3951    
3952     if (usb_disabled())
3953     @@ -5619,7 +5619,7 @@ static int fotg210_hcd_probe(struct platform_device *pdev)
3954     hcd = usb_create_hcd(&fotg210_fotg210_hc_driver, dev,
3955     dev_name(dev));
3956     if (!hcd) {
3957     - dev_err(dev, "failed to create hcd with err %d\n", retval);
3958     + dev_err(dev, "failed to create hcd\n");
3959     retval = -ENOMEM;
3960     goto fail_create_hcd;
3961     }
3962     diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
3963     index fd2a11473be79..455c59fe32fa7 100644
3964     --- a/drivers/usb/host/sl811-hcd.c
3965     +++ b/drivers/usb/host/sl811-hcd.c
3966     @@ -1286,11 +1286,10 @@ sl811h_hub_control(
3967     goto error;
3968     put_unaligned_le32(sl811->port1, buf);
3969    
3970     -#ifndef VERBOSE
3971     - if (*(u16*)(buf+2)) /* only if wPortChange is interesting */
3972     -#endif
3973     - dev_dbg(hcd->self.controller, "GetPortStatus %08x\n",
3974     - sl811->port1);
3975     + if (__is_defined(VERBOSE) ||
3976     + *(u16*)(buf+2)) /* only if wPortChange is interesting */
3977     + dev_dbg(hcd->self.controller, "GetPortStatus %08x\n",
3978     + sl811->port1);
3979     break;
3980     case SetPortFeature:
3981     if (wIndex != 1 || wLength != 0)
3982     diff --git a/drivers/usb/host/xhci-ext-caps.h b/drivers/usb/host/xhci-ext-caps.h
3983     index e0244fb3903dc..1e9b2ed83da24 100644
3984     --- a/drivers/usb/host/xhci-ext-caps.h
3985     +++ b/drivers/usb/host/xhci-ext-caps.h
3986     @@ -19,8 +19,9 @@
3987     * along with this program; if not, write to the Free Software Foundation,
3988     * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
3989     */
3990     -/* Up to 16 ms to halt an HC */
3991     -#define XHCI_MAX_HALT_USEC (16*1000)
3992     +
3993     +/* HC should halt within 16 ms, but use 32 ms as some hosts take longer */
3994     +#define XHCI_MAX_HALT_USEC (32 * 1000)
3995     /* HC not running - set to 1 when run/stop bit is cleared. */
3996     #define XHCI_STS_HALT (1<<0)
3997    
3998     diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
3999     index 3cca60b845a86..9b30936904da7 100644
4000     --- a/drivers/usb/host/xhci-mem.c
4001     +++ b/drivers/usb/host/xhci-mem.c
4002     @@ -2159,6 +2159,15 @@ static void xhci_add_in_port(struct xhci_hcd *xhci, unsigned int num_ports,
4003    
4004     if (major_revision == 0x03) {
4005     rhub = &xhci->usb3_rhub;
4006     + /*
4007     + * Some hosts incorrectly use sub-minor version for minor
4008     + * version (i.e. 0x02 instead of 0x20 for bcdUSB 0x320 and 0x01
4009     + * for bcdUSB 0x310). Since there is no USB release with sub
4010     + * minor version 0x301 to 0x309, we can assume that they are
4011     + * incorrect and fix it here.
4012     + */
4013     + if (minor_revision > 0x00 && minor_revision < 0x10)
4014     + minor_revision <<= 4;
4015     } else if (major_revision <= 0x02) {
4016     rhub = &xhci->usb2_rhub;
4017     } else {
4018     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
4019     index 809f5f2b0dd9f..ec00eff017942 100644
4020     --- a/drivers/usb/host/xhci.c
4021     +++ b/drivers/usb/host/xhci.c
4022     @@ -1309,7 +1309,7 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci,
4023     * we need to issue an evaluate context command and wait on it.
4024     */
4025     static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
4026     - unsigned int ep_index, struct urb *urb)
4027     + unsigned int ep_index, struct urb *urb, gfp_t mem_flags)
4028     {
4029     struct xhci_container_ctx *out_ctx;
4030     struct xhci_input_control_ctx *ctrl_ctx;
4031     @@ -1340,7 +1340,7 @@ static int xhci_check_maxpacket(struct xhci_hcd *xhci, unsigned int slot_id,
4032     * changes max packet sizes.
4033     */
4034    
4035     - command = xhci_alloc_command(xhci, false, true, GFP_KERNEL);
4036     + command = xhci_alloc_command(xhci, false, true, mem_flags);
4037     if (!command)
4038     return -ENOMEM;
4039    
4040     @@ -1447,7 +1447,7 @@ int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags)
4041     */
4042     if (urb->dev->speed == USB_SPEED_FULL) {
4043     ret = xhci_check_maxpacket(xhci, slot_id,
4044     - ep_index, urb);
4045     + ep_index, urb, mem_flags);
4046     if (ret < 0) {
4047     xhci_urb_free_priv(urb_priv);
4048     urb->hcpriv = NULL;
4049     diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
4050     index 2811c4afde01c..e8ea768481049 100644
4051     --- a/drivers/video/fbdev/core/fbcmap.c
4052     +++ b/drivers/video/fbdev/core/fbcmap.c
4053     @@ -101,17 +101,17 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
4054     if (!len)
4055     return 0;
4056    
4057     - cmap->red = kmalloc(size, flags);
4058     + cmap->red = kzalloc(size, flags);
4059     if (!cmap->red)
4060     goto fail;
4061     - cmap->green = kmalloc(size, flags);
4062     + cmap->green = kzalloc(size, flags);
4063     if (!cmap->green)
4064     goto fail;
4065     - cmap->blue = kmalloc(size, flags);
4066     + cmap->blue = kzalloc(size, flags);
4067     if (!cmap->blue)
4068     goto fail;
4069     if (transp) {
4070     - cmap->transp = kmalloc(size, flags);
4071     + cmap->transp = kzalloc(size, flags);
4072     if (!cmap->transp)
4073     goto fail;
4074     } else {
4075     diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
4076     index ebca009030c3a..cb6e1ce1e25f5 100644
4077     --- a/fs/btrfs/ioctl.c
4078     +++ b/fs/btrfs/ioctl.c
4079     @@ -557,8 +557,6 @@ static noinline int create_subvol(struct inode *dir,
4080     btrfs_set_root_otransid(root_item, trans->transid);
4081    
4082     btrfs_tree_unlock(leaf);
4083     - free_extent_buffer(leaf);
4084     - leaf = NULL;
4085    
4086     btrfs_set_root_dirid(root_item, new_dirid);
4087    
4088     @@ -567,8 +565,22 @@ static noinline int create_subvol(struct inode *dir,
4089     key.type = BTRFS_ROOT_ITEM_KEY;
4090     ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key,
4091     root_item);
4092     - if (ret)
4093     + if (ret) {
4094     + /*
4095     + * Since we don't abort the transaction in this case, free the
4096     + * tree block so that we don't leak space and leave the
4097     + * filesystem in an inconsistent state (an extent item in the
4098     + * extent tree without backreferences). Also no need to have
4099     + * the tree block locked since it is not in any tree at this
4100     + * point, so no other task can find it and use it.
4101     + */
4102     + btrfs_free_tree_block(trans, root, leaf, 0, 1);
4103     + free_extent_buffer(leaf);
4104     goto fail;
4105     + }
4106     +
4107     + free_extent_buffer(leaf);
4108     + leaf = NULL;
4109    
4110     key.offset = (u64)-1;
4111     new_root = btrfs_read_fs_root_no_name(root->fs_info, &key);
4112     diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
4113     index cd5b86d80e7a0..5caf4dbdd8017 100644
4114     --- a/fs/btrfs/relocation.c
4115     +++ b/fs/btrfs/relocation.c
4116     @@ -1801,8 +1801,8 @@ int replace_path(struct btrfs_trans_handle *trans,
4117     int ret;
4118     int slot;
4119    
4120     - BUG_ON(src->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
4121     - BUG_ON(dest->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
4122     + ASSERT(src->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID);
4123     + ASSERT(dest->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID);
4124    
4125     last_snapshot = btrfs_root_last_snapshot(&src->root_item);
4126     again:
4127     @@ -1834,7 +1834,7 @@ again:
4128     parent = eb;
4129     while (1) {
4130     level = btrfs_header_level(parent);
4131     - BUG_ON(level < lowest_level);
4132     + ASSERT(level >= lowest_level);
4133    
4134     ret = btrfs_bin_search(parent, &key, level, &slot);
4135     if (ret && slot > 0)
4136     diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
4137     index 2a351821d8f32..0eb2ada032c74 100644
4138     --- a/fs/ceph/caps.c
4139     +++ b/fs/ceph/caps.c
4140     @@ -1577,6 +1577,7 @@ static int try_nonblocking_invalidate(struct inode *inode)
4141     u32 invalidating_gen = ci->i_rdcache_gen;
4142    
4143     spin_unlock(&ci->i_ceph_lock);
4144     + ceph_fscache_invalidate(inode);
4145     invalidate_mapping_pages(&inode->i_data, 0, -1);
4146     spin_lock(&ci->i_ceph_lock);
4147    
4148     diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
4149     index 049cff197d2a1..5e12ea92f7cdb 100644
4150     --- a/fs/ceph/inode.c
4151     +++ b/fs/ceph/inode.c
4152     @@ -1762,6 +1762,7 @@ static void ceph_invalidate_work(struct work_struct *work)
4153     orig_gen = ci->i_rdcache_gen;
4154     spin_unlock(&ci->i_ceph_lock);
4155    
4156     + ceph_fscache_invalidate(inode);
4157     if (invalidate_inode_pages2(inode->i_mapping) < 0) {
4158     pr_err("invalidate_pages %p fails\n", inode);
4159     }
4160     diff --git a/fs/dlm/debug_fs.c b/fs/dlm/debug_fs.c
4161     index 466f7d60edc27..fabce23fdbacc 100644
4162     --- a/fs/dlm/debug_fs.c
4163     +++ b/fs/dlm/debug_fs.c
4164     @@ -545,6 +545,7 @@ static void *table_seq_next(struct seq_file *seq, void *iter_ptr, loff_t *pos)
4165    
4166     if (bucket >= ls->ls_rsbtbl_size) {
4167     kfree(ri);
4168     + ++*pos;
4169     return NULL;
4170     }
4171     tree = toss ? &ls->ls_rsbtbl[bucket].toss : &ls->ls_rsbtbl[bucket].keep;
4172     diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
4173     index 151872dcc1f40..7468f2753e992 100644
4174     --- a/fs/ecryptfs/main.c
4175     +++ b/fs/ecryptfs/main.c
4176     @@ -506,6 +506,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags
4177     goto out;
4178     }
4179    
4180     + if (!dev_name) {
4181     + rc = -EINVAL;
4182     + err = "Device name cannot be null";
4183     + goto out;
4184     + }
4185     +
4186     rc = ecryptfs_parse_options(sbi, raw_data, &check_ruid);
4187     if (rc) {
4188     err = "Error parsing options";
4189     diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
4190     index 2b699b1f42c00..11ebd274b7c00 100644
4191     --- a/fs/ext4/ialloc.c
4192     +++ b/fs/ext4/ialloc.c
4193     @@ -1286,6 +1286,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
4194     handle_t *handle;
4195     ext4_fsblk_t blk;
4196     int num, ret = 0, used_blks = 0;
4197     + unsigned long used_inos = 0;
4198    
4199     /* This should not happen, but just to be sure check this */
4200     if (sb->s_flags & MS_RDONLY) {
4201     @@ -1316,22 +1317,37 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group,
4202     * used inodes so we need to skip blocks with used inodes in
4203     * inode table.
4204     */
4205     - if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)))
4206     - used_blks = DIV_ROUND_UP((EXT4_INODES_PER_GROUP(sb) -
4207     - ext4_itable_unused_count(sb, gdp)),
4208     - sbi->s_inodes_per_block);
4209     -
4210     - if ((used_blks < 0) || (used_blks > sbi->s_itb_per_group) ||
4211     - ((group == 0) && ((EXT4_INODES_PER_GROUP(sb) -
4212     - ext4_itable_unused_count(sb, gdp)) <
4213     - EXT4_FIRST_INO(sb)))) {
4214     - ext4_error(sb, "Something is wrong with group %u: "
4215     - "used itable blocks: %d; "
4216     - "itable unused count: %u",
4217     - group, used_blks,
4218     - ext4_itable_unused_count(sb, gdp));
4219     - ret = 1;
4220     - goto err_out;
4221     + if (!(gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT))) {
4222     + used_inos = EXT4_INODES_PER_GROUP(sb) -
4223     + ext4_itable_unused_count(sb, gdp);
4224     + used_blks = DIV_ROUND_UP(used_inos, sbi->s_inodes_per_block);
4225     +
4226     + /* Bogus inode unused count? */
4227     + if (used_blks < 0 || used_blks > sbi->s_itb_per_group) {
4228     + ext4_error(sb, "Something is wrong with group %u: "
4229     + "used itable blocks: %d; "
4230     + "itable unused count: %u",
4231     + group, used_blks,
4232     + ext4_itable_unused_count(sb, gdp));
4233     + ret = 1;
4234     + goto err_out;
4235     + }
4236     +
4237     + used_inos += group * EXT4_INODES_PER_GROUP(sb);
4238     + /*
4239     + * Are there some uninitialized inodes in the inode table
4240     + * before the first normal inode?
4241     + */
4242     + if ((used_blks != sbi->s_itb_per_group) &&
4243     + (used_inos < EXT4_FIRST_INO(sb))) {
4244     + ext4_error(sb, "Something is wrong with group %u: "
4245     + "itable unused count: %u; "
4246     + "itables initialized count: %ld",
4247     + group, ext4_itable_unused_count(sb, gdp),
4248     + used_inos);
4249     + ret = 1;
4250     + goto err_out;
4251     + }
4252     }
4253    
4254     blk = ext4_inode_table(sb, gdp) + used_blks;
4255     diff --git a/fs/ext4/super.c b/fs/ext4/super.c
4256     index f70c5541d718d..ca89590d1df57 100644
4257     --- a/fs/ext4/super.c
4258     +++ b/fs/ext4/super.c
4259     @@ -4678,8 +4678,10 @@ static int ext4_commit_super(struct super_block *sb, int sync)
4260     struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
4261     int error = 0;
4262    
4263     - if (!sbh || block_device_ejected(sb))
4264     - return error;
4265     + if (!sbh)
4266     + return -EINVAL;
4267     + if (block_device_ejected(sb))
4268     + return -ENODEV;
4269    
4270     /*
4271     * If the file system is mounted read-only, don't update the
4272     diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
4273     index 482888ee89429..481fae63f1630 100644
4274     --- a/fs/f2fs/inline.c
4275     +++ b/fs/f2fs/inline.c
4276     @@ -196,7 +196,8 @@ out:
4277    
4278     f2fs_put_page(page, 1);
4279    
4280     - f2fs_balance_fs(sbi, dn.node_changed);
4281     + if (!err)
4282     + f2fs_balance_fs(sbi, dn.node_changed);
4283    
4284     return err;
4285     }
4286     diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
4287     index d9aba97007267..b83367300f487 100644
4288     --- a/fs/fuse/cuse.c
4289     +++ b/fs/fuse/cuse.c
4290     @@ -616,6 +616,8 @@ static int __init cuse_init(void)
4291     cuse_channel_fops.owner = THIS_MODULE;
4292     cuse_channel_fops.open = cuse_channel_open;
4293     cuse_channel_fops.release = cuse_channel_release;
4294     + /* CUSE is not prepared for FUSE_DEV_IOC_CLONE */
4295     + cuse_channel_fops.unlocked_ioctl = NULL;
4296    
4297     cuse_class = class_create(THIS_MODULE, "cuse");
4298     if (IS_ERR(cuse_class))
4299     diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c
4300     index 406d9cc84ba8d..79e771ab624f4 100644
4301     --- a/fs/jffs2/compr_rtime.c
4302     +++ b/fs/jffs2/compr_rtime.c
4303     @@ -37,6 +37,9 @@ static int jffs2_rtime_compress(unsigned char *data_in,
4304     int outpos = 0;
4305     int pos=0;
4306    
4307     + if (*dstlen <= 3)
4308     + return -1;
4309     +
4310     memset(positions,0,sizeof(positions));
4311    
4312     while (pos < (*sourcelen) && outpos <= (*dstlen)-2) {
4313     diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
4314     index 90431dd613b8d..08813789fcf06 100644
4315     --- a/fs/jffs2/scan.c
4316     +++ b/fs/jffs2/scan.c
4317     @@ -1075,7 +1075,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info *c, struct jffs2_eraseblo
4318     memcpy(&fd->name, rd->name, checkedlen);
4319     fd->name[checkedlen] = 0;
4320    
4321     - crc = crc32(0, fd->name, rd->nsize);
4322     + crc = crc32(0, fd->name, checkedlen);
4323     if (crc != je32_to_cpu(rd->name_crc)) {
4324     pr_notice("%s(): Name CRC failed on node at 0x%08x: Read 0x%08x, calculated 0x%08x\n",
4325     __func__, ofs, je32_to_cpu(rd->name_crc), crc);
4326     diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
4327     index 83149cbae0931..ee12253697009 100644
4328     --- a/fs/nfs/flexfilelayout/flexfilelayout.c
4329     +++ b/fs/nfs/flexfilelayout/flexfilelayout.c
4330     @@ -93,7 +93,7 @@ static int decode_nfs_fh(struct xdr_stream *xdr, struct nfs_fh *fh)
4331     if (unlikely(!p))
4332     return -ENOBUFS;
4333     fh->size = be32_to_cpup(p++);
4334     - if (fh->size > sizeof(struct nfs_fh)) {
4335     + if (fh->size > NFS_MAXFHSIZE) {
4336     printk(KERN_ERR "NFS flexfiles: Too big fh received %d\n",
4337     fh->size);
4338     return -EOVERFLOW;
4339     diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
4340     index 6c0035761d170..7a94f5a5f8c8c 100644
4341     --- a/fs/nfs/inode.c
4342     +++ b/fs/nfs/inode.c
4343     @@ -1469,10 +1469,10 @@ EXPORT_SYMBOL_GPL(_nfs_display_fhandle);
4344     */
4345     static int nfs_inode_attrs_need_update(const struct inode *inode, const struct nfs_fattr *fattr)
4346     {
4347     - const struct nfs_inode *nfsi = NFS_I(inode);
4348     + unsigned long attr_gencount = NFS_I(inode)->attr_gencount;
4349    
4350     - return ((long)fattr->gencount - (long)nfsi->attr_gencount) > 0 ||
4351     - ((long)nfsi->attr_gencount - (long)nfs_read_attr_generation_counter() > 0);
4352     + return (long)(fattr->gencount - attr_gencount) > 0 ||
4353     + (long)(attr_gencount - nfs_read_attr_generation_counter()) > 0;
4354     }
4355    
4356     static int nfs_refresh_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
4357     @@ -1882,7 +1882,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
4358     nfsi->attrtimeo_timestamp = now;
4359     }
4360     /* Set the barrier to be more recent than this fattr */
4361     - if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0)
4362     + if ((long)(fattr->gencount - nfsi->attr_gencount) > 0)
4363     nfsi->attr_gencount = fattr->gencount;
4364     }
4365    
4366     diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
4367     index 5cda392028ce1..7efb9e0e9f25b 100644
4368     --- a/fs/nfs/nfs42proc.c
4369     +++ b/fs/nfs/nfs42proc.c
4370     @@ -56,7 +56,8 @@ static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
4371     static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
4372     loff_t offset, loff_t len)
4373     {
4374     - struct nfs_server *server = NFS_SERVER(file_inode(filep));
4375     + struct inode *inode = file_inode(filep);
4376     + struct nfs_server *server = NFS_SERVER(inode);
4377     struct nfs4_exception exception = { };
4378     struct nfs_lock_context *lock;
4379     int err;
4380     @@ -65,9 +66,13 @@ static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
4381     if (IS_ERR(lock))
4382     return PTR_ERR(lock);
4383    
4384     - exception.inode = file_inode(filep);
4385     + exception.inode = inode;
4386     exception.state = lock->open_context->state;
4387    
4388     + err = nfs_sync_inode(inode);
4389     + if (err)
4390     + goto out;
4391     +
4392     do {
4393     err = _nfs42_proc_fallocate(msg, filep, lock, offset, len);
4394     if (err == -ENOTSUPP) {
4395     @@ -76,7 +81,7 @@ static int nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep,
4396     }
4397     err = nfs4_handle_exception(server, err, &exception);
4398     } while (exception.retry);
4399     -
4400     +out:
4401     nfs_put_lock_context(lock);
4402     return err;
4403     }
4404     @@ -114,16 +119,13 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len)
4405     return -EOPNOTSUPP;
4406    
4407     inode_lock(inode);
4408     - err = nfs_sync_inode(inode);
4409     - if (err)
4410     - goto out_unlock;
4411    
4412     err = nfs42_proc_fallocate(&msg, filep, offset, len);
4413     if (err == 0)
4414     truncate_pagecache_range(inode, offset, (offset + len) -1);
4415     if (err == -EOPNOTSUPP)
4416     NFS_SERVER(inode)->caps &= ~NFS_CAP_DEALLOCATE;
4417     -out_unlock:
4418     +
4419     inode_unlock(inode);
4420     return err;
4421     }
4422     @@ -292,7 +294,10 @@ static loff_t _nfs42_proc_llseek(struct file *filep,
4423     if (status)
4424     return status;
4425    
4426     - return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes);
4427     + if (whence == SEEK_DATA && res.sr_eof)
4428     + return -NFS4ERR_NXIO;
4429     + else
4430     + return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes);
4431     }
4432    
4433     loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence)
4434     diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
4435     index c3abf92adfb7d..d347d95a1bac1 100644
4436     --- a/fs/nfs/pnfs.c
4437     +++ b/fs/nfs/pnfs.c
4438     @@ -1088,7 +1088,7 @@ _pnfs_return_layout(struct inode *ino)
4439     pnfs_get_layout_hdr(lo);
4440     empty = list_empty(&lo->plh_segs);
4441     pnfs_clear_layoutcommit(ino, &tmp_list);
4442     - pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL, 0);
4443     + pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0);
4444    
4445     if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
4446     struct pnfs_layout_range range = {
4447     diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
4448     index f1c1430ae7213..0bcb83479fcba 100644
4449     --- a/fs/squashfs/file.c
4450     +++ b/fs/squashfs/file.c
4451     @@ -224,11 +224,11 @@ failure:
4452     * If the skip factor is limited in this way then the file will use multiple
4453     * slots.
4454     */
4455     -static inline int calculate_skip(int blocks)
4456     +static inline int calculate_skip(u64 blocks)
4457     {
4458     - int skip = blocks / ((SQUASHFS_META_ENTRIES + 1)
4459     + u64 skip = blocks / ((SQUASHFS_META_ENTRIES + 1)
4460     * SQUASHFS_META_INDEXES);
4461     - return min(SQUASHFS_CACHED_BLKS - 1, skip + 1);
4462     + return min((u64) SQUASHFS_CACHED_BLKS - 1, skip + 1);
4463     }
4464    
4465    
4466     diff --git a/include/linux/extcon/extcon-adc-jack.h b/include/linux/extcon/extcon-adc-jack.h
4467     index a0e03b13b449d..2aa32075bca15 100644
4468     --- a/include/linux/extcon/extcon-adc-jack.h
4469     +++ b/include/linux/extcon/extcon-adc-jack.h
4470     @@ -59,7 +59,7 @@ struct adc_jack_pdata {
4471     const char *name;
4472     const char *consumer_channel;
4473    
4474     - const enum extcon *cable_names;
4475     + const unsigned int *cable_names;
4476    
4477     /* The last entry's state should be 0 */
4478     struct adc_jack_cond *adc_conditions;
4479     diff --git a/include/linux/hid.h b/include/linux/hid.h
4480     index 981657075f051..41c372573a289 100644
4481     --- a/include/linux/hid.h
4482     +++ b/include/linux/hid.h
4483     @@ -248,6 +248,8 @@ struct hid_item {
4484     #define HID_CP_SELECTION 0x000c0080
4485     #define HID_CP_MEDIASELECTION 0x000c0087
4486     #define HID_CP_SELECTDISC 0x000c00ba
4487     +#define HID_CP_VOLUMEUP 0x000c00e9
4488     +#define HID_CP_VOLUMEDOWN 0x000c00ea
4489     #define HID_CP_PLAYBACKSPEED 0x000c00f1
4490     #define HID_CP_PROXIMITY 0x000c0109
4491     #define HID_CP_SPEAKERSYSTEM 0x000c0160
4492     diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
4493     index b742b5e47cc20..ae63c962fa22c 100644
4494     --- a/include/linux/tty_driver.h
4495     +++ b/include/linux/tty_driver.h
4496     @@ -235,7 +235,7 @@
4497     *
4498     * Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel
4499     * structure to complete. This method is optional and will only be called
4500     - * if provided (otherwise EINVAL will be returned).
4501     + * if provided (otherwise ENOTTY will be returned).
4502     */
4503    
4504     #include <linux/export.h>
4505     diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
4506     index 52b5352e8fe08..33db6c6d3fba8 100644
4507     --- a/include/net/bluetooth/hci_core.h
4508     +++ b/include/net/bluetooth/hci_core.h
4509     @@ -512,6 +512,7 @@ struct hci_chan {
4510     struct sk_buff_head data_q;
4511     unsigned int sent;
4512     __u8 state;
4513     + bool amp;
4514     };
4515    
4516     struct hci_conn_params {
4517     diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
4518     index 6be92eede5c01..a911f993219d7 100644
4519     --- a/include/scsi/libfcoe.h
4520     +++ b/include/scsi/libfcoe.h
4521     @@ -261,7 +261,7 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
4522     struct fc_frame *);
4523    
4524     /* libfcoe funcs */
4525     -u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
4526     +u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
4527     int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *,
4528     const struct libfc_function_template *, int init_fcp);
4529     u32 fcoe_fc_crc(struct fc_frame *fp);
4530     diff --git a/include/uapi/linux/tty_flags.h b/include/uapi/linux/tty_flags.h
4531     index 66e4d8bcb16f9..9f9572b2a596c 100644
4532     --- a/include/uapi/linux/tty_flags.h
4533     +++ b/include/uapi/linux/tty_flags.h
4534     @@ -38,7 +38,7 @@
4535     * WARNING: These flags are no longer used and have been superceded by the
4536     * TTY_PORT_ flags in the iflags field (and not userspace-visible)
4537     */
4538     -#ifndef _KERNEL_
4539     +#ifndef __KERNEL__
4540     #define ASYNCB_INITIALIZED 31 /* Serial port was initialized */
4541     #define ASYNCB_SUSPENDED 30 /* Serial port is suspended */
4542     #define ASYNCB_NORMAL_ACTIVE 29 /* Normal device is active */
4543     @@ -80,7 +80,7 @@
4544     #define ASYNC_SPD_WARP (ASYNC_SPD_HI|ASYNC_SPD_SHI)
4545     #define ASYNC_SPD_MASK (ASYNC_SPD_HI|ASYNC_SPD_VHI|ASYNC_SPD_SHI)
4546    
4547     -#ifndef _KERNEL_
4548     +#ifndef __KERNEL__
4549     /* These flags are no longer used (and were always masked from userspace) */
4550     #define ASYNC_INITIALIZED (1U << ASYNCB_INITIALIZED)
4551     #define ASYNC_NORMAL_ACTIVE (1U << ASYNCB_NORMAL_ACTIVE)
4552     diff --git a/kernel/futex.c b/kernel/futex.c
4553     index 468f39476476b..324fb85c89049 100644
4554     --- a/kernel/futex.c
4555     +++ b/kernel/futex.c
4556     @@ -3860,8 +3860,7 @@ long do_futex(u32 __user *uaddr, int op, u32 val, ktime_t *timeout,
4557    
4558     if (op & FUTEX_CLOCK_REALTIME) {
4559     flags |= FLAGS_CLOCKRT;
4560     - if (cmd != FUTEX_WAIT && cmd != FUTEX_WAIT_BITSET && \
4561     - cmd != FUTEX_WAIT_REQUEUE_PI)
4562     + if (cmd != FUTEX_WAIT_BITSET && cmd != FUTEX_WAIT_REQUEUE_PI)
4563     return -ENOSYS;
4564     }
4565    
4566     diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c
4567     index 037c321c56188..2edaed6803ff7 100644
4568     --- a/kernel/kexec_file.c
4569     +++ b/kernel/kexec_file.c
4570     @@ -528,8 +528,10 @@ static int kexec_calculate_store_digests(struct kimage *image)
4571    
4572     sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region);
4573     sha_regions = vzalloc(sha_region_sz);
4574     - if (!sha_regions)
4575     + if (!sha_regions) {
4576     + ret = -ENOMEM;
4577     goto out_free_desc;
4578     + }
4579    
4580     desc->tfm = tfm;
4581     desc->flags = 0;
4582     diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
4583     index ce49b62b08346..a6851f8b9b245 100644
4584     --- a/kernel/trace/ftrace.c
4585     +++ b/kernel/trace/ftrace.c
4586     @@ -4486,8 +4486,11 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
4587    
4588     parser = &iter->parser;
4589     if (trace_parser_loaded(parser)) {
4590     + int enable = !(iter->flags & FTRACE_ITER_NOTRACE);
4591     +
4592     parser->buffer[parser->idx] = 0;
4593     - ftrace_match_records(iter->hash, parser->buffer, parser->idx);
4594     + ftrace_process_regex(iter->hash, parser->buffer,
4595     + parser->idx, enable);
4596     }
4597    
4598     trace_parser_put(parser);
4599     diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
4600     index 8c6b682b83b80..55b7b4cf0080d 100644
4601     --- a/kernel/trace/trace.c
4602     +++ b/kernel/trace/trace.c
4603     @@ -1809,10 +1809,13 @@ void trace_stop_cmdline_recording(void);
4604    
4605     static int trace_save_cmdline(struct task_struct *tsk)
4606     {
4607     - unsigned pid, idx;
4608     + unsigned tpid, idx;
4609    
4610     - if (!tsk->pid || unlikely(tsk->pid > PID_MAX_DEFAULT))
4611     - return 0;
4612     + /* treat recording of idle task as a success */
4613     + if (!tsk->pid)
4614     + return 1;
4615     +
4616     + tpid = tsk->pid & (PID_MAX_DEFAULT - 1);
4617    
4618     /*
4619     * It's not the end of the world if we don't get
4620     @@ -1823,26 +1826,15 @@ static int trace_save_cmdline(struct task_struct *tsk)
4621     if (!arch_spin_trylock(&trace_cmdline_lock))
4622     return 0;
4623    
4624     - idx = savedcmd->map_pid_to_cmdline[tsk->pid];
4625     + idx = savedcmd->map_pid_to_cmdline[tpid];
4626     if (idx == NO_CMDLINE_MAP) {
4627     idx = (savedcmd->cmdline_idx + 1) % savedcmd->cmdline_num;
4628    
4629     - /*
4630     - * Check whether the cmdline buffer at idx has a pid
4631     - * mapped. We are going to overwrite that entry so we
4632     - * need to clear the map_pid_to_cmdline. Otherwise we
4633     - * would read the new comm for the old pid.
4634     - */
4635     - pid = savedcmd->map_cmdline_to_pid[idx];
4636     - if (pid != NO_CMDLINE_MAP)
4637     - savedcmd->map_pid_to_cmdline[pid] = NO_CMDLINE_MAP;
4638     -
4639     - savedcmd->map_cmdline_to_pid[idx] = tsk->pid;
4640     - savedcmd->map_pid_to_cmdline[tsk->pid] = idx;
4641     -
4642     + savedcmd->map_pid_to_cmdline[tpid] = idx;
4643     savedcmd->cmdline_idx = idx;
4644     }
4645    
4646     + savedcmd->map_cmdline_to_pid[idx] = tsk->pid;
4647     set_cmdline(idx, tsk->comm);
4648    
4649     arch_spin_unlock(&trace_cmdline_lock);
4650     @@ -1853,6 +1845,7 @@ static int trace_save_cmdline(struct task_struct *tsk)
4651     static void __trace_find_cmdline(int pid, char comm[])
4652     {
4653     unsigned map;
4654     + int tpid;
4655    
4656     if (!pid) {
4657     strcpy(comm, "<idle>");
4658     @@ -1864,16 +1857,16 @@ static void __trace_find_cmdline(int pid, char comm[])
4659     return;
4660     }
4661    
4662     - if (pid > PID_MAX_DEFAULT) {
4663     - strcpy(comm, "<...>");
4664     - return;
4665     + tpid = pid & (PID_MAX_DEFAULT - 1);
4666     + map = savedcmd->map_pid_to_cmdline[tpid];
4667     + if (map != NO_CMDLINE_MAP) {
4668     + tpid = savedcmd->map_cmdline_to_pid[map];
4669     + if (tpid == pid) {
4670     + strlcpy(comm, get_saved_cmdlines(map), TASK_COMM_LEN);
4671     + return;
4672     + }
4673     }
4674     -
4675     - map = savedcmd->map_pid_to_cmdline[pid];
4676     - if (map != NO_CMDLINE_MAP)
4677     - strcpy(comm, get_saved_cmdlines(map));
4678     - else
4679     - strcpy(comm, "<...>");
4680     + strcpy(comm, "<...>");
4681     }
4682    
4683     void trace_find_cmdline(int pid, char comm[])
4684     diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
4685     index 0f06532a755b7..b67ea5eed2a89 100644
4686     --- a/kernel/trace/trace_clock.c
4687     +++ b/kernel/trace/trace_clock.c
4688     @@ -93,33 +93,49 @@ u64 notrace trace_clock_global(void)
4689     {
4690     unsigned long flags;
4691     int this_cpu;
4692     - u64 now;
4693     + u64 now, prev_time;
4694    
4695     local_irq_save(flags);
4696    
4697     this_cpu = raw_smp_processor_id();
4698     - now = sched_clock_cpu(this_cpu);
4699     +
4700     /*
4701     - * If in an NMI context then dont risk lockups and return the
4702     - * cpu_clock() time:
4703     + * The global clock "guarantees" that the events are ordered
4704     + * between CPUs. But if two events on two different CPUS call
4705     + * trace_clock_global at roughly the same time, it really does
4706     + * not matter which one gets the earlier time. Just make sure
4707     + * that the same CPU will always show a monotonic clock.
4708     + *
4709     + * Use a read memory barrier to get the latest written
4710     + * time that was recorded.
4711     */
4712     - if (unlikely(in_nmi()))
4713     - goto out;
4714     + smp_rmb();
4715     + prev_time = READ_ONCE(trace_clock_struct.prev_time);
4716     + now = sched_clock_cpu(this_cpu);
4717    
4718     - arch_spin_lock(&trace_clock_struct.lock);
4719     + /* Make sure that now is always greater than prev_time */
4720     + if ((s64)(now - prev_time) < 0)
4721     + now = prev_time + 1;
4722    
4723     /*
4724     - * TODO: if this happens often then maybe we should reset
4725     - * my_scd->clock to prev_time+1, to make sure
4726     - * we start ticking with the local clock from now on?
4727     + * If in an NMI context then dont risk lockups and simply return
4728     + * the current time.
4729     */
4730     - if ((s64)(now - trace_clock_struct.prev_time) < 0)
4731     - now = trace_clock_struct.prev_time + 1;
4732     + if (unlikely(in_nmi()))
4733     + goto out;
4734    
4735     - trace_clock_struct.prev_time = now;
4736     + /* Tracing can cause strange recursion, always use a try lock */
4737     + if (arch_spin_trylock(&trace_clock_struct.lock)) {
4738     + /* Reread prev_time in case it was already updated */
4739     + prev_time = READ_ONCE(trace_clock_struct.prev_time);
4740     + if ((s64)(now - prev_time) < 0)
4741     + now = prev_time + 1;
4742    
4743     - arch_spin_unlock(&trace_clock_struct.lock);
4744     + trace_clock_struct.prev_time = now;
4745    
4746     + /* The unlock acts as the wmb for the above rmb */
4747     + arch_spin_unlock(&trace_clock_struct.lock);
4748     + }
4749     out:
4750     local_irq_restore(flags);
4751    
4752     diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
4753     index f6c2c1e7779c9..6104daf98ad9f 100644
4754     --- a/lib/kobject_uevent.c
4755     +++ b/lib/kobject_uevent.c
4756     @@ -128,12 +128,13 @@ static int kobj_usermode_filter(struct kobject *kobj)
4757    
4758     static int init_uevent_argv(struct kobj_uevent_env *env, const char *subsystem)
4759     {
4760     + int buffer_size = sizeof(env->buf) - env->buflen;
4761     int len;
4762    
4763     - len = strlcpy(&env->buf[env->buflen], subsystem,
4764     - sizeof(env->buf) - env->buflen);
4765     - if (len >= (sizeof(env->buf) - env->buflen)) {
4766     - WARN(1, KERN_ERR "init_uevent_argv: buffer size too small\n");
4767     + len = strlcpy(&env->buf[env->buflen], subsystem, buffer_size);
4768     + if (len >= buffer_size) {
4769     + pr_warn("init_uevent_argv: buffer size of %d too small, needed %d\n",
4770     + buffer_size, len);
4771     return -ENOMEM;
4772     }
4773    
4774     diff --git a/lib/stackdepot.c b/lib/stackdepot.c
4775     index 759ff419fe61f..c519aa07d2e98 100644
4776     --- a/lib/stackdepot.c
4777     +++ b/lib/stackdepot.c
4778     @@ -78,7 +78,7 @@ static void *stack_slabs[STACK_ALLOC_MAX_SLABS];
4779     static int depot_index;
4780     static int next_slab_inited;
4781     static size_t depot_offset;
4782     -static DEFINE_SPINLOCK(depot_lock);
4783     +static DEFINE_RAW_SPINLOCK(depot_lock);
4784    
4785     static bool init_stack_slab(void **prealloc)
4786     {
4787     @@ -253,7 +253,7 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
4788     prealloc = page_address(page);
4789     }
4790    
4791     - spin_lock_irqsave(&depot_lock, flags);
4792     + raw_spin_lock_irqsave(&depot_lock, flags);
4793    
4794     found = find_stack(*bucket, trace->entries, trace->nr_entries, hash);
4795     if (!found) {
4796     @@ -277,7 +277,7 @@ depot_stack_handle_t depot_save_stack(struct stack_trace *trace,
4797     WARN_ON(!init_stack_slab(&prealloc));
4798     }
4799    
4800     - spin_unlock_irqrestore(&depot_lock, flags);
4801     + raw_spin_unlock_irqrestore(&depot_lock, flags);
4802     exit:
4803     if (prealloc) {
4804     /* Nobody used this memory, ok to free it. */
4805     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
4806     index e2b5e38e7a4b7..9049e8613237f 100644
4807     --- a/mm/hugetlb.c
4808     +++ b/mm/hugetlb.c
4809     @@ -586,13 +586,20 @@ void hugetlb_fix_reserve_counts(struct inode *inode)
4810     {
4811     struct hugepage_subpool *spool = subpool_inode(inode);
4812     long rsv_adjust;
4813     + bool reserved = false;
4814    
4815     rsv_adjust = hugepage_subpool_get_pages(spool, 1);
4816     - if (rsv_adjust) {
4817     + if (rsv_adjust > 0) {
4818     struct hstate *h = hstate_inode(inode);
4819    
4820     - hugetlb_acct_memory(h, 1);
4821     + if (!hugetlb_acct_memory(h, 1))
4822     + reserved = true;
4823     + } else if (!rsv_adjust) {
4824     + reserved = true;
4825     }
4826     +
4827     + if (!reserved)
4828     + pr_warn("hugetlb: Huge Page Reserved count may go negative.\n");
4829     }
4830    
4831     /*
4832     diff --git a/mm/khugepaged.c b/mm/khugepaged.c
4833     index 753b0e2fef368..0f1bdbae45e21 100644
4834     --- a/mm/khugepaged.c
4835     +++ b/mm/khugepaged.c
4836     @@ -596,17 +596,17 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
4837     mmu_notifier_test_young(vma->vm_mm, address))
4838     referenced++;
4839     }
4840     - if (likely(writable)) {
4841     - if (likely(referenced)) {
4842     - result = SCAN_SUCCEED;
4843     - trace_mm_collapse_huge_page_isolate(page, none_or_zero,
4844     - referenced, writable, result);
4845     - return 1;
4846     - }
4847     - } else {
4848     +
4849     + if (unlikely(!writable)) {
4850     result = SCAN_PAGE_RO;
4851     + } else if (unlikely(!referenced)) {
4852     + result = SCAN_LACK_REFERENCED_PAGE;
4853     + } else {
4854     + result = SCAN_SUCCEED;
4855     + trace_mm_collapse_huge_page_isolate(page, none_or_zero,
4856     + referenced, writable, result);
4857     + return 1;
4858     }
4859     -
4860     out:
4861     release_pte_pages(pte, _pte);
4862     trace_mm_collapse_huge_page_isolate(page, none_or_zero,
4863     diff --git a/mm/ksm.c b/mm/ksm.c
4864     index d6c81a5076a78..27ff68050d856 100644
4865     --- a/mm/ksm.c
4866     +++ b/mm/ksm.c
4867     @@ -629,6 +629,7 @@ static void remove_rmap_item_from_tree(struct rmap_item *rmap_item)
4868     ksm_pages_shared--;
4869    
4870     put_anon_vma(rmap_item->anon_vma);
4871     + rmap_item->head = NULL;
4872     rmap_item->address &= PAGE_MASK;
4873    
4874     } else if (rmap_item->address & UNSTABLE_FLAG) {
4875     diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
4876     index d01bf6a111cee..44eeb27e341af 100644
4877     --- a/net/bluetooth/hci_event.c
4878     +++ b/net/bluetooth/hci_event.c
4879     @@ -4399,6 +4399,7 @@ static void hci_loglink_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
4880     return;
4881    
4882     hchan->handle = le16_to_cpu(ev->handle);
4883     + hchan->amp = true;
4884    
4885     BT_DBG("hcon %p mgr %p hchan %p", hcon, hcon->amp_mgr, hchan);
4886    
4887     @@ -4431,7 +4432,7 @@ static void hci_disconn_loglink_complete_evt(struct hci_dev *hdev,
4888     hci_dev_lock(hdev);
4889    
4890     hchan = hci_chan_lookup_handle(hdev, le16_to_cpu(ev->handle));
4891     - if (!hchan)
4892     + if (!hchan || !hchan->amp)
4893     goto unlock;
4894    
4895     amp_destroy_logical_link(hchan, ev->reason);
4896     diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
4897     index 4a89e121d6627..bfbfe17589784 100644
4898     --- a/net/bluetooth/hci_request.c
4899     +++ b/net/bluetooth/hci_request.c
4900     @@ -275,12 +275,16 @@ int hci_req_sync(struct hci_dev *hdev, int (*req)(struct hci_request *req,
4901     {
4902     int ret;
4903    
4904     - if (!test_bit(HCI_UP, &hdev->flags))
4905     - return -ENETDOWN;
4906     -
4907     /* Serialize all requests */
4908     hci_req_sync_lock(hdev);
4909     - ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
4910     + /* check the state after obtaing the lock to protect the HCI_UP
4911     + * against any races from hci_dev_do_close when the controller
4912     + * gets removed.
4913     + */
4914     + if (test_bit(HCI_UP, &hdev->flags))
4915     + ret = __hci_req_sync(hdev, req, opt, timeout, hci_status);
4916     + else
4917     + ret = -ENETDOWN;
4918     hci_req_sync_unlock(hdev);
4919    
4920     return ret;
4921     diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
4922     index b96818cda12da..204b6ebd2a24e 100644
4923     --- a/net/bluetooth/l2cap_core.c
4924     +++ b/net/bluetooth/l2cap_core.c
4925     @@ -445,6 +445,8 @@ struct l2cap_chan *l2cap_chan_create(void)
4926     if (!chan)
4927     return NULL;
4928    
4929     + skb_queue_head_init(&chan->tx_q);
4930     + skb_queue_head_init(&chan->srej_q);
4931     mutex_init(&chan->lock);
4932    
4933     /* Set default lock nesting level */
4934     @@ -510,7 +512,9 @@ void l2cap_chan_set_defaults(struct l2cap_chan *chan)
4935     chan->flush_to = L2CAP_DEFAULT_FLUSH_TO;
4936     chan->retrans_timeout = L2CAP_DEFAULT_RETRANS_TO;
4937     chan->monitor_timeout = L2CAP_DEFAULT_MONITOR_TO;
4938     +
4939     chan->conf_state = 0;
4940     + set_bit(CONF_NOT_COMPLETE, &chan->conf_state);
4941    
4942     set_bit(FLAG_FORCE_ACTIVE, &chan->flags);
4943     }
4944     diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
4945     index d7206581145d5..336cffd932939 100644
4946     --- a/net/hsr/hsr_framereg.c
4947     +++ b/net/hsr/hsr_framereg.c
4948     @@ -310,7 +310,8 @@ void hsr_addr_subst_dest(struct hsr_node *node_src, struct sk_buff *skb,
4949    
4950     node_dst = find_node_by_AddrA(&port->hsr->node_db, eth_hdr(skb)->h_dest);
4951     if (!node_dst) {
4952     - WARN_ONCE(1, "%s: Unknown node\n", __func__);
4953     + if (net_ratelimit())
4954     + netdev_err(skb->dev, "%s: Unknown node\n", __func__);
4955     return;
4956     }
4957     if (port->type != node_dst->AddrB_port)
4958     diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
4959     index e0a2a3d6772d3..a25dd5c72cff5 100644
4960     --- a/net/ipv6/ip6_gre.c
4961     +++ b/net/ipv6/ip6_gre.c
4962     @@ -350,7 +350,6 @@ static struct ip6_tnl *ip6gre_tunnel_locate(struct net *net,
4963     if (!(nt->parms.o_flags & TUNNEL_SEQ))
4964     dev->features |= NETIF_F_LLTX;
4965    
4966     - dev_hold(dev);
4967     ip6gre_tunnel_link(ign, nt);
4968     return nt;
4969    
4970     @@ -1085,8 +1084,6 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
4971     strcpy(tunnel->parms.name, dev->name);
4972    
4973     tunnel->hlen = sizeof(struct ipv6hdr) + 4;
4974     -
4975     - dev_hold(dev);
4976     }
4977    
4978    
4979     diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
4980     index d9e60aa2ea1b2..4e18ce5b939ac 100644
4981     --- a/net/ipv6/ip6_tunnel.c
4982     +++ b/net/ipv6/ip6_tunnel.c
4983     @@ -273,7 +273,6 @@ static int ip6_tnl_create2(struct net_device *dev)
4984    
4985     strcpy(t->parms.name, dev->name);
4986    
4987     - dev_hold(dev);
4988     ip6_tnl_link(ip6n, t);
4989     return 0;
4990    
4991     @@ -1845,6 +1844,7 @@ ip6_tnl_dev_init_gen(struct net_device *dev)
4992     if (!(t->parms.flags & IP6_TNL_F_IGN_ENCAP_LIMIT))
4993     dev->mtu -= 8;
4994    
4995     + dev_hold(dev);
4996     return 0;
4997    
4998     destroy_dst:
4999     @@ -1888,7 +1888,6 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
5000     struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
5001    
5002     t->parms.proto = IPPROTO_IPV6;
5003     - dev_hold(dev);
5004    
5005     rcu_assign_pointer(ip6n->tnls_wc[0], t);
5006     return 0;
5007     diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
5008     index b9f5155a77ef4..f58d69216b616 100644
5009     --- a/net/ipv6/ip6_vti.c
5010     +++ b/net/ipv6/ip6_vti.c
5011     @@ -196,7 +196,6 @@ static int vti6_tnl_create2(struct net_device *dev)
5012    
5013     strcpy(t->parms.name, dev->name);
5014    
5015     - dev_hold(dev);
5016     vti6_tnl_link(ip6n, t);
5017    
5018     return 0;
5019     @@ -914,6 +913,7 @@ static inline int vti6_dev_init_gen(struct net_device *dev)
5020     dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
5021     if (!dev->tstats)
5022     return -ENOMEM;
5023     + dev_hold(dev);
5024     return 0;
5025     }
5026    
5027     @@ -945,7 +945,6 @@ static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
5028     struct vti6_net *ip6n = net_generic(net, vti6_net_id);
5029    
5030     t->parms.proto = IPPROTO_IPV6;
5031     - dev_hold(dev);
5032    
5033     rcu_assign_pointer(ip6n->tnls_wc[0], t);
5034     return 0;
5035     diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
5036     index 157358a15d599..07e545fd2a3d8 100644
5037     --- a/net/ipv6/sit.c
5038     +++ b/net/ipv6/sit.c
5039     @@ -209,8 +209,6 @@ static int ipip6_tunnel_create(struct net_device *dev)
5040    
5041     ipip6_tunnel_clone_6rd(dev, sitn);
5042    
5043     - dev_hold(dev);
5044     -
5045     ipip6_tunnel_link(sitn, t);
5046     return 0;
5047    
5048     @@ -1400,7 +1398,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
5049     dev->tstats = NULL;
5050     return err;
5051     }
5052     -
5053     + dev_hold(dev);
5054     return 0;
5055     }
5056    
5057     @@ -1416,7 +1414,6 @@ static void __net_init ipip6_fb_tunnel_init(struct net_device *dev)
5058     iph->ihl = 5;
5059     iph->ttl = 64;
5060    
5061     - dev_hold(dev);
5062     rcu_assign_pointer(sitn->tunnels_wc[0], tunnel);
5063     }
5064    
5065     diff --git a/net/mac80211/main.c b/net/mac80211/main.c
5066     index f31fd21d59ba9..5f8c6f9563b0b 100644
5067     --- a/net/mac80211/main.c
5068     +++ b/net/mac80211/main.c
5069     @@ -1036,8 +1036,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
5070     if (local->hw.wiphy->max_scan_ie_len)
5071     local->hw.wiphy->max_scan_ie_len -= local->scan_ies_len;
5072    
5073     - WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes,
5074     - local->hw.n_cipher_schemes));
5075     + if (WARN_ON(!ieee80211_cs_list_valid(local->hw.cipher_schemes,
5076     + local->hw.n_cipher_schemes))) {
5077     + result = -EINVAL;
5078     + goto fail_workqueue;
5079     + }
5080    
5081     result = ieee80211_init_cipher_suites(local);
5082     if (result < 0)
5083     diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
5084     index 58b80270e58c2..3217c98f2b5a2 100644
5085     --- a/net/mac80211/mlme.c
5086     +++ b/net/mac80211/mlme.c
5087     @@ -1101,6 +1101,11 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_sub_if_data *sdata)
5088    
5089     sdata->vif.csa_active = false;
5090     ifmgd->csa_waiting_bcn = false;
5091     + /*
5092     + * If the CSA IE is still present on the beacon after the switch,
5093     + * we need to consider it as a new CSA (possibly to self).
5094     + */
5095     + ifmgd->beacon_crc_valid = false;
5096    
5097     ret = drv_post_channel_switch(sdata);
5098     if (ret) {
5099     diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
5100     index 0dbd17137dee6..039fc7c539e2e 100644
5101     --- a/net/netfilter/nf_conntrack_standalone.c
5102     +++ b/net/netfilter/nf_conntrack_standalone.c
5103     @@ -551,8 +551,11 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
5104     if (net->user_ns != &init_user_ns)
5105     table[0].procname = NULL;
5106    
5107     - if (!net_eq(&init_net, net))
5108     + if (!net_eq(&init_net, net)) {
5109     + table[0].mode = 0444;
5110     table[2].mode = 0444;
5111     + table[5].mode = 0444;
5112     + }
5113    
5114     net->ct.sysctl_header = register_net_sysctl(net, "net/netfilter", table);
5115     if (!net->ct.sysctl_header)
5116     diff --git a/net/nfc/digital_dep.c b/net/nfc/digital_dep.c
5117     index f864ce19e13db..582f97d035ef1 100644
5118     --- a/net/nfc/digital_dep.c
5119     +++ b/net/nfc/digital_dep.c
5120     @@ -1289,6 +1289,8 @@ static void digital_tg_recv_dep_req(struct nfc_digital_dev *ddev, void *arg,
5121     }
5122    
5123     rc = nfc_tm_data_received(ddev->nfc_dev, resp);
5124     + if (rc)
5125     + resp = NULL;
5126    
5127     exit:
5128     kfree_skb(ddev->chaining_skb);
5129     diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
5130     index c2bc0f0f04786..22e340a9049c8 100644
5131     --- a/net/nfc/llcp_sock.c
5132     +++ b/net/nfc/llcp_sock.c
5133     @@ -120,12 +120,14 @@ static int llcp_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
5134     GFP_KERNEL);
5135     if (!llcp_sock->service_name) {
5136     nfc_llcp_local_put(llcp_sock->local);
5137     + llcp_sock->local = NULL;
5138     ret = -ENOMEM;
5139     goto put_dev;
5140     }
5141     llcp_sock->ssap = nfc_llcp_get_sdp_ssap(local, llcp_sock);
5142     if (llcp_sock->ssap == LLCP_SAP_MAX) {
5143     nfc_llcp_local_put(llcp_sock->local);
5144     + llcp_sock->local = NULL;
5145     kfree(llcp_sock->service_name);
5146     llcp_sock->service_name = NULL;
5147     ret = -EADDRINUSE;
5148     @@ -721,6 +723,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
5149     llcp_sock->ssap = nfc_llcp_get_local_ssap(local);
5150     if (llcp_sock->ssap == LLCP_SAP_MAX) {
5151     nfc_llcp_local_put(llcp_sock->local);
5152     + llcp_sock->local = NULL;
5153     ret = -ENOMEM;
5154     goto put_dev;
5155     }
5156     @@ -759,6 +762,7 @@ static int llcp_sock_connect(struct socket *sock, struct sockaddr *_addr,
5157     sock_unlink:
5158     nfc_llcp_put_ssap(local, llcp_sock->ssap);
5159     nfc_llcp_local_put(llcp_sock->local);
5160     + llcp_sock->local = NULL;
5161    
5162     nfc_llcp_sock_unlink(&local->connecting_sockets, sk);
5163     kfree(llcp_sock->service_name);
5164     diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
5165     index 7135aff3946d7..5fa7b2569a3ab 100644
5166     --- a/net/openvswitch/actions.c
5167     +++ b/net/openvswitch/actions.c
5168     @@ -710,16 +710,16 @@ static void ovs_fragment(struct net *net, struct vport *vport,
5169     }
5170    
5171     if (ethertype == htons(ETH_P_IP)) {
5172     - struct dst_entry ovs_dst;
5173     + struct rtable ovs_rt = { 0 };
5174     unsigned long orig_dst;
5175    
5176     prepare_frag(vport, skb);
5177     - dst_init(&ovs_dst, &ovs_dst_ops, NULL, 1,
5178     + dst_init(&ovs_rt.dst, &ovs_dst_ops, NULL, 1,
5179     DST_OBSOLETE_NONE, DST_NOCOUNT);
5180     - ovs_dst.dev = vport->dev;
5181     + ovs_rt.dst.dev = vport->dev;
5182    
5183     orig_dst = skb->_skb_refdst;
5184     - skb_dst_set_noref(skb, &ovs_dst);
5185     + skb_dst_set_noref(skb, &ovs_rt.dst);
5186     IPCB(skb)->frag_max_size = mru;
5187    
5188     ip_do_fragment(net, skb->sk, skb, ovs_vport_output);
5189     diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
5190     index acb0c2631c792..0c5aff3bb5391 100644
5191     --- a/net/sctp/sm_make_chunk.c
5192     +++ b/net/sctp/sm_make_chunk.c
5193     @@ -3129,7 +3129,7 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
5194     * primary.
5195     */
5196     if (af->is_any(&addr))
5197     - memcpy(&addr.v4, sctp_source(asconf), sizeof(addr));
5198     + memcpy(&addr, sctp_source(asconf), sizeof(addr));
5199    
5200     peer = sctp_assoc_lookup_paddr(asoc, &addr);
5201     if (!peer)
5202     diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
5203     index 146b568962e01..9045f6bcb34c4 100644
5204     --- a/net/sctp/sm_statefuns.c
5205     +++ b/net/sctp/sm_statefuns.c
5206     @@ -1851,7 +1851,8 @@ static sctp_disposition_t sctp_sf_do_dupcook_b(struct net *net,
5207     sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
5208     sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE,
5209     SCTP_STATE(SCTP_STATE_ESTABLISHED));
5210     - SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
5211     + if (asoc->state < SCTP_STATE_ESTABLISHED)
5212     + SCTP_INC_STATS(net, SCTP_MIB_CURRESTAB);
5213     sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL());
5214    
5215     repl = sctp_make_cookie_ack(new_asoc, chunk);
5216     diff --git a/net/sctp/socket.c b/net/sctp/socket.c
5217     index 029ec12c77bd7..09a99c92c27dc 100644
5218     --- a/net/sctp/socket.c
5219     +++ b/net/sctp/socket.c
5220     @@ -367,6 +367,18 @@ static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt,
5221     return af;
5222     }
5223    
5224     +static void sctp_auto_asconf_init(struct sctp_sock *sp)
5225     +{
5226     + struct net *net = sock_net(&sp->inet.sk);
5227     +
5228     + if (net->sctp.default_auto_asconf) {
5229     + spin_lock(&net->sctp.addr_wq_lock);
5230     + list_add_tail(&sp->auto_asconf_list, &net->sctp.auto_asconf_splist);
5231     + spin_unlock(&net->sctp.addr_wq_lock);
5232     + sp->do_auto_asconf = 1;
5233     + }
5234     +}
5235     +
5236     /* Bind a local address either to an endpoint or to an association. */
5237     static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
5238     {
5239     @@ -429,8 +441,10 @@ static int sctp_do_bind(struct sock *sk, union sctp_addr *addr, int len)
5240     }
5241    
5242     /* Refresh ephemeral port. */
5243     - if (!bp->port)
5244     + if (!bp->port) {
5245     bp->port = inet_sk(sk)->inet_num;
5246     + sctp_auto_asconf_init(sp);
5247     + }
5248    
5249     /* Add the address to the bind address list.
5250     * Use GFP_ATOMIC since BHs will be disabled.
5251     @@ -1582,9 +1596,11 @@ static void sctp_close(struct sock *sk, long timeout)
5252    
5253     /* Supposedly, no process has access to the socket, but
5254     * the net layers still may.
5255     + * Also, sctp_destroy_sock() needs to be called with addr_wq_lock
5256     + * held and that should be grabbed before socket lock.
5257     */
5258     - local_bh_disable();
5259     - bh_lock_sock(sk);
5260     + spin_lock_bh(&net->sctp.addr_wq_lock);
5261     + bh_lock_sock_nested(sk);
5262    
5263     /* Hold the sock, since sk_common_release() will put sock_put()
5264     * and we have just a little more cleanup.
5265     @@ -1593,7 +1609,7 @@ static void sctp_close(struct sock *sk, long timeout)
5266     sk_common_release(sk);
5267    
5268     bh_unlock_sock(sk);
5269     - local_bh_enable();
5270     + spin_unlock_bh(&net->sctp.addr_wq_lock);
5271    
5272     sock_put(sk);
5273    
5274     @@ -4260,16 +4276,6 @@ static int sctp_init_sock(struct sock *sk)
5275     sk_sockets_allocated_inc(sk);
5276     sock_prot_inuse_add(net, sk->sk_prot, 1);
5277    
5278     - if (net->sctp.default_auto_asconf) {
5279     - spin_lock(&sock_net(sk)->sctp.addr_wq_lock);
5280     - list_add_tail(&sp->auto_asconf_list,
5281     - &net->sctp.auto_asconf_splist);
5282     - sp->do_auto_asconf = 1;
5283     - spin_unlock(&sock_net(sk)->sctp.addr_wq_lock);
5284     - } else {
5285     - sp->do_auto_asconf = 0;
5286     - }
5287     -
5288     local_bh_enable();
5289    
5290     return 0;
5291     @@ -4294,9 +4300,7 @@ static void sctp_destroy_sock(struct sock *sk)
5292    
5293     if (sp->do_auto_asconf) {
5294     sp->do_auto_asconf = 0;
5295     - spin_lock_bh(&sock_net(sk)->sctp.addr_wq_lock);
5296     list_del(&sp->auto_asconf_list);
5297     - spin_unlock_bh(&sock_net(sk)->sctp.addr_wq_lock);
5298     }
5299     sctp_endpoint_free(sp->ep);
5300     local_bh_disable();
5301     @@ -7814,6 +7818,8 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
5302     sctp_bind_addr_dup(&newsp->ep->base.bind_addr,
5303     &oldsp->ep->base.bind_addr, GFP_KERNEL);
5304    
5305     + sctp_auto_asconf_init(newsp);
5306     +
5307     /* Move any messages in the old socket's receive queue that are for the
5308     * peeled off association to the new socket's receive queue.
5309     */
5310     diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
5311     index 403be9bfd8d16..69151de9657c6 100644
5312     --- a/net/tipc/netlink_compat.c
5313     +++ b/net/tipc/netlink_compat.c
5314     @@ -662,7 +662,7 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
5315     if (err)
5316     return err;
5317    
5318     - link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
5319     + link_info.dest = htonl(nla_get_flag(link[TIPC_NLA_LINK_DEST]));
5320     link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
5321     nla_strlcpy(link_info.str, link[TIPC_NLA_LINK_NAME],
5322     TIPC_MAX_LINK_NAME);
5323     diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
5324     index 102bf9194662c..c09efcdf72d27 100644
5325     --- a/net/vmw_vsock/vmci_transport.c
5326     +++ b/net/vmw_vsock/vmci_transport.c
5327     @@ -593,8 +593,7 @@ vmci_transport_queue_pair_alloc(struct vmci_qp **qpair,
5328     peer, flags, VMCI_NO_PRIVILEGE_FLAGS);
5329     out:
5330     if (err < 0) {
5331     - pr_err("Could not attach to queue pair with %d\n",
5332     - err);
5333     + pr_err_once("Could not attach to queue pair with %d\n", err);
5334     err = vmci_transport_error_to_vsock_error(err);
5335     }
5336    
5337     diff --git a/net/wireless/scan.c b/net/wireless/scan.c
5338     index c60be11b5e08b..71a8e6980e2fc 100644
5339     --- a/net/wireless/scan.c
5340     +++ b/net/wireless/scan.c
5341     @@ -956,6 +956,8 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,
5342    
5343     if (rdev->bss_entries >= bss_entries_limit &&
5344     !cfg80211_bss_expire_oldest(rdev)) {
5345     + if (!list_empty(&new->hidden_list))
5346     + list_del(&new->hidden_list);
5347     kfree(new);
5348     goto drop;
5349     }
5350     diff --git a/samples/bpf/tracex1_kern.c b/samples/bpf/tracex1_kern.c
5351     index 107da148820fc..9c74b45c5720f 100644
5352     --- a/samples/bpf/tracex1_kern.c
5353     +++ b/samples/bpf/tracex1_kern.c
5354     @@ -20,7 +20,7 @@
5355     SEC("kprobe/__netif_receive_skb_core")
5356     int bpf_prog1(struct pt_regs *ctx)
5357     {
5358     - /* attaches to kprobe netif_receive_skb,
5359     + /* attaches to kprobe __netif_receive_skb_core,
5360     * looks for packets on loobpack device and prints them
5361     */
5362     char devname[IFNAMSIZ];
5363     @@ -29,7 +29,7 @@ int bpf_prog1(struct pt_regs *ctx)
5364     int len;
5365    
5366     /* non-portable! works for the given kernel only */
5367     - skb = (struct sk_buff *) PT_REGS_PARM1(ctx);
5368     + bpf_probe_read_kernel(&skb, sizeof(skb), (void *)PT_REGS_PARM1(ctx));
5369     dev = _(skb->dev);
5370     len = _(skb->len);
5371    
5372     diff --git a/samples/kfifo/bytestream-example.c b/samples/kfifo/bytestream-example.c
5373     index 2fca916d9edfd..a7f5ee8b6edcf 100644
5374     --- a/samples/kfifo/bytestream-example.c
5375     +++ b/samples/kfifo/bytestream-example.c
5376     @@ -124,8 +124,10 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
5377     ret = kfifo_from_user(&test, buf, count, &copied);
5378    
5379     mutex_unlock(&write_lock);
5380     + if (ret)
5381     + return ret;
5382    
5383     - return ret ? ret : copied;
5384     + return copied;
5385     }
5386    
5387     static ssize_t fifo_read(struct file *file, char __user *buf,
5388     @@ -140,8 +142,10 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
5389     ret = kfifo_to_user(&test, buf, count, &copied);
5390    
5391     mutex_unlock(&read_lock);
5392     + if (ret)
5393     + return ret;
5394    
5395     - return ret ? ret : copied;
5396     + return copied;
5397     }
5398    
5399     static const struct file_operations fifo_fops = {
5400     diff --git a/samples/kfifo/inttype-example.c b/samples/kfifo/inttype-example.c
5401     index 8dc3c2e7105a0..a326a37e91631 100644
5402     --- a/samples/kfifo/inttype-example.c
5403     +++ b/samples/kfifo/inttype-example.c
5404     @@ -117,8 +117,10 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
5405     ret = kfifo_from_user(&test, buf, count, &copied);
5406    
5407     mutex_unlock(&write_lock);
5408     + if (ret)
5409     + return ret;
5410    
5411     - return ret ? ret : copied;
5412     + return copied;
5413     }
5414    
5415     static ssize_t fifo_read(struct file *file, char __user *buf,
5416     @@ -133,8 +135,10 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
5417     ret = kfifo_to_user(&test, buf, count, &copied);
5418    
5419     mutex_unlock(&read_lock);
5420     + if (ret)
5421     + return ret;
5422    
5423     - return ret ? ret : copied;
5424     + return copied;
5425     }
5426    
5427     static const struct file_operations fifo_fops = {
5428     diff --git a/samples/kfifo/record-example.c b/samples/kfifo/record-example.c
5429     index 2d7529eeb2940..deb87a2e4e6bc 100644
5430     --- a/samples/kfifo/record-example.c
5431     +++ b/samples/kfifo/record-example.c
5432     @@ -131,8 +131,10 @@ static ssize_t fifo_write(struct file *file, const char __user *buf,
5433     ret = kfifo_from_user(&test, buf, count, &copied);
5434    
5435     mutex_unlock(&write_lock);
5436     + if (ret)
5437     + return ret;
5438    
5439     - return ret ? ret : copied;
5440     + return copied;
5441     }
5442    
5443     static ssize_t fifo_read(struct file *file, char __user *buf,
5444     @@ -147,8 +149,10 @@ static ssize_t fifo_read(struct file *file, char __user *buf,
5445     ret = kfifo_to_user(&test, buf, count, &copied);
5446    
5447     mutex_unlock(&read_lock);
5448     + if (ret)
5449     + return ret;
5450    
5451     - return ret ? ret : copied;
5452     + return copied;
5453     }
5454    
5455     static const struct file_operations fifo_fops = {
5456     diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
5457     index f7049e288e93d..c58a46904861f 100644
5458     --- a/scripts/kconfig/nconf.c
5459     +++ b/scripts/kconfig/nconf.c
5460     @@ -502,8 +502,8 @@ static int get_mext_match(const char *match_str, match_f flag)
5461     else if (flag == FIND_NEXT_MATCH_UP)
5462     --match_start;
5463    
5464     + match_start = (match_start + items_num) % items_num;
5465     index = match_start;
5466     - index = (index + items_num) % items_num;
5467     while (true) {
5468     char *str = k_menu_items[index].str;
5469     if (strcasestr(str, match_str) != 0)
5470     diff --git a/sound/core/init.c b/sound/core/init.c
5471     index 02e96c580cb74..59377e579adb1 100644
5472     --- a/sound/core/init.c
5473     +++ b/sound/core/init.c
5474     @@ -406,10 +406,8 @@ int snd_card_disconnect(struct snd_card *card)
5475     return 0;
5476     }
5477     card->shutdown = 1;
5478     - spin_unlock(&card->files_lock);
5479    
5480     /* replace file->f_op with special dummy operations */
5481     - spin_lock(&card->files_lock);
5482     list_for_each_entry(mfile, &card->files_list, list) {
5483     /* it's critical part, use endless loop */
5484     /* we have no room to fail */
5485     diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c
5486     index 94c411299e5a0..470058e89fef8 100644
5487     --- a/sound/isa/sb/emu8000.c
5488     +++ b/sound/isa/sb/emu8000.c
5489     @@ -1042,8 +1042,10 @@ snd_emu8000_create_mixer(struct snd_card *card, struct snd_emu8000 *emu)
5490    
5491     memset(emu->controls, 0, sizeof(emu->controls));
5492     for (i = 0; i < EMU8000_NUM_CONTROLS; i++) {
5493     - if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0)
5494     + if ((err = snd_ctl_add(card, emu->controls[i] = snd_ctl_new1(mixer_defs[i], emu))) < 0) {
5495     + emu->controls[i] = NULL;
5496     goto __error;
5497     + }
5498     }
5499     return 0;
5500    
5501     diff --git a/sound/isa/sb/sb16_csp.c b/sound/isa/sb/sb16_csp.c
5502     index 48da2276683d2..2cc068be7d3be 100644
5503     --- a/sound/isa/sb/sb16_csp.c
5504     +++ b/sound/isa/sb/sb16_csp.c
5505     @@ -1059,10 +1059,14 @@ static int snd_sb_qsound_build(struct snd_sb_csp * p)
5506    
5507     spin_lock_init(&p->q_lock);
5508    
5509     - if ((err = snd_ctl_add(card, p->qsound_switch = snd_ctl_new1(&snd_sb_qsound_switch, p))) < 0)
5510     + if ((err = snd_ctl_add(card, p->qsound_switch = snd_ctl_new1(&snd_sb_qsound_switch, p))) < 0) {
5511     + p->qsound_switch = NULL;
5512     goto __error;
5513     - if ((err = snd_ctl_add(card, p->qsound_space = snd_ctl_new1(&snd_sb_qsound_space, p))) < 0)
5514     + }
5515     + if ((err = snd_ctl_add(card, p->qsound_space = snd_ctl_new1(&snd_sb_qsound_space, p))) < 0) {
5516     + p->qsound_space = NULL;
5517     goto __error;
5518     + }
5519    
5520     return 0;
5521    
5522     diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
5523     index 6089ed6efc8dd..8d99ac931ff6b 100644
5524     --- a/sound/pci/hda/hda_generic.c
5525     +++ b/sound/pci/hda/hda_generic.c
5526     @@ -1165,11 +1165,17 @@ static const char *get_line_out_pfx(struct hda_codec *codec, int ch,
5527     *index = ch;
5528     return "Headphone";
5529     case AUTO_PIN_LINE_OUT:
5530     - /* This deals with the case where we have two DACs and
5531     - * one LO, one HP and one Speaker */
5532     - if (!ch && cfg->speaker_outs && cfg->hp_outs) {
5533     - bool hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type);
5534     - bool spk_lo_shared = !path_has_mixer(codec, spec->speaker_paths[0], ctl_type);
5535     + /* This deals with the case where one HP or one Speaker or
5536     + * one HP + one Speaker need to share the DAC with LO
5537     + */
5538     + if (!ch) {
5539     + bool hp_lo_shared = false, spk_lo_shared = false;
5540     +
5541     + if (cfg->speaker_outs)
5542     + spk_lo_shared = !path_has_mixer(codec,
5543     + spec->speaker_paths[0], ctl_type);
5544     + if (cfg->hp_outs)
5545     + hp_lo_shared = !path_has_mixer(codec, spec->hp_paths[0], ctl_type);
5546     if (hp_lo_shared && spk_lo_shared)
5547     return spec->vmaster_mute.hook ? "PCM" : "Master";
5548     if (hp_lo_shared)
5549     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5550     index 7b94170aa5ecb..58f03b0bb4c46 100644
5551     --- a/sound/pci/hda/patch_realtek.c
5552     +++ b/sound/pci/hda/patch_realtek.c
5553     @@ -2219,13 +2219,13 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5554     ALC882_FIXUP_ACER_ASPIRE_8930G),
5555     SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
5556     ALC882_FIXUP_ACER_ASPIRE_8930G),
5557     + SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5558     + ALC882_FIXUP_ACER_ASPIRE_4930G),
5559     + SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
5560     SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
5561     ALC882_FIXUP_ACER_ASPIRE_4930G),
5562     SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
5563     ALC882_FIXUP_ACER_ASPIRE_4930G),
5564     - SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
5565     - ALC882_FIXUP_ACER_ASPIRE_4930G),
5566     - SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
5567     SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
5568     ALC882_FIXUP_ACER_ASPIRE_4930G),
5569     SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
5570     @@ -2237,11 +2237,11 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5571     SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
5572     SND_PCI_QUIRK(0x1043, 0x84bc, "ASUS ET2700", ALC887_FIXUP_ASUS_BASS),
5573     SND_PCI_QUIRK(0x1043, 0x8691, "ASUS ROG Ranger VIII", ALC882_FIXUP_GPIO3),
5574     + SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
5575     + SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
5576     SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
5577     SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
5578     SND_PCI_QUIRK(0x104d, 0x9060, "Sony Vaio VPCL14M1R", ALC882_FIXUP_NO_PRIMARY_HP),
5579     - SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
5580     - SND_PCI_QUIRK(0x104d, 0x9044, "Sony VAIO AiO", ALC882_FIXUP_NO_PRIMARY_HP),
5581    
5582     /* All Apple entries are in codec SSIDs */
5583     SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
5584     @@ -5821,12 +5821,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5585     SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5586     SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
5587     SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
5588     - SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
5589     - SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
5590     SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
5591     SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5592     SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
5593     SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX),
5594     + SND_PCI_QUIRK(0x104d, 0x90b5, "Sony VAIO Pro 11", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
5595     + SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
5596     SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
5597     SND_PCI_QUIRK(0x10cf, 0x159f, "Lifebook E780", ALC269_FIXUP_LIFEBOOK_NO_HP_TO_LINEOUT),
5598     SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN),
5599     @@ -5841,9 +5841,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5600     SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
5601     SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
5602     SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
5603     + SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
5604     SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK_LIMIT_BOOST),
5605     SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
5606     - SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
5607     SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
5608     SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
5609     SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
5610     @@ -5875,6 +5875,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5611     SND_PCI_QUIRK(0x17aa, 0x3902, "Lenovo E50-80", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
5612     SND_PCI_QUIRK(0x17aa, 0x3977, "IdeaPad S210", ALC283_FIXUP_INT_MIC),
5613     SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo B50-70", ALC269_FIXUP_DMIC_THINKPAD_ACPI),
5614     + SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
5615     SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5616     SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
5617     SND_PCI_QUIRK(0x17aa, 0x501e, "Thinkpad L440", ALC292_FIXUP_TPT440_DOCK),
5618     @@ -5893,7 +5894,6 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
5619     SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
5620     SND_PCI_QUIRK(0x17aa, 0x511e, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
5621     SND_PCI_QUIRK(0x17aa, 0x511f, "Thinkpad", ALC298_FIXUP_TPT470_DOCK),
5622     - SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
5623     SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
5624     SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
5625    
5626     @@ -6569,8 +6569,7 @@ static const struct snd_pci_quirk alc861_fixup_tbl[] = {
5627     SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
5628     SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
5629     SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
5630     - SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
5631     - SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
5632     + SND_PCI_QUIRK_VENDOR(0x1584, "Haier/Uniwill", ALC861_FIXUP_AMP_VREF_0F),
5633     SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
5634     {}
5635     };
5636     diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
5637     index b044dea3c8157..9843954698f45 100644
5638     --- a/sound/pci/rme9652/hdsp.c
5639     +++ b/sound/pci/rme9652/hdsp.c
5640     @@ -5314,7 +5314,8 @@ static int snd_hdsp_free(struct hdsp *hdsp)
5641     if (hdsp->port)
5642     pci_release_regions(hdsp->pci);
5643    
5644     - pci_disable_device(hdsp->pci);
5645     + if (pci_is_enabled(hdsp->pci))
5646     + pci_disable_device(hdsp->pci);
5647     return 0;
5648     }
5649    
5650     diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
5651     index 9899ef4c7efa7..a88a81fc638a6 100644
5652     --- a/sound/pci/rme9652/hdspm.c
5653     +++ b/sound/pci/rme9652/hdspm.c
5654     @@ -6912,7 +6912,8 @@ static int snd_hdspm_free(struct hdspm * hdspm)
5655     if (hdspm->port)
5656     pci_release_regions(hdspm->pci);
5657    
5658     - pci_disable_device(hdspm->pci);
5659     + if (pci_is_enabled(hdspm->pci))
5660     + pci_disable_device(hdspm->pci);
5661     return 0;
5662     }
5663    
5664     diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
5665     index a76b1f1476609..67bd75fbdc7e6 100644
5666     --- a/sound/pci/rme9652/rme9652.c
5667     +++ b/sound/pci/rme9652/rme9652.c
5668     @@ -1761,7 +1761,8 @@ static int snd_rme9652_free(struct snd_rme9652 *rme9652)
5669     if (rme9652->port)
5670     pci_release_regions(rme9652->pci);
5671    
5672     - pci_disable_device(rme9652->pci);
5673     + if (pci_is_enabled(rme9652->pci))
5674     + pci_disable_device(rme9652->pci);
5675     return 0;
5676     }
5677    
5678     diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c
5679     index 7899a2cdeb42f..a41dd9d1eb829 100644
5680     --- a/sound/soc/codecs/rt286.c
5681     +++ b/sound/soc/codecs/rt286.c
5682     @@ -174,6 +174,9 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg)
5683     case RT286_PROC_COEF:
5684     case RT286_SET_AMP_GAIN_ADC_IN1:
5685     case RT286_SET_AMP_GAIN_ADC_IN2:
5686     + case RT286_SET_GPIO_MASK:
5687     + case RT286_SET_GPIO_DIRECTION:
5688     + case RT286_SET_GPIO_DATA:
5689     case RT286_SET_POWER(RT286_DAC_OUT1):
5690     case RT286_SET_POWER(RT286_DAC_OUT2):
5691     case RT286_SET_POWER(RT286_ADC_IN1):
5692     @@ -1119,12 +1122,11 @@ static const struct dmi_system_id force_combo_jack_table[] = {
5693     { }
5694     };
5695    
5696     -static const struct dmi_system_id dmi_dell_dino[] = {
5697     +static const struct dmi_system_id dmi_dell[] = {
5698     {
5699     - .ident = "Dell Dino",
5700     + .ident = "Dell",
5701     .matches = {
5702     DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
5703     - DMI_MATCH(DMI_PRODUCT_NAME, "XPS 13 9343")
5704     }
5705     },
5706     { }
5707     @@ -1135,7 +1137,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
5708     {
5709     struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev);
5710     struct rt286_priv *rt286;
5711     - int i, ret, val;
5712     + int i, ret, vendor_id;
5713    
5714     rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286),
5715     GFP_KERNEL);
5716     @@ -1151,14 +1153,15 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
5717     }
5718    
5719     ret = regmap_read(rt286->regmap,
5720     - RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &val);
5721     + RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &vendor_id);
5722     if (ret != 0) {
5723     dev_err(&i2c->dev, "I2C error %d\n", ret);
5724     return ret;
5725     }
5726     - if (val != RT286_VENDOR_ID && val != RT288_VENDOR_ID) {
5727     + if (vendor_id != RT286_VENDOR_ID && vendor_id != RT288_VENDOR_ID) {
5728     dev_err(&i2c->dev,
5729     - "Device with ID register %#x is not rt286\n", val);
5730     + "Device with ID register %#x is not rt286\n",
5731     + vendor_id);
5732     return -ENODEV;
5733     }
5734    
5735     @@ -1182,8 +1185,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
5736     if (pdata)
5737     rt286->pdata = *pdata;
5738    
5739     - if (dmi_check_system(force_combo_jack_table) ||
5740     - dmi_check_system(dmi_dell_dino))
5741     + if ((vendor_id == RT288_VENDOR_ID && dmi_check_system(dmi_dell)) ||
5742     + dmi_check_system(force_combo_jack_table))
5743     rt286->pdata.cbj_en = true;
5744    
5745     regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3);
5746     @@ -1222,7 +1225,7 @@ static int rt286_i2c_probe(struct i2c_client *i2c,
5747     regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737);
5748     regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f);
5749    
5750     - if (dmi_check_system(dmi_dell_dino)) {
5751     + if (vendor_id == RT288_VENDOR_ID && dmi_check_system(dmi_dell)) {
5752     regmap_update_bits(rt286->regmap,
5753     RT286_SET_GPIO_MASK, 0x40, 0x40);
5754     regmap_update_bits(rt286->regmap,
5755     diff --git a/sound/usb/card.c b/sound/usb/card.c
5756     index 023a36a4922b2..6c5be4e3cb9df 100644
5757     --- a/sound/usb/card.c
5758     +++ b/sound/usb/card.c
5759     @@ -183,9 +183,8 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
5760     ctrlif, interface);
5761     return -EINVAL;
5762     }
5763     - usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
5764     -
5765     - return 0;
5766     + return usb_driver_claim_interface(&usb_audio_driver, iface,
5767     + USB_AUDIO_IFACE_UNUSED);
5768     }
5769    
5770     if ((altsd->bInterfaceClass != USB_CLASS_AUDIO &&
5771     @@ -205,7 +204,8 @@ static int snd_usb_create_stream(struct snd_usb_audio *chip, int ctrlif, int int
5772    
5773     if (! snd_usb_parse_audio_interface(chip, interface)) {
5774     usb_set_interface(dev, interface, 0); /* reset the current interface */
5775     - usb_driver_claim_interface(&usb_audio_driver, iface, (void *)-1L);
5776     + return usb_driver_claim_interface(&usb_audio_driver, iface,
5777     + USB_AUDIO_IFACE_UNUSED);
5778     }
5779    
5780     return 0;
5781     @@ -665,7 +665,7 @@ static void usb_audio_disconnect(struct usb_interface *intf)
5782     struct snd_card *card;
5783     struct list_head *p;
5784    
5785     - if (chip == (void *)-1L)
5786     + if (chip == USB_AUDIO_IFACE_UNUSED)
5787     return;
5788    
5789     card = chip->card;
5790     @@ -765,7 +765,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
5791     struct usb_mixer_interface *mixer;
5792     struct list_head *p;
5793    
5794     - if (chip == (void *)-1L)
5795     + if (chip == USB_AUDIO_IFACE_UNUSED)
5796     return 0;
5797    
5798     if (!chip->num_suspended_intf++) {
5799     @@ -795,7 +795,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
5800     struct list_head *p;
5801     int err = 0;
5802    
5803     - if (chip == (void *)-1L)
5804     + if (chip == USB_AUDIO_IFACE_UNUSED)
5805     return 0;
5806    
5807     atomic_inc(&chip->active); /* avoid autopm */
5808     diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
5809     index a917b7e02d312..d3d3e05fe5b8d 100644
5810     --- a/sound/usb/quirks-table.h
5811     +++ b/sound/usb/quirks-table.h
5812     @@ -2479,6 +2479,16 @@ YAMAHA_DEVICE(0x7010, "UB99"),
5813     }
5814     },
5815    
5816     +{
5817     + USB_DEVICE_VENDOR_SPEC(0x0944, 0x0204),
5818     + .driver_info = (unsigned long) & (const struct snd_usb_audio_quirk) {
5819     + .vendor_name = "KORG, Inc.",
5820     + /* .product_name = "ToneLab EX", */
5821     + .ifnum = 3,
5822     + .type = QUIRK_MIDI_STANDARD_INTERFACE,
5823     + }
5824     +},
5825     +
5826     /* AKAI devices */
5827     {
5828     USB_DEVICE(0x09e8, 0x0062),
5829     diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c
5830     index 6b9e6b57d58df..02b4d0638e008 100644
5831     --- a/sound/usb/quirks.c
5832     +++ b/sound/usb/quirks.c
5833     @@ -66,8 +66,12 @@ static int create_composite_quirk(struct snd_usb_audio *chip,
5834     if (!iface)
5835     continue;
5836     if (quirk->ifnum != probed_ifnum &&
5837     - !usb_interface_claimed(iface))
5838     - usb_driver_claim_interface(driver, iface, (void *)-1L);
5839     + !usb_interface_claimed(iface)) {
5840     + err = usb_driver_claim_interface(driver, iface,
5841     + USB_AUDIO_IFACE_UNUSED);
5842     + if (err < 0)
5843     + return err;
5844     + }
5845     }
5846    
5847     return 0;
5848     @@ -399,8 +403,12 @@ static int create_autodetect_quirks(struct snd_usb_audio *chip,
5849     continue;
5850    
5851     err = create_autodetect_quirk(chip, iface, driver);
5852     - if (err >= 0)
5853     - usb_driver_claim_interface(driver, iface, (void *)-1L);
5854     + if (err >= 0) {
5855     + err = usb_driver_claim_interface(driver, iface,
5856     + USB_AUDIO_IFACE_UNUSED);
5857     + if (err < 0)
5858     + return err;
5859     + }
5860     }
5861    
5862     return 0;
5863     diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
5864     index f4ee83c8e0b2b..62456a806bb4d 100644
5865     --- a/sound/usb/usbaudio.h
5866     +++ b/sound/usb/usbaudio.h
5867     @@ -63,6 +63,8 @@ struct snd_usb_audio {
5868     struct usb_host_interface *ctrl_intf; /* the audio control interface */
5869     };
5870    
5871     +#define USB_AUDIO_IFACE_UNUSED ((void *)-1L)
5872     +
5873     #define usb_audio_err(chip, fmt, args...) \
5874     dev_err(&(chip)->dev->dev, fmt, ##args)
5875     #define usb_audio_warn(chip, fmt, args...) \
5876     diff --git a/tools/perf/util/symbol_fprintf.c b/tools/perf/util/symbol_fprintf.c
5877     index a680bdaa65dc3..060957aeb79a7 100644
5878     --- a/tools/perf/util/symbol_fprintf.c
5879     +++ b/tools/perf/util/symbol_fprintf.c
5880     @@ -64,7 +64,7 @@ size_t dso__fprintf_symbols_by_name(struct dso *dso,
5881    
5882     for (nd = rb_first(&dso->symbol_names[type]); nd; nd = rb_next(nd)) {
5883     pos = rb_entry(nd, struct symbol_name_rb_node, rb_node);
5884     - fprintf(fp, "%s\n", pos->sym.name);
5885     + ret += fprintf(fp, "%s\n", pos->sym.name);
5886     }
5887    
5888     return ret;
5889     diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
5890     index 50a93f5f13d64..d8fa6c72b7ca7 100644
5891     --- a/tools/testing/selftests/lib.mk
5892     +++ b/tools/testing/selftests/lib.mk
5893     @@ -1,6 +1,10 @@
5894     # This mimics the top-level Makefile. We do it explicitly here so that this
5895     # Makefile can operate with or without the kbuild infrastructure.
5896     +ifneq ($(LLVM),)
5897     +CC := clang
5898     +else
5899     CC := $(CROSS_COMPILE)gcc
5900     +endif
5901    
5902     define RUN_TESTS
5903     @for TEST in $(TEST_PROGS); do \