Magellan Linux

Annotation of /trunk/kernel-alx-legacy/patches-4.9/0417-4.9.318-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3719 - (hide annotations) (download)
Mon Oct 24 14:08:31 2022 UTC (18 months, 3 weeks ago) by niro
File size: 146084 byte(s)
-linux-4.9.318
1 niro 3719 diff --git a/Documentation/ABI/testing/sysfs-ata b/Documentation/ABI/testing/sysfs-ata
2     index aa4296498859e..c5dda2bc477d4 100644
3     --- a/Documentation/ABI/testing/sysfs-ata
4     +++ b/Documentation/ABI/testing/sysfs-ata
5     @@ -59,17 +59,18 @@ class
6    
7     dma_mode
8    
9     - Transfer modes supported by the device when in DMA mode.
10     + DMA transfer mode used by the device.
11     Mostly used by PATA device.
12    
13     pio_mode
14    
15     - Transfer modes supported by the device when in PIO mode.
16     + PIO transfer mode used by the device.
17     Mostly used by PATA device.
18    
19     xfer_mode
20    
21     Current transfer mode.
22     + Mostly used by PATA device.
23    
24     id
25    
26     diff --git a/Documentation/conf.py b/Documentation/conf.py
27     index da7b54388eff6..6818dfbeac7fb 100644
28     --- a/Documentation/conf.py
29     +++ b/Documentation/conf.py
30     @@ -96,7 +96,7 @@ finally:
31     #
32     # This is also used if you do content translation via gettext catalogs.
33     # Usually you set "language" from the command line for these cases.
34     -language = None
35     +language = 'en'
36    
37     # There are two options for replacing |today|: either, you set today to some
38     # non-false value, then it is used:
39     diff --git a/Documentation/devicetree/bindings/gpio/gpio-altera.txt b/Documentation/devicetree/bindings/gpio/gpio-altera.txt
40     index 826a7208ca93a..184ecd6bc39d2 100644
41     --- a/Documentation/devicetree/bindings/gpio/gpio-altera.txt
42     +++ b/Documentation/devicetree/bindings/gpio/gpio-altera.txt
43     @@ -9,8 +9,9 @@ Required properties:
44     - The second cell is reserved and is currently unused.
45     - gpio-controller : Marks the device node as a GPIO controller.
46     - interrupt-controller: Mark the device node as an interrupt controller
47     -- #interrupt-cells : Should be 1. The interrupt type is fixed in the hardware.
48     +- #interrupt-cells : Should be 2. The interrupt type is fixed in the hardware.
49     - The first cell is the GPIO offset number within the GPIO controller.
50     + - The second cell is the interrupt trigger type and level flags.
51     - interrupts: Specify the interrupt.
52     - altr,interrupt-type: Specifies the interrupt trigger type the GPIO
53     hardware is synthesized. This field is required if the Altera GPIO controller
54     @@ -38,6 +39,6 @@ gpio_altr: gpio@0xff200000 {
55     altr,interrupt-type = <IRQ_TYPE_EDGE_RISING>;
56     #gpio-cells = <2>;
57     gpio-controller;
58     - #interrupt-cells = <1>;
59     + #interrupt-cells = <2>;
60     interrupt-controller;
61     };
62     diff --git a/Makefile b/Makefile
63     index cc1a47220975b..46bea19a6c96d 100644
64     --- a/Makefile
65     +++ b/Makefile
66     @@ -1,6 +1,6 @@
67     VERSION = 4
68     PATCHLEVEL = 9
69     -SUBLEVEL = 317
70     +SUBLEVEL = 318
71     EXTRAVERSION =
72     NAME = Roaring Lionus
73    
74     diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
75     index 54e79f6887ffa..3dda0569f86af 100644
76     --- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
77     +++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
78     @@ -129,7 +129,7 @@
79     samsung,i2c-max-bus-freq = <20000>;
80    
81     eeprom@50 {
82     - compatible = "samsung,s524ad0xd1";
83     + compatible = "samsung,s524ad0xd1", "atmel,24c128";
84     reg = <0x50>;
85     };
86    
87     @@ -288,7 +288,7 @@
88     samsung,i2c-max-bus-freq = <20000>;
89    
90     eeprom@51 {
91     - compatible = "samsung,s524ad0xd1";
92     + compatible = "samsung,s524ad0xd1", "atmel,24c128";
93     reg = <0x51>;
94     };
95    
96     diff --git a/arch/arm/mach-hisi/platsmp.c b/arch/arm/mach-hisi/platsmp.c
97     index e1d67648d5d02..fccceab333253 100644
98     --- a/arch/arm/mach-hisi/platsmp.c
99     +++ b/arch/arm/mach-hisi/platsmp.c
100     @@ -70,14 +70,17 @@ static void __init hi3xxx_smp_prepare_cpus(unsigned int max_cpus)
101     }
102     ctrl_base = of_iomap(np, 0);
103     if (!ctrl_base) {
104     + of_node_put(np);
105     pr_err("failed to map address\n");
106     return;
107     }
108     if (of_property_read_u32(np, "smp-offset", &offset) < 0) {
109     + of_node_put(np);
110     pr_err("failed to find smp-offset property\n");
111     return;
112     }
113     ctrl_base += offset;
114     + of_node_put(np);
115     }
116     }
117    
118     @@ -163,6 +166,7 @@ static int hip01_boot_secondary(unsigned int cpu, struct task_struct *idle)
119     if (WARN_ON(!node))
120     return -1;
121     ctrl_base = of_iomap(node, 0);
122     + of_node_put(node);
123    
124     /* set the secondary core boot from DDR */
125     remap_reg_value = readl_relaxed(ctrl_base + REG_SC_CTRL);
126     diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
127     index 034b89499bd72..a3599696e7ccd 100644
128     --- a/arch/arm/mach-omap1/clock.c
129     +++ b/arch/arm/mach-omap1/clock.c
130     @@ -44,7 +44,7 @@ static DEFINE_SPINLOCK(clockfw_lock);
131     unsigned long omap1_uart_recalc(struct clk *clk)
132     {
133     unsigned int val = __raw_readl(clk->enable_reg);
134     - return val & clk->enable_bit ? 48000000 : 12000000;
135     + return val & 1 << clk->enable_bit ? 48000000 : 12000000;
136     }
137    
138     unsigned long omap1_sossi_recalc(struct clk *clk)
139     diff --git a/arch/arm/mach-vexpress/dcscb.c b/arch/arm/mach-vexpress/dcscb.c
140     index 5cedcf572104b..3e86cff1d4d3b 100644
141     --- a/arch/arm/mach-vexpress/dcscb.c
142     +++ b/arch/arm/mach-vexpress/dcscb.c
143     @@ -146,6 +146,7 @@ static int __init dcscb_init(void)
144     if (!node)
145     return -ENODEV;
146     dcscb_base = of_iomap(node, 0);
147     + of_node_put(node);
148     if (!dcscb_base)
149     return -EADDRNOTAVAIL;
150     cfg = readl_relaxed(dcscb_base + DCS_CFG_R);
151     diff --git a/arch/m68k/Kconfig.cpu b/arch/m68k/Kconfig.cpu
152     index d2219f30b78f0..2268d19cc915d 100644
153     --- a/arch/m68k/Kconfig.cpu
154     +++ b/arch/m68k/Kconfig.cpu
155     @@ -307,7 +307,7 @@ comment "Processor Specific Options"
156    
157     config M68KFPU_EMU
158     bool "Math emulation support"
159     - depends on MMU
160     + depends on M68KCLASSIC && FPU
161     help
162     At some point in the future, this will cause floating-point math
163     instructions to be emulated by the kernel on machines that lack a
164     diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
165     index f622c3ccafc31..9f2896493ca00 100644
166     --- a/arch/m68k/Kconfig.machine
167     +++ b/arch/m68k/Kconfig.machine
168     @@ -302,6 +302,7 @@ comment "Machine Options"
169    
170     config UBOOT
171     bool "Support for U-Boot command line parameters"
172     + depends on COLDFIRE
173     help
174     If you say Y here kernel will try to collect command
175     line parameters from the initial u-boot stack.
176     diff --git a/arch/m68k/include/asm/pgtable_no.h b/arch/m68k/include/asm/pgtable_no.h
177     index ac7d87a02335e..269443e1084b3 100644
178     --- a/arch/m68k/include/asm/pgtable_no.h
179     +++ b/arch/m68k/include/asm/pgtable_no.h
180     @@ -41,7 +41,8 @@ extern void paging_init(void);
181     * ZERO_PAGE is a global shared page that is always zero: used
182     * for zero-mapped memory areas etc..
183     */
184     -#define ZERO_PAGE(vaddr) (virt_to_page(0))
185     +extern void *empty_zero_page;
186     +#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
187    
188     /*
189     * No page table caches to initialise.
190     diff --git a/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
191     index 7449794eade6c..dff5c2885d150 100644
192     --- a/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
193     +++ b/arch/mips/include/asm/mach-ip27/cpu-feature-overrides.h
194     @@ -28,7 +28,6 @@
195     #define cpu_has_6k_cache 0
196     #define cpu_has_8k_cache 0
197     #define cpu_has_tx39_cache 0
198     -#define cpu_has_fpu 1
199     #define cpu_has_nofpuex 0
200     #define cpu_has_32fpr 1
201     #define cpu_has_counter 1
202     diff --git a/arch/openrisc/include/asm/timex.h b/arch/openrisc/include/asm/timex.h
203     index 9935cad1b9b93..34d015bf04628 100644
204     --- a/arch/openrisc/include/asm/timex.h
205     +++ b/arch/openrisc/include/asm/timex.h
206     @@ -27,6 +27,7 @@ static inline cycles_t get_cycles(void)
207     {
208     return mfspr(SPR_TTCR);
209     }
210     +#define get_cycles get_cycles
211    
212     /* This isn't really used any more */
213     #define CLOCK_TICK_RATE 1000
214     diff --git a/arch/openrisc/kernel/head.S b/arch/openrisc/kernel/head.S
215     index 98dd6860bc0b9..0b6be5b3522b0 100644
216     --- a/arch/openrisc/kernel/head.S
217     +++ b/arch/openrisc/kernel/head.S
218     @@ -452,6 +452,15 @@ _start:
219     l.ori r3,r0,0x1
220     l.mtspr r0,r3,SPR_SR
221    
222     + /*
223     + * Start the TTCR as early as possible, so that the RNG can make use of
224     + * measurements of boot time from the earliest opportunity. Especially
225     + * important is that the TTCR does not return zero by the time we reach
226     + * rand_initialize().
227     + */
228     + l.movhi r3,hi(SPR_TTMR_CR)
229     + l.mtspr r0,r3,SPR_TTMR
230     +
231     CLEAR_GPR(r1)
232     CLEAR_GPR(r2)
233     CLEAR_GPR(r3)
234     diff --git a/arch/powerpc/kernel/idle.c b/arch/powerpc/kernel/idle.c
235     index d7216c9abda15..ca79aacfeda2a 100644
236     --- a/arch/powerpc/kernel/idle.c
237     +++ b/arch/powerpc/kernel/idle.c
238     @@ -41,7 +41,7 @@ static int __init powersave_off(char *arg)
239     {
240     ppc_md.power_save = NULL;
241     cpuidle_disable = IDLE_POWERSAVE_OFF;
242     - return 0;
243     + return 1;
244     }
245     __setup("powersave=off", powersave_off);
246    
247     diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
248     index 4f2829634d795..88947f5fd7781 100644
249     --- a/arch/powerpc/kernel/ptrace.c
250     +++ b/arch/powerpc/kernel/ptrace.c
251     @@ -2938,8 +2938,13 @@ long arch_ptrace(struct task_struct *child, long request,
252    
253     flush_fp_to_thread(child);
254     if (fpidx < (PT_FPSCR - PT_FPR0))
255     - memcpy(&tmp, &child->thread.TS_FPR(fpidx),
256     - sizeof(long));
257     + if (IS_ENABLED(CONFIG_PPC32)) {
258     + // On 32-bit the index we are passed refers to 32-bit words
259     + tmp = ((u32 *)child->thread.fp_state.fpr)[fpidx];
260     + } else {
261     + memcpy(&tmp, &child->thread.TS_FPR(fpidx),
262     + sizeof(long));
263     + }
264     else
265     tmp = child->thread.fp_state.fpscr;
266     }
267     @@ -2971,8 +2976,13 @@ long arch_ptrace(struct task_struct *child, long request,
268    
269     flush_fp_to_thread(child);
270     if (fpidx < (PT_FPSCR - PT_FPR0))
271     - memcpy(&child->thread.TS_FPR(fpidx), &data,
272     - sizeof(long));
273     + if (IS_ENABLED(CONFIG_PPC32)) {
274     + // On 32-bit the index we are passed refers to 32-bit words
275     + ((u32 *)child->thread.fp_state.fpr)[fpidx] = data;
276     + } else {
277     + memcpy(&child->thread.TS_FPR(fpidx), &data,
278     + sizeof(long));
279     + }
280     else
281     child->thread.fp_state.fpscr = data;
282     ret = 0;
283     diff --git a/arch/powerpc/sysdev/cpm1.c b/arch/powerpc/sysdev/cpm1.c
284     index 986cd111d4df1..8f2dc4ea9376f 100644
285     --- a/arch/powerpc/sysdev/cpm1.c
286     +++ b/arch/powerpc/sysdev/cpm1.c
287     @@ -290,6 +290,7 @@ cpm_setbrg(uint brg, uint rate)
288     out_be32(bp, (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) |
289     CPM_BRG_EN | CPM_BRG_DIV16);
290     }
291     +EXPORT_SYMBOL(cpm_setbrg);
292    
293     struct cpm_ioport16 {
294     __be16 dir, par, odr_sor, dat, intr;
295     diff --git a/arch/powerpc/sysdev/ppc4xx_cpm.c b/arch/powerpc/sysdev/ppc4xx_cpm.c
296     index ba95adf81d8d9..05047cf32dbb0 100644
297     --- a/arch/powerpc/sysdev/ppc4xx_cpm.c
298     +++ b/arch/powerpc/sysdev/ppc4xx_cpm.c
299     @@ -341,6 +341,6 @@ late_initcall(cpm_init);
300     static int __init cpm_powersave_off(char *arg)
301     {
302     cpm.powersave_off = 1;
303     - return 0;
304     + return 1;
305     }
306     __setup("powersave=off", cpm_powersave_off);
307     diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
308     index b53f80f0b4d82..80a4fa6dcc550 100644
309     --- a/arch/powerpc/sysdev/xics/icp-opal.c
310     +++ b/arch/powerpc/sysdev/xics/icp-opal.c
311     @@ -199,6 +199,7 @@ int icp_opal_init(void)
312    
313     printk("XICS: Using OPAL ICP fallbacks\n");
314    
315     + of_node_put(np);
316     return 0;
317     }
318    
319     diff --git a/arch/um/drivers/chan_user.c b/arch/um/drivers/chan_user.c
320     index feb7f5ab40841..cd7346d26b89c 100644
321     --- a/arch/um/drivers/chan_user.c
322     +++ b/arch/um/drivers/chan_user.c
323     @@ -220,7 +220,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
324     unsigned long *stack_out)
325     {
326     struct winch_data data;
327     - int fds[2], n, err;
328     + int fds[2], n, err, pid;
329     char c;
330    
331     err = os_pipe(fds, 1, 1);
332     @@ -238,8 +238,9 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
333     * problem with /dev/net/tun, which if held open by this
334     * thread, prevents the TUN/TAP device from being reused.
335     */
336     - err = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
337     - if (err < 0) {
338     + pid = run_helper_thread(winch_thread, &data, CLONE_FILES, stack_out);
339     + if (pid < 0) {
340     + err = pid;
341     printk(UM_KERN_ERR "fork of winch_thread failed - errno = %d\n",
342     -err);
343     goto out_close;
344     @@ -263,7 +264,7 @@ static int winch_tramp(int fd, struct tty_port *port, int *fd_out,
345     goto out_close;
346     }
347    
348     - return err;
349     + return pid;
350    
351     out_close:
352     close(fds[1]);
353     diff --git a/arch/x86/include/asm/acenv.h b/arch/x86/include/asm/acenv.h
354     index 1b010a859b8b4..6de59a4f723ca 100644
355     --- a/arch/x86/include/asm/acenv.h
356     +++ b/arch/x86/include/asm/acenv.h
357     @@ -16,7 +16,19 @@
358    
359     /* Asm macros */
360    
361     -#define ACPI_FLUSH_CPU_CACHE() wbinvd()
362     +/*
363     + * ACPI_FLUSH_CPU_CACHE() flushes caches on entering sleep states.
364     + * It is required to prevent data loss.
365     + *
366     + * While running inside virtual machine, the kernel can bypass cache flushing.
367     + * Changing sleep state in a virtual machine doesn't affect the host system
368     + * sleep state and cannot lead to data loss.
369     + */
370     +#define ACPI_FLUSH_CPU_CACHE() \
371     +do { \
372     + if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR)) \
373     + wbinvd(); \
374     +} while (0)
375    
376     int __acpi_acquire_global_lock(unsigned int *lock);
377     int __acpi_release_global_lock(unsigned int *lock);
378     diff --git a/arch/x86/include/asm/suspend_32.h b/arch/x86/include/asm/suspend_32.h
379     index 5cc2ce4ab8a32..4cb2a435dc859 100644
380     --- a/arch/x86/include/asm/suspend_32.h
381     +++ b/arch/x86/include/asm/suspend_32.h
382     @@ -20,7 +20,6 @@ struct saved_context {
383     #endif
384     unsigned long cr0, cr2, cr3, cr4;
385     u64 misc_enable;
386     - bool misc_enable_saved;
387     struct saved_msrs saved_msrs;
388     struct desc_ptr gdt_desc;
389     struct desc_ptr idt;
390     @@ -29,6 +28,7 @@ struct saved_context {
391     unsigned long tr;
392     unsigned long safety;
393     unsigned long return_address;
394     + bool misc_enable_saved;
395     } __attribute__((packed));
396    
397     #endif /* _ASM_X86_SUSPEND_32_H */
398     diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h
399     index 7017519189216..a235dd7983f01 100644
400     --- a/arch/x86/include/asm/suspend_64.h
401     +++ b/arch/x86/include/asm/suspend_64.h
402     @@ -13,9 +13,13 @@
403     * Image of the saved processor state, used by the low level ACPI suspend to
404     * RAM code and by the low level hibernation code.
405     *
406     - * If you modify it, fix arch/x86/kernel/acpi/wakeup_64.S and make sure that
407     - * __save/__restore_processor_state(), defined in arch/x86/kernel/suspend_64.c,
408     - * still work as required.
409     + * If you modify it, check how it is used in arch/x86/kernel/acpi/wakeup_64.S
410     + * and make sure that __save/__restore_processor_state(), defined in
411     + * arch/x86/power/cpu.c, still work as required.
412     + *
413     + * Because the structure is packed, make sure to avoid unaligned members. For
414     + * optimisation purposes but also because tools like kmemleak only search for
415     + * pointers that are aligned.
416     */
417     struct saved_context {
418     struct pt_regs regs;
419     @@ -35,7 +39,6 @@ struct saved_context {
420    
421     unsigned long cr0, cr2, cr3, cr4, cr8;
422     u64 misc_enable;
423     - bool misc_enable_saved;
424     struct saved_msrs saved_msrs;
425     unsigned long efer;
426     u16 gdt_pad; /* Unused */
427     @@ -47,6 +50,7 @@ struct saved_context {
428     unsigned long tr;
429     unsigned long safety;
430     unsigned long return_address;
431     + bool misc_enable_saved;
432     } __attribute__((packed));
433    
434     #define loaddebug(thread,register) \
435     diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
436     index a23ce84a3f6cc..1def1e8de4bd1 100644
437     --- a/arch/x86/kernel/step.c
438     +++ b/arch/x86/kernel/step.c
439     @@ -173,8 +173,7 @@ void set_task_blockstep(struct task_struct *task, bool on)
440     *
441     * NOTE: this means that set/clear TIF_BLOCKSTEP is only safe if
442     * task is current or it can't be running, otherwise we can race
443     - * with __switch_to_xtra(). We rely on ptrace_freeze_traced() but
444     - * PTRACE_KILL is not safe.
445     + * with __switch_to_xtra(). We rely on ptrace_freeze_traced().
446     */
447     local_irq_disable();
448     debugctl = get_debugctlmsr();
449     diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
450     index 1d4e7fd3e66dc..1078705292fce 100644
451     --- a/arch/x86/kernel/sys_x86_64.c
452     +++ b/arch/x86/kernel/sys_x86_64.c
453     @@ -66,9 +66,6 @@ static int __init control_va_addr_alignment(char *str)
454     if (*str == 0)
455     return 1;
456    
457     - if (*str == '=')
458     - str++;
459     -
460     if (!strcmp(str, "32"))
461     va_align.flags = ALIGN_VA_32;
462     else if (!strcmp(str, "64"))
463     @@ -78,11 +75,11 @@ static int __init control_va_addr_alignment(char *str)
464     else if (!strcmp(str, "on"))
465     va_align.flags = ALIGN_VA_32 | ALIGN_VA_64;
466     else
467     - return 0;
468     + pr_warn("invalid option value: 'align_va_addr=%s'\n", str);
469    
470     return 1;
471     }
472     -__setup("align_va_addr", control_va_addr_alignment);
473     +__setup("align_va_addr=", control_va_addr_alignment);
474    
475     SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
476     unsigned long, prot, unsigned long, flags,
477     diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c
478     index 71a3759a2d4e8..60cc4f222cbfb 100644
479     --- a/arch/x86/lib/delay.c
480     +++ b/arch/x86/lib/delay.c
481     @@ -42,8 +42,8 @@ static void delay_loop(unsigned long loops)
482     " jnz 2b \n"
483     "3: dec %0 \n"
484    
485     - : /* we don't need output */
486     - :"a" (loops)
487     + : "+a" (loops)
488     + :
489     );
490     }
491    
492     diff --git a/arch/x86/um/ldt.c b/arch/x86/um/ldt.c
493     index 3ee234b6234dd..255a44dd415a9 100644
494     --- a/arch/x86/um/ldt.c
495     +++ b/arch/x86/um/ldt.c
496     @@ -23,9 +23,11 @@ static long write_ldt_entry(struct mm_id *mm_idp, int func,
497     {
498     long res;
499     void *stub_addr;
500     +
501     + BUILD_BUG_ON(sizeof(*desc) % sizeof(long));
502     +
503     res = syscall_stub_data(mm_idp, (unsigned long *)desc,
504     - (sizeof(*desc) + sizeof(long) - 1) &
505     - ~(sizeof(long) - 1),
506     + sizeof(*desc) / sizeof(long),
507     addr, &stub_addr);
508     if (!res) {
509     unsigned long args[] = { func,
510     diff --git a/arch/xtensa/kernel/ptrace.c b/arch/xtensa/kernel/ptrace.c
511     index a651f3a628eec..63612244dbcab 100644
512     --- a/arch/xtensa/kernel/ptrace.c
513     +++ b/arch/xtensa/kernel/ptrace.c
514     @@ -34,12 +34,12 @@
515    
516     void user_enable_single_step(struct task_struct *child)
517     {
518     - child->ptrace |= PT_SINGLESTEP;
519     + set_tsk_thread_flag(child, TIF_SINGLESTEP);
520     }
521    
522     void user_disable_single_step(struct task_struct *child)
523     {
524     - child->ptrace &= ~PT_SINGLESTEP;
525     + clear_tsk_thread_flag(child, TIF_SINGLESTEP);
526     }
527    
528     /*
529     diff --git a/arch/xtensa/kernel/signal.c b/arch/xtensa/kernel/signal.c
530     index e87adaa07ff3f..1a4462a003aa8 100644
531     --- a/arch/xtensa/kernel/signal.c
532     +++ b/arch/xtensa/kernel/signal.c
533     @@ -458,7 +458,7 @@ static void do_signal(struct pt_regs *regs)
534     /* Set up the stack frame */
535     ret = setup_frame(&ksig, sigmask_to_save(), regs);
536     signal_setup_done(ret, &ksig, 0);
537     - if (current->ptrace & PT_SINGLESTEP)
538     + if (test_thread_flag(TIF_SINGLESTEP))
539     task_pt_regs(current)->icountlevel = 1;
540    
541     return;
542     @@ -484,7 +484,7 @@ static void do_signal(struct pt_regs *regs)
543     /* If there's no signal to deliver, we just restore the saved mask. */
544     restore_saved_sigmask();
545    
546     - if (current->ptrace & PT_SINGLESTEP)
547     + if (test_thread_flag(TIF_SINGLESTEP))
548     task_pt_regs(current)->icountlevel = 1;
549     return;
550     }
551     diff --git a/drivers/ata/libata-transport.c b/drivers/ata/libata-transport.c
552     index 20e2b7ad89250..841ab8a2cae61 100644
553     --- a/drivers/ata/libata-transport.c
554     +++ b/drivers/ata/libata-transport.c
555     @@ -196,7 +196,7 @@ static struct {
556     { XFER_PIO_0, "XFER_PIO_0" },
557     { XFER_PIO_SLOW, "XFER_PIO_SLOW" }
558     };
559     -ata_bitfield_name_match(xfer,ata_xfer_names)
560     +ata_bitfield_name_search(xfer, ata_xfer_names)
561    
562     /*
563     * ATA Port attributes
564     diff --git a/drivers/ata/pata_octeon_cf.c b/drivers/ata/pata_octeon_cf.c
565     index 7e6359e32ab63..fb07d16a9f2a6 100644
566     --- a/drivers/ata/pata_octeon_cf.c
567     +++ b/drivers/ata/pata_octeon_cf.c
568     @@ -898,12 +898,14 @@ static int octeon_cf_probe(struct platform_device *pdev)
569     int i;
570     res_dma = platform_get_resource(dma_dev, IORESOURCE_MEM, 0);
571     if (!res_dma) {
572     + put_device(&dma_dev->dev);
573     of_node_put(dma_node);
574     return -EINVAL;
575     }
576     cf_port->dma_base = (u64)devm_ioremap_nocache(&pdev->dev, res_dma->start,
577     resource_size(res_dma));
578     if (!cf_port->dma_base) {
579     + put_device(&dma_dev->dev);
580     of_node_put(dma_node);
581     return -EINVAL;
582     }
583     @@ -913,6 +915,7 @@ static int octeon_cf_probe(struct platform_device *pdev)
584     irq = i;
585     irq_handler = octeon_cf_interrupt;
586     }
587     + put_device(&dma_dev->dev);
588     }
589     of_node_put(dma_node);
590     }
591     diff --git a/drivers/base/node.c b/drivers/base/node.c
592     index 5548f96860162..7f91266330809 100644
593     --- a/drivers/base/node.c
594     +++ b/drivers/base/node.c
595     @@ -315,6 +315,7 @@ static int register_node(struct node *node, int num, struct node *parent)
596     */
597     void unregister_node(struct node *node)
598     {
599     + compaction_unregister_node(node);
600     hugetlb_unregister_node(node); /* no-op, if memoryless node */
601    
602     device_unregister(&node->dev);
603     diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
604     index a4ef9a6bd3678..45117728e735e 100644
605     --- a/drivers/char/ipmi/ipmi_ssif.c
606     +++ b/drivers/char/ipmi/ipmi_ssif.c
607     @@ -812,6 +812,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
608     break;
609    
610     case SSIF_GETTING_EVENTS:
611     + if (!msg) {
612     + /* Should never happen, but just in case. */
613     + dev_warn(&ssif_info->client->dev,
614     + "No message set while getting events\n");
615     + ipmi_ssif_unlock_cond(ssif_info, flags);
616     + break;
617     + }
618     +
619     if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
620     /* Error getting event, probably done. */
621     msg->done(msg);
622     @@ -835,6 +843,14 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
623     break;
624    
625     case SSIF_GETTING_MESSAGES:
626     + if (!msg) {
627     + /* Should never happen, but just in case. */
628     + dev_warn(&ssif_info->client->dev,
629     + "No message set while getting messages\n");
630     + ipmi_ssif_unlock_cond(ssif_info, flags);
631     + break;
632     + }
633     +
634     if ((result < 0) || (len < 3) || (msg->rsp[2] != 0)) {
635     /* Error getting event, probably done. */
636     msg->done(msg);
637     @@ -857,6 +873,13 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
638     deliver_recv_msg(ssif_info, msg);
639     }
640     break;
641     +
642     + default:
643     + /* Should never happen, but just in case. */
644     + dev_warn(&ssif_info->client->dev,
645     + "Invalid state in message done handling: %d\n",
646     + ssif_info->ssif_state);
647     + ipmi_ssif_unlock_cond(ssif_info, flags);
648     }
649    
650     flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
651     diff --git a/drivers/clocksource/timer-oxnas-rps.c b/drivers/clocksource/timer-oxnas-rps.c
652     index d630bf417773a..411f211185d36 100644
653     --- a/drivers/clocksource/timer-oxnas-rps.c
654     +++ b/drivers/clocksource/timer-oxnas-rps.c
655     @@ -247,7 +247,7 @@ static int __init oxnas_rps_timer_init(struct device_node *np)
656     }
657    
658     rps->irq = irq_of_parse_and_map(np, 0);
659     - if (rps->irq < 0) {
660     + if (!rps->irq) {
661     ret = -EINVAL;
662     goto err_iomap;
663     }
664     diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c
665     index d07863388e05e..780699e4d120d 100644
666     --- a/drivers/clocksource/timer-sp804.c
667     +++ b/drivers/clocksource/timer-sp804.c
668     @@ -227,6 +227,11 @@ static int __init sp804_of_init(struct device_node *np)
669     struct clk *clk1, *clk2;
670     const char *name = of_get_property(np, "compatible", NULL);
671    
672     + if (initialized) {
673     + pr_debug("%pOF: skipping further SP804 timer device\n", np);
674     + return 0;
675     + }
676     +
677     base = of_iomap(np, 0);
678     if (!base)
679     return -ENXIO;
680     @@ -235,11 +240,6 @@ static int __init sp804_of_init(struct device_node *np)
681     writel(0, base + TIMER_CTRL);
682     writel(0, base + TIMER_2_BASE + TIMER_CTRL);
683    
684     - if (initialized || !of_device_is_available(np)) {
685     - ret = -EINVAL;
686     - goto err;
687     - }
688     -
689     clk1 = of_clk_get(np, 0);
690     if (IS_ERR(clk1))
691     clk1 = NULL;
692     diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
693     index ef76e5eecf0b0..37f76daa2b3db 100644
694     --- a/drivers/firmware/dmi-sysfs.c
695     +++ b/drivers/firmware/dmi-sysfs.c
696     @@ -601,7 +601,7 @@ static void __init dmi_sysfs_register_handle(const struct dmi_header *dh,
697     "%d-%d", dh->type, entry->instance);
698    
699     if (*ret) {
700     - kfree(entry);
701     + kobject_put(&entry->kobj);
702     return;
703     }
704    
705     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
706     index c801624f33bd9..35130c07e17f7 100644
707     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
708     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
709     @@ -139,7 +139,7 @@ int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, void *data)
710     int ret;
711    
712     if (cs->in.num_chunks == 0)
713     - return 0;
714     + return -EINVAL;
715    
716     chunk_array = kmalloc_array(cs->in.num_chunks, sizeof(uint64_t), GFP_KERNEL);
717     if (!chunk_array)
718     diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
719     index f61c489e5f6d9..81f1591a9be97 100644
720     --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
721     +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
722     @@ -1617,19 +1617,7 @@ static int kv_update_samu_dpm(struct amdgpu_device *adev, bool gate)
723    
724     static u8 kv_get_acp_boot_level(struct amdgpu_device *adev)
725     {
726     - u8 i;
727     - struct amdgpu_clock_voltage_dependency_table *table =
728     - &adev->pm.dpm.dyn_state.acp_clock_voltage_dependency_table;
729     -
730     - for (i = 0; i < table->count; i++) {
731     - if (table->entries[i].clk >= 0) /* XXX */
732     - break;
733     - }
734     -
735     - if (i >= table->count)
736     - i = table->count - 1;
737     -
738     - return i;
739     + return 0;
740     }
741    
742     static void kv_update_acp_boot_level(struct amdgpu_device *adev)
743     diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
744     index 4826befc1bc36..fe6fda42fde87 100644
745     --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
746     +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
747     @@ -7313,17 +7313,15 @@ static int si_parse_power_table(struct amdgpu_device *adev)
748     if (!adev->pm.dpm.ps)
749     return -ENOMEM;
750     power_state_offset = (u8 *)state_array->states;
751     - for (i = 0; i < state_array->ucNumEntries; i++) {
752     + for (adev->pm.dpm.num_ps = 0, i = 0; i < state_array->ucNumEntries; i++) {
753     u8 *idx;
754     power_state = (union pplib_power_state *)power_state_offset;
755     non_clock_array_index = power_state->v2.nonClockInfoIndex;
756     non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
757     &non_clock_info_array->nonClockInfo[non_clock_array_index];
758     ps = kzalloc(sizeof(struct si_ps), GFP_KERNEL);
759     - if (ps == NULL) {
760     - kfree(adev->pm.dpm.ps);
761     + if (ps == NULL)
762     return -ENOMEM;
763     - }
764     adev->pm.dpm.ps[i].ps_priv = ps;
765     si_parse_pplib_non_clock_info(adev, &adev->pm.dpm.ps[i],
766     non_clock_info,
767     @@ -7345,8 +7343,8 @@ static int si_parse_power_table(struct amdgpu_device *adev)
768     k++;
769     }
770     power_state_offset += 2 + power_state->v2.ucNumDPMLevels;
771     + adev->pm.dpm.num_ps++;
772     }
773     - adev->pm.dpm.num_ps = state_array->ucNumEntries;
774    
775     /* fill in the vce power states */
776     for (i = 0; i < AMDGPU_MAX_VCE_LEVELS; i++) {
777     diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
778     index 72ec93de0e76a..d1077a342f38d 100644
779     --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
780     +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
781     @@ -1275,8 +1275,19 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
782     struct drm_dp_aux_msg *msg)
783     {
784     struct analogix_dp_device *dp = to_dp(aux);
785     + int ret;
786     +
787     + pm_runtime_get_sync(dp->dev);
788    
789     - return analogix_dp_transfer(dp, msg);
790     + ret = analogix_dp_detect_hpd(dp);
791     + if (ret)
792     + goto out;
793     +
794     + ret = analogix_dp_transfer(dp, msg);
795     +out:
796     + pm_runtime_put(dp->dev);
797     +
798     + return ret;
799     }
800    
801     int analogix_dp_bind(struct device *dev, struct drm_device *drm_dev,
802     diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c
803     index 7b6c849250984..389c4973fea86 100644
804     --- a/drivers/gpu/drm/gma500/psb_intel_display.c
805     +++ b/drivers/gpu/drm/gma500/psb_intel_display.c
806     @@ -548,14 +548,15 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
807    
808     struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
809     {
810     - struct drm_crtc *crtc = NULL;
811     + struct drm_crtc *crtc;
812    
813     list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
814     struct gma_crtc *gma_crtc = to_gma_crtc(crtc);
815     +
816     if (gma_crtc->pipe == pipe)
817     - break;
818     + return crtc;
819     }
820     - return crtc;
821     + return NULL;
822     }
823    
824     int gma_connector_clones(struct drm_device *dev, int type_mask)
825     diff --git a/drivers/gpu/drm/mediatek/mtk_cec.c b/drivers/gpu/drm/mediatek/mtk_cec.c
826     index 7a3eb8c17ef99..4e5482986dc2d 100644
827     --- a/drivers/gpu/drm/mediatek/mtk_cec.c
828     +++ b/drivers/gpu/drm/mediatek/mtk_cec.c
829     @@ -91,7 +91,7 @@ static void mtk_cec_mask(struct mtk_cec *cec, unsigned int offset,
830     u32 tmp = readl(cec->regs + offset) & ~mask;
831    
832     tmp |= val & mask;
833     - writel(val, cec->regs + offset);
834     + writel(tmp, cec->regs + offset);
835     }
836    
837     void mtk_cec_set_hpd_event(struct device *dev,
838     diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c b/drivers/gpu/drm/msm/dsi/dsi_host.c
839     index 246336a9f47d6..bea4969900ab4 100644
840     --- a/drivers/gpu/drm/msm/dsi/dsi_host.c
841     +++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
842     @@ -1240,10 +1240,10 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
843     dsi_get_bpp(msm_host->format) / 8;
844    
845     len = dsi_cmd_dma_add(msm_host, msg);
846     - if (!len) {
847     + if (len < 0) {
848     pr_err("%s: failed to add cmd type = 0x%x\n",
849     __func__, msg->type);
850     - return -EINVAL;
851     + return len;
852     }
853    
854     /* for video mode, do not send cmds more than
855     @@ -1262,10 +1262,14 @@ static int dsi_cmds2buf_tx(struct msm_dsi_host *msm_host,
856     }
857    
858     ret = dsi_cmd_dma_tx(msm_host, len);
859     - if (ret < len) {
860     - pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d\n",
861     - __func__, msg->type, (*(u8 *)(msg->tx_buf)), len);
862     - return -ECOMM;
863     + if (ret < 0) {
864     + pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, len=%d, ret=%d\n",
865     + __func__, msg->type, (*(u8 *)(msg->tx_buf)), len, ret);
866     + return ret;
867     + } else if (ret < len) {
868     + pr_err("%s: cmd dma tx failed, type=0x%x, data0=0x%x, ret=%d len=%d\n",
869     + __func__, msg->type, (*(u8 *)(msg->tx_buf)), ret, len);
870     + return -EIO;
871     }
872    
873     return len;
874     @@ -1979,9 +1983,12 @@ int msm_dsi_host_cmd_rx(struct mipi_dsi_host *host,
875     }
876    
877     ret = dsi_cmds2buf_tx(msm_host, msg);
878     - if (ret < msg->tx_len) {
879     + if (ret < 0) {
880     pr_err("%s: Read cmd Tx failed, %d\n", __func__, ret);
881     return ret;
882     + } else if (ret < msg->tx_len) {
883     + pr_err("%s: Read cmd Tx failed, too short: %d\n", __func__, ret);
884     + return -ECOMM;
885     }
886    
887     /*
888     diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c
889     index a968cad509c23..48ab467267079 100644
890     --- a/drivers/gpu/drm/msm/hdmi/hdmi.c
891     +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c
892     @@ -148,6 +148,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
893     /* HDCP needs physical address of hdmi register */
894     res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
895     config->mmio_name);
896     + if (!res) {
897     + ret = -EINVAL;
898     + goto fail;
899     + }
900     hdmi->mmio_phy_addr = res->start;
901    
902     hdmi->qfprom_mmio = msm_ioremap(pdev,
903     diff --git a/drivers/gpu/drm/msm/msm_gem_prime.c b/drivers/gpu/drm/msm/msm_gem_prime.c
904     index 13403c6da6c75..7e4664968106f 100644
905     --- a/drivers/gpu/drm/msm/msm_gem_prime.c
906     +++ b/drivers/gpu/drm/msm/msm_gem_prime.c
907     @@ -26,7 +26,7 @@ struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
908     int npages = obj->size >> PAGE_SHIFT;
909    
910     if (WARN_ON(!msm_obj->pages)) /* should have already pinned! */
911     - return NULL;
912     + return ERR_PTR(-ENOMEM);
913    
914     return drm_prime_pages_to_sg(msm_obj->pages, npages);
915     }
916     diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
917     index 9e6c2be0cc7d4..a759955e37979 100644
918     --- a/drivers/gpu/drm/radeon/radeon_connectors.c
919     +++ b/drivers/gpu/drm/radeon/radeon_connectors.c
920     @@ -489,6 +489,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
921     native_mode->vdisplay != 0 &&
922     native_mode->clock != 0) {
923     mode = drm_mode_duplicate(dev, native_mode);
924     + if (!mode)
925     + return NULL;
926     mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
927     drm_mode_set_name(mode);
928    
929     @@ -503,6 +505,8 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
930     * simpler.
931     */
932     mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
933     + if (!mode)
934     + return NULL;
935     mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
936     DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name);
937     }
938     diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
939     index 5bed63eee5f05..050f9a59ed54d 100644
940     --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
941     +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
942     @@ -1524,10 +1524,10 @@ static int vop_bind(struct device *dev, struct device *master, void *data)
943     vop_win_init(vop);
944    
945     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
946     - vop->len = resource_size(res);
947     vop->regs = devm_ioremap_resource(dev, res);
948     if (IS_ERR(vop->regs))
949     return PTR_ERR(vop->regs);
950     + vop->len = resource_size(res);
951    
952     vop->regsbak = devm_kzalloc(dev, vop->len, GFP_KERNEL);
953     if (!vop->regsbak)
954     diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c
955     index 58048709c34e6..1e528f13959d2 100644
956     --- a/drivers/gpu/drm/virtio/virtgpu_display.c
957     +++ b/drivers/gpu/drm/virtio/virtgpu_display.c
958     @@ -184,6 +184,8 @@ static int virtio_gpu_conn_get_modes(struct drm_connector *connector)
959     DRM_DEBUG("add mode: %dx%d\n", width, height);
960     mode = drm_cvt_mode(connector->dev, width, height, 60,
961     false, false, false);
962     + if (!mode)
963     + return count;
964     mode->type |= DRM_MODE_TYPE_PREFERRED;
965     drm_mode_probed_add(connector, mode);
966     count++;
967     diff --git a/drivers/hid/hid-led.c b/drivers/hid/hid-led.c
968     index d3e1ab162f7c6..7fc5982a0ca49 100644
969     --- a/drivers/hid/hid-led.c
970     +++ b/drivers/hid/hid-led.c
971     @@ -369,7 +369,7 @@ static const struct hidled_config hidled_configs[] = {
972     .type = DREAM_CHEEKY,
973     .name = "Dream Cheeky Webmail Notifier",
974     .short_name = "dream_cheeky",
975     - .max_brightness = 31,
976     + .max_brightness = 63,
977     .num_leds = 1,
978     .report_size = 9,
979     .report_type = RAW_REQUEST,
980     diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
981     index 23ee1a4236545..a29ac9bae6d5e 100644
982     --- a/drivers/i2c/busses/i2c-cadence.c
983     +++ b/drivers/i2c/busses/i2c-cadence.c
984     @@ -511,7 +511,7 @@ static void cdns_i2c_master_reset(struct i2c_adapter *adap)
985     static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
986     struct i2c_adapter *adap)
987     {
988     - unsigned long time_left;
989     + unsigned long time_left, msg_timeout;
990     u32 reg;
991    
992     id->p_msg = msg;
993     @@ -536,8 +536,16 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
994     else
995     cdns_i2c_msend(id);
996    
997     + /* Minimal time to execute this message */
998     + msg_timeout = msecs_to_jiffies((1000 * msg->len * BITS_PER_BYTE) / id->i2c_clk);
999     + /* Plus some wiggle room */
1000     + msg_timeout += msecs_to_jiffies(500);
1001     +
1002     + if (msg_timeout < adap->timeout)
1003     + msg_timeout = adap->timeout;
1004     +
1005     /* Wait for the signal of completion */
1006     - time_left = wait_for_completion_timeout(&id->xfer_done, adap->timeout);
1007     + time_left = wait_for_completion_timeout(&id->xfer_done, msg_timeout);
1008     if (time_left == 0) {
1009     cdns_i2c_master_reset(adap);
1010     dev_err(id->adap.dev.parent,
1011     diff --git a/drivers/iio/dummy/iio_simple_dummy.c b/drivers/iio/dummy/iio_simple_dummy.c
1012     index ad3410e528b68..7fef76f0b5c7a 100644
1013     --- a/drivers/iio/dummy/iio_simple_dummy.c
1014     +++ b/drivers/iio/dummy/iio_simple_dummy.c
1015     @@ -572,10 +572,9 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
1016     struct iio_sw_device *swd;
1017    
1018     swd = kzalloc(sizeof(*swd), GFP_KERNEL);
1019     - if (!swd) {
1020     - ret = -ENOMEM;
1021     - goto error_kzalloc;
1022     - }
1023     + if (!swd)
1024     + return ERR_PTR(-ENOMEM);
1025     +
1026     /*
1027     * Allocate an IIO device.
1028     *
1029     @@ -587,7 +586,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
1030     indio_dev = iio_device_alloc(sizeof(*st));
1031     if (!indio_dev) {
1032     ret = -ENOMEM;
1033     - goto error_ret;
1034     + goto error_free_swd;
1035     }
1036    
1037     st = iio_priv(indio_dev);
1038     @@ -618,6 +617,10 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
1039     * indio_dev->name = spi_get_device_id(spi)->name;
1040     */
1041     indio_dev->name = kstrdup(name, GFP_KERNEL);
1042     + if (!indio_dev->name) {
1043     + ret = -ENOMEM;
1044     + goto error_free_device;
1045     + }
1046    
1047     /* Provide description of available channels */
1048     indio_dev->channels = iio_dummy_channels;
1049     @@ -634,7 +637,7 @@ static struct iio_sw_device *iio_dummy_probe(const char *name)
1050    
1051     ret = iio_simple_dummy_events_register(indio_dev);
1052     if (ret < 0)
1053     - goto error_free_device;
1054     + goto error_free_name;
1055    
1056     ret = iio_simple_dummy_configure_buffer(indio_dev);
1057     if (ret < 0)
1058     @@ -651,11 +654,12 @@ error_unconfigure_buffer:
1059     iio_simple_dummy_unconfigure_buffer(indio_dev);
1060     error_unregister_events:
1061     iio_simple_dummy_events_unregister(indio_dev);
1062     +error_free_name:
1063     + kfree(indio_dev->name);
1064     error_free_device:
1065     iio_device_free(indio_dev);
1066     -error_ret:
1067     +error_free_swd:
1068     kfree(swd);
1069     -error_kzalloc:
1070     return ERR_PTR(ret);
1071     }
1072    
1073     diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
1074     index 93ace2609bdd1..9d90017a14060 100644
1075     --- a/drivers/infiniband/hw/hfi1/init.c
1076     +++ b/drivers/infiniband/hw/hfi1/init.c
1077     @@ -371,7 +371,7 @@ void set_link_ipg(struct hfi1_pportdata *ppd)
1078     u16 shift, mult;
1079     u64 src;
1080     u32 current_egress_rate; /* Mbits /sec */
1081     - u32 max_pkt_time;
1082     + u64 max_pkt_time;
1083     /*
1084     * max_pkt_time is the maximum packet egress time in units
1085     * of the fabric clock period 1/(805 MHz).
1086     diff --git a/drivers/infiniband/sw/rxe/rxe_req.c b/drivers/infiniband/sw/rxe/rxe_req.c
1087     index 463c4b3e73661..4553bed5353ee 100644
1088     --- a/drivers/infiniband/sw/rxe/rxe_req.c
1089     +++ b/drivers/infiniband/sw/rxe/rxe_req.c
1090     @@ -677,7 +677,7 @@ next_wqe:
1091     opcode = next_opcode(qp, wqe, wqe->wr.opcode);
1092     if (unlikely(opcode < 0)) {
1093     wqe->status = IB_WC_LOC_QP_OP_ERR;
1094     - goto exit;
1095     + goto err;
1096     }
1097    
1098     mask = rxe_opcode[opcode].mask;
1099     diff --git a/drivers/input/misc/sparcspkr.c b/drivers/input/misc/sparcspkr.c
1100     index 4a5afc7fe96ea..f6e1f38267d94 100644
1101     --- a/drivers/input/misc/sparcspkr.c
1102     +++ b/drivers/input/misc/sparcspkr.c
1103     @@ -204,6 +204,7 @@ static int bbc_beep_probe(struct platform_device *op)
1104    
1105     info = &state->u.bbc;
1106     info->clock_freq = of_getintprop_default(dp, "clock-frequency", 0);
1107     + of_node_put(dp);
1108     if (!info->clock_freq)
1109     goto out_free;
1110    
1111     diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
1112     index 30e3442518f85..0daf27ed4b16a 100644
1113     --- a/drivers/input/mouse/bcm5974.c
1114     +++ b/drivers/input/mouse/bcm5974.c
1115     @@ -956,17 +956,22 @@ static int bcm5974_probe(struct usb_interface *iface,
1116     if (!dev->tp_data)
1117     goto err_free_bt_buffer;
1118    
1119     - if (dev->bt_urb)
1120     + if (dev->bt_urb) {
1121     usb_fill_int_urb(dev->bt_urb, udev,
1122     usb_rcvintpipe(udev, cfg->bt_ep),
1123     dev->bt_data, dev->cfg.bt_datalen,
1124     bcm5974_irq_button, dev, 1);
1125    
1126     + dev->bt_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1127     + }
1128     +
1129     usb_fill_int_urb(dev->tp_urb, udev,
1130     usb_rcvintpipe(udev, cfg->tp_ep),
1131     dev->tp_data, dev->cfg.tp_datalen,
1132     bcm5974_irq_trackpad, dev, 1);
1133    
1134     + dev->tp_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1135     +
1136     /* create bcm5974 device */
1137     usb_make_path(udev, dev->phys, sizeof(dev->phys));
1138     strlcat(dev->phys, "/input0", sizeof(dev->phys));
1139     diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
1140     index 45c809f3d24f4..03bf538eabdaa 100644
1141     --- a/drivers/iommu/amd_iommu_init.c
1142     +++ b/drivers/iommu/amd_iommu_init.c
1143     @@ -86,7 +86,7 @@
1144     #define ACPI_DEVFLAG_LINT1 0x80
1145     #define ACPI_DEVFLAG_ATSDIS 0x10000000
1146    
1147     -#define LOOP_TIMEOUT 100000
1148     +#define LOOP_TIMEOUT 2000000
1149     /*
1150     * ACPI table definitions
1151     *
1152     diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
1153     index b09692bb5b0a2..df65464fffd4a 100644
1154     --- a/drivers/iommu/msm_iommu.c
1155     +++ b/drivers/iommu/msm_iommu.c
1156     @@ -580,16 +580,19 @@ static void insert_iommu_master(struct device *dev,
1157     static int qcom_iommu_of_xlate(struct device *dev,
1158     struct of_phandle_args *spec)
1159     {
1160     - struct msm_iommu_dev *iommu;
1161     + struct msm_iommu_dev *iommu = NULL, *iter;
1162     unsigned long flags;
1163     int ret = 0;
1164    
1165     spin_lock_irqsave(&msm_iommu_lock, flags);
1166     - list_for_each_entry(iommu, &qcom_iommu_devices, dev_node)
1167     - if (iommu->dev->of_node == spec->np)
1168     + list_for_each_entry(iter, &qcom_iommu_devices, dev_node) {
1169     + if (iter->dev->of_node == spec->np) {
1170     + iommu = iter;
1171     break;
1172     + }
1173     + }
1174    
1175     - if (!iommu || iommu->dev->of_node != spec->np) {
1176     + if (!iommu) {
1177     ret = -ENODEV;
1178     goto fail;
1179     }
1180     diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
1181     index ace01a626b098..75ce43ea79806 100644
1182     --- a/drivers/irqchip/irq-armada-370-xp.c
1183     +++ b/drivers/irqchip/irq-armada-370-xp.c
1184     @@ -312,7 +312,16 @@ static void armada_xp_mpic_smp_cpu_init(void)
1185    
1186     static void armada_xp_mpic_perf_init(void)
1187     {
1188     - unsigned long cpuid = cpu_logical_map(smp_processor_id());
1189     + unsigned long cpuid;
1190     +
1191     + /*
1192     + * This Performance Counter Overflow interrupt is specific for
1193     + * Armada 370 and XP. It is not available on Armada 375, 38x and 39x.
1194     + */
1195     + if (!of_machine_is_compatible("marvell,armada-370-xp"))
1196     + return;
1197     +
1198     + cpuid = cpu_logical_map(smp_processor_id());
1199    
1200     /* Enable Performance Counter Overflow interrupts */
1201     writel(ARMADA_370_XP_INT_CAUSE_PERF(cpuid),
1202     diff --git a/drivers/irqchip/irq-xtensa-mx.c b/drivers/irqchip/irq-xtensa-mx.c
1203     index 72a391e01011c..1082f5284cd99 100644
1204     --- a/drivers/irqchip/irq-xtensa-mx.c
1205     +++ b/drivers/irqchip/irq-xtensa-mx.c
1206     @@ -139,14 +139,25 @@ static struct irq_chip xtensa_mx_irq_chip = {
1207     .irq_set_affinity = xtensa_mx_irq_set_affinity,
1208     };
1209    
1210     +static void __init xtensa_mx_init_common(struct irq_domain *root_domain)
1211     +{
1212     + unsigned int i;
1213     +
1214     + irq_set_default_host(root_domain);
1215     + secondary_init_irq();
1216     +
1217     + /* Initialize default IRQ routing to CPU 0 */
1218     + for (i = 0; i < XCHAL_NUM_EXTINTERRUPTS; ++i)
1219     + set_er(1, MIROUT(i));
1220     +}
1221     +
1222     int __init xtensa_mx_init_legacy(struct device_node *interrupt_parent)
1223     {
1224     struct irq_domain *root_domain =
1225     irq_domain_add_legacy(NULL, NR_IRQS - 1, 1, 0,
1226     &xtensa_mx_irq_domain_ops,
1227     &xtensa_mx_irq_chip);
1228     - irq_set_default_host(root_domain);
1229     - secondary_init_irq();
1230     + xtensa_mx_init_common(root_domain);
1231     return 0;
1232     }
1233    
1234     @@ -156,8 +167,7 @@ static int __init xtensa_mx_init(struct device_node *np,
1235     struct irq_domain *root_domain =
1236     irq_domain_add_linear(np, NR_IRQS, &xtensa_mx_irq_domain_ops,
1237     &xtensa_mx_irq_chip);
1238     - irq_set_default_host(root_domain);
1239     - secondary_init_irq();
1240     + xtensa_mx_init_common(root_domain);
1241     return 0;
1242     }
1243     IRQCHIP_DECLARE(xtensa_mx_irq_chip, "cdns,xtensa-mx", xtensa_mx_init);
1244     diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
1245     index d28690f6e2621..9e226e1434730 100644
1246     --- a/drivers/macintosh/Kconfig
1247     +++ b/drivers/macintosh/Kconfig
1248     @@ -87,6 +87,10 @@ config ADB_PMU
1249     this device; you should do so if your machine is one of those
1250     mentioned above.
1251    
1252     +config ADB_PMU_EVENT
1253     + def_bool y
1254     + depends on ADB_PMU && INPUT=y
1255     +
1256     config ADB_PMU_LED
1257     bool "Support for the Power/iBook front LED"
1258     depends on ADB_PMU
1259     diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile
1260     index 383ba920085b3..8513c8aa2fafd 100644
1261     --- a/drivers/macintosh/Makefile
1262     +++ b/drivers/macintosh/Makefile
1263     @@ -11,7 +11,8 @@ obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o
1264     obj-$(CONFIG_INPUT_ADBHID) += adbhid.o
1265     obj-$(CONFIG_ANSLCD) += ans-lcd.o
1266    
1267     -obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o
1268     +obj-$(CONFIG_ADB_PMU) += via-pmu.o
1269     +obj-$(CONFIG_ADB_PMU_EVENT) += via-pmu-event.o
1270     obj-$(CONFIG_ADB_PMU_LED) += via-pmu-led.o
1271     obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o
1272     obj-$(CONFIG_ADB_CUDA) += via-cuda.o
1273     diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
1274     index 32c6967993005..9bdb7d2055b1c 100644
1275     --- a/drivers/macintosh/via-pmu.c
1276     +++ b/drivers/macintosh/via-pmu.c
1277     @@ -1439,7 +1439,7 @@ next:
1278     pmu_pass_intr(data, len);
1279     /* len == 6 is probably a bad check. But how do I
1280     * know what PMU versions send what events here? */
1281     - if (len == 6) {
1282     + if (IS_ENABLED(CONFIG_ADB_PMU_EVENT) && len == 6) {
1283     via_pmu_event(PMU_EVT_POWER, !!(data[1]&8));
1284     via_pmu_event(PMU_EVT_LID, data[1]&1);
1285     }
1286     diff --git a/drivers/md/md.c b/drivers/md/md.c
1287     index 98c72dd56a2d4..9e8373e7e2877 100644
1288     --- a/drivers/md/md.c
1289     +++ b/drivers/md/md.c
1290     @@ -2254,14 +2254,16 @@ static void sync_sbs(struct mddev *mddev, int nospares)
1291    
1292     static bool does_sb_need_changing(struct mddev *mddev)
1293     {
1294     - struct md_rdev *rdev;
1295     + struct md_rdev *rdev = NULL, *iter;
1296     struct mdp_superblock_1 *sb;
1297     int role;
1298    
1299     /* Find a good rdev */
1300     - rdev_for_each(rdev, mddev)
1301     - if ((rdev->raid_disk >= 0) && !test_bit(Faulty, &rdev->flags))
1302     + rdev_for_each(iter, mddev)
1303     + if ((iter->raid_disk >= 0) && !test_bit(Faulty, &iter->flags)) {
1304     + rdev = iter;
1305     break;
1306     + }
1307    
1308     /* No good device found. */
1309     if (!rdev)
1310     @@ -7252,17 +7254,22 @@ EXPORT_SYMBOL(md_register_thread);
1311    
1312     void md_unregister_thread(struct md_thread **threadp)
1313     {
1314     - struct md_thread *thread = *threadp;
1315     - if (!thread)
1316     - return;
1317     - pr_debug("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk));
1318     - /* Locking ensures that mddev_unlock does not wake_up a
1319     + struct md_thread *thread;
1320     +
1321     + /*
1322     + * Locking ensures that mddev_unlock does not wake_up a
1323     * non-existent thread
1324     */
1325     spin_lock(&pers_lock);
1326     + thread = *threadp;
1327     + if (!thread) {
1328     + spin_unlock(&pers_lock);
1329     + return;
1330     + }
1331     *threadp = NULL;
1332     spin_unlock(&pers_lock);
1333    
1334     + pr_debug("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk));
1335     kthread_stop(thread->tsk);
1336     kfree(thread);
1337     }
1338     @@ -8880,16 +8887,18 @@ static int read_rdev(struct mddev *mddev, struct md_rdev *rdev)
1339    
1340     void md_reload_sb(struct mddev *mddev, int nr)
1341     {
1342     - struct md_rdev *rdev;
1343     + struct md_rdev *rdev = NULL, *iter;
1344     int err;
1345    
1346     /* Find the rdev */
1347     - rdev_for_each_rcu(rdev, mddev) {
1348     - if (rdev->desc_nr == nr)
1349     + rdev_for_each_rcu(iter, mddev) {
1350     + if (iter->desc_nr == nr) {
1351     + rdev = iter;
1352     break;
1353     + }
1354     }
1355    
1356     - if (!rdev || rdev->desc_nr != nr) {
1357     + if (!rdev) {
1358     pr_warn("%s: %d Could not find rdev with nr %d\n", __func__, __LINE__, nr);
1359     return;
1360     }
1361     diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c
1362     index d58c58e61bde0..acd896ca13395 100644
1363     --- a/drivers/media/pci/cx25821/cx25821-core.c
1364     +++ b/drivers/media/pci/cx25821/cx25821-core.c
1365     @@ -1354,11 +1354,11 @@ static void cx25821_finidev(struct pci_dev *pci_dev)
1366     struct cx25821_dev *dev = get_cx25821(v4l2_dev);
1367    
1368     cx25821_shutdown(dev);
1369     - pci_disable_device(pci_dev);
1370    
1371     /* unregister stuff */
1372     if (pci_dev->irq)
1373     free_irq(pci_dev->irq, dev);
1374     + pci_disable_device(pci_dev);
1375    
1376     cx25821_dev_unregister(dev);
1377     v4l2_device_unregister(v4l2_dev);
1378     diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
1379     index f9456f26ff4fa..590ec04de827b 100644
1380     --- a/drivers/media/platform/exynos4-is/fimc-is.c
1381     +++ b/drivers/media/platform/exynos4-is/fimc-is.c
1382     @@ -144,7 +144,7 @@ static int fimc_is_enable_clocks(struct fimc_is *is)
1383     dev_err(&is->pdev->dev, "clock %s enable failed\n",
1384     fimc_is_clocks[i]);
1385     for (--i; i >= 0; i--)
1386     - clk_disable(is->clocks[i]);
1387     + clk_disable_unprepare(is->clocks[i]);
1388     return ret;
1389     }
1390     pr_debug("enabled clock: %s\n", fimc_is_clocks[i]);
1391     diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.h b/drivers/media/platform/exynos4-is/fimc-isp-video.h
1392     index f79a1b348aa6f..67ef85249912b 100644
1393     --- a/drivers/media/platform/exynos4-is/fimc-isp-video.h
1394     +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.h
1395     @@ -35,7 +35,7 @@ static inline int fimc_isp_video_device_register(struct fimc_isp *isp,
1396     return 0;
1397     }
1398    
1399     -void fimc_isp_video_device_unregister(struct fimc_isp *isp,
1400     +static inline void fimc_isp_video_device_unregister(struct fimc_isp *isp,
1401     enum v4l2_buf_type type)
1402     {
1403     }
1404     diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1405     index 40535db585a0e..b868a77a048ca 100644
1406     --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1407     +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
1408     @@ -2615,6 +2615,11 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1409     } while (0);
1410     mutex_unlock(&pvr2_unit_mtx);
1411    
1412     + INIT_WORK(&hdw->workpoll, pvr2_hdw_worker_poll);
1413     +
1414     + if (hdw->unit_number == -1)
1415     + goto fail;
1416     +
1417     cnt1 = 0;
1418     cnt2 = scnprintf(hdw->name+cnt1,sizeof(hdw->name)-cnt1,"pvrusb2");
1419     cnt1 += cnt2;
1420     @@ -2626,8 +2631,6 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
1421     if (cnt1 >= sizeof(hdw->name)) cnt1 = sizeof(hdw->name)-1;
1422     hdw->name[cnt1] = 0;
1423    
1424     - INIT_WORK(&hdw->workpoll,pvr2_hdw_worker_poll);
1425     -
1426     pvr2_trace(PVR2_TRACE_INIT,"Driver unit number is %d, name is %s",
1427     hdw->unit_number,hdw->name);
1428    
1429     diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
1430     index 2b1e06e825f0d..53d81ef9a4bea 100644
1431     --- a/drivers/media/usb/uvc/uvc_v4l2.c
1432     +++ b/drivers/media/usb/uvc/uvc_v4l2.c
1433     @@ -846,29 +846,31 @@ static int uvc_ioctl_enum_input(struct file *file, void *fh,
1434     struct uvc_video_chain *chain = handle->chain;
1435     const struct uvc_entity *selector = chain->selector;
1436     struct uvc_entity *iterm = NULL;
1437     + struct uvc_entity *it;
1438     u32 index = input->index;
1439     - int pin = 0;
1440    
1441     if (selector == NULL ||
1442     (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
1443     if (index != 0)
1444     return -EINVAL;
1445     - list_for_each_entry(iterm, &chain->entities, chain) {
1446     - if (UVC_ENTITY_IS_ITERM(iterm))
1447     + list_for_each_entry(it, &chain->entities, chain) {
1448     + if (UVC_ENTITY_IS_ITERM(it)) {
1449     + iterm = it;
1450     break;
1451     + }
1452     }
1453     - pin = iterm->id;
1454     } else if (index < selector->bNrInPins) {
1455     - pin = selector->baSourceID[index];
1456     - list_for_each_entry(iterm, &chain->entities, chain) {
1457     - if (!UVC_ENTITY_IS_ITERM(iterm))
1458     + list_for_each_entry(it, &chain->entities, chain) {
1459     + if (!UVC_ENTITY_IS_ITERM(it))
1460     continue;
1461     - if (iterm->id == pin)
1462     + if (it->id == selector->baSourceID[index]) {
1463     + iterm = it;
1464     break;
1465     + }
1466     }
1467     }
1468    
1469     - if (iterm == NULL || iterm->id != pin)
1470     + if (iterm == NULL)
1471     return -EINVAL;
1472    
1473     memset(input, 0, sizeof(*input));
1474     diff --git a/drivers/mfd/ipaq-micro.c b/drivers/mfd/ipaq-micro.c
1475     index df16fd1df68be..b03489268252d 100644
1476     --- a/drivers/mfd/ipaq-micro.c
1477     +++ b/drivers/mfd/ipaq-micro.c
1478     @@ -418,7 +418,7 @@ static int __init micro_probe(struct platform_device *pdev)
1479     micro_reset_comm(micro);
1480    
1481     irq = platform_get_irq(pdev, 0);
1482     - if (!irq)
1483     + if (irq < 0)
1484     return -EINVAL;
1485     ret = devm_request_irq(&pdev->dev, irq, micro_serial_isr,
1486     IRQF_SHARED, "ipaq-micro",
1487     diff --git a/drivers/mfd/rtsx_usb.c b/drivers/mfd/rtsx_usb.c
1488     index 691dab791f7af..e94f855eac155 100644
1489     --- a/drivers/mfd/rtsx_usb.c
1490     +++ b/drivers/mfd/rtsx_usb.c
1491     @@ -678,6 +678,7 @@ static int rtsx_usb_probe(struct usb_interface *intf,
1492     return 0;
1493    
1494     out_init_fail:
1495     + usb_set_intfdata(ucr->pusb_intf, NULL);
1496     usb_free_coherent(ucr->pusb_dev, IOBUF_SIZE, ucr->iobuf,
1497     ucr->iobuf_dma);
1498     return ret;
1499     diff --git a/drivers/misc/lkdtm_usercopy.c b/drivers/misc/lkdtm_usercopy.c
1500     index 1dd611423d8be..36438947244d0 100644
1501     --- a/drivers/misc/lkdtm_usercopy.c
1502     +++ b/drivers/misc/lkdtm_usercopy.c
1503     @@ -28,12 +28,12 @@ static const unsigned char test_text[] = "This is a test.\n";
1504     */
1505     static noinline unsigned char *trick_compiler(unsigned char *stack)
1506     {
1507     - return stack + 0;
1508     + return stack + unconst;
1509     }
1510    
1511     static noinline unsigned char *do_usercopy_stack_callee(int value)
1512     {
1513     - unsigned char buf[32];
1514     + unsigned char buf[128];
1515     int i;
1516    
1517     /* Exercise stack to avoid everything living in registers. */
1518     @@ -41,7 +41,12 @@ static noinline unsigned char *do_usercopy_stack_callee(int value)
1519     buf[i] = value & 0xff;
1520     }
1521    
1522     - return trick_compiler(buf);
1523     + /*
1524     + * Put the target buffer in the middle of stack allocation
1525     + * so that we don't step on future stack users regardless
1526     + * of stack growth direction.
1527     + */
1528     + return trick_compiler(&buf[(128/2)-32]);
1529     }
1530    
1531     static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
1532     @@ -64,6 +69,12 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
1533     bad_stack -= sizeof(unsigned long);
1534     }
1535    
1536     +#ifdef ARCH_HAS_CURRENT_STACK_POINTER
1537     + pr_info("stack : %px\n", (void *)current_stack_pointer);
1538     +#endif
1539     + pr_info("good_stack: %px-%px\n", good_stack, good_stack + sizeof(good_stack));
1540     + pr_info("bad_stack : %px-%px\n", bad_stack, bad_stack + sizeof(good_stack));
1541     +
1542     user_addr = vm_mmap(NULL, 0, PAGE_SIZE,
1543     PROT_READ | PROT_WRITE | PROT_EXEC,
1544     MAP_ANONYMOUS | MAP_PRIVATE, 0);
1545     diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
1546     index 3c4819a05bf03..a2b12d347f4dc 100644
1547     --- a/drivers/mtd/chips/cfi_cmdset_0002.c
1548     +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
1549     @@ -49,6 +49,10 @@
1550     #define SST49LF008A 0x005a
1551     #define AT49BV6416 0x00d6
1552    
1553     +enum cfi_quirks {
1554     + CFI_QUIRK_DQ_TRUE_DATA = BIT(0),
1555     +};
1556     +
1557     static int cfi_amdstd_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
1558     static int cfi_amdstd_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
1559     static int cfi_amdstd_write_buffers(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
1560     @@ -361,6 +365,15 @@ static void fixup_s29ns512p_sectors(struct mtd_info *mtd)
1561     pr_warning("%s: Bad S29NS512P CFI data; adjust to 512 sectors\n", mtd->name);
1562     }
1563    
1564     +static void fixup_quirks(struct mtd_info *mtd)
1565     +{
1566     + struct map_info *map = mtd->priv;
1567     + struct cfi_private *cfi = map->fldrv_priv;
1568     +
1569     + if (cfi->mfr == CFI_MFR_AMD && cfi->id == 0x0c01)
1570     + cfi->quirks |= CFI_QUIRK_DQ_TRUE_DATA;
1571     +}
1572     +
1573     /* Used to fix CFI-Tables of chips without Extended Query Tables */
1574     static struct cfi_fixup cfi_nopri_fixup_table[] = {
1575     { CFI_MFR_SST, 0x234a, fixup_sst39vf }, /* SST39VF1602 */
1576     @@ -399,6 +412,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
1577     #if !FORCE_WORD_WRITE
1578     { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers },
1579     #endif
1580     + { CFI_MFR_ANY, CFI_ID_ANY, fixup_quirks },
1581     { 0, 0, NULL }
1582     };
1583     static struct cfi_fixup jedec_fixup_table[] = {
1584     @@ -726,50 +740,46 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
1585     }
1586    
1587     /*
1588     - * Return true if the chip is ready.
1589     + * Return true if the chip is ready and has the correct value.
1590     *
1591     * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
1592     * non-suspended sector) and is indicated by no toggle bits toggling.
1593     *
1594     + * Error are indicated by toggling bits or bits held with the wrong value,
1595     + * or with bits toggling.
1596     + *
1597     * Note that anything more complicated than checking if no bits are toggling
1598     * (including checking DQ5 for an error status) is tricky to get working
1599     * correctly and is therefore not done (particularly with interleaved chips
1600     * as each chip must be checked independently of the others).
1601     */
1602     -static int __xipram chip_ready(struct map_info *map, unsigned long addr)
1603     +static int __xipram chip_ready(struct map_info *map, unsigned long addr,
1604     + map_word *expected)
1605     {
1606     map_word d, t;
1607     + int ret;
1608    
1609     d = map_read(map, addr);
1610     t = map_read(map, addr);
1611    
1612     - return map_word_equal(map, d, t);
1613     + ret = map_word_equal(map, d, t);
1614     +
1615     + if (!ret || !expected)
1616     + return ret;
1617     +
1618     + return map_word_equal(map, t, *expected);
1619     }
1620    
1621     -/*
1622     - * Return true if the chip is ready and has the correct value.
1623     - *
1624     - * Ready is one of: read mode, query mode, erase-suspend-read mode (in any
1625     - * non-suspended sector) and it is indicated by no bits toggling.
1626     - *
1627     - * Error are indicated by toggling bits or bits held with the wrong value,
1628     - * or with bits toggling.
1629     - *
1630     - * Note that anything more complicated than checking if no bits are toggling
1631     - * (including checking DQ5 for an error status) is tricky to get working
1632     - * correctly and is therefore not done (particularly with interleaved chips
1633     - * as each chip must be checked independently of the others).
1634     - *
1635     - */
1636     -static int __xipram chip_good(struct map_info *map, unsigned long addr, map_word expected)
1637     +static int __xipram chip_good(struct map_info *map, unsigned long addr,
1638     + map_word *expected)
1639     {
1640     - map_word oldd, curd;
1641     + struct cfi_private *cfi = map->fldrv_priv;
1642     + map_word *datum = expected;
1643    
1644     - oldd = map_read(map, addr);
1645     - curd = map_read(map, addr);
1646     + if (cfi->quirks & CFI_QUIRK_DQ_TRUE_DATA)
1647     + datum = NULL;
1648    
1649     - return map_word_equal(map, oldd, curd) &&
1650     - map_word_equal(map, curd, expected);
1651     + return chip_ready(map, addr, datum);
1652     }
1653    
1654     static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr, int mode)
1655     @@ -786,7 +796,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
1656    
1657     case FL_STATUS:
1658     for (;;) {
1659     - if (chip_ready(map, adr))
1660     + if (chip_ready(map, adr, NULL))
1661     break;
1662    
1663     if (time_after(jiffies, timeo)) {
1664     @@ -824,7 +834,7 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
1665     chip->state = FL_ERASE_SUSPENDING;
1666     chip->erase_suspended = 1;
1667     for (;;) {
1668     - if (chip_ready(map, adr))
1669     + if (chip_ready(map, adr, NULL))
1670     break;
1671    
1672     if (time_after(jiffies, timeo)) {
1673     @@ -1357,7 +1367,7 @@ static int do_otp_lock(struct map_info *map, struct flchip *chip, loff_t adr,
1674     /* wait for chip to become ready */
1675     timeo = jiffies + msecs_to_jiffies(2);
1676     for (;;) {
1677     - if (chip_ready(map, adr))
1678     + if (chip_ready(map, adr, NULL))
1679     break;
1680    
1681     if (time_after(jiffies, timeo)) {
1682     @@ -1627,7 +1637,8 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1683     * We check "time_after" and "!chip_good" before checking
1684     * "chip_good" to avoid the failure due to scheduling.
1685     */
1686     - if (time_after(jiffies, timeo) && !chip_good(map, adr, datum)) {
1687     + if (time_after(jiffies, timeo) &&
1688     + !chip_good(map, adr, &datum)) {
1689     xip_enable(map, chip, adr);
1690     printk(KERN_WARNING "MTD %s(): software timeout\n", __func__);
1691     xip_disable(map, chip, adr);
1692     @@ -1635,7 +1646,7 @@ static int __xipram do_write_oneword(struct map_info *map, struct flchip *chip,
1693     break;
1694     }
1695    
1696     - if (chip_good(map, adr, datum))
1697     + if (chip_good(map, adr, &datum))
1698     break;
1699    
1700     /* Latency issues. Drop the lock, wait a while and retry */
1701     @@ -1879,13 +1890,13 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
1702     }
1703    
1704     /*
1705     - * We check "time_after" and "!chip_good" before checking "chip_good" to avoid
1706     - * the failure due to scheduling.
1707     + * We check "time_after" and "!chip_good" before checking
1708     + * "chip_good" to avoid the failure due to scheduling.
1709     */
1710     - if (time_after(jiffies, timeo) && !chip_good(map, adr, datum))
1711     + if (time_after(jiffies, timeo) && !chip_good(map, adr, &datum))
1712     break;
1713    
1714     - if (chip_good(map, adr, datum)) {
1715     + if (chip_good(map, adr, &datum)) {
1716     xip_enable(map, chip, adr);
1717     goto op_done;
1718     }
1719     @@ -2019,7 +2030,7 @@ static int cfi_amdstd_panic_wait(struct map_info *map, struct flchip *chip,
1720     * If the driver thinks the chip is idle, and no toggle bits
1721     * are changing, then the chip is actually idle for sure.
1722     */
1723     - if (chip->state == FL_READY && chip_ready(map, adr))
1724     + if (chip->state == FL_READY && chip_ready(map, adr, NULL))
1725     return 0;
1726    
1727     /*
1728     @@ -2036,7 +2047,7 @@ static int cfi_amdstd_panic_wait(struct map_info *map, struct flchip *chip,
1729    
1730     /* wait for the chip to become ready */
1731     for (i = 0; i < jiffies_to_usecs(timeo); i++) {
1732     - if (chip_ready(map, adr))
1733     + if (chip_ready(map, adr, NULL))
1734     return 0;
1735    
1736     udelay(1);
1737     @@ -2100,13 +2111,13 @@ retry:
1738     map_write(map, datum, adr);
1739    
1740     for (i = 0; i < jiffies_to_usecs(uWriteTimeout); i++) {
1741     - if (chip_ready(map, adr))
1742     + if (chip_ready(map, adr, NULL))
1743     break;
1744    
1745     udelay(1);
1746     }
1747    
1748     - if (!chip_good(map, adr, datum)) {
1749     + if (!chip_ready(map, adr, &datum)) {
1750     /* reset on all failures. */
1751     map_write(map, CMD(0xF0), chip->start);
1752     /* FIXME - should have reset delay before continuing */
1753     @@ -2247,6 +2258,7 @@ static int __xipram do_erase_chip(struct map_info *map, struct flchip *chip)
1754     DECLARE_WAITQUEUE(wait, current);
1755     int ret = 0;
1756     int retry_cnt = 0;
1757     + map_word datum = map_word_ff(map);
1758    
1759     adr = cfi->addr_unlock1;
1760    
1761     @@ -2301,7 +2313,7 @@ static int __xipram do_erase_chip(struct map_info *map, struct flchip *chip)
1762     chip->erase_suspended = 0;
1763     }
1764    
1765     - if (chip_good(map, adr, map_word_ff(map)))
1766     + if (chip_ready(map, adr, &datum))
1767     break;
1768    
1769     if (time_after(jiffies, timeo)) {
1770     @@ -2343,6 +2355,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1771     DECLARE_WAITQUEUE(wait, current);
1772     int ret = 0;
1773     int retry_cnt = 0;
1774     + map_word datum = map_word_ff(map);
1775    
1776     adr += chip->start;
1777    
1778     @@ -2397,7 +2410,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
1779     chip->erase_suspended = 0;
1780     }
1781    
1782     - if (chip_good(map, adr, map_word_ff(map))) {
1783     + if (chip_ready(map, adr, &datum)) {
1784     xip_enable(map, chip, adr);
1785     break;
1786     }
1787     @@ -2612,7 +2625,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map,
1788     */
1789     timeo = jiffies + msecs_to_jiffies(2000); /* 2s max (un)locking */
1790     for (;;) {
1791     - if (chip_ready(map, adr))
1792     + if (chip_ready(map, adr, NULL))
1793     break;
1794    
1795     if (time_after(jiffies, timeo)) {
1796     diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
1797     index e02b99f77b1ca..9d63bb33844ec 100644
1798     --- a/drivers/net/ethernet/altera/altera_tse_main.c
1799     +++ b/drivers/net/ethernet/altera/altera_tse_main.c
1800     @@ -152,7 +152,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
1801     mdio = mdiobus_alloc();
1802     if (mdio == NULL) {
1803     netdev_err(dev, "Error allocating MDIO bus\n");
1804     - return -ENOMEM;
1805     + ret = -ENOMEM;
1806     + goto put_node;
1807     }
1808    
1809     mdio->name = ALTERA_TSE_RESOURCE_NAME;
1810     @@ -169,6 +170,7 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
1811     mdio->id);
1812     goto out_free_mdio;
1813     }
1814     + of_node_put(mdio_node);
1815    
1816     if (netif_msg_drv(priv))
1817     netdev_info(dev, "MDIO bus %s: created\n", mdio->id);
1818     @@ -178,6 +180,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id)
1819     out_free_mdio:
1820     mdiobus_free(mdio);
1821     mdio = NULL;
1822     +put_node:
1823     + of_node_put(mdio_node);
1824     return ret;
1825     }
1826    
1827     diff --git a/drivers/net/ethernet/broadcom/Makefile b/drivers/net/ethernet/broadcom/Makefile
1828     index 79f2372c66ec9..4211c6cd6b353 100644
1829     --- a/drivers/net/ethernet/broadcom/Makefile
1830     +++ b/drivers/net/ethernet/broadcom/Makefile
1831     @@ -15,3 +15,8 @@ obj-$(CONFIG_BGMAC_BCMA) += bgmac-bcma.o bgmac-bcma-mdio.o
1832     obj-$(CONFIG_BGMAC_PLATFORM) += bgmac-platform.o
1833     obj-$(CONFIG_SYSTEMPORT) += bcmsysport.o
1834     obj-$(CONFIG_BNXT) += bnxt/
1835     +
1836     +# FIXME: temporarily silence -Warray-bounds on non W=1+ builds
1837     +ifndef KBUILD_EXTRA_WARN
1838     +CFLAGS_tg3.o += -Wno-array-bounds
1839     +endif
1840     diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1841     index 5b072bf80783a..84d6679572210 100644
1842     --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1843     +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1844     @@ -1496,6 +1496,9 @@ static int mtk_hwlro_get_fdir_entry(struct net_device *dev,
1845     struct ethtool_rx_flow_spec *fsp =
1846     (struct ethtool_rx_flow_spec *)&cmd->fs;
1847    
1848     + if (fsp->location >= ARRAY_SIZE(mac->hwlro_ip))
1849     + return -EINVAL;
1850     +
1851     /* only tcp dst ipv4 is meaningful, others are meaningless */
1852     fsp->flow_type = TCP_V4_FLOW;
1853     fsp->h_u.tcp_ip4_spec.ip4dst = ntohl(mac->hwlro_ip[fsp->location]);
1854     diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1855     index 1569300844f0c..8b0c28d4c627f 100644
1856     --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1857     +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1858     @@ -2003,7 +2003,7 @@ static int mlx4_en_get_module_eeprom(struct net_device *dev,
1859     en_err(priv,
1860     "mlx4_get_module_info i(%d) offset(%d) bytes_to_read(%d) - FAILED (0x%x)\n",
1861     i, offset, ee->len - i, ret);
1862     - return 0;
1863     + return ret;
1864     }
1865    
1866     i += ret;
1867     diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
1868     index a171dbb29fbb6..ad949eb02f3d2 100644
1869     --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
1870     +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
1871     @@ -720,7 +720,7 @@
1872     #define AR_CH0_TOP2 (AR_SREV_9300(ah) ? 0x1628c : \
1873     (AR_SREV_9462(ah) ? 0x16290 : 0x16284))
1874     #define AR_CH0_TOP2_XPABIASLVL (AR_SREV_9561(ah) ? 0x1e00 : 0xf000)
1875     -#define AR_CH0_TOP2_XPABIASLVL_S 12
1876     +#define AR_CH0_TOP2_XPABIASLVL_S (AR_SREV_9561(ah) ? 9 : 12)
1877    
1878     #define AR_CH0_XTAL (AR_SREV_9300(ah) ? 0x16294 : \
1879     ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x16298 : \
1880     diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
1881     index 6a9c9b4ef2c92..fe4491eff8ca2 100644
1882     --- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
1883     +++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
1884     @@ -1004,6 +1004,14 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
1885     goto rx_next;
1886     }
1887    
1888     + if (rxstatus->rs_keyix >= ATH_KEYMAX &&
1889     + rxstatus->rs_keyix != ATH9K_RXKEYIX_INVALID) {
1890     + ath_dbg(common, ANY,
1891     + "Invalid keyix, dropping (keyix: %d)\n",
1892     + rxstatus->rs_keyix);
1893     + goto rx_next;
1894     + }
1895     +
1896     /* Get the RX status information */
1897    
1898     memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
1899     diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c
1900     index 2bf04c9edc983..73f14d57e65dc 100644
1901     --- a/drivers/net/wireless/ath/carl9170/tx.c
1902     +++ b/drivers/net/wireless/ath/carl9170/tx.c
1903     @@ -1554,6 +1554,9 @@ static struct carl9170_vif_info *carl9170_pick_beaconing_vif(struct ar9170 *ar)
1904     goto out;
1905     }
1906     } while (ar->beacon_enabled && i--);
1907     +
1908     + /* no entry found in list */
1909     + return NULL;
1910     }
1911    
1912     out:
1913     diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c
1914     index d1afa74aa144b..9cbc17c2751cf 100644
1915     --- a/drivers/net/wireless/broadcom/b43/phy_n.c
1916     +++ b/drivers/net/wireless/broadcom/b43/phy_n.c
1917     @@ -594,7 +594,7 @@ static void b43_nphy_adjust_lna_gain_table(struct b43_wldev *dev)
1918     u16 data[4];
1919     s16 gain[2];
1920     u16 minmax[2];
1921     - static const u16 lna_gain[4] = { -2, 10, 19, 25 };
1922     + static const s16 lna_gain[4] = { -2, 10, 19, 25 };
1923    
1924     if (nphy->hang_avoid)
1925     b43_nphy_stay_in_carrier_search(dev, 1);
1926     diff --git a/drivers/net/wireless/broadcom/b43legacy/phy.c b/drivers/net/wireless/broadcom/b43legacy/phy.c
1927     index 995c7d0c212ae..11ee5ee489767 100644
1928     --- a/drivers/net/wireless/broadcom/b43legacy/phy.c
1929     +++ b/drivers/net/wireless/broadcom/b43legacy/phy.c
1930     @@ -1148,7 +1148,7 @@ void b43legacy_phy_lo_b_measure(struct b43legacy_wldev *dev)
1931     struct b43legacy_phy *phy = &dev->phy;
1932     u16 regstack[12] = { 0 };
1933     u16 mls;
1934     - u16 fval;
1935     + s16 fval;
1936     int i;
1937     int j;
1938    
1939     diff --git a/drivers/net/wireless/intel/ipw2x00/libipw_tx.c b/drivers/net/wireless/intel/ipw2x00/libipw_tx.c
1940     index e8c039879b05a..cb30b3b63635b 100644
1941     --- a/drivers/net/wireless/intel/ipw2x00/libipw_tx.c
1942     +++ b/drivers/net/wireless/intel/ipw2x00/libipw_tx.c
1943     @@ -397,7 +397,7 @@ netdev_tx_t libipw_xmit(struct sk_buff *skb, struct net_device *dev)
1944    
1945     /* Each fragment may need to have room for encryption
1946     * pre/postfix */
1947     - if (host_encrypt)
1948     + if (host_encrypt && crypt && crypt->ops)
1949     bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len +
1950     crypt->ops->extra_mpdu_postfix_len;
1951    
1952     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/power.c b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
1953     index af6d10c23e5aa..47b716b611e1c 100644
1954     --- a/drivers/net/wireless/intel/iwlwifi/mvm/power.c
1955     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/power.c
1956     @@ -612,6 +612,9 @@ static void iwl_mvm_power_get_vifs_iterator(void *_data, u8 *mac,
1957     struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1958     struct iwl_power_vifs *power_iterator = _data;
1959    
1960     + if (!mvmvif->uploaded)
1961     + return;
1962     +
1963     switch (ieee80211_vif_type_p2p(vif)) {
1964     case NL80211_IFTYPE_P2P_DEVICE:
1965     break;
1966     diff --git a/drivers/net/wireless/marvell/mwifiex/11h.c b/drivers/net/wireless/marvell/mwifiex/11h.c
1967     index 43dccd5b0291f..3024a83c0f33c 100644
1968     --- a/drivers/net/wireless/marvell/mwifiex/11h.c
1969     +++ b/drivers/net/wireless/marvell/mwifiex/11h.c
1970     @@ -308,5 +308,7 @@ void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work)
1971    
1972     mwifiex_dbg(priv->adapter, MSG,
1973     "indicating channel switch completion to kernel\n");
1974     + mutex_lock(&priv->wdev.mtx);
1975     cfg80211_ch_switch_notify(priv->netdev, &priv->dfs_chandef);
1976     + mutex_unlock(&priv->wdev.mtx);
1977     }
1978     diff --git a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
1979     index e895a84481da0..8ef6020292a9a 100644
1980     --- a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
1981     +++ b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c
1982     @@ -460,8 +460,10 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
1983     struct rtl8180_priv *priv = dev->priv;
1984     struct rtl8180_tx_ring *ring;
1985     struct rtl8180_tx_desc *entry;
1986     + unsigned int prio = 0;
1987     unsigned long flags;
1988     - unsigned int idx, prio, hw_prio;
1989     + unsigned int idx, hw_prio;
1990     +
1991     dma_addr_t mapping;
1992     u32 tx_flags;
1993     u8 rc_flags;
1994     @@ -470,7 +472,9 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
1995     /* do arithmetic and then convert to le16 */
1996     u16 frame_duration = 0;
1997    
1998     - prio = skb_get_queue_mapping(skb);
1999     + /* rtl8180/rtl8185 only has one useable tx queue */
2000     + if (dev->queues > IEEE80211_AC_BK)
2001     + prio = skb_get_queue_mapping(skb);
2002     ring = &priv->tx_ring[prio];
2003    
2004     mapping = pci_map_single(priv->pdev, skb->data,
2005     diff --git a/drivers/nfc/st21nfca/se.c b/drivers/nfc/st21nfca/se.c
2006     index 475f8a67856d0..21ab3e678cf36 100644
2007     --- a/drivers/nfc/st21nfca/se.c
2008     +++ b/drivers/nfc/st21nfca/se.c
2009     @@ -320,7 +320,7 @@ int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host,
2010     * AID 81 5 to 16
2011     * PARAMETERS 82 0 to 255
2012     */
2013     - if (skb->len < NFC_MIN_AID_LENGTH + 2 &&
2014     + if (skb->len < NFC_MIN_AID_LENGTH + 2 ||
2015     skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)
2016     return -EPROTO;
2017    
2018     @@ -332,22 +332,29 @@ int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host,
2019     transaction->aid_len = skb->data[1];
2020    
2021     /* Checking if the length of the AID is valid */
2022     - if (transaction->aid_len > sizeof(transaction->aid))
2023     + if (transaction->aid_len > sizeof(transaction->aid)) {
2024     + devm_kfree(dev, transaction);
2025     return -EINVAL;
2026     + }
2027    
2028     memcpy(transaction->aid, &skb->data[2],
2029     transaction->aid_len);
2030    
2031     /* Check next byte is PARAMETERS tag (82) */
2032     if (skb->data[transaction->aid_len + 2] !=
2033     - NFC_EVT_TRANSACTION_PARAMS_TAG)
2034     + NFC_EVT_TRANSACTION_PARAMS_TAG) {
2035     + devm_kfree(dev, transaction);
2036     return -EPROTO;
2037     + }
2038    
2039     transaction->params_len = skb->data[transaction->aid_len + 3];
2040    
2041     /* Total size is allocated (skb->len - 2) minus fixed array members */
2042     - if (transaction->params_len > ((skb->len - 2) - sizeof(struct nfc_evt_transaction)))
2043     + if (transaction->params_len > ((skb->len - 2) -
2044     + sizeof(struct nfc_evt_transaction))) {
2045     + devm_kfree(dev, transaction);
2046     return -EINVAL;
2047     + }
2048    
2049     memcpy(transaction->params, skb->data +
2050     transaction->aid_len + 4, transaction->params_len);
2051     diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
2052     index c87f27d3ee31f..e7b872592f369 100644
2053     --- a/drivers/nvme/host/pci.c
2054     +++ b/drivers/nvme/host/pci.c
2055     @@ -1203,6 +1203,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev)
2056     dev->ctrl.admin_q = blk_mq_init_queue(&dev->admin_tagset);
2057     if (IS_ERR(dev->ctrl.admin_q)) {
2058     blk_mq_free_tag_set(&dev->admin_tagset);
2059     + dev->ctrl.admin_q = NULL;
2060     return -ENOMEM;
2061     }
2062     if (!blk_get_queue(dev->ctrl.admin_q)) {
2063     diff --git a/drivers/pci/host/pcie-qcom.c b/drivers/pci/host/pcie-qcom.c
2064     index 35936409b2d45..f5f9828f96bf0 100644
2065     --- a/drivers/pci/host/pcie-qcom.c
2066     +++ b/drivers/pci/host/pcie-qcom.c
2067     @@ -562,10 +562,15 @@ static int qcom_pcie_probe(struct platform_device *pdev)
2068     ret = dw_pcie_host_init(pp);
2069     if (ret) {
2070     dev_err(dev, "cannot initialize host\n");
2071     - return ret;
2072     + goto err_phy_exit;
2073     }
2074    
2075     return 0;
2076     +
2077     +err_phy_exit:
2078     + phy_exit(pcie->phy);
2079     +
2080     + return ret;
2081     }
2082    
2083     static const struct of_device_id qcom_pcie_match[] = {
2084     diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2085     index 2cf13578fe754..e6e0012269cd3 100644
2086     --- a/drivers/pci/pci.c
2087     +++ b/drivers/pci/pci.c
2088     @@ -4079,18 +4079,18 @@ done:
2089    
2090     static void pci_dev_lock(struct pci_dev *dev)
2091     {
2092     - pci_cfg_access_lock(dev);
2093     /* block PM suspend, driver probe, etc. */
2094     device_lock(&dev->dev);
2095     + pci_cfg_access_lock(dev);
2096     }
2097    
2098     /* Return 1 on successful lock, 0 on contention */
2099     static int pci_dev_trylock(struct pci_dev *dev)
2100     {
2101     - if (pci_cfg_access_trylock(dev)) {
2102     - if (device_trylock(&dev->dev))
2103     + if (device_trylock(&dev->dev)) {
2104     + if (pci_cfg_access_trylock(dev))
2105     return 1;
2106     - pci_cfg_access_unlock(dev);
2107     + device_unlock(&dev->dev);
2108     }
2109    
2110     return 0;
2111     @@ -4098,8 +4098,8 @@ static int pci_dev_trylock(struct pci_dev *dev)
2112    
2113     static void pci_dev_unlock(struct pci_dev *dev)
2114     {
2115     - device_unlock(&dev->dev);
2116     pci_cfg_access_unlock(dev);
2117     + device_unlock(&dev->dev);
2118     }
2119    
2120     /**
2121     diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
2122     index d3c378b4db6c5..20d85d564b803 100644
2123     --- a/drivers/pcmcia/Kconfig
2124     +++ b/drivers/pcmcia/Kconfig
2125     @@ -146,7 +146,7 @@ config TCIC
2126    
2127     config PCMCIA_ALCHEMY_DEVBOARD
2128     tristate "Alchemy Db/Pb1xxx PCMCIA socket services"
2129     - depends on MIPS_ALCHEMY && PCMCIA
2130     + depends on MIPS_DB1XXX && PCMCIA
2131     help
2132     Enable this driver of you want PCMCIA support on your Alchemy
2133     Db1000, Db/Pb1100, Db/Pb1500, Db/Pb1550, Db/Pb1200, DB1300
2134     diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c
2135     index 872ea76a4f190..4612315687cd9 100644
2136     --- a/drivers/pwm/pwm-lp3943.c
2137     +++ b/drivers/pwm/pwm-lp3943.c
2138     @@ -128,6 +128,7 @@ static int lp3943_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
2139     if (err)
2140     return err;
2141    
2142     + duty_ns = min(duty_ns, period_ns);
2143     val = (u8)(duty_ns * LP3943_MAX_DUTY / period_ns);
2144    
2145     return lp3943_write_byte(lp3943, reg_duty, val);
2146     diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c
2147     index ffb1f61d2c752..998c7c972e604 100644
2148     --- a/drivers/regulator/pfuze100-regulator.c
2149     +++ b/drivers/regulator/pfuze100-regulator.c
2150     @@ -407,6 +407,7 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
2151     parent = of_get_child_by_name(np, "regulators");
2152     if (!parent) {
2153     dev_err(dev, "regulators node not found\n");
2154     + of_node_put(np);
2155     return -EINVAL;
2156     }
2157    
2158     @@ -431,6 +432,7 @@ static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
2159     }
2160    
2161     of_node_put(parent);
2162     + of_node_put(np);
2163     if (ret < 0) {
2164     dev_err(dev, "Error parsing regulator init data: %d\n",
2165     ret);
2166     diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
2167     index 312cb7fec5b01..5e67e42e64619 100644
2168     --- a/drivers/rpmsg/qcom_smd.c
2169     +++ b/drivers/rpmsg/qcom_smd.c
2170     @@ -1258,7 +1258,7 @@ static int qcom_smd_parse_edge(struct device *dev,
2171     }
2172    
2173     irq = irq_of_parse_and_map(node, 0);
2174     - if (irq < 0) {
2175     + if (!irq) {
2176     dev_err(dev, "required smd interrupt missing\n");
2177     return -EINVAL;
2178     }
2179     diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
2180     index 494a7fbd512b7..7e37ec7c8e02b 100644
2181     --- a/drivers/rtc/rtc-mt6397.c
2182     +++ b/drivers/rtc/rtc-mt6397.c
2183     @@ -339,6 +339,8 @@ static int mtk_rtc_probe(struct platform_device *pdev)
2184     return -ENOMEM;
2185    
2186     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2187     + if (!res)
2188     + return -EINVAL;
2189     rtc->addr_base = res->start;
2190    
2191     res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
2192     diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
2193     index 8490d0ff04ca7..f7304ff0e08ee 100644
2194     --- a/drivers/scsi/dc395x.c
2195     +++ b/drivers/scsi/dc395x.c
2196     @@ -3775,10 +3775,19 @@ static struct DeviceCtlBlk *device_alloc(struct AdapterCtlBlk *acb,
2197     #endif
2198     if (dcb->target_lun != 0) {
2199     /* Copy settings */
2200     - struct DeviceCtlBlk *p;
2201     - list_for_each_entry(p, &acb->dcb_list, list)
2202     - if (p->target_id == dcb->target_id)
2203     + struct DeviceCtlBlk *p = NULL, *iter;
2204     +
2205     + list_for_each_entry(iter, &acb->dcb_list, list)
2206     + if (iter->target_id == dcb->target_id) {
2207     + p = iter;
2208     break;
2209     + }
2210     +
2211     + if (!p) {
2212     + kfree(dcb);
2213     + return NULL;
2214     + }
2215     +
2216     dprintkdbg(DBG_1,
2217     "device_alloc: <%02i-%i> copy from <%02i-%i>\n",
2218     dcb->target_id, dcb->target_lun,
2219     diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
2220     index f5f3a8113bc55..5bb85b424eba3 100644
2221     --- a/drivers/scsi/fcoe/fcoe_ctlr.c
2222     +++ b/drivers/scsi/fcoe/fcoe_ctlr.c
2223     @@ -1945,7 +1945,7 @@ EXPORT_SYMBOL(fcoe_ctlr_recv_flogi);
2224     *
2225     * Returns: u64 fc world wide name
2226     */
2227     -u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN],
2228     +u64 fcoe_wwn_from_mac(unsigned char mac[ETH_ALEN],
2229     unsigned int scheme, unsigned int port)
2230     {
2231     u64 wwn;
2232     diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
2233     index 2cbfec6a74662..2f7132edcd3f7 100644
2234     --- a/drivers/scsi/megaraid.c
2235     +++ b/drivers/scsi/megaraid.c
2236     @@ -4705,7 +4705,7 @@ static int __init megaraid_init(void)
2237     * major number allocation.
2238     */
2239     major = register_chrdev(0, "megadev_legacy", &megadev_fops);
2240     - if (!major) {
2241     + if (major < 0) {
2242     printk(KERN_WARNING
2243     "megaraid: failed to register char device\n");
2244     }
2245     diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
2246     index 1fe193590b8bd..eada1b3573389 100644
2247     --- a/drivers/scsi/ufs/ufs-qcom.c
2248     +++ b/drivers/scsi/ufs/ufs-qcom.c
2249     @@ -915,8 +915,11 @@ static void ufs_qcom_dev_ref_clk_ctrl(struct ufs_qcom_host *host, bool enable)
2250    
2251     writel_relaxed(temp, host->dev_ref_clk_ctrl_mmio);
2252    
2253     - /* ensure that ref_clk is enabled/disabled before we return */
2254     - wmb();
2255     + /*
2256     + * Make sure the write to ref_clk reaches the destination and
2257     + * not stored in a Write Buffer (WB).
2258     + */
2259     + readl(host->dev_ref_clk_ctrl_mmio);
2260    
2261     /*
2262     * If we call hibern8 exit after this, we need to make sure that
2263     diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c
2264     index 4c5767c73b7a8..a0562dec9604a 100644
2265     --- a/drivers/soc/qcom/smp2p.c
2266     +++ b/drivers/soc/qcom/smp2p.c
2267     @@ -416,6 +416,7 @@ static int smp2p_parse_ipc(struct qcom_smp2p *smp2p)
2268     }
2269    
2270     smp2p->ipc_regmap = syscon_node_to_regmap(syscon);
2271     + of_node_put(syscon);
2272     if (IS_ERR(smp2p->ipc_regmap))
2273     return PTR_ERR(smp2p->ipc_regmap);
2274    
2275     diff --git a/drivers/soc/qcom/smsm.c b/drivers/soc/qcom/smsm.c
2276     index 783cb3364599b..01bc8528f24d5 100644
2277     --- a/drivers/soc/qcom/smsm.c
2278     +++ b/drivers/soc/qcom/smsm.c
2279     @@ -367,6 +367,7 @@ static int smsm_parse_ipc(struct qcom_smsm *smsm, unsigned host_id)
2280     return 0;
2281    
2282     host->ipc_regmap = syscon_node_to_regmap(syscon);
2283     + of_node_put(syscon);
2284     if (IS_ERR(host->ipc_regmap))
2285     return PTR_ERR(host->ipc_regmap);
2286    
2287     diff --git a/drivers/spi/spi-img-spfi.c b/drivers/spi/spi-img-spfi.c
2288     index 2a340234c85c1..82ab1bc2196a9 100644
2289     --- a/drivers/spi/spi-img-spfi.c
2290     +++ b/drivers/spi/spi-img-spfi.c
2291     @@ -771,7 +771,7 @@ static int img_spfi_resume(struct device *dev)
2292     int ret;
2293    
2294     ret = pm_runtime_get_sync(dev);
2295     - if (ret) {
2296     + if (ret < 0) {
2297     pm_runtime_put_noidle(dev);
2298     return ret;
2299     }
2300     diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
2301     index b0a5486936c01..0b0f69551da05 100644
2302     --- a/drivers/spi/spi-ti-qspi.c
2303     +++ b/drivers/spi/spi-ti-qspi.c
2304     @@ -401,6 +401,7 @@ static int ti_qspi_dma_xfer(struct ti_qspi *qspi, dma_addr_t dma_dst,
2305     enum dma_ctrl_flags flags = DMA_CTRL_ACK | DMA_PREP_INTERRUPT;
2306     struct dma_async_tx_descriptor *tx;
2307     int ret;
2308     + unsigned long time_left;
2309    
2310     tx = dma_dev->device_prep_dma_memcpy(chan, dma_dst, dma_src,
2311     len, flags);
2312     @@ -420,9 +421,9 @@ static int ti_qspi_dma_xfer(struct ti_qspi *qspi, dma_addr_t dma_dst,
2313     }
2314    
2315     dma_async_issue_pending(chan);
2316     - ret = wait_for_completion_timeout(&qspi->transfer_complete,
2317     + time_left = wait_for_completion_timeout(&qspi->transfer_complete,
2318     msecs_to_jiffies(len));
2319     - if (ret <= 0) {
2320     + if (time_left == 0) {
2321     dmaengine_terminate_sync(chan);
2322     dev_err(qspi->dev, "DMA wait_for_completion_timeout\n");
2323     return -ETIMEDOUT;
2324     diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
2325     index 4c2d6c2d4fb41..90bc23408a9c2 100644
2326     --- a/drivers/staging/greybus/audio_codec.c
2327     +++ b/drivers/staging/greybus/audio_codec.c
2328     @@ -618,8 +618,8 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
2329     break;
2330     }
2331     if (!data) {
2332     - dev_err(dai->dev, "%s:%s DATA connection missing\n",
2333     - dai->name, module->name);
2334     + dev_err(dai->dev, "%s DATA connection missing\n",
2335     + dai->name);
2336     mutex_unlock(&codec->lock);
2337     return -ENODEV;
2338     }
2339     diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
2340     index da74dc49b95ec..f46def63967b4 100644
2341     --- a/drivers/staging/rtl8192e/rtllib_softmac.c
2342     +++ b/drivers/staging/rtl8192e/rtllib_softmac.c
2343     @@ -655,9 +655,9 @@ static void rtllib_beacons_stop(struct rtllib_device *ieee)
2344     spin_lock_irqsave(&ieee->beacon_lock, flags);
2345    
2346     ieee->beacon_txing = 0;
2347     - del_timer_sync(&ieee->beacon_timer);
2348    
2349     spin_unlock_irqrestore(&ieee->beacon_lock, flags);
2350     + del_timer_sync(&ieee->beacon_timer);
2351    
2352     }
2353    
2354     diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c
2355     index d0ba42dfafebf..7b7cb2a7db605 100644
2356     --- a/drivers/staging/rtl8712/usb_intf.c
2357     +++ b/drivers/staging/rtl8712/usb_intf.c
2358     @@ -569,13 +569,13 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf,
2359     } else {
2360     AutoloadFail = false;
2361     }
2362     - if (((mac[0] == 0xff) && (mac[1] == 0xff) &&
2363     + if ((!AutoloadFail) ||
2364     + ((mac[0] == 0xff) && (mac[1] == 0xff) &&
2365     (mac[2] == 0xff) && (mac[3] == 0xff) &&
2366     (mac[4] == 0xff) && (mac[5] == 0xff)) ||
2367     ((mac[0] == 0x00) && (mac[1] == 0x00) &&
2368     (mac[2] == 0x00) && (mac[3] == 0x00) &&
2369     - (mac[4] == 0x00) && (mac[5] == 0x00)) ||
2370     - (!AutoloadFail)) {
2371     + (mac[4] == 0x00) && (mac[5] == 0x00))) {
2372     mac[0] = 0x00;
2373     mac[1] = 0xe0;
2374     mac[2] = 0x4c;
2375     diff --git a/drivers/tty/serial/digicolor-usart.c b/drivers/tty/serial/digicolor-usart.c
2376     index 794864fac6250..74127813e6dbc 100644
2377     --- a/drivers/tty/serial/digicolor-usart.c
2378     +++ b/drivers/tty/serial/digicolor-usart.c
2379     @@ -313,6 +313,8 @@ static void digicolor_uart_set_termios(struct uart_port *port,
2380     case CS8:
2381     default:
2382     config |= UA_CONFIG_CHAR_LEN;
2383     + termios->c_cflag &= ~CSIZE;
2384     + termios->c_cflag |= CS8;
2385     break;
2386     }
2387    
2388     diff --git a/drivers/tty/serial/icom.c b/drivers/tty/serial/icom.c
2389     index c60a8d5e40201..a3e4206696742 100644
2390     --- a/drivers/tty/serial/icom.c
2391     +++ b/drivers/tty/serial/icom.c
2392     @@ -1515,7 +1515,7 @@ static int icom_probe(struct pci_dev *dev,
2393     retval = pci_read_config_dword(dev, PCI_COMMAND, &command_reg);
2394     if (retval) {
2395     dev_err(&dev->dev, "PCI Config read FAILED\n");
2396     - return retval;
2397     + goto probe_exit0;
2398     }
2399    
2400     pci_write_config_dword(dev, PCI_COMMAND,
2401     diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
2402     index 6aea0f4a91658..273292f09bf6d 100644
2403     --- a/drivers/tty/serial/meson_uart.c
2404     +++ b/drivers/tty/serial/meson_uart.c
2405     @@ -253,6 +253,14 @@ static const char *meson_uart_type(struct uart_port *port)
2406     return (port->type == PORT_MESON) ? "meson_uart" : NULL;
2407     }
2408    
2409     +/*
2410     + * This function is called only from probe() using a temporary io mapping
2411     + * in order to perform a reset before setting up the device. Since the
2412     + * temporarily mapped region was successfully requested, there can be no
2413     + * console on this port at this time. Hence it is not necessary for this
2414     + * function to acquire the port->lock. (Since there is no console on this
2415     + * port at this time, the port->lock is not initialized yet.)
2416     + */
2417     static void meson_uart_reset(struct uart_port *port)
2418     {
2419     u32 val;
2420     @@ -267,9 +275,12 @@ static void meson_uart_reset(struct uart_port *port)
2421    
2422     static int meson_uart_startup(struct uart_port *port)
2423     {
2424     + unsigned long flags;
2425     u32 val;
2426     int ret = 0;
2427    
2428     + spin_lock_irqsave(&port->lock, flags);
2429     +
2430     val = readl(port->membase + AML_UART_CONTROL);
2431     val |= AML_UART_CLR_ERR;
2432     writel(val, port->membase + AML_UART_CONTROL);
2433     @@ -285,6 +296,8 @@ static int meson_uart_startup(struct uart_port *port)
2434     val = (AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(port->fifosize / 2));
2435     writel(val, port->membase + AML_UART_MISC);
2436    
2437     + spin_unlock_irqrestore(&port->lock, flags);
2438     +
2439     ret = request_irq(port->irq, meson_uart_interrupt, 0,
2440     meson_uart_type(port), port);
2441    
2442     diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
2443     index c284e61ed4fcc..33d035f9fdedd 100644
2444     --- a/drivers/tty/serial/msm_serial.c
2445     +++ b/drivers/tty/serial/msm_serial.c
2446     @@ -1578,6 +1578,7 @@ static inline struct uart_port *msm_get_port_from_line(unsigned int line)
2447     static void __msm_console_write(struct uart_port *port, const char *s,
2448     unsigned int count, bool is_uartdm)
2449     {
2450     + unsigned long flags;
2451     int i;
2452     int num_newlines = 0;
2453     bool replaced = false;
2454     @@ -1595,6 +1596,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,
2455     num_newlines++;
2456     count += num_newlines;
2457    
2458     + local_irq_save(flags);
2459     +
2460     if (port->sysrq)
2461     locked = 0;
2462     else if (oops_in_progress)
2463     @@ -1640,6 +1643,8 @@ static void __msm_console_write(struct uart_port *port, const char *s,
2464    
2465     if (locked)
2466     spin_unlock(&port->lock);
2467     +
2468     + local_irq_restore(flags);
2469     }
2470    
2471     static void msm_console_write(struct console *co, const char *s,
2472     diff --git a/drivers/tty/serial/sa1100.c b/drivers/tty/serial/sa1100.c
2473     index fd3d1329d48c3..68eb1c9faa29e 100644
2474     --- a/drivers/tty/serial/sa1100.c
2475     +++ b/drivers/tty/serial/sa1100.c
2476     @@ -452,6 +452,8 @@ sa1100_set_termios(struct uart_port *port, struct ktermios *termios,
2477     baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
2478     quot = uart_get_divisor(port, baud);
2479    
2480     + del_timer_sync(&sport->timer);
2481     +
2482     spin_lock_irqsave(&sport->port.lock, flags);
2483    
2484     sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS);
2485     @@ -482,8 +484,6 @@ sa1100_set_termios(struct uart_port *port, struct ktermios *termios,
2486     UTSR1_TO_SM(UTSR1_ROR);
2487     }
2488    
2489     - del_timer_sync(&sport->timer);
2490     -
2491     /*
2492     * Update the per-port timeout.
2493     */
2494     diff --git a/drivers/tty/serial/serial_txx9.c b/drivers/tty/serial/serial_txx9.c
2495     index ffb3fb1bda9e7..61e0b65c3aaf2 100644
2496     --- a/drivers/tty/serial/serial_txx9.c
2497     +++ b/drivers/tty/serial/serial_txx9.c
2498     @@ -652,6 +652,8 @@ serial_txx9_set_termios(struct uart_port *port, struct ktermios *termios,
2499     case CS6: /* not supported */
2500     case CS8:
2501     cval |= TXX9_SILCR_UMODE_8BIT;
2502     + termios->c_cflag &= ~CSIZE;
2503     + termios->c_cflag |= CS8;
2504     break;
2505     }
2506    
2507     diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
2508     index 5c6243a31166a..91c69fc3987a6 100644
2509     --- a/drivers/tty/serial/sh-sci.c
2510     +++ b/drivers/tty/serial/sh-sci.c
2511     @@ -2206,8 +2206,12 @@ static void sci_set_termios(struct uart_port *port, struct ktermios *termios,
2512     unsigned long max_freq = 0;
2513     int best_clk = -1;
2514    
2515     - if ((termios->c_cflag & CSIZE) == CS7)
2516     + if ((termios->c_cflag & CSIZE) == CS7) {
2517     smr_val |= SCSMR_CHR;
2518     + } else {
2519     + termios->c_cflag &= ~CSIZE;
2520     + termios->c_cflag |= CS8;
2521     + }
2522     if (termios->c_cflag & PARENB)
2523     smr_val |= SCSMR_PE;
2524     if (termios->c_cflag & PARODD)
2525     diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
2526     index 379e5bd37df94..b845cd05e3500 100644
2527     --- a/drivers/tty/serial/st-asc.c
2528     +++ b/drivers/tty/serial/st-asc.c
2529     @@ -509,10 +509,14 @@ static void asc_set_termios(struct uart_port *port, struct ktermios *termios,
2530     /* set character length */
2531     if ((cflag & CSIZE) == CS7) {
2532     ctrl_val |= ASC_CTL_MODE_7BIT_PAR;
2533     + cflag |= PARENB;
2534     } else {
2535     ctrl_val |= (cflag & PARENB) ? ASC_CTL_MODE_8BIT_PAR :
2536     ASC_CTL_MODE_8BIT;
2537     + cflag &= ~CSIZE;
2538     + cflag |= CS8;
2539     }
2540     + termios->c_cflag = cflag;
2541    
2542     /* set stop bit */
2543     ctrl_val |= (cflag & CSTOPB) ? ASC_CTL_STOP_2BIT : ASC_CTL_STOP_1BIT;
2544     diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
2545     index 7446ce29f6770..b5d053763263e 100644
2546     --- a/drivers/tty/synclink_gt.c
2547     +++ b/drivers/tty/synclink_gt.c
2548     @@ -1823,6 +1823,8 @@ static int hdlcdev_init(struct slgt_info *info)
2549     */
2550     static void hdlcdev_exit(struct slgt_info *info)
2551     {
2552     + if (!info->netdev)
2553     + return;
2554     unregister_hdlc_device(info->netdev);
2555     free_netdev(info->netdev);
2556     info->netdev = NULL;
2557     diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
2558     index dfccc102c1ddd..e65faa98146ef 100644
2559     --- a/drivers/tty/tty_buffer.c
2560     +++ b/drivers/tty/tty_buffer.c
2561     @@ -166,7 +166,8 @@ static struct tty_buffer *tty_buffer_alloc(struct tty_port *port, size_t size)
2562     have queued and recycle that ? */
2563     if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit)
2564     return NULL;
2565     - p = kmalloc(sizeof(struct tty_buffer) + 2 * size, GFP_ATOMIC);
2566     + p = kmalloc(sizeof(struct tty_buffer) + 2 * size,
2567     + GFP_ATOMIC | __GFP_NOWARN);
2568     if (p == NULL)
2569     return NULL;
2570    
2571     diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
2572     index 7af23b2152548..a416eea9a366f 100644
2573     --- a/drivers/usb/core/hcd-pci.c
2574     +++ b/drivers/usb/core/hcd-pci.c
2575     @@ -637,10 +637,10 @@ const struct dev_pm_ops usb_hcd_pci_pm_ops = {
2576     .suspend_noirq = hcd_pci_suspend_noirq,
2577     .resume_noirq = hcd_pci_resume_noirq,
2578     .resume = hcd_pci_resume,
2579     - .freeze = check_root_hub_suspended,
2580     + .freeze = hcd_pci_suspend,
2581     .freeze_noirq = check_root_hub_suspended,
2582     .thaw_noirq = NULL,
2583     - .thaw = NULL,
2584     + .thaw = hcd_pci_resume,
2585     .poweroff = hcd_pci_suspend,
2586     .poweroff_noirq = hcd_pci_suspend_noirq,
2587     .restore_noirq = hcd_pci_resume_noirq,
2588     diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
2589     index bba74e9b7da0f..1f26f0ab155f2 100644
2590     --- a/drivers/usb/core/quirks.c
2591     +++ b/drivers/usb/core/quirks.c
2592     @@ -328,6 +328,9 @@ static const struct usb_device_id usb_quirk_list[] = {
2593     /* DJI CineSSD */
2594     { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
2595    
2596     + /* DELL USB GEN2 */
2597     + { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME },
2598     +
2599     /* VCOM device */
2600     { USB_DEVICE(0x4296, 0x7570), .driver_info = USB_QUIRK_CONFIG_INTF_STRINGS },
2601    
2602     diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
2603     index 65bcbbad6d545..44bab6727b43f 100644
2604     --- a/drivers/usb/dwc2/gadget.c
2605     +++ b/drivers/usb/dwc2/gadget.c
2606     @@ -3445,7 +3445,6 @@ static int dwc2_hsotg_udc_start(struct usb_gadget *gadget,
2607    
2608     WARN_ON(hsotg->driver);
2609    
2610     - driver->driver.bus = NULL;
2611     hsotg->driver = driver;
2612     hsotg->gadget.dev.of_node = hsotg->dev->of_node;
2613     hsotg->gadget.speed = USB_SPEED_UNKNOWN;
2614     diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
2615     index d089b3fb7a13d..c32145e63aea6 100644
2616     --- a/drivers/usb/host/isp116x-hcd.c
2617     +++ b/drivers/usb/host/isp116x-hcd.c
2618     @@ -1551,10 +1551,12 @@ static int isp116x_remove(struct platform_device *pdev)
2619    
2620     iounmap(isp116x->data_reg);
2621     res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
2622     - release_mem_region(res->start, 2);
2623     + if (res)
2624     + release_mem_region(res->start, 2);
2625     iounmap(isp116x->addr_reg);
2626     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2627     - release_mem_region(res->start, 2);
2628     + if (res)
2629     + release_mem_region(res->start, 2);
2630    
2631     usb_put_hcd(hcd);
2632     return 0;
2633     diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c
2634     index 2f48da0c0bb39..af5248f62c59b 100644
2635     --- a/drivers/usb/host/oxu210hp-hcd.c
2636     +++ b/drivers/usb/host/oxu210hp-hcd.c
2637     @@ -3491,8 +3491,10 @@ static int oxu_bus_suspend(struct usb_hcd *hcd)
2638     }
2639     }
2640    
2641     + spin_unlock_irq(&oxu->lock);
2642     /* turn off now-idle HC */
2643     del_timer_sync(&oxu->watchdog);
2644     + spin_lock_irq(&oxu->lock);
2645     ehci_halt(oxu);
2646     hcd->state = HC_STATE_SUSPENDED;
2647    
2648     diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
2649     index f9d407f0b5086..13d77421a9154 100644
2650     --- a/drivers/usb/storage/karma.c
2651     +++ b/drivers/usb/storage/karma.c
2652     @@ -185,23 +185,24 @@ static void rio_karma_destructor(void *extra)
2653    
2654     static int rio_karma_init(struct us_data *us)
2655     {
2656     - int ret = 0;
2657     struct karma_data *data = kzalloc(sizeof(struct karma_data), GFP_NOIO);
2658     if (!data)
2659     - goto out;
2660     + return -ENOMEM;
2661    
2662     data->recv = kmalloc(RIO_RECV_LEN, GFP_NOIO);
2663     if (!data->recv) {
2664     kfree(data);
2665     - goto out;
2666     + return -ENOMEM;
2667     }
2668    
2669     us->extra = data;
2670     us->extra_destructor = rio_karma_destructor;
2671     - ret = rio_karma_send_command(RIO_ENTER_STORAGE, us);
2672     - data->in_storage = (ret == 0);
2673     -out:
2674     - return ret;
2675     + if (rio_karma_send_command(RIO_ENTER_STORAGE, us))
2676     + return -EIO;
2677     +
2678     + data->in_storage = 1;
2679     +
2680     + return 0;
2681     }
2682    
2683     static struct scsi_host_template karma_host_template;
2684     diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c
2685     index cec5805feb254..ca76ee4058c9b 100644
2686     --- a/drivers/usb/usbip/stub_dev.c
2687     +++ b/drivers/usb/usbip/stub_dev.c
2688     @@ -441,7 +441,6 @@ err_files:
2689     (struct usb_dev_state *) udev);
2690     err_port:
2691     dev_set_drvdata(&udev->dev, NULL);
2692     - usb_put_dev(udev);
2693    
2694     /* we already have busid_priv, just lock busid_lock */
2695     spin_lock(&busid_priv->busid_lock);
2696     @@ -456,6 +455,7 @@ call_put_busid_priv:
2697     put_busid_priv(busid_priv);
2698    
2699     sdev_free:
2700     + usb_put_dev(udev);
2701     stub_device_free(sdev);
2702    
2703     return rc;
2704     diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c
2705     index d47176f9c3103..dd6228a51d0da 100644
2706     --- a/drivers/usb/usbip/stub_rx.c
2707     +++ b/drivers/usb/usbip/stub_rx.c
2708     @@ -151,7 +151,9 @@ static int tweak_set_configuration_cmd(struct urb *urb)
2709     req = (struct usb_ctrlrequest *) urb->setup_packet;
2710     config = le16_to_cpu(req->wValue);
2711    
2712     + usb_lock_device(sdev->udev);
2713     err = usb_set_configuration(sdev->udev, config);
2714     + usb_unlock_device(sdev->udev);
2715     if (err && err != -ENODEV)
2716     dev_err(&sdev->udev->dev, "can't set config #%d, error %d\n",
2717     config, err);
2718     diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
2719     index da47542496cc3..63f0ab3e6f635 100644
2720     --- a/drivers/vhost/vringh.c
2721     +++ b/drivers/vhost/vringh.c
2722     @@ -262,7 +262,7 @@ __vringh_iov(struct vringh *vrh, u16 i,
2723     gfp_t gfp,
2724     int (*copy)(void *dst, const void *src, size_t len))
2725     {
2726     - int err, count = 0, up_next, desc_max;
2727     + int err, count = 0, indirect_count = 0, up_next, desc_max;
2728     struct vring_desc desc, *descs;
2729     struct vringh_range range = { -1ULL, 0 }, slowrange;
2730     bool slow = false;
2731     @@ -319,7 +319,12 @@ __vringh_iov(struct vringh *vrh, u16 i,
2732     continue;
2733     }
2734    
2735     - if (count++ == vrh->vring.num) {
2736     + if (up_next == -1)
2737     + count++;
2738     + else
2739     + indirect_count++;
2740     +
2741     + if (count > vrh->vring.num || indirect_count > desc_max) {
2742     vringh_bad("Descriptor loop in %p", descs);
2743     err = -ELOOP;
2744     goto fail;
2745     @@ -381,6 +386,7 @@ __vringh_iov(struct vringh *vrh, u16 i,
2746     i = return_from_indirect(vrh, &up_next,
2747     &descs, &desc_max);
2748     slow = false;
2749     + indirect_count = 0;
2750     } else
2751     break;
2752     }
2753     diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
2754     index 89880b70cc288..ca3707e596332 100644
2755     --- a/drivers/video/fbdev/amba-clcd.c
2756     +++ b/drivers/video/fbdev/amba-clcd.c
2757     @@ -849,12 +849,15 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb)
2758     return -ENODEV;
2759    
2760     fb->fb.screen_base = of_iomap(memory, 0);
2761     - if (!fb->fb.screen_base)
2762     + if (!fb->fb.screen_base) {
2763     + of_node_put(memory);
2764     return -ENOMEM;
2765     + }
2766    
2767     fb->fb.fix.smem_start = of_translate_address(memory,
2768     of_get_address(memory, 0, &size, NULL));
2769     fb->fb.fix.smem_len = size;
2770     + of_node_put(memory);
2771    
2772     return 0;
2773     }
2774     diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c
2775     index 50bce45e7f3d4..184773b6b9e4f 100644
2776     --- a/drivers/video/fbdev/pxa3xx-gcu.c
2777     +++ b/drivers/video/fbdev/pxa3xx-gcu.c
2778     @@ -662,6 +662,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev)
2779     for (i = 0; i < 8; i++) {
2780     ret = pxa3xx_gcu_add_buffer(dev, priv);
2781     if (ret) {
2782     + pxa3xx_gcu_free_buffers(dev, priv);
2783     dev_err(dev, "failed to allocate DMA memory\n");
2784     goto err_disable_clk;
2785     }
2786     @@ -677,15 +678,15 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev)
2787     SHARED_SIZE, irq);
2788     return 0;
2789    
2790     -err_free_dma:
2791     - dma_free_coherent(dev, SHARED_SIZE,
2792     - priv->shared, priv->shared_phys);
2793     +err_disable_clk:
2794     + clk_disable_unprepare(priv->clk);
2795    
2796     err_misc_deregister:
2797     misc_deregister(&priv->misc_dev);
2798    
2799     -err_disable_clk:
2800     - clk_disable_unprepare(priv->clk);
2801     +err_free_dma:
2802     + dma_free_coherent(dev, SHARED_SIZE,
2803     + priv->shared, priv->shared_phys);
2804    
2805     return ret;
2806     }
2807     @@ -698,6 +699,7 @@ static int pxa3xx_gcu_remove(struct platform_device *pdev)
2808     pxa3xx_gcu_wait_idle(priv);
2809     misc_deregister(&priv->misc_dev);
2810     dma_free_coherent(dev, SHARED_SIZE, priv->shared, priv->shared_phys);
2811     + clk_disable_unprepare(priv->clk);
2812     pxa3xx_gcu_free_buffers(dev, priv);
2813    
2814     return 0;
2815     diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
2816     index b100b8dae5884..46ecb7405af1f 100644
2817     --- a/fs/btrfs/disk-io.c
2818     +++ b/fs/btrfs/disk-io.c
2819     @@ -2716,7 +2716,7 @@ int open_ctree(struct super_block *sb,
2820     ~BTRFS_FEATURE_INCOMPAT_SUPP;
2821     if (features) {
2822     btrfs_err(fs_info,
2823     - "cannot mount because of unsupported optional features (%llx)",
2824     + "cannot mount because of unsupported optional features (0x%llx)",
2825     features);
2826     err = -EINVAL;
2827     goto fail_alloc;
2828     @@ -2769,7 +2769,7 @@ int open_ctree(struct super_block *sb,
2829     ~BTRFS_FEATURE_COMPAT_RO_SUPP;
2830     if (!(sb->s_flags & MS_RDONLY) && features) {
2831     btrfs_err(fs_info,
2832     - "cannot mount read-write because of unsupported optional features (%llx)",
2833     + "cannot mount read-write because of unsupported optional features (0x%llx)",
2834     features);
2835     err = -EINVAL;
2836     goto fail_alloc;
2837     diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
2838     index cf1a3d2f6ad8b..0eb69b0b543a0 100644
2839     --- a/fs/cifs/smb2pdu.c
2840     +++ b/fs/cifs/smb2pdu.c
2841     @@ -265,6 +265,9 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon)
2842     rc = -EHOSTDOWN;
2843     mutex_unlock(&tcon->ses->session_mutex);
2844     goto failed;
2845     + } else if (rc) {
2846     + mutex_unlock(&ses->session_mutex);
2847     + goto out;
2848     }
2849     }
2850     if (rc || !tcon->need_reconnect) {
2851     diff --git a/fs/dlm/lock.c b/fs/dlm/lock.c
2852     index ffab7dc881574..a1f5982f0b519 100644
2853     --- a/fs/dlm/lock.c
2854     +++ b/fs/dlm/lock.c
2855     @@ -1555,6 +1555,7 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
2856     lkb->lkb_wait_type = 0;
2857     lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL;
2858     lkb->lkb_wait_count--;
2859     + unhold_lkb(lkb);
2860     goto out_del;
2861     }
2862    
2863     @@ -1581,6 +1582,7 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
2864     log_error(ls, "remwait error %x reply %d wait_type %d overlap",
2865     lkb->lkb_id, mstype, lkb->lkb_wait_type);
2866     lkb->lkb_wait_count--;
2867     + unhold_lkb(lkb);
2868     lkb->lkb_wait_type = 0;
2869     }
2870    
2871     @@ -5314,11 +5316,16 @@ int dlm_recover_waiters_post(struct dlm_ls *ls)
2872     lkb->lkb_flags &= ~DLM_IFL_OVERLAP_UNLOCK;
2873     lkb->lkb_flags &= ~DLM_IFL_OVERLAP_CANCEL;
2874     lkb->lkb_wait_type = 0;
2875     - lkb->lkb_wait_count = 0;
2876     + /* drop all wait_count references we still
2877     + * hold a reference for this iteration.
2878     + */
2879     + while (lkb->lkb_wait_count) {
2880     + lkb->lkb_wait_count--;
2881     + unhold_lkb(lkb);
2882     + }
2883     mutex_lock(&ls->ls_waiters_mutex);
2884     list_del_init(&lkb->lkb_wait_reply);
2885     mutex_unlock(&ls->ls_waiters_mutex);
2886     - unhold_lkb(lkb); /* for waiters list */
2887    
2888     if (oc || ou) {
2889     /* do an unlock or cancel instead of resending */
2890     diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c
2891     index d401425f602a4..b81c7473f2bf2 100644
2892     --- a/fs/dlm/plock.c
2893     +++ b/fs/dlm/plock.c
2894     @@ -26,11 +26,11 @@ struct plock_op {
2895     struct list_head list;
2896     int done;
2897     struct dlm_plock_info info;
2898     + int (*callback)(struct file_lock *fl, int result);
2899     };
2900    
2901     struct plock_xop {
2902     struct plock_op xop;
2903     - int (*callback)(struct file_lock *fl, int result);
2904     void *fl;
2905     void *file;
2906     struct file_lock flc;
2907     @@ -132,19 +132,18 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
2908     /* fl_owner is lockd which doesn't distinguish
2909     processes on the nfs client */
2910     op->info.owner = (__u64) fl->fl_pid;
2911     - xop->callback = fl->fl_lmops->lm_grant;
2912     + op->callback = fl->fl_lmops->lm_grant;
2913     locks_init_lock(&xop->flc);
2914     locks_copy_lock(&xop->flc, fl);
2915     xop->fl = fl;
2916     xop->file = file;
2917     } else {
2918     op->info.owner = (__u64)(long) fl->fl_owner;
2919     - xop->callback = NULL;
2920     }
2921    
2922     send_op(op);
2923    
2924     - if (xop->callback == NULL) {
2925     + if (!op->callback) {
2926     rv = wait_event_interruptible(recv_wq, (op->done != 0));
2927     if (rv == -ERESTARTSYS) {
2928     log_debug(ls, "dlm_posix_lock: wait killed %llx",
2929     @@ -206,7 +205,7 @@ static int dlm_plock_callback(struct plock_op *op)
2930     file = xop->file;
2931     flc = &xop->flc;
2932     fl = xop->fl;
2933     - notify = xop->callback;
2934     + notify = op->callback;
2935    
2936     if (op->info.rv) {
2937     notify(fl, op->info.rv);
2938     @@ -439,10 +438,9 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
2939     if (op->info.fsid == info.fsid &&
2940     op->info.number == info.number &&
2941     op->info.owner == info.owner) {
2942     - struct plock_xop *xop = (struct plock_xop *)op;
2943     list_del_init(&op->list);
2944     memcpy(&op->info, &info, sizeof(info));
2945     - if (xop->callback)
2946     + if (op->callback)
2947     do_callback = 1;
2948     else
2949     op->done = 1;
2950     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
2951     index c87558f120fb9..3ca319e6c9791 100644
2952     --- a/fs/ext4/inline.c
2953     +++ b/fs/ext4/inline.c
2954     @@ -1984,6 +1984,18 @@ int ext4_convert_inline_data(struct inode *inode)
2955     if (!ext4_has_inline_data(inode)) {
2956     ext4_clear_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
2957     return 0;
2958     + } else if (!ext4_test_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA)) {
2959     + /*
2960     + * Inode has inline data but EXT4_STATE_MAY_INLINE_DATA is
2961     + * cleared. This means we are in the middle of moving of
2962     + * inline data to delay allocated block. Just force writeout
2963     + * here to finish conversion.
2964     + */
2965     + error = filemap_flush(inode->i_mapping);
2966     + if (error)
2967     + return error;
2968     + if (!ext4_has_inline_data(inode))
2969     + return 0;
2970     }
2971    
2972     needed_blocks = ext4_writepage_trans_blocks(inode);
2973     diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
2974     index 4d9901a18b975..159d259e5e5e9 100644
2975     --- a/fs/ext4/namei.c
2976     +++ b/fs/ext4/namei.c
2977     @@ -270,9 +270,9 @@ static struct dx_frame *dx_probe(struct ext4_filename *fname,
2978     struct dx_hash_info *hinfo,
2979     struct dx_frame *frame);
2980     static void dx_release(struct dx_frame *frames);
2981     -static int dx_make_map(struct inode *dir, struct ext4_dir_entry_2 *de,
2982     - unsigned blocksize, struct dx_hash_info *hinfo,
2983     - struct dx_map_entry map[]);
2984     +static int dx_make_map(struct inode *dir, struct buffer_head *bh,
2985     + struct dx_hash_info *hinfo,
2986     + struct dx_map_entry *map_tail);
2987     static void dx_sort_map(struct dx_map_entry *map, unsigned count);
2988     static struct ext4_dir_entry_2 *dx_move_dirents(char *from, char *to,
2989     struct dx_map_entry *offsets, int count, unsigned blocksize);
2990     @@ -1185,15 +1185,23 @@ static inline int search_dirblock(struct buffer_head *bh,
2991     * Create map of hash values, offsets, and sizes, stored at end of block.
2992     * Returns number of entries mapped.
2993     */
2994     -static int dx_make_map(struct inode *dir, struct ext4_dir_entry_2 *de,
2995     - unsigned blocksize, struct dx_hash_info *hinfo,
2996     +static int dx_make_map(struct inode *dir, struct buffer_head *bh,
2997     + struct dx_hash_info *hinfo,
2998     struct dx_map_entry *map_tail)
2999     {
3000     int count = 0;
3001     - char *base = (char *) de;
3002     + struct ext4_dir_entry_2 *de = (struct ext4_dir_entry_2 *)bh->b_data;
3003     + unsigned int buflen = bh->b_size;
3004     + char *base = bh->b_data;
3005     struct dx_hash_info h = *hinfo;
3006    
3007     - while ((char *) de < base + blocksize) {
3008     + if (ext4_has_metadata_csum(dir->i_sb))
3009     + buflen -= sizeof(struct ext4_dir_entry_tail);
3010     +
3011     + while ((char *) de < base + buflen) {
3012     + if (ext4_check_dir_entry(dir, NULL, de, bh, base, buflen,
3013     + ((char *)de) - base))
3014     + return -EFSCORRUPTED;
3015     if (de->name_len && de->inode) {
3016     ext4fs_dirhash(de->name, de->name_len, &h);
3017     map_tail--;
3018     @@ -1203,8 +1211,7 @@ static int dx_make_map(struct inode *dir, struct ext4_dir_entry_2 *de,
3019     count++;
3020     cond_resched();
3021     }
3022     - /* XXX: do we need to check rec_len == 0 case? -Chris */
3023     - de = ext4_next_entry(de, blocksize);
3024     + de = ext4_next_entry(de, dir->i_sb->s_blocksize);
3025     }
3026     return count;
3027     }
3028     @@ -1755,8 +1762,11 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
3029    
3030     /* create map in the end of data2 block */
3031     map = (struct dx_map_entry *) (data2 + blocksize);
3032     - count = dx_make_map(dir, (struct ext4_dir_entry_2 *) data1,
3033     - blocksize, hinfo, map);
3034     + count = dx_make_map(dir, *bh, hinfo, map);
3035     + if (count < 0) {
3036     + err = count;
3037     + goto journal_error;
3038     + }
3039     map -= count;
3040     dx_sort_map(map, count);
3041     /* Ensure that neither split block is over half full */
3042     @@ -3318,6 +3328,9 @@ static struct buffer_head *ext4_get_first_dir_block(handle_t *handle,
3043     struct buffer_head *bh;
3044    
3045     if (!ext4_has_inline_data(inode)) {
3046     + struct ext4_dir_entry_2 *de;
3047     + unsigned int offset;
3048     +
3049     /* The first directory block must not be a hole, so
3050     * treat it as DIRENT_HTREE
3051     */
3052     @@ -3326,9 +3339,30 @@ static struct buffer_head *ext4_get_first_dir_block(handle_t *handle,
3053     *retval = PTR_ERR(bh);
3054     return NULL;
3055     }
3056     - *parent_de = ext4_next_entry(
3057     - (struct ext4_dir_entry_2 *)bh->b_data,
3058     - inode->i_sb->s_blocksize);
3059     +
3060     + de = (struct ext4_dir_entry_2 *) bh->b_data;
3061     + if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data,
3062     + bh->b_size, 0) ||
3063     + le32_to_cpu(de->inode) != inode->i_ino ||
3064     + strcmp(".", de->name)) {
3065     + EXT4_ERROR_INODE(inode, "directory missing '.'");
3066     + brelse(bh);
3067     + *retval = -EFSCORRUPTED;
3068     + return NULL;
3069     + }
3070     + offset = ext4_rec_len_from_disk(de->rec_len,
3071     + inode->i_sb->s_blocksize);
3072     + de = ext4_next_entry(de, inode->i_sb->s_blocksize);
3073     + if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data,
3074     + bh->b_size, offset) ||
3075     + le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {
3076     + EXT4_ERROR_INODE(inode, "directory missing '..'");
3077     + brelse(bh);
3078     + *retval = -EFSCORRUPTED;
3079     + return NULL;
3080     + }
3081     + *parent_de = de;
3082     +
3083     return bh;
3084     }
3085    
3086     diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
3087     index 0129d4d07a544..b0b1a71c07b72 100644
3088     --- a/fs/fat/fatent.c
3089     +++ b/fs/fat/fatent.c
3090     @@ -92,7 +92,8 @@ static int fat12_ent_bread(struct super_block *sb, struct fat_entry *fatent,
3091     err_brelse:
3092     brelse(bhs[0]);
3093     err:
3094     - fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)", (llu)blocknr);
3095     + fat_msg_ratelimit(sb, KERN_ERR, "FAT read failed (blocknr %llu)",
3096     + (llu)blocknr);
3097     return -EIO;
3098     }
3099    
3100     @@ -105,8 +106,8 @@ static int fat_ent_bread(struct super_block *sb, struct fat_entry *fatent,
3101     fatent->fat_inode = MSDOS_SB(sb)->fat_inode;
3102     fatent->bhs[0] = sb_bread(sb, blocknr);
3103     if (!fatent->bhs[0]) {
3104     - fat_msg(sb, KERN_ERR, "FAT read failed (blocknr %llu)",
3105     - (llu)blocknr);
3106     + fat_msg_ratelimit(sb, KERN_ERR, "FAT read failed (blocknr %llu)",
3107     + (llu)blocknr);
3108     return -EIO;
3109     }
3110     fatent->nr_bhs = 1;
3111     diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
3112     index e7815bebaeb85..1014659a19af3 100644
3113     --- a/fs/fs-writeback.c
3114     +++ b/fs/fs-writeback.c
3115     @@ -1569,11 +1569,12 @@ static long writeback_sb_inodes(struct super_block *sb,
3116     };
3117     unsigned long start_time = jiffies;
3118     long write_chunk;
3119     - long wrote = 0; /* count both pages and inodes */
3120     + long total_wrote = 0; /* count both pages and inodes */
3121    
3122     while (!list_empty(&wb->b_io)) {
3123     struct inode *inode = wb_inode(wb->b_io.prev);
3124     struct bdi_writeback *tmp_wb;
3125     + long wrote;
3126    
3127     if (inode->i_sb != sb) {
3128     if (work->sb) {
3129     @@ -1649,7 +1650,9 @@ static long writeback_sb_inodes(struct super_block *sb,
3130    
3131     wbc_detach_inode(&wbc);
3132     work->nr_pages -= write_chunk - wbc.nr_to_write;
3133     - wrote += write_chunk - wbc.nr_to_write;
3134     + wrote = write_chunk - wbc.nr_to_write - wbc.pages_skipped;
3135     + wrote = wrote < 0 ? 0 : wrote;
3136     + total_wrote += wrote;
3137    
3138     if (need_resched()) {
3139     /*
3140     @@ -1671,7 +1674,7 @@ static long writeback_sb_inodes(struct super_block *sb,
3141     tmp_wb = inode_to_wb_and_lock_list(inode);
3142     spin_lock(&inode->i_lock);
3143     if (!(inode->i_state & I_DIRTY_ALL))
3144     - wrote++;
3145     + total_wrote++;
3146     requeue_inode(inode, tmp_wb, &wbc);
3147     inode_sync_complete(inode);
3148     spin_unlock(&inode->i_lock);
3149     @@ -1685,14 +1688,14 @@ static long writeback_sb_inodes(struct super_block *sb,
3150     * bail out to wb_writeback() often enough to check
3151     * background threshold and other termination conditions.
3152     */
3153     - if (wrote) {
3154     + if (total_wrote) {
3155     if (time_is_before_jiffies(start_time + HZ / 10UL))
3156     break;
3157     if (work->nr_pages <= 0)
3158     break;
3159     }
3160     }
3161     - return wrote;
3162     + return total_wrote;
3163     }
3164    
3165     static long __writeback_inodes_wb(struct bdi_writeback *wb,
3166     diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
3167     index d3c9e4c82e57c..610e11e76f2d3 100644
3168     --- a/fs/jffs2/fs.c
3169     +++ b/fs/jffs2/fs.c
3170     @@ -597,6 +597,7 @@ out_root:
3171     jffs2_free_raw_node_refs(c);
3172     kvfree(c->blocks);
3173     jffs2_clear_xattr_subsystem(c);
3174     + jffs2_sum_exit(c);
3175     out_inohash:
3176     kfree(c->inocache_list);
3177     out_wbuf:
3178     diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
3179     index 6dac48e29d282..a07fbb60ac3ca 100644
3180     --- a/fs/jfs/jfs_dmap.c
3181     +++ b/fs/jfs/jfs_dmap.c
3182     @@ -398,7 +398,8 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks)
3183     }
3184    
3185     /* write the last buffer. */
3186     - write_metapage(mp);
3187     + if (mp)
3188     + write_metapage(mp);
3189    
3190     IREAD_UNLOCK(ipbmap);
3191    
3192     diff --git a/fs/notify/fdinfo.c b/fs/notify/fdinfo.c
3193     index fd98e5100cabe..317b7e7eb2e7f 100644
3194     --- a/fs/notify/fdinfo.c
3195     +++ b/fs/notify/fdinfo.c
3196     @@ -83,16 +83,9 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
3197     inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
3198     inode = igrab(mark->inode);
3199     if (inode) {
3200     - /*
3201     - * IN_ALL_EVENTS represents all of the mask bits
3202     - * that we expose to userspace. There is at
3203     - * least one bit (FS_EVENT_ON_CHILD) which is
3204     - * used only internally to the kernel.
3205     - */
3206     - u32 mask = mark->mask & IN_ALL_EVENTS;
3207     - seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:%x ",
3208     + seq_printf(m, "inotify wd:%x ino:%lx sdev:%x mask:%x ignored_mask:0 ",
3209     inode_mark->wd, inode->i_ino, inode->i_sb->s_dev,
3210     - mask, mark->ignored_mask);
3211     + inotify_mark_user_mask(mark));
3212     show_mark_fhandle(m, inode);
3213     seq_putc(m, '\n');
3214     iput(inode);
3215     diff --git a/fs/notify/inotify/inotify.h b/fs/notify/inotify/inotify.h
3216     index ed855ef6f0775..b0440287d7dd0 100644
3217     --- a/fs/notify/inotify/inotify.h
3218     +++ b/fs/notify/inotify/inotify.h
3219     @@ -20,6 +20,18 @@ static inline struct inotify_event_info *INOTIFY_E(struct fsnotify_event *fse)
3220     return container_of(fse, struct inotify_event_info, fse);
3221     }
3222    
3223     +/*
3224     + * INOTIFY_USER_FLAGS represents all of the mask bits that we expose to
3225     + * userspace. There is at least one bit (FS_EVENT_ON_CHILD) which is
3226     + * used only internally to the kernel.
3227     + */
3228     +#define INOTIFY_USER_MASK (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK)
3229     +
3230     +static inline __u32 inotify_mark_user_mask(struct fsnotify_mark *fsn_mark)
3231     +{
3232     + return fsn_mark->mask & INOTIFY_USER_MASK;
3233     +}
3234     +
3235     extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
3236     struct fsnotify_group *group);
3237     extern int inotify_handle_event(struct fsnotify_group *group,
3238     diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
3239     index 69d1ea3d292a8..bb60bf1527e47 100644
3240     --- a/fs/notify/inotify/inotify_user.c
3241     +++ b/fs/notify/inotify/inotify_user.c
3242     @@ -97,7 +97,7 @@ static inline __u32 inotify_arg_to_mask(u32 arg)
3243     mask = (FS_IN_IGNORED | FS_EVENT_ON_CHILD | FS_UNMOUNT);
3244    
3245     /* mask off the flags used to open the fd */
3246     - mask |= (arg & (IN_ALL_EVENTS | IN_ONESHOT | IN_EXCL_UNLINK));
3247     + mask |= (arg & INOTIFY_USER_MASK);
3248    
3249     return mask;
3250     }
3251     diff --git a/fs/ocfs2/dlmfs/userdlm.c b/fs/ocfs2/dlmfs/userdlm.c
3252     index f70cda2f090d5..cf5fbd3a616f8 100644
3253     --- a/fs/ocfs2/dlmfs/userdlm.c
3254     +++ b/fs/ocfs2/dlmfs/userdlm.c
3255     @@ -448,6 +448,11 @@ again:
3256     }
3257    
3258     spin_lock(&lockres->l_lock);
3259     + if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
3260     + spin_unlock(&lockres->l_lock);
3261     + status = -EAGAIN;
3262     + goto bail;
3263     + }
3264    
3265     /* We only compare against the currently granted level
3266     * here. If the lock is blocked waiting on a downconvert,
3267     @@ -614,7 +619,7 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
3268     spin_lock(&lockres->l_lock);
3269     if (lockres->l_flags & USER_LOCK_IN_TEARDOWN) {
3270     spin_unlock(&lockres->l_lock);
3271     - return 0;
3272     + goto bail;
3273     }
3274    
3275     lockres->l_flags |= USER_LOCK_IN_TEARDOWN;
3276     @@ -628,12 +633,17 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
3277     }
3278    
3279     if (lockres->l_ro_holders || lockres->l_ex_holders) {
3280     + lockres->l_flags &= ~USER_LOCK_IN_TEARDOWN;
3281     spin_unlock(&lockres->l_lock);
3282     goto bail;
3283     }
3284    
3285     status = 0;
3286     if (!(lockres->l_flags & USER_LOCK_ATTACHED)) {
3287     + /*
3288     + * lock is never requested, leave USER_LOCK_IN_TEARDOWN set
3289     + * to avoid new lock request coming in.
3290     + */
3291     spin_unlock(&lockres->l_lock);
3292     goto bail;
3293     }
3294     @@ -644,6 +654,10 @@ int user_dlm_destroy_lock(struct user_lock_res *lockres)
3295    
3296     status = ocfs2_dlm_unlock(conn, &lockres->l_lksb, DLM_LKF_VALBLK);
3297     if (status) {
3298     + spin_lock(&lockres->l_lock);
3299     + lockres->l_flags &= ~USER_LOCK_IN_TEARDOWN;
3300     + lockres->l_flags &= ~USER_LOCK_BUSY;
3301     + spin_unlock(&lockres->l_lock);
3302     user_log_dlm_error("ocfs2_dlm_unlock", status, lockres);
3303     goto bail;
3304     }
3305     diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
3306     index c3a7d440bc11f..514a02095983c 100644
3307     --- a/include/drm/drm_edid.h
3308     +++ b/include/drm/drm_edid.h
3309     @@ -114,7 +114,7 @@ struct detailed_data_monitor_range {
3310     u8 supported_scalings;
3311     u8 preferred_refresh;
3312     } __attribute__((packed)) cvt;
3313     - } formula;
3314     + } __attribute__((packed)) formula;
3315     } __attribute__((packed));
3316    
3317     struct detailed_data_wpindex {
3318     @@ -147,7 +147,7 @@ struct detailed_non_pixel {
3319     struct detailed_data_wpindex color;
3320     struct std_timing timings[6];
3321     struct cvt_timing cvt[4];
3322     - } data;
3323     + } __attribute__((packed)) data;
3324     } __attribute__((packed));
3325    
3326     #define EDID_DETAIL_EST_TIMINGS 0xf7
3327     @@ -165,7 +165,7 @@ struct detailed_timing {
3328     union {
3329     struct detailed_pixel_timing pixel_data;
3330     struct detailed_non_pixel other_data;
3331     - } data;
3332     + } __attribute__((packed)) data;
3333     } __attribute__((packed));
3334    
3335     #define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0)
3336     diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
3337     index 9b57a9b1b081d..4ead3d1559f54 100644
3338     --- a/include/linux/mtd/cfi.h
3339     +++ b/include/linux/mtd/cfi.h
3340     @@ -293,6 +293,7 @@ struct cfi_private {
3341     map_word sector_erase_cmd;
3342     unsigned long chipshift; /* Because they're of the same type */
3343     const char *im_name; /* inter_module name for cmdset_setup */
3344     + unsigned long quirks;
3345     struct flchip chips[0]; /* per-chip data structure for each chip */
3346     };
3347    
3348     diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
3349     index f746e44d40461..3cc98ded33735 100644
3350     --- a/include/linux/nodemask.h
3351     +++ b/include/linux/nodemask.h
3352     @@ -41,11 +41,11 @@
3353     * void nodes_shift_right(dst, src, n) Shift right
3354     * void nodes_shift_left(dst, src, n) Shift left
3355     *
3356     - * int first_node(mask) Number lowest set bit, or MAX_NUMNODES
3357     - * int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
3358     - * int next_node_in(node, mask) Next node past 'node', or wrap to first,
3359     + * unsigned int first_node(mask) Number lowest set bit, or MAX_NUMNODES
3360     + * unsigend int next_node(node, mask) Next node past 'node', or MAX_NUMNODES
3361     + * unsigned int next_node_in(node, mask) Next node past 'node', or wrap to first,
3362     * or MAX_NUMNODES
3363     - * int first_unset_node(mask) First node not set in mask, or
3364     + * unsigned int first_unset_node(mask) First node not set in mask, or
3365     * MAX_NUMNODES
3366     *
3367     * nodemask_t nodemask_of_node(node) Return nodemask with bit 'node' set
3368     @@ -143,7 +143,7 @@ static inline void __nodes_clear(nodemask_t *dstp, unsigned int nbits)
3369    
3370     #define node_test_and_set(node, nodemask) \
3371     __node_test_and_set((node), &(nodemask))
3372     -static inline int __node_test_and_set(int node, nodemask_t *addr)
3373     +static inline bool __node_test_and_set(int node, nodemask_t *addr)
3374     {
3375     return test_and_set_bit(node, addr->bits);
3376     }
3377     @@ -190,7 +190,7 @@ static inline void __nodes_complement(nodemask_t *dstp,
3378    
3379     #define nodes_equal(src1, src2) \
3380     __nodes_equal(&(src1), &(src2), MAX_NUMNODES)
3381     -static inline int __nodes_equal(const nodemask_t *src1p,
3382     +static inline bool __nodes_equal(const nodemask_t *src1p,
3383     const nodemask_t *src2p, unsigned int nbits)
3384     {
3385     return bitmap_equal(src1p->bits, src2p->bits, nbits);
3386     @@ -198,7 +198,7 @@ static inline int __nodes_equal(const nodemask_t *src1p,
3387    
3388     #define nodes_intersects(src1, src2) \
3389     __nodes_intersects(&(src1), &(src2), MAX_NUMNODES)
3390     -static inline int __nodes_intersects(const nodemask_t *src1p,
3391     +static inline bool __nodes_intersects(const nodemask_t *src1p,
3392     const nodemask_t *src2p, unsigned int nbits)
3393     {
3394     return bitmap_intersects(src1p->bits, src2p->bits, nbits);
3395     @@ -206,20 +206,20 @@ static inline int __nodes_intersects(const nodemask_t *src1p,
3396    
3397     #define nodes_subset(src1, src2) \
3398     __nodes_subset(&(src1), &(src2), MAX_NUMNODES)
3399     -static inline int __nodes_subset(const nodemask_t *src1p,
3400     +static inline bool __nodes_subset(const nodemask_t *src1p,
3401     const nodemask_t *src2p, unsigned int nbits)
3402     {
3403     return bitmap_subset(src1p->bits, src2p->bits, nbits);
3404     }
3405    
3406     #define nodes_empty(src) __nodes_empty(&(src), MAX_NUMNODES)
3407     -static inline int __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
3408     +static inline bool __nodes_empty(const nodemask_t *srcp, unsigned int nbits)
3409     {
3410     return bitmap_empty(srcp->bits, nbits);
3411     }
3412    
3413     #define nodes_full(nodemask) __nodes_full(&(nodemask), MAX_NUMNODES)
3414     -static inline int __nodes_full(const nodemask_t *srcp, unsigned int nbits)
3415     +static inline bool __nodes_full(const nodemask_t *srcp, unsigned int nbits)
3416     {
3417     return bitmap_full(srcp->bits, nbits);
3418     }
3419     @@ -250,15 +250,15 @@ static inline void __nodes_shift_left(nodemask_t *dstp,
3420     > MAX_NUMNODES, then the silly min_ts could be dropped. */
3421    
3422     #define first_node(src) __first_node(&(src))
3423     -static inline int __first_node(const nodemask_t *srcp)
3424     +static inline unsigned int __first_node(const nodemask_t *srcp)
3425     {
3426     - return min_t(int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
3427     + return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES));
3428     }
3429    
3430     #define next_node(n, src) __next_node((n), &(src))
3431     -static inline int __next_node(int n, const nodemask_t *srcp)
3432     +static inline unsigned int __next_node(int n, const nodemask_t *srcp)
3433     {
3434     - return min_t(int,MAX_NUMNODES,find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
3435     + return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1));
3436     }
3437    
3438     /*
3439     @@ -266,7 +266,7 @@ static inline int __next_node(int n, const nodemask_t *srcp)
3440     * the first node in src if needed. Returns MAX_NUMNODES if src is empty.
3441     */
3442     #define next_node_in(n, src) __next_node_in((n), &(src))
3443     -int __next_node_in(int node, const nodemask_t *srcp);
3444     +unsigned int __next_node_in(int node, const nodemask_t *srcp);
3445    
3446     static inline void init_nodemask_of_node(nodemask_t *mask, int node)
3447     {
3448     @@ -286,9 +286,9 @@ static inline void init_nodemask_of_node(nodemask_t *mask, int node)
3449     })
3450    
3451     #define first_unset_node(mask) __first_unset_node(&(mask))
3452     -static inline int __first_unset_node(const nodemask_t *maskp)
3453     +static inline unsigned int __first_unset_node(const nodemask_t *maskp)
3454     {
3455     - return min_t(int,MAX_NUMNODES,
3456     + return min_t(unsigned int, MAX_NUMNODES,
3457     find_first_zero_bit(maskp->bits, MAX_NUMNODES));
3458     }
3459    
3460     @@ -365,14 +365,13 @@ static inline void __nodes_fold(nodemask_t *dstp, const nodemask_t *origp,
3461     }
3462    
3463     #if MAX_NUMNODES > 1
3464     -#define for_each_node_mask(node, mask) \
3465     - for ((node) = first_node(mask); \
3466     - (node) < MAX_NUMNODES; \
3467     - (node) = next_node((node), (mask)))
3468     +#define for_each_node_mask(node, mask) \
3469     + for ((node) = first_node(mask); \
3470     + (node >= 0) && (node) < MAX_NUMNODES; \
3471     + (node) = next_node((node), (mask)))
3472     #else /* MAX_NUMNODES == 1 */
3473     -#define for_each_node_mask(node, mask) \
3474     - if (!nodes_empty(mask)) \
3475     - for ((node) = 0; (node) < 1; (node)++)
3476     +#define for_each_node_mask(node, mask) \
3477     + for ((node) = 0; (node) < 1 && !nodes_empty(mask); (node)++)
3478     #endif /* MAX_NUMNODES */
3479    
3480     /*
3481     @@ -429,11 +428,11 @@ static inline int num_node_state(enum node_states state)
3482    
3483     #define first_online_node first_node(node_states[N_ONLINE])
3484     #define first_memory_node first_node(node_states[N_MEMORY])
3485     -static inline int next_online_node(int nid)
3486     +static inline unsigned int next_online_node(int nid)
3487     {
3488     return next_node(nid, node_states[N_ONLINE]);
3489     }
3490     -static inline int next_memory_node(int nid)
3491     +static inline unsigned int next_memory_node(int nid)
3492     {
3493     return next_node(nid, node_states[N_MEMORY]);
3494     }
3495     diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
3496     index 58ae371556bcd..ac57a0641294a 100644
3497     --- a/include/linux/ptrace.h
3498     +++ b/include/linux/ptrace.h
3499     @@ -38,12 +38,6 @@ extern int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
3500     #define PT_EXITKILL (PTRACE_O_EXITKILL << PT_OPT_FLAG_SHIFT)
3501     #define PT_SUSPEND_SECCOMP (PTRACE_O_SUSPEND_SECCOMP << PT_OPT_FLAG_SHIFT)
3502    
3503     -/* single stepping state bits (used on ARM and PA-RISC) */
3504     -#define PT_SINGLESTEP_BIT 31
3505     -#define PT_SINGLESTEP (1<<PT_SINGLESTEP_BIT)
3506     -#define PT_BLOCKSTEP_BIT 30
3507     -#define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT)
3508     -
3509     extern long arch_ptrace(struct task_struct *child, long request,
3510     unsigned long addr, unsigned long data);
3511     extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len);
3512     diff --git a/include/scsi/libfcoe.h b/include/scsi/libfcoe.h
3513     index a911f993219d7..ac14f3798e84b 100644
3514     --- a/include/scsi/libfcoe.h
3515     +++ b/include/scsi/libfcoe.h
3516     @@ -261,7 +261,8 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
3517     struct fc_frame *);
3518    
3519     /* libfcoe funcs */
3520     -u64 fcoe_wwn_from_mac(unsigned char mac[MAX_ADDR_LEN], unsigned int, unsigned int);
3521     +u64 fcoe_wwn_from_mac(unsigned char mac[ETH_ALEN], unsigned int scheme,
3522     + unsigned int port);
3523     int fcoe_libfc_config(struct fc_lport *, struct fcoe_ctlr *,
3524     const struct libfc_function_template *, int init_fcp);
3525     u32 fcoe_fc_crc(struct fc_frame *fp);
3526     diff --git a/include/sound/jack.h b/include/sound/jack.h
3527     index 1e84bfb553cf7..4742f842b4573 100644
3528     --- a/include/sound/jack.h
3529     +++ b/include/sound/jack.h
3530     @@ -77,6 +77,7 @@ struct snd_jack {
3531     const char *id;
3532     #ifdef CONFIG_SND_JACK_INPUT_DEV
3533     struct input_dev *input_dev;
3534     + struct mutex input_dev_lock;
3535     int registered;
3536     int type;
3537     char name[100];
3538     diff --git a/kernel/ptrace.c b/kernel/ptrace.c
3539     index 2b59212ddcc6e..a91a2abcafa20 100644
3540     --- a/kernel/ptrace.c
3541     +++ b/kernel/ptrace.c
3542     @@ -1120,9 +1120,8 @@ int ptrace_request(struct task_struct *child, long request,
3543     return ptrace_resume(child, request, data);
3544    
3545     case PTRACE_KILL:
3546     - if (child->exit_state) /* already dead */
3547     - return 0;
3548     - return ptrace_resume(child, request, SIGKILL);
3549     + send_sig_info(SIGKILL, SEND_SIG_NOINFO, child);
3550     + return 0;
3551    
3552     #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
3553     case PTRACE_GETREGSET:
3554     diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
3555     index 90e0fd5621da9..de1638df2b095 100644
3556     --- a/kernel/trace/trace.c
3557     +++ b/kernel/trace/trace.c
3558     @@ -4798,12 +4798,18 @@ static void tracing_set_nop(struct trace_array *tr)
3559     tr->current_trace = &nop_trace;
3560     }
3561    
3562     +static bool tracer_options_updated;
3563     +
3564     static void add_tracer_options(struct trace_array *tr, struct tracer *t)
3565     {
3566     /* Only enable if the directory has been created already. */
3567     if (!tr->dir)
3568     return;
3569    
3570     + /* Only create trace option files after update_tracer_options finish */
3571     + if (!tracer_options_updated)
3572     + return;
3573     +
3574     create_trace_option_files(tr, t);
3575     }
3576    
3577     @@ -7082,6 +7088,7 @@ static void __update_tracer_options(struct trace_array *tr)
3578     static void update_tracer_options(struct trace_array *tr)
3579     {
3580     mutex_lock(&trace_types_lock);
3581     + tracer_options_updated = true;
3582     __update_tracer_options(tr);
3583     mutex_unlock(&trace_types_lock);
3584     }
3585     diff --git a/lib/dma-debug.c b/lib/dma-debug.c
3586     index 4435bec55fb59..baafebabe3ac3 100644
3587     --- a/lib/dma-debug.c
3588     +++ b/lib/dma-debug.c
3589     @@ -463,7 +463,7 @@ EXPORT_SYMBOL(debug_dma_dump_mappings);
3590     * At any time debug_dma_assert_idle() can be called to trigger a
3591     * warning if any cachelines in the given page are in the active set.
3592     */
3593     -static RADIX_TREE(dma_active_cacheline, GFP_NOWAIT);
3594     +static RADIX_TREE(dma_active_cacheline, GFP_ATOMIC);
3595     static DEFINE_SPINLOCK(radix_lock);
3596     #define ACTIVE_CACHELINE_MAX_OVERLAP ((1 << RADIX_TREE_MAX_TAGS) - 1)
3597     #define CACHELINE_PER_PAGE_SHIFT (PAGE_SHIFT - L1_CACHE_SHIFT)
3598     diff --git a/lib/nlattr.c b/lib/nlattr.c
3599     index fce1e9afc6d97..ea27e1d069b12 100644
3600     --- a/lib/nlattr.c
3601     +++ b/lib/nlattr.c
3602     @@ -316,7 +316,7 @@ int nla_strcmp(const struct nlattr *nla, const char *str)
3603     int attrlen = nla_len(nla);
3604     int d;
3605    
3606     - if (attrlen > 0 && buf[attrlen - 1] == '\0')
3607     + while (attrlen > 0 && buf[attrlen - 1] == '\0')
3608     attrlen--;
3609    
3610     d = attrlen - len;
3611     diff --git a/lib/nodemask.c b/lib/nodemask.c
3612     index e42a5bf44d330..f6ad9c2775a8b 100644
3613     --- a/lib/nodemask.c
3614     +++ b/lib/nodemask.c
3615     @@ -2,9 +2,9 @@
3616     #include <linux/module.h>
3617     #include <linux/random.h>
3618    
3619     -int __next_node_in(int node, const nodemask_t *srcp)
3620     +unsigned int __next_node_in(int node, const nodemask_t *srcp)
3621     {
3622     - int ret = __next_node(node, srcp);
3623     + unsigned int ret = __next_node(node, srcp);
3624    
3625     if (ret == MAX_NUMNODES)
3626     ret = __first_node(srcp);
3627     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3628     index 8aad9bd08462e..6bed5da45f8f6 100644
3629     --- a/mm/hugetlb.c
3630     +++ b/mm/hugetlb.c
3631     @@ -4593,7 +4593,14 @@ int huge_pmd_unshare(struct mm_struct *mm, unsigned long *addr, pte_t *ptep)
3632     pud_clear(pud);
3633     put_page(virt_to_page(ptep));
3634     mm_dec_nr_pmds(mm);
3635     - *addr = ALIGN(*addr, HPAGE_SIZE * PTRS_PER_PTE) - HPAGE_SIZE;
3636     + /*
3637     + * This update of passed address optimizes loops sequentially
3638     + * processing addresses in increments of huge page size (PMD_SIZE
3639     + * in this case). By clearing the pud, a PUD_SIZE area is unmapped.
3640     + * Update address to the 'last page' in the cleared area so that
3641     + * calling loop can move to first page past this area.
3642     + */
3643     + *addr |= PUD_SIZE - PMD_SIZE;
3644     return 1;
3645     }
3646     #define want_pmd_share() (1)
3647     diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
3648     index b3b4ffaa394f6..9892ce82cbdff 100644
3649     --- a/net/bluetooth/sco.c
3650     +++ b/net/bluetooth/sco.c
3651     @@ -542,19 +542,24 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
3652     addr->sa_family != AF_BLUETOOTH)
3653     return -EINVAL;
3654    
3655     - if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND)
3656     - return -EBADFD;
3657     + lock_sock(sk);
3658     + if (sk->sk_state != BT_OPEN && sk->sk_state != BT_BOUND) {
3659     + err = -EBADFD;
3660     + goto done;
3661     + }
3662    
3663     - if (sk->sk_type != SOCK_SEQPACKET)
3664     - return -EINVAL;
3665     + if (sk->sk_type != SOCK_SEQPACKET) {
3666     + err = -EINVAL;
3667     + goto done;
3668     + }
3669    
3670     hdev = hci_get_route(&sa->sco_bdaddr, &sco_pi(sk)->src, BDADDR_BREDR);
3671     - if (!hdev)
3672     - return -EHOSTUNREACH;
3673     + if (!hdev) {
3674     + err = -EHOSTUNREACH;
3675     + goto done;
3676     + }
3677     hci_dev_lock(hdev);
3678    
3679     - lock_sock(sk);
3680     -
3681     /* Set destination address and psm */
3682     bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
3683    
3684     diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
3685     index 7f48f85042843..b12a329ef1873 100644
3686     --- a/net/ipv4/tcp_input.c
3687     +++ b/net/ipv4/tcp_input.c
3688     @@ -2663,12 +2663,15 @@ static void tcp_mtup_probe_success(struct sock *sk)
3689     {
3690     struct tcp_sock *tp = tcp_sk(sk);
3691     struct inet_connection_sock *icsk = inet_csk(sk);
3692     + u64 val;
3693    
3694     - /* FIXME: breaks with very large cwnd */
3695     tp->prior_ssthresh = tcp_current_ssthresh(sk);
3696     - tp->snd_cwnd = tp->snd_cwnd *
3697     - tcp_mss_to_mtu(sk, tp->mss_cache) /
3698     - icsk->icsk_mtup.probe_size;
3699     +
3700     + val = (u64)tp->snd_cwnd * tcp_mss_to_mtu(sk, tp->mss_cache);
3701     + do_div(val, icsk->icsk_mtup.probe_size);
3702     + WARN_ON_ONCE((u32)val != val);
3703     + tp->snd_cwnd = max_t(u32, 1U, val);
3704     +
3705     tp->snd_cwnd_cnt = 0;
3706     tp->snd_cwnd_stamp = tcp_time_stamp;
3707     tp->snd_ssthresh = tcp_current_ssthresh(sk);
3708     diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
3709     index 95b0f486cb105..e0009cd69da75 100644
3710     --- a/net/ipv4/tcp_output.c
3711     +++ b/net/ipv4/tcp_output.c
3712     @@ -3709,8 +3709,8 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)
3713     tcp_rsk(req)->txhash = net_tx_rndhash();
3714     res = af_ops->send_synack(sk, NULL, &fl, req, NULL, TCP_SYNACK_NORMAL);
3715     if (!res) {
3716     - __TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
3717     - __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
3718     + TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);
3719     + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPSYNRETRANS);
3720     if (unlikely(tcp_passive_fastopen(sk)))
3721     tcp_sk(sk)->total_retrans++;
3722     }
3723     diff --git a/net/ipv4/xfrm4_protocol.c b/net/ipv4/xfrm4_protocol.c
3724     index dccefa9d84cfd..5a4b19834fe21 100644
3725     --- a/net/ipv4/xfrm4_protocol.c
3726     +++ b/net/ipv4/xfrm4_protocol.c
3727     @@ -298,4 +298,3 @@ void __init xfrm4_protocol_init(void)
3728     {
3729     xfrm_input_register_afinfo(&xfrm4_input_afinfo);
3730     }
3731     -EXPORT_SYMBOL(xfrm4_protocol_init);
3732     diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
3733     index 30ca73c781253..02f62253a835d 100644
3734     --- a/net/ipv6/addrconf.c
3735     +++ b/net/ipv6/addrconf.c
3736     @@ -3993,7 +3993,8 @@ static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id)
3737     send_rs = send_mld &&
3738     ipv6_accept_ra(ifp->idev) &&
3739     ifp->idev->cnf.rtr_solicits != 0 &&
3740     - (dev->flags&IFF_LOOPBACK) == 0;
3741     + (dev->flags & IFF_LOOPBACK) == 0 &&
3742     + (dev->type != ARPHRD_TUNNEL);
3743     read_unlock_bh(&ifp->idev->lock);
3744    
3745     /* While dad is in progress mld report's source address is in6_addrany.
3746     diff --git a/net/key/af_key.c b/net/key/af_key.c
3747     index d5dc614af2f91..0737fc7b7ebdb 100644
3748     --- a/net/key/af_key.c
3749     +++ b/net/key/af_key.c
3750     @@ -2861,10 +2861,12 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb
3751     void *ext_hdrs[SADB_EXT_MAX];
3752     int err;
3753    
3754     - err = pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
3755     - BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
3756     - if (err)
3757     - return err;
3758     + /* Non-zero return value of pfkey_broadcast() does not always signal
3759     + * an error and even on an actual error we may still want to process
3760     + * the message so rather ignore the return value.
3761     + */
3762     + pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL,
3763     + BROADCAST_PROMISC_ONLY, NULL, sock_net(sk));
3764    
3765     memset(ext_hdrs, 0, sizeof(ext_hdrs));
3766     err = parse_exthdrs(skb, hdr, ext_hdrs);
3767     diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c
3768     index a0d901d8992ea..324b685b343e1 100644
3769     --- a/net/mac80211/chan.c
3770     +++ b/net/mac80211/chan.c
3771     @@ -1640,12 +1640,9 @@ int ieee80211_vif_use_reserved_context(struct ieee80211_sub_if_data *sdata)
3772    
3773     if (new_ctx->replace_state == IEEE80211_CHANCTX_REPLACE_NONE) {
3774     if (old_ctx)
3775     - err = ieee80211_vif_use_reserved_reassign(sdata);
3776     - else
3777     - err = ieee80211_vif_use_reserved_assign(sdata);
3778     + return ieee80211_vif_use_reserved_reassign(sdata);
3779    
3780     - if (err)
3781     - return err;
3782     + return ieee80211_vif_use_reserved_assign(sdata);
3783     }
3784    
3785     /*
3786     diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
3787     index f5532a3ce72e1..0eb5dfb1031f5 100644
3788     --- a/net/mac80211/ieee80211_i.h
3789     +++ b/net/mac80211/ieee80211_i.h
3790     @@ -1066,6 +1066,9 @@ struct tpt_led_trigger {
3791     * a scan complete for an aborted scan.
3792     * @SCAN_HW_CANCELLED: Set for our scan work function when the scan is being
3793     * cancelled.
3794     + * @SCAN_BEACON_WAIT: Set whenever we're passive scanning because of radar/no-IR
3795     + * and could send a probe request after receiving a beacon.
3796     + * @SCAN_BEACON_DONE: Beacon received, we can now send a probe request
3797     */
3798     enum {
3799     SCAN_SW_SCANNING,
3800     @@ -1074,6 +1077,8 @@ enum {
3801     SCAN_COMPLETED,
3802     SCAN_ABORTED,
3803     SCAN_HW_CANCELLED,
3804     + SCAN_BEACON_WAIT,
3805     + SCAN_BEACON_DONE,
3806     };
3807    
3808     /**
3809     diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
3810     index 23d8ac8292796..701adcb9262eb 100644
3811     --- a/net/mac80211/scan.c
3812     +++ b/net/mac80211/scan.c
3813     @@ -205,6 +205,16 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
3814     if (likely(!sdata1 && !sdata2))
3815     return;
3816    
3817     + if (test_and_clear_bit(SCAN_BEACON_WAIT, &local->scanning)) {
3818     + /*
3819     + * we were passive scanning because of radar/no-IR, but
3820     + * the beacon/proberesp rx gives us an opportunity to upgrade
3821     + * to active scan
3822     + */
3823     + set_bit(SCAN_BEACON_DONE, &local->scanning);
3824     + ieee80211_queue_delayed_work(&local->hw, &local->scan_work, 0);
3825     + }
3826     +
3827     if (ieee80211_is_probe_resp(mgmt->frame_control)) {
3828     struct cfg80211_scan_request *scan_req;
3829     struct cfg80211_sched_scan_request *sched_scan_req;
3830     @@ -646,6 +656,8 @@ static int __ieee80211_start_scan(struct ieee80211_sub_if_data *sdata,
3831     IEEE80211_CHAN_RADAR)) ||
3832     !req->n_ssids) {
3833     next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3834     + if (req->n_ssids)
3835     + set_bit(SCAN_BEACON_WAIT, &local->scanning);
3836     } else {
3837     ieee80211_scan_state_send_probe(local, &next_delay);
3838     next_delay = IEEE80211_CHANNEL_TIME;
3839     @@ -826,6 +838,8 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
3840     !scan_req->n_ssids) {
3841     *next_delay = IEEE80211_PASSIVE_CHANNEL_TIME;
3842     local->next_scan_state = SCAN_DECISION;
3843     + if (scan_req->n_ssids)
3844     + set_bit(SCAN_BEACON_WAIT, &local->scanning);
3845     return;
3846     }
3847    
3848     @@ -918,6 +932,8 @@ void ieee80211_scan_work(struct work_struct *work)
3849     goto out;
3850     }
3851    
3852     + clear_bit(SCAN_BEACON_WAIT, &local->scanning);
3853     +
3854     /*
3855     * as long as no delay is required advance immediately
3856     * without scheduling a new work
3857     @@ -928,6 +944,10 @@ void ieee80211_scan_work(struct work_struct *work)
3858     goto out_complete;
3859     }
3860    
3861     + if (test_and_clear_bit(SCAN_BEACON_DONE, &local->scanning) &&
3862     + local->next_scan_state == SCAN_DECISION)
3863     + local->next_scan_state = SCAN_SEND_PROBE;
3864     +
3865     switch (local->next_scan_state) {
3866     case SCAN_DECISION:
3867     /* if no more bands/channels left, complete scan */
3868     diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
3869     index ec460aedfc617..0aad9b8466aa8 100644
3870     --- a/net/netfilter/nf_tables_api.c
3871     +++ b/net/netfilter/nf_tables_api.c
3872     @@ -1756,23 +1756,27 @@ struct nft_expr *nft_expr_init(const struct nft_ctx *ctx,
3873    
3874     err = nf_tables_expr_parse(ctx, nla, &info);
3875     if (err < 0)
3876     - goto err1;
3877     + goto err_expr_parse;
3878     +
3879     + err = -EOPNOTSUPP;
3880     + if (!(info.ops->type->flags & NFT_EXPR_STATEFUL))
3881     + goto err_expr_stateful;
3882    
3883     err = -ENOMEM;
3884     expr = kzalloc(info.ops->size, GFP_KERNEL);
3885     if (expr == NULL)
3886     - goto err2;
3887     + goto err_expr_stateful;
3888    
3889     err = nf_tables_newexpr(ctx, &info, expr);
3890     if (err < 0)
3891     - goto err3;
3892     + goto err_expr_new;
3893    
3894     return expr;
3895     -err3:
3896     +err_expr_new:
3897     kfree(expr);
3898     -err2:
3899     +err_expr_stateful:
3900     module_put(info.ops->type->owner);
3901     -err1:
3902     +err_expr_parse:
3903     return ERR_PTR(err);
3904     }
3905    
3906     diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
3907     index 81adbfaffe38f..5c25ffec27559 100644
3908     --- a/net/netfilter/nft_dynset.c
3909     +++ b/net/netfilter/nft_dynset.c
3910     @@ -196,9 +196,6 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
3911     if (IS_ERR(priv->expr))
3912     return PTR_ERR(priv->expr);
3913    
3914     - err = -EOPNOTSUPP;
3915     - if (!(priv->expr->ops->type->flags & NFT_EXPR_STATEFUL))
3916     - goto err1;
3917     } else if (set->flags & NFT_SET_EVAL)
3918     return -EINVAL;
3919    
3920     diff --git a/net/nfc/core.c b/net/nfc/core.c
3921     index 8c38a21fb0c69..120259c2b6a7b 100644
3922     --- a/net/nfc/core.c
3923     +++ b/net/nfc/core.c
3924     @@ -1174,6 +1174,7 @@ void nfc_unregister_device(struct nfc_dev *dev)
3925     if (dev->rfkill) {
3926     rfkill_unregister(dev->rfkill);
3927     rfkill_destroy(dev->rfkill);
3928     + dev->rfkill = NULL;
3929     }
3930     dev->shutting_down = true;
3931     device_unlock(&dev->dev);
3932     diff --git a/net/rxrpc/call_event.c b/net/rxrpc/call_event.c
3933     index 97a17ada4431d..4aae0904ae1bb 100644
3934     --- a/net/rxrpc/call_event.c
3935     +++ b/net/rxrpc/call_event.c
3936     @@ -403,7 +403,8 @@ recheck_state:
3937     goto recheck_state;
3938     }
3939    
3940     - if (test_and_clear_bit(RXRPC_CALL_EV_RESEND, &call->events)) {
3941     + if (test_and_clear_bit(RXRPC_CALL_EV_RESEND, &call->events) &&
3942     + call->state != RXRPC_CALL_CLIENT_RECV_REPLY) {
3943     rxrpc_resend(call, now);
3944     goto recheck_state;
3945     }
3946     diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
3947     index 2ec1c29eeba4b..b8e87804296cc 100644
3948     --- a/net/rxrpc/sendmsg.c
3949     +++ b/net/rxrpc/sendmsg.c
3950     @@ -336,6 +336,12 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
3951    
3952     success:
3953     ret = copied;
3954     + if (READ_ONCE(call->state) == RXRPC_CALL_COMPLETE) {
3955     + read_lock_bh(&call->state_lock);
3956     + if (call->error < 0)
3957     + ret = call->error;
3958     + read_unlock_bh(&call->state_lock);
3959     + }
3960     out:
3961     call->tx_pending = skb;
3962     _leave(" = %d", ret);
3963     diff --git a/net/rxrpc/sysctl.c b/net/rxrpc/sysctl.c
3964     index 34c706d2f79c6..f9afc21b7e2cf 100644
3965     --- a/net/rxrpc/sysctl.c
3966     +++ b/net/rxrpc/sysctl.c
3967     @@ -18,7 +18,7 @@ static struct ctl_table_header *rxrpc_sysctl_reg_table;
3968     static const unsigned int zero = 0;
3969     static const unsigned int one = 1;
3970     static const unsigned int four = 4;
3971     -static const unsigned int thirtytwo = 32;
3972     +static const unsigned int max_backlog = RXRPC_BACKLOG_MAX - 1;
3973     static const unsigned int n_65535 = 65535;
3974     static const unsigned int n_max_acks = RXRPC_RXTX_BUFF_SIZE - 1;
3975    
3976     @@ -114,7 +114,7 @@ static struct ctl_table rxrpc_sysctl_table[] = {
3977     .mode = 0644,
3978     .proc_handler = proc_dointvec_minmax,
3979     .extra1 = (void *)&four,
3980     - .extra2 = (void *)&thirtytwo,
3981     + .extra2 = (void *)&max_backlog,
3982     },
3983     {
3984     .procname = "rx_window_size",
3985     diff --git a/net/sctp/input.c b/net/sctp/input.c
3986     index 9c1670b4a687d..ed3a8a66a00b8 100644
3987     --- a/net/sctp/input.c
3988     +++ b/net/sctp/input.c
3989     @@ -103,6 +103,7 @@ int sctp_rcv(struct sk_buff *skb)
3990     struct sctp_chunk *chunk;
3991     union sctp_addr src;
3992     union sctp_addr dest;
3993     + int bound_dev_if;
3994     int family;
3995     struct sctp_af *af;
3996     struct net *net = dev_net(skb->dev);
3997     @@ -180,7 +181,8 @@ int sctp_rcv(struct sk_buff *skb)
3998     * If a frame arrives on an interface and the receiving socket is
3999     * bound to another interface, via SO_BINDTODEVICE, treat it as OOTB
4000     */
4001     - if (sk->sk_bound_dev_if && (sk->sk_bound_dev_if != af->skb_iif(skb))) {
4002     + bound_dev_if = READ_ONCE(sk->sk_bound_dev_if);
4003     + if (bound_dev_if && (bound_dev_if != af->skb_iif(skb))) {
4004     if (transport) {
4005     sctp_transport_put(transport);
4006     asoc = NULL;
4007     diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
4008     index dd547edee59f2..06b4b76edd9dc 100644
4009     --- a/net/sunrpc/xdr.c
4010     +++ b/net/sunrpc/xdr.c
4011     @@ -544,7 +544,11 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
4012     */
4013     xdr->p = (void *)p + frag2bytes;
4014     space_left = xdr->buf->buflen - xdr->buf->len;
4015     - xdr->end = (void *)p + min_t(int, space_left, PAGE_SIZE);
4016     + if (space_left - nbytes >= PAGE_SIZE)
4017     + xdr->end = (void *)p + PAGE_SIZE;
4018     + else
4019     + xdr->end = (void *)p + space_left - frag1bytes;
4020     +
4021     xdr->buf->page_len += frag2bytes;
4022     xdr->buf->len += nbytes;
4023     return p;
4024     diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
4025     index 62b0552b7b718..c5f3267aa08a0 100644
4026     --- a/scripts/mod/modpost.c
4027     +++ b/scripts/mod/modpost.c
4028     @@ -1212,7 +1212,8 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
4029    
4030     static inline int is_arm_mapping_symbol(const char *str)
4031     {
4032     - return str[0] == '$' && strchr("axtd", str[1])
4033     + return str[0] == '$' &&
4034     + (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x')
4035     && (str[2] == '\0' || str[2] == '.');
4036     }
4037    
4038     @@ -1932,7 +1933,7 @@ static char *remove_dot(char *s)
4039    
4040     if (n && s[n]) {
4041     size_t m = strspn(s + n + 1, "0123456789");
4042     - if (m && (s[n + m] == '.' || s[n + m] == 0))
4043     + if (m && (s[n + m + 1] == '.' || s[n + m + 1] == 0))
4044     s[n] = 0;
4045     }
4046     return s;
4047     diff --git a/sound/core/jack.c b/sound/core/jack.c
4048     index 36cfe1c54109d..d2f9a92453f2f 100644
4049     --- a/sound/core/jack.c
4050     +++ b/sound/core/jack.c
4051     @@ -48,8 +48,11 @@ static int snd_jack_dev_disconnect(struct snd_device *device)
4052     #ifdef CONFIG_SND_JACK_INPUT_DEV
4053     struct snd_jack *jack = device->device_data;
4054    
4055     - if (!jack->input_dev)
4056     + mutex_lock(&jack->input_dev_lock);
4057     + if (!jack->input_dev) {
4058     + mutex_unlock(&jack->input_dev_lock);
4059     return 0;
4060     + }
4061    
4062     /* If the input device is registered with the input subsystem
4063     * then we need to use a different deallocator. */
4064     @@ -58,6 +61,7 @@ static int snd_jack_dev_disconnect(struct snd_device *device)
4065     else
4066     input_free_device(jack->input_dev);
4067     jack->input_dev = NULL;
4068     + mutex_unlock(&jack->input_dev_lock);
4069     #endif /* CONFIG_SND_JACK_INPUT_DEV */
4070     return 0;
4071     }
4072     @@ -96,8 +100,11 @@ static int snd_jack_dev_register(struct snd_device *device)
4073     snprintf(jack->name, sizeof(jack->name), "%s %s",
4074     card->shortname, jack->id);
4075    
4076     - if (!jack->input_dev)
4077     + mutex_lock(&jack->input_dev_lock);
4078     + if (!jack->input_dev) {
4079     + mutex_unlock(&jack->input_dev_lock);
4080     return 0;
4081     + }
4082    
4083     jack->input_dev->name = jack->name;
4084    
4085     @@ -122,6 +129,7 @@ static int snd_jack_dev_register(struct snd_device *device)
4086     if (err == 0)
4087     jack->registered = 1;
4088    
4089     + mutex_unlock(&jack->input_dev_lock);
4090     return err;
4091     }
4092     #endif /* CONFIG_SND_JACK_INPUT_DEV */
4093     @@ -242,9 +250,11 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
4094     return -ENOMEM;
4095     }
4096    
4097     - /* don't creat input device for phantom jack */
4098     - if (!phantom_jack) {
4099     #ifdef CONFIG_SND_JACK_INPUT_DEV
4100     + mutex_init(&jack->input_dev_lock);
4101     +
4102     + /* don't create input device for phantom jack */
4103     + if (!phantom_jack) {
4104     int i;
4105    
4106     jack->input_dev = input_allocate_device();
4107     @@ -262,8 +272,8 @@ int snd_jack_new(struct snd_card *card, const char *id, int type,
4108     input_set_capability(jack->input_dev, EV_SW,
4109     jack_switch_types[i]);
4110    
4111     -#endif /* CONFIG_SND_JACK_INPUT_DEV */
4112     }
4113     +#endif /* CONFIG_SND_JACK_INPUT_DEV */
4114    
4115     err = snd_device_new(card, SNDRV_DEV_JACK, jack, &ops);
4116     if (err < 0)
4117     @@ -303,10 +313,14 @@ EXPORT_SYMBOL(snd_jack_new);
4118     void snd_jack_set_parent(struct snd_jack *jack, struct device *parent)
4119     {
4120     WARN_ON(jack->registered);
4121     - if (!jack->input_dev)
4122     + mutex_lock(&jack->input_dev_lock);
4123     + if (!jack->input_dev) {
4124     + mutex_unlock(&jack->input_dev_lock);
4125     return;
4126     + }
4127    
4128     jack->input_dev->dev.parent = parent;
4129     + mutex_unlock(&jack->input_dev_lock);
4130     }
4131     EXPORT_SYMBOL(snd_jack_set_parent);
4132    
4133     @@ -354,6 +368,8 @@ EXPORT_SYMBOL(snd_jack_set_key);
4134    
4135     /**
4136     * snd_jack_report - Report the current status of a jack
4137     + * Note: This function uses mutexes and should be called from a
4138     + * context which can sleep (such as a workqueue).
4139     *
4140     * @jack: The jack to report status for
4141     * @status: The current status of the jack
4142     @@ -373,8 +389,11 @@ void snd_jack_report(struct snd_jack *jack, int status)
4143     status & jack_kctl->mask_bits);
4144    
4145     #ifdef CONFIG_SND_JACK_INPUT_DEV
4146     - if (!jack->input_dev)
4147     + mutex_lock(&jack->input_dev_lock);
4148     + if (!jack->input_dev) {
4149     + mutex_unlock(&jack->input_dev_lock);
4150     return;
4151     + }
4152    
4153     for (i = 0; i < ARRAY_SIZE(jack->key); i++) {
4154     int testbit = SND_JACK_BTN_0 >> i;
4155     @@ -393,6 +412,7 @@ void snd_jack_report(struct snd_jack *jack, int status)
4156     }
4157    
4158     input_sync(jack->input_dev);
4159     + mutex_unlock(&jack->input_dev_lock);
4160     #endif /* CONFIG_SND_JACK_INPUT_DEV */
4161     }
4162     EXPORT_SYMBOL(snd_jack_report);
4163     diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
4164     index f7797e546e3de..5a3dd06ff105d 100644
4165     --- a/sound/pci/hda/patch_conexant.c
4166     +++ b/sound/pci/hda/patch_conexant.c
4167     @@ -942,6 +942,13 @@ static int patch_conexant_auto(struct hda_codec *codec)
4168     snd_hda_pick_fixup(codec, cxt5051_fixup_models,
4169     cxt5051_fixups, cxt_fixups);
4170     break;
4171     + case 0x14f15098:
4172     + codec->pin_amp_workaround = 1;
4173     + spec->gen.mixer_nid = 0x22;
4174     + spec->gen.add_stereo_mix_input = HDA_HINT_STEREO_MIX_AUTO;
4175     + snd_hda_pick_fixup(codec, cxt5066_fixup_models,
4176     + cxt5066_fixups, cxt_fixups);
4177     + break;
4178     case 0x14f150f2:
4179     codec->power_save_node = 1;
4180     /* Fall through */
4181     diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c
4182     index e024800213f52..a86ed616ec417 100644
4183     --- a/sound/soc/codecs/rt5514.c
4184     +++ b/sound/soc/codecs/rt5514.c
4185     @@ -345,7 +345,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol,
4186     }
4187     }
4188    
4189     - return 0;
4190     + return 1;
4191     }
4192    
4193     static const struct snd_kcontrol_new rt5514_snd_controls[] = {
4194     diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
4195     index 1ac96ef9ee207..703b26ec4e157 100644
4196     --- a/sound/soc/codecs/rt5645.c
4197     +++ b/sound/soc/codecs/rt5645.c
4198     @@ -3878,6 +3878,12 @@ static int rt5645_i2c_remove(struct i2c_client *i2c)
4199     if (i2c->irq)
4200     free_irq(i2c->irq, rt5645);
4201    
4202     + /*
4203     + * Since the rt5645_btn_check_callback() can queue jack_detect_work,
4204     + * the timer need to be delted first
4205     + */
4206     + del_timer_sync(&rt5645->btn_check_timer);
4207     +
4208     cancel_delayed_work_sync(&rt5645->jack_detect_work);
4209     cancel_delayed_work_sync(&rt5645->rcclock_work);
4210    
4211     diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
4212     index 23cde3a0dc112..73cda3c2a8614 100644
4213     --- a/sound/soc/codecs/wm2000.c
4214     +++ b/sound/soc/codecs/wm2000.c
4215     @@ -545,7 +545,7 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000,
4216     {
4217     struct i2c_client *i2c = wm2000->i2c;
4218     int i, j;
4219     - int ret;
4220     + int ret = 0;
4221    
4222     if (wm2000->anc_mode == mode)
4223     return 0;
4224     @@ -575,13 +575,13 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000,
4225     ret = anc_transitions[i].step[j](i2c,
4226     anc_transitions[i].analogue);
4227     if (ret != 0)
4228     - return ret;
4229     + break;
4230     }
4231    
4232     if (anc_transitions[i].dest == ANC_OFF)
4233     clk_disable_unprepare(wm2000->mclk);
4234    
4235     - return 0;
4236     + return ret;
4237     }
4238    
4239     static int wm2000_anc_set_mode(struct wm2000_priv *wm2000)
4240     diff --git a/sound/soc/mediatek/mt8173/mt8173-max98090.c b/sound/soc/mediatek/mt8173/mt8173-max98090.c
4241     index cab30cb48366d..85bf9eafda499 100644
4242     --- a/sound/soc/mediatek/mt8173/mt8173-max98090.c
4243     +++ b/sound/soc/mediatek/mt8173/mt8173-max98090.c
4244     @@ -170,7 +170,8 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)
4245     if (!codec_node) {
4246     dev_err(&pdev->dev,
4247     "Property 'audio-codec' missing or invalid\n");
4248     - return -EINVAL;
4249     + ret = -EINVAL;
4250     + goto put_platform_node;
4251     }
4252     for (i = 0; i < card->num_links; i++) {
4253     if (mt8173_max98090_dais[i].codec_name)
4254     @@ -185,6 +186,8 @@ static int mt8173_max98090_dev_probe(struct platform_device *pdev)
4255     __func__, ret);
4256    
4257     of_node_put(codec_node);
4258     +
4259     +put_platform_node:
4260     of_node_put(platform_node);
4261     return ret;
4262     }
4263     diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
4264     index 5977a2011d9e6..76e1059e7f152 100644
4265     --- a/sound/soc/mxs/mxs-saif.c
4266     +++ b/sound/soc/mxs/mxs-saif.c
4267     @@ -748,6 +748,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
4268     saif->master_id = saif->id;
4269     } else {
4270     ret = of_alias_get_id(master, "saif");
4271     + of_node_put(master);
4272     if (ret < 0)
4273     return ret;
4274     else
4275     diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
4276     index 878a4fc97f042..40bf50cd87bc6 100644
4277     --- a/sound/soc/soc-dapm.c
4278     +++ b/sound/soc/soc-dapm.c
4279     @@ -3165,7 +3165,6 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol,
4280     update.val = val;
4281     card->update = &update;
4282     }
4283     - change |= reg_change;
4284    
4285     ret = soc_dapm_mixer_update_power(card, kcontrol, connect);
4286    
4287     @@ -3270,7 +3269,6 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
4288     update.val = val;
4289     card->update = &update;
4290     }
4291     - change |= reg_change;
4292    
4293     ret = soc_dapm_mux_update_power(card, kcontrol, item[0], e);
4294