Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0382-4.9.283-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3684 - (show annotations) (download)
Mon Oct 24 14:08:00 2022 UTC (18 months, 1 week ago) by niro
File size: 155293 byte(s)
-linux-4.9.283
1 diff --git a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
2 index 174f68c26c1b2..34981b98d807c 100644
3 --- a/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
4 +++ b/Documentation/devicetree/bindings/mtd/gpmc-nand.txt
5 @@ -123,7 +123,7 @@ on various other factors also like;
6 so the device should have enough free bytes available its OOB/Spare
7 area to accommodate ECC for entire page. In general following expression
8 helps in determining if given device can accommodate ECC syndrome:
9 - "2 + (PAGESIZE / 512) * ECC_BYTES" >= OOBSIZE"
10 + "2 + (PAGESIZE / 512) * ECC_BYTES" <= OOBSIZE"
11 where
12 OOBSIZE number of bytes in OOB/spare area
13 PAGESIZE number of bytes in main-area of device page
14 diff --git a/Makefile b/Makefile
15 index ca08ef26f416b..ef029a28bb53c 100644
16 --- a/Makefile
17 +++ b/Makefile
18 @@ -1,6 +1,6 @@
19 VERSION = 4
20 PATCHLEVEL = 9
21 -SUBLEVEL = 282
22 +SUBLEVEL = 283
23 EXTRAVERSION =
24 NAME = Roaring Lionus
25
26 diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c
27 index fefe357c3d31a..076b5e8c8562f 100644
28 --- a/arch/arc/mm/cache.c
29 +++ b/arch/arc/mm/cache.c
30 @@ -923,7 +923,7 @@ void clear_user_page(void *to, unsigned long u_vaddr, struct page *page)
31 clear_page(to);
32 clear_bit(PG_dc_clean, &page->flags);
33 }
34 -
35 +EXPORT_SYMBOL(clear_user_page);
36
37 /**********************************************************************
38 * Explicit Cache flush request from user space via syscall
39 diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
40 index 552c7d7f84ce1..2f3ba4d9683c3 100644
41 --- a/arch/arm/boot/compressed/Makefile
42 +++ b/arch/arm/boot/compressed/Makefile
43 @@ -86,6 +86,8 @@ $(addprefix $(obj)/,$(libfdt_objs) atags_to_fdt.o): \
44 $(addprefix $(obj)/,$(libfdt_hdrs))
45
46 ifeq ($(CONFIG_ARM_ATAG_DTB_COMPAT),y)
47 +CFLAGS_REMOVE_atags_to_fdt.o += -Wframe-larger-than=${CONFIG_FRAME_WARN}
48 +CFLAGS_atags_to_fdt.o += -Wframe-larger-than=1280
49 OBJS += $(libfdt_objs) atags_to_fdt.o
50 endif
51
52 diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi
53 index 27d2bbbf1eae2..a613e3b85b456 100644
54 --- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
55 +++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
56 @@ -184,8 +184,9 @@
57 nvidia,pins = "ata", "atb", "atc", "atd", "ate",
58 "cdev1", "cdev2", "dap1", "dtb", "gma",
59 "gmb", "gmc", "gmd", "gme", "gpu7",
60 - "gpv", "i2cp", "pta", "rm", "slxa",
61 - "slxk", "spia", "spib", "uac";
62 + "gpv", "i2cp", "irrx", "irtx", "pta",
63 + "rm", "slxa", "slxk", "spia", "spib",
64 + "uac";
65 nvidia,pull = <TEGRA_PIN_PULL_NONE>;
66 nvidia,tristate = <TEGRA_PIN_DISABLE>;
67 };
68 @@ -210,7 +211,7 @@
69 conf_ddc {
70 nvidia,pins = "ddc", "dta", "dtd", "kbca",
71 "kbcb", "kbcc", "kbcd", "kbce", "kbcf",
72 - "sdc";
73 + "sdc", "uad", "uca";
74 nvidia,pull = <TEGRA_PIN_PULL_UP>;
75 nvidia,tristate = <TEGRA_PIN_DISABLE>;
76 };
77 @@ -220,10 +221,9 @@
78 "lvp0", "owc", "sdb";
79 nvidia,tristate = <TEGRA_PIN_ENABLE>;
80 };
81 - conf_irrx {
82 - nvidia,pins = "irrx", "irtx", "sdd", "spic",
83 - "spie", "spih", "uaa", "uab", "uad",
84 - "uca", "ucb";
85 + conf_sdd {
86 + nvidia,pins = "sdd", "spic", "spie", "spih",
87 + "uaa", "uab", "ucb";
88 nvidia,pull = <TEGRA_PIN_PULL_UP>;
89 nvidia,tristate = <TEGRA_PIN_ENABLE>;
90 };
91 diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile
92 index adb9add28b6f3..9bddd762880cf 100644
93 --- a/arch/arm/kernel/Makefile
94 +++ b/arch/arm/kernel/Makefile
95 @@ -16,10 +16,14 @@ CFLAGS_REMOVE_return_address.o = -pg
96 # Object file lists.
97
98 obj-y := elf.o entry-common.o irq.o opcodes.o \
99 - process.o ptrace.o reboot.o return_address.o \
100 + process.o ptrace.o reboot.o \
101 setup.o signal.o sigreturn_codes.o \
102 stacktrace.o sys_arm.o time.o traps.o
103
104 +ifneq ($(CONFIG_ARM_UNWIND),y)
105 +obj-$(CONFIG_FRAME_POINTER) += return_address.o
106 +endif
107 +
108 obj-$(CONFIG_ATAGS) += atags_parse.o
109 obj-$(CONFIG_ATAGS_PROC) += atags_proc.o
110 obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) += atags_compat.o
111 diff --git a/arch/arm/kernel/return_address.c b/arch/arm/kernel/return_address.c
112 index 36ed35073289b..f945742dea449 100644
113 --- a/arch/arm/kernel/return_address.c
114 +++ b/arch/arm/kernel/return_address.c
115 @@ -10,8 +10,6 @@
116 */
117 #include <linux/export.h>
118 #include <linux/ftrace.h>
119 -
120 -#if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND)
121 #include <linux/sched.h>
122
123 #include <asm/stacktrace.h>
124 @@ -56,6 +54,4 @@ void *return_address(unsigned int level)
125 return NULL;
126 }
127
128 -#endif /* if defined(CONFIG_FRAME_POINTER) && !defined(CONFIG_ARM_UNWIND) */
129 -
130 EXPORT_SYMBOL_GPL(return_address);
131 diff --git a/arch/arm64/boot/dts/exynos/exynos7.dtsi b/arch/arm64/boot/dts/exynos/exynos7.dtsi
132 index 4c7c40ce50662..1fe4d1dd50ee7 100644
133 --- a/arch/arm64/boot/dts/exynos/exynos7.dtsi
134 +++ b/arch/arm64/boot/dts/exynos/exynos7.dtsi
135 @@ -94,7 +94,7 @@
136 #address-cells = <0>;
137 interrupt-controller;
138 reg = <0x11001000 0x1000>,
139 - <0x11002000 0x1000>,
140 + <0x11002000 0x2000>,
141 <0x11004000 0x2000>,
142 <0x11006000 0x2000>;
143 };
144 diff --git a/arch/m68k/emu/nfeth.c b/arch/m68k/emu/nfeth.c
145 index a0985fd088d1c..7d695fc7a2d02 100644
146 --- a/arch/m68k/emu/nfeth.c
147 +++ b/arch/m68k/emu/nfeth.c
148 @@ -260,8 +260,8 @@ static void __exit nfeth_cleanup(void)
149
150 for (i = 0; i < MAX_UNIT; i++) {
151 if (nfeth_dev[i]) {
152 - unregister_netdev(nfeth_dev[0]);
153 - free_netdev(nfeth_dev[0]);
154 + unregister_netdev(nfeth_dev[i]);
155 + free_netdev(nfeth_dev[i]);
156 }
157 }
158 free_irq(nfEtherIRQ, nfeth_interrupt);
159 diff --git a/arch/mips/mti-malta/malta-dtshim.c b/arch/mips/mti-malta/malta-dtshim.c
160 index c398582c316fc..4fc73ee2ca9da 100644
161 --- a/arch/mips/mti-malta/malta-dtshim.c
162 +++ b/arch/mips/mti-malta/malta-dtshim.c
163 @@ -26,7 +26,7 @@
164 #define ROCIT_CONFIG_GEN1_MEMMAP_SHIFT 8
165 #define ROCIT_CONFIG_GEN1_MEMMAP_MASK (0xf << 8)
166
167 -static unsigned char fdt_buf[16 << 10] __initdata;
168 +static unsigned char fdt_buf[16 << 10] __initdata __aligned(8);
169
170 /* determined physical memory size, not overridden by command line args */
171 extern unsigned long physical_memsize;
172 diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
173 index 3fbe420f49c43..92cdc1e56b602 100644
174 --- a/arch/openrisc/kernel/entry.S
175 +++ b/arch/openrisc/kernel/entry.S
176 @@ -491,6 +491,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
177 l.bnf 1f // ext irq enabled, all ok.
178 l.nop
179
180 +#ifdef CONFIG_PRINTK
181 l.addi r1,r1,-0x8
182 l.movhi r3,hi(42f)
183 l.ori r3,r3,lo(42f)
184 @@ -504,6 +505,7 @@ EXCEPTION_ENTRY(_external_irq_handler)
185 .string "\n\rESR interrupt bug: in _external_irq_handler (ESR %x)\n\r"
186 .align 4
187 .previous
188 +#endif
189
190 l.ori r4,r4,SPR_SR_IEE // fix the bug
191 // l.sw PT_SR(r1),r4
192 diff --git a/arch/parisc/kernel/signal.c b/arch/parisc/kernel/signal.c
193 index 2264f68f3c2f9..d9a4d6ffc0a8d 100644
194 --- a/arch/parisc/kernel/signal.c
195 +++ b/arch/parisc/kernel/signal.c
196 @@ -239,6 +239,12 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs,
197 #endif
198
199 usp = (regs->gr[30] & ~(0x01UL));
200 +#ifdef CONFIG_64BIT
201 + if (is_compat_task()) {
202 + /* The gcc alloca implementation leaves garbage in the upper 32 bits of sp */
203 + usp = (compat_uint_t)usp;
204 + }
205 +#endif
206 /*FIXME: frame_size parameter is unused, remove it. */
207 frame = get_sigframe(&ksig->ka, usp, sizeof(*frame));
208
209 diff --git a/arch/powerpc/boot/crt0.S b/arch/powerpc/boot/crt0.S
210 index a3550e8f1a77b..51669cdbf011e 100644
211 --- a/arch/powerpc/boot/crt0.S
212 +++ b/arch/powerpc/boot/crt0.S
213 @@ -49,9 +49,6 @@ p_end: .long _end
214 p_pstack: .long _platform_stack_top
215 #endif
216
217 - .globl _zimage_start
218 - /* Clang appears to require the .weak directive to be after the symbol
219 - * is defined. See https://bugs.llvm.org/show_bug.cgi?id=38921 */
220 .weak _zimage_start
221 _zimage_start:
222 .globl _zimage_start_lib
223 diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
224 index 99407cf12ad5b..e19dadffd9b7a 100644
225 --- a/arch/powerpc/kernel/module_64.c
226 +++ b/arch/powerpc/kernel/module_64.c
227 @@ -691,7 +691,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
228 /*
229 * If found, replace it with:
230 * addis r2, r12, (.TOC.-func)@ha
231 - * addi r2, r12, (.TOC.-func)@l
232 + * addi r2, r2, (.TOC.-func)@l
233 */
234 ((uint32_t *)location)[0] = 0x3c4c0000 + PPC_HA(value);
235 ((uint32_t *)location)[1] = 0x38420000 + PPC_LO(value);
236 diff --git a/arch/powerpc/perf/hv-gpci.c b/arch/powerpc/perf/hv-gpci.c
237 index 43fabb3cae0fa..160b86d9d8199 100644
238 --- a/arch/powerpc/perf/hv-gpci.c
239 +++ b/arch/powerpc/perf/hv-gpci.c
240 @@ -168,7 +168,7 @@ static unsigned long single_gpci_request(u32 req, u32 starting_index,
241 */
242 count = 0;
243 for (i = offset; i < offset + length; i++)
244 - count |= arg->bytes[i] << (i - offset);
245 + count |= (u64)(arg->bytes[i]) << ((length - 1 - (i - offset)) * 8);
246
247 *value = count;
248 out:
249 diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
250 index 17b3e82415f89..7dfc0c1ce4861 100644
251 --- a/arch/s390/kernel/dis.c
252 +++ b/arch/s390/kernel/dis.c
253 @@ -2018,7 +2018,7 @@ void show_code(struct pt_regs *regs)
254 start += opsize;
255 pr_cont("%s", buffer);
256 ptr = buffer;
257 - ptr += sprintf(ptr, "\n\t ");
258 + ptr += sprintf(ptr, "\n ");
259 hops++;
260 }
261 pr_cont("\n");
262 diff --git a/arch/s390/kernel/jump_label.c b/arch/s390/kernel/jump_label.c
263 index 083b05f5f5ab6..cbc1877066482 100644
264 --- a/arch/s390/kernel/jump_label.c
265 +++ b/arch/s390/kernel/jump_label.c
266 @@ -43,7 +43,7 @@ static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
267 unsigned char *ipe = (unsigned char *)expected;
268 unsigned char *ipn = (unsigned char *)new;
269
270 - pr_emerg("Jump label code mismatch at %pS [%p]\n", ipc, ipc);
271 + pr_emerg("Jump label code mismatch at %pS [%px]\n", ipc, ipc);
272 pr_emerg("Found: %6ph\n", ipc);
273 pr_emerg("Expected: %6ph\n", ipe);
274 pr_emerg("New: %6ph\n", ipn);
275 diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
276 index ed58ebab96cd8..53bb9700cf411 100644
277 --- a/arch/s390/net/bpf_jit_comp.c
278 +++ b/arch/s390/net/bpf_jit_comp.c
279 @@ -625,8 +625,13 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, int i
280 case BPF_ALU64 | BPF_SUB | BPF_K: /* dst = dst - imm */
281 if (!imm)
282 break;
283 - /* agfi %dst,-imm */
284 - EMIT6_IMM(0xc2080000, dst_reg, -imm);
285 + if (imm == -0x80000000) {
286 + /* algfi %dst,0x80000000 */
287 + EMIT6_IMM(0xc20a0000, dst_reg, 0x80000000);
288 + } else {
289 + /* agfi %dst,-imm */
290 + EMIT6_IMM(0xc2080000, dst_reg, -imm);
291 + }
292 break;
293 /*
294 * BPF_MUL
295 diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
296 index f6e57bebbc6bb..5c6aad14cdd96 100644
297 --- a/arch/x86/events/amd/ibs.c
298 +++ b/arch/x86/events/amd/ibs.c
299 @@ -89,6 +89,7 @@ struct perf_ibs {
300 unsigned long offset_mask[1];
301 int offset_max;
302 unsigned int fetch_count_reset_broken : 1;
303 + unsigned int fetch_ignore_if_zero_rip : 1;
304 struct cpu_perf_ibs __percpu *pcpu;
305
306 struct attribute **format_attrs;
307 @@ -673,6 +674,10 @@ fail:
308 if (check_rip && (ibs_data.regs[2] & IBS_RIP_INVALID)) {
309 regs.flags &= ~PERF_EFLAGS_EXACT;
310 } else {
311 + /* Workaround for erratum #1197 */
312 + if (perf_ibs->fetch_ignore_if_zero_rip && !(ibs_data.regs[1]))
313 + goto out;
314 +
315 set_linear_ip(&regs, ibs_data.regs[1]);
316 regs.flags |= PERF_EFLAGS_EXACT;
317 }
318 @@ -766,6 +771,9 @@ static __init void perf_event_ibs_init(void)
319 if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
320 perf_ibs_fetch.fetch_count_reset_broken = 1;
321
322 + if (boot_cpu_data.x86 == 0x19 && boot_cpu_data.x86_model < 0x10)
323 + perf_ibs_fetch.fetch_ignore_if_zero_rip = 1;
324 +
325 perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
326
327 if (ibs_caps & IBS_CAPS_OPCNT) {
328 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
329 index 75a1fd8b0e903..77e45db89d119 100644
330 --- a/arch/x86/kernel/reboot.c
331 +++ b/arch/x86/kernel/reboot.c
332 @@ -389,10 +389,11 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
333 },
334 { /* Handle problems with rebooting on the OptiPlex 990. */
335 .callback = set_pci_reboot,
336 - .ident = "Dell OptiPlex 990",
337 + .ident = "Dell OptiPlex 990 BIOS A0x",
338 .matches = {
339 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
340 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 990"),
341 + DMI_MATCH(DMI_BIOS_VERSION, "A0"),
342 },
343 },
344 { /* Handle problems with rebooting on Dell 300's */
345 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
346 index c959720c75938..c0f7e746722d9 100644
347 --- a/arch/x86/kvm/x86.c
348 +++ b/arch/x86/kvm/x86.c
349 @@ -2315,6 +2315,10 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
350 if (!msr_info->host_initiated) {
351 s64 adj = data - vcpu->arch.ia32_tsc_adjust_msr;
352 adjust_tsc_offset_guest(vcpu, adj);
353 + /* Before back to guest, tsc_timestamp must be adjusted
354 + * as well, otherwise guest's percpu pvclock time could jump.
355 + */
356 + kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
357 }
358 vcpu->arch.ia32_tsc_adjust_msr = data;
359 }
360 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
361 index d35d0e4bbf99a..bd6905ce590fa 100644
362 --- a/arch/x86/mm/init_64.c
363 +++ b/arch/x86/mm/init_64.c
364 @@ -1126,21 +1126,21 @@ int kern_addr_valid(unsigned long addr)
365 return 0;
366
367 pud = pud_offset(pgd, addr);
368 - if (pud_none(*pud))
369 + if (!pud_present(*pud))
370 return 0;
371
372 if (pud_large(*pud))
373 return pfn_valid(pud_pfn(*pud));
374
375 pmd = pmd_offset(pud, addr);
376 - if (pmd_none(*pmd))
377 + if (!pmd_present(*pmd))
378 return 0;
379
380 if (pmd_large(*pmd))
381 return pfn_valid(pmd_pfn(*pmd));
382
383 pte = pte_offset_kernel(pmd, addr);
384 - if (pte_none(*pte))
385 + if (!pte_present(*pte))
386 return 0;
387
388 return pfn_valid(pte_pfn(*pte));
389 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
390 index db7cf8727e1cf..21e01fc632adb 100644
391 --- a/arch/x86/xen/enlighten.c
392 +++ b/arch/x86/xen/enlighten.c
393 @@ -1576,6 +1576,11 @@ static int xen_cpuhp_setup(void)
394 return rc >= 0 ? 0 : rc;
395 }
396
397 +static void __init xen_domu_set_legacy_features(void)
398 +{
399 + x86_platform.legacy.rtc = 0;
400 +}
401 +
402 /* First C function to be called on Xen boot */
403 asmlinkage __visible void __init xen_start_kernel(void)
404 {
405 @@ -1741,6 +1746,8 @@ asmlinkage __visible void __init xen_start_kernel(void)
406 add_preferred_console("hvc", 0, NULL);
407 if (pci_xen)
408 x86_init.pci.arch_init = pci_xen_init;
409 + x86_platform.set_legacy_features =
410 + xen_domu_set_legacy_features;
411 } else {
412 const struct dom0_vga_console_info *info =
413 (void *)((char *)xen_start_info +
414 diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
415 index d6ed664c1e39d..3d2015011ca94 100644
416 --- a/arch/x86/xen/p2m.c
417 +++ b/arch/x86/xen/p2m.c
418 @@ -623,8 +623,8 @@ int xen_alloc_p2m_entry(unsigned long pfn)
419 }
420
421 /* Expanded the p2m? */
422 - if (pfn > xen_p2m_last_pfn) {
423 - xen_p2m_last_pfn = pfn;
424 + if (pfn >= xen_p2m_last_pfn) {
425 + xen_p2m_last_pfn = ALIGN(pfn + 1, P2M_PER_PAGE);
426 HYPERVISOR_shared_info->arch.max_pfn = xen_p2m_last_pfn;
427 }
428
429 diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
430 index f61058617ada4..ff45491c64e0e 100644
431 --- a/arch/xtensa/Kconfig
432 +++ b/arch/xtensa/Kconfig
433 @@ -17,7 +17,7 @@ config XTENSA
434 select HAVE_DMA_API_DEBUG
435 select HAVE_EXIT_THREAD
436 select HAVE_FUNCTION_TRACER
437 - select HAVE_FUTEX_CMPXCHG if !MMU
438 + select HAVE_FUTEX_CMPXCHG if !MMU && FUTEX
439 select HAVE_HW_BREAKPOINT if PERF_EVENTS
440 select HAVE_IRQ_TIME_ACCOUNTING
441 select HAVE_MEMBLOCK
442 diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
443 index c68f1e6158aa6..a2d93a7c7ff24 100644
444 --- a/arch/xtensa/platforms/iss/console.c
445 +++ b/arch/xtensa/platforms/iss/console.c
446 @@ -182,9 +182,13 @@ static const struct tty_operations serial_ops = {
447
448 int __init rs_init(void)
449 {
450 - tty_port_init(&serial_port);
451 + int ret;
452
453 serial_driver = alloc_tty_driver(SERIAL_MAX_NUM_LINES);
454 + if (!serial_driver)
455 + return -ENOMEM;
456 +
457 + tty_port_init(&serial_port);
458
459 printk ("%s %s\n", serial_name, serial_version);
460
461 @@ -204,8 +208,15 @@ int __init rs_init(void)
462 tty_set_operations(serial_driver, &serial_ops);
463 tty_port_link_device(&serial_port, serial_driver, 0);
464
465 - if (tty_register_driver(serial_driver))
466 - panic("Couldn't register serial driver\n");
467 + ret = tty_register_driver(serial_driver);
468 + if (ret) {
469 + pr_err("Couldn't register serial driver\n");
470 + tty_driver_kref_put(serial_driver);
471 + tty_port_destroy(&serial_port);
472 +
473 + return ret;
474 + }
475 +
476 return 0;
477 }
478
479 diff --git a/certs/Makefile b/certs/Makefile
480 index 2773c4afa24c0..4417cc5cf5e89 100644
481 --- a/certs/Makefile
482 +++ b/certs/Makefile
483 @@ -39,11 +39,19 @@ endif
484 redirect_openssl = 2>&1
485 quiet_redirect_openssl = 2>&1
486 silent_redirect_openssl = 2>/dev/null
487 +openssl_available = $(shell openssl help 2>/dev/null && echo yes)
488
489 # We do it this way rather than having a boolean option for enabling an
490 # external private key, because 'make randconfig' might enable such a
491 # boolean option and we unfortunately can't make it depend on !RANDCONFIG.
492 ifeq ($(CONFIG_MODULE_SIG_KEY),"certs/signing_key.pem")
493 +
494 +ifeq ($(openssl_available),yes)
495 +X509TEXT=$(shell openssl x509 -in "certs/signing_key.pem" -text 2>/dev/null)
496 +
497 +$(if $(findstring rsaEncryption,$(X509TEXT)),,$(shell rm -f "certs/signing_key.pem"))
498 +endif
499 +
500 $(obj)/signing_key.pem: $(obj)/x509.genkey
501 @$(kecho) "###"
502 @$(kecho) "### Now generating an X.509 key pair to be used for signing modules."
503 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
504 index 228a4cfb0e7d2..adbf0486422b8 100644
505 --- a/drivers/ata/libata-core.c
506 +++ b/drivers/ata/libata-core.c
507 @@ -4447,6 +4447,10 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
508 ATA_HORKAGE_ZERO_AFTER_TRIM, },
509 { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
510 ATA_HORKAGE_ZERO_AFTER_TRIM, },
511 + { "Samsung SSD 860*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
512 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
513 + { "Samsung SSD 870*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
514 + ATA_HORKAGE_ZERO_AFTER_TRIM, },
515 { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM |
516 ATA_HORKAGE_ZERO_AFTER_TRIM, },
517
518 @@ -6213,7 +6217,7 @@ int ata_host_start(struct ata_host *host)
519 have_stop = 1;
520 }
521
522 - if (host->ops->host_stop)
523 + if (host->ops && host->ops->host_stop)
524 have_stop = 1;
525
526 if (have_stop) {
527 diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
528 index e0939bd5ea735..6797871f8bc60 100644
529 --- a/drivers/ata/sata_dwc_460ex.c
530 +++ b/drivers/ata/sata_dwc_460ex.c
531 @@ -1253,24 +1253,20 @@ static int sata_dwc_probe(struct platform_device *ofdev)
532 irq = irq_of_parse_and_map(np, 0);
533 if (irq == NO_IRQ) {
534 dev_err(&ofdev->dev, "no SATA DMA irq\n");
535 - err = -ENODEV;
536 - goto error_out;
537 + return -ENODEV;
538 }
539
540 #ifdef CONFIG_SATA_DWC_OLD_DMA
541 if (!of_find_property(np, "dmas", NULL)) {
542 err = sata_dwc_dma_init_old(ofdev, hsdev);
543 if (err)
544 - goto error_out;
545 + return err;
546 }
547 #endif
548
549 hsdev->phy = devm_phy_optional_get(hsdev->dev, "sata-phy");
550 - if (IS_ERR(hsdev->phy)) {
551 - err = PTR_ERR(hsdev->phy);
552 - hsdev->phy = NULL;
553 - goto error_out;
554 - }
555 + if (IS_ERR(hsdev->phy))
556 + return PTR_ERR(hsdev->phy);
557
558 err = phy_init(hsdev->phy);
559 if (err)
560 diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
561 index feba1b2118983..ee63ccaea8d57 100644
562 --- a/drivers/base/power/wakeirq.c
563 +++ b/drivers/base/power/wakeirq.c
564 @@ -319,8 +319,12 @@ void dev_pm_arm_wake_irq(struct wake_irq *wirq)
565 if (!wirq)
566 return;
567
568 - if (device_may_wakeup(wirq->dev))
569 + if (device_may_wakeup(wirq->dev)) {
570 + if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED)
571 + enable_irq(wirq->irq);
572 +
573 enable_irq_wake(wirq->irq);
574 + }
575 }
576
577 /**
578 @@ -335,6 +339,10 @@ void dev_pm_disarm_wake_irq(struct wake_irq *wirq)
579 if (!wirq)
580 return;
581
582 - if (device_may_wakeup(wirq->dev))
583 + if (device_may_wakeup(wirq->dev)) {
584 disable_irq_wake(wirq->irq);
585 +
586 + if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED)
587 + disable_irq_nosync(wirq->irq);
588 + }
589 }
590 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
591 index cd984b59a8a16..40a9e5378633c 100644
592 --- a/drivers/base/regmap/regmap.c
593 +++ b/drivers/base/regmap/regmap.c
594 @@ -1375,7 +1375,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg,
595 if (ret) {
596 dev_err(map->dev,
597 "Error in caching of register: %x ret: %d\n",
598 - reg + i, ret);
599 + reg + regmap_get_offset(map, i), ret);
600 return ret;
601 }
602 }
603 diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
604 index 38688236b3cde..be551f01f7f07 100644
605 --- a/drivers/bcma/main.c
606 +++ b/drivers/bcma/main.c
607 @@ -239,6 +239,7 @@ EXPORT_SYMBOL(bcma_core_irq);
608
609 void bcma_prepare_core(struct bcma_bus *bus, struct bcma_device *core)
610 {
611 + device_initialize(&core->dev);
612 core->dev.release = bcma_release_core_dev;
613 core->dev.bus = &bcma_bus_type;
614 dev_set_name(&core->dev, "bcma%d:%d", bus->num, core->core_index);
615 @@ -302,11 +303,10 @@ static void bcma_register_core(struct bcma_bus *bus, struct bcma_device *core)
616 {
617 int err;
618
619 - err = device_register(&core->dev);
620 + err = device_add(&core->dev);
621 if (err) {
622 bcma_err(bus, "Could not register dev for core 0x%03X\n",
623 core->id.id);
624 - put_device(&core->dev);
625 return;
626 }
627 core->dev_registered = true;
628 @@ -397,7 +397,7 @@ void bcma_unregister_cores(struct bcma_bus *bus)
629 /* Now noone uses internally-handled cores, we can free them */
630 list_for_each_entry_safe(core, tmp, &bus->cores, list) {
631 list_del(&core->list);
632 - kfree(core);
633 + put_device(&core->dev);
634 }
635 }
636
637 diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
638 index 894102fd5a069..b701c79f07e53 100644
639 --- a/drivers/block/Kconfig
640 +++ b/drivers/block/Kconfig
641 @@ -257,7 +257,7 @@ config BLK_DEV_LOOP_MIN_COUNT
642 dynamically allocated with the /dev/loop-control interface.
643
644 config BLK_DEV_CRYPTOLOOP
645 - tristate "Cryptoloop Support"
646 + tristate "Cryptoloop Support (DEPRECATED)"
647 select CRYPTO
648 select CRYPTO_CBC
649 depends on BLK_DEV_LOOP
650 @@ -269,7 +269,7 @@ config BLK_DEV_CRYPTOLOOP
651 WARNING: This device is not safe for journaled file systems like
652 ext3 or Reiserfs. Please use the Device Mapper crypto module
653 instead, which can be configured to be on-disk compatible with the
654 - cryptoloop device.
655 + cryptoloop device. cryptoloop support will be removed in Linux 5.16.
656
657 source "drivers/block/drbd/Kconfig"
658
659 diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
660 index 3d31761c0ed05..adbfd3e2a60f5 100644
661 --- a/drivers/block/cryptoloop.c
662 +++ b/drivers/block/cryptoloop.c
663 @@ -203,6 +203,8 @@ init_cryptoloop(void)
664
665 if (rc)
666 printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
667 + else
668 + pr_warn("the cryptoloop driver has been deprecated and will be removed in in Linux 5.16\n");
669 return rc;
670 }
671
672 diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c
673 index 890ebf623261b..38612cd9092eb 100644
674 --- a/drivers/clk/mvebu/kirkwood.c
675 +++ b/drivers/clk/mvebu/kirkwood.c
676 @@ -254,6 +254,7 @@ static const char *powersave_parents[] = {
677 static const struct clk_muxing_soc_desc kirkwood_mux_desc[] __initconst = {
678 { "powersave", powersave_parents, ARRAY_SIZE(powersave_parents),
679 11, 1, 0 },
680 + { }
681 };
682
683 static struct clk *clk_muxing_get_src(
684 diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
685 index 34839b539207e..0e14a6642de42 100644
686 --- a/drivers/crypto/mxs-dcp.c
687 +++ b/drivers/crypto/mxs-dcp.c
688 @@ -167,15 +167,19 @@ static struct dcp *global_sdcp;
689
690 static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
691 {
692 + int dma_err;
693 struct dcp *sdcp = global_sdcp;
694 const int chan = actx->chan;
695 uint32_t stat;
696 unsigned long ret;
697 struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
698 -
699 dma_addr_t desc_phys = dma_map_single(sdcp->dev, desc, sizeof(*desc),
700 DMA_TO_DEVICE);
701
702 + dma_err = dma_mapping_error(sdcp->dev, desc_phys);
703 + if (dma_err)
704 + return dma_err;
705 +
706 reinit_completion(&sdcp->completion[chan]);
707
708 /* Clear status register. */
709 @@ -213,18 +217,29 @@ static int mxs_dcp_start_dma(struct dcp_async_ctx *actx)
710 static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
711 struct ablkcipher_request *req, int init)
712 {
713 + dma_addr_t key_phys, src_phys, dst_phys;
714 struct dcp *sdcp = global_sdcp;
715 struct dcp_dma_desc *desc = &sdcp->coh->desc[actx->chan];
716 struct dcp_aes_req_ctx *rctx = ablkcipher_request_ctx(req);
717 int ret;
718
719 - dma_addr_t key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
720 - 2 * AES_KEYSIZE_128,
721 - DMA_TO_DEVICE);
722 - dma_addr_t src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
723 - DCP_BUF_SZ, DMA_TO_DEVICE);
724 - dma_addr_t dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
725 - DCP_BUF_SZ, DMA_FROM_DEVICE);
726 + key_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_key,
727 + 2 * AES_KEYSIZE_128, DMA_TO_DEVICE);
728 + ret = dma_mapping_error(sdcp->dev, key_phys);
729 + if (ret)
730 + return ret;
731 +
732 + src_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_in_buf,
733 + DCP_BUF_SZ, DMA_TO_DEVICE);
734 + ret = dma_mapping_error(sdcp->dev, src_phys);
735 + if (ret)
736 + goto err_src;
737 +
738 + dst_phys = dma_map_single(sdcp->dev, sdcp->coh->aes_out_buf,
739 + DCP_BUF_SZ, DMA_FROM_DEVICE);
740 + ret = dma_mapping_error(sdcp->dev, dst_phys);
741 + if (ret)
742 + goto err_dst;
743
744 if (actx->fill % AES_BLOCK_SIZE) {
745 dev_err(sdcp->dev, "Invalid block size!\n");
746 @@ -262,10 +277,12 @@ static int mxs_dcp_run_aes(struct dcp_async_ctx *actx,
747 ret = mxs_dcp_start_dma(actx);
748
749 aes_done_run:
750 + dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
751 +err_dst:
752 + dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
753 +err_src:
754 dma_unmap_single(sdcp->dev, key_phys, 2 * AES_KEYSIZE_128,
755 DMA_TO_DEVICE);
756 - dma_unmap_single(sdcp->dev, src_phys, DCP_BUF_SZ, DMA_TO_DEVICE);
757 - dma_unmap_single(sdcp->dev, dst_phys, DCP_BUF_SZ, DMA_FROM_DEVICE);
758
759 return ret;
760 }
761 @@ -280,21 +297,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
762
763 struct scatterlist *dst = req->dst;
764 struct scatterlist *src = req->src;
765 - const int nents = sg_nents(req->src);
766 + int dst_nents = sg_nents(dst);
767
768 const int out_off = DCP_BUF_SZ;
769 uint8_t *in_buf = sdcp->coh->aes_in_buf;
770 uint8_t *out_buf = sdcp->coh->aes_out_buf;
771
772 - uint8_t *out_tmp, *src_buf, *dst_buf = NULL;
773 uint32_t dst_off = 0;
774 + uint8_t *src_buf = NULL;
775 uint32_t last_out_len = 0;
776
777 uint8_t *key = sdcp->coh->aes_key;
778
779 int ret = 0;
780 - int split = 0;
781 - unsigned int i, len, clen, rem = 0, tlen = 0;
782 + unsigned int i, len, clen, tlen = 0;
783 int init = 0;
784 bool limit_hit = false;
785
786 @@ -312,7 +328,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
787 memset(key + AES_KEYSIZE_128, 0, AES_KEYSIZE_128);
788 }
789
790 - for_each_sg(req->src, src, nents, i) {
791 + for_each_sg(req->src, src, sg_nents(src), i) {
792 src_buf = sg_virt(src);
793 len = sg_dma_len(src);
794 tlen += len;
795 @@ -337,34 +353,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
796 * submit the buffer.
797 */
798 if (actx->fill == out_off || sg_is_last(src) ||
799 - limit_hit) {
800 + limit_hit) {
801 ret = mxs_dcp_run_aes(actx, req, init);
802 if (ret)
803 return ret;
804 init = 0;
805
806 - out_tmp = out_buf;
807 + sg_pcopy_from_buffer(dst, dst_nents, out_buf,
808 + actx->fill, dst_off);
809 + dst_off += actx->fill;
810 last_out_len = actx->fill;
811 - while (dst && actx->fill) {
812 - if (!split) {
813 - dst_buf = sg_virt(dst);
814 - dst_off = 0;
815 - }
816 - rem = min(sg_dma_len(dst) - dst_off,
817 - actx->fill);
818 -
819 - memcpy(dst_buf + dst_off, out_tmp, rem);
820 - out_tmp += rem;
821 - dst_off += rem;
822 - actx->fill -= rem;
823 -
824 - if (dst_off == sg_dma_len(dst)) {
825 - dst = sg_next(dst);
826 - split = 0;
827 - } else {
828 - split = 1;
829 - }
830 - }
831 + actx->fill = 0;
832 }
833 } while (len);
834
835 @@ -565,6 +564,10 @@ static int mxs_dcp_run_sha(struct ahash_request *req)
836 dma_addr_t buf_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_in_buf,
837 DCP_BUF_SZ, DMA_TO_DEVICE);
838
839 + ret = dma_mapping_error(sdcp->dev, buf_phys);
840 + if (ret)
841 + return ret;
842 +
843 /* Fill in the DMA descriptor. */
844 desc->control0 = MXS_DCP_CONTROL0_DECR_SEMAPHORE |
845 MXS_DCP_CONTROL0_INTERRUPT |
846 @@ -597,6 +600,10 @@ static int mxs_dcp_run_sha(struct ahash_request *req)
847 if (rctx->fini) {
848 digest_phys = dma_map_single(sdcp->dev, sdcp->coh->sha_out_buf,
849 DCP_SHA_PAY_SZ, DMA_FROM_DEVICE);
850 + ret = dma_mapping_error(sdcp->dev, digest_phys);
851 + if (ret)
852 + goto done_run;
853 +
854 desc->control0 |= MXS_DCP_CONTROL0_HASH_TERM;
855 desc->payload = digest_phys;
856 }
857 diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
858 index 4adcf89add252..801ae958b0adb 100644
859 --- a/drivers/crypto/omap-sham.c
860 +++ b/drivers/crypto/omap-sham.c
861 @@ -1745,7 +1745,7 @@ static void omap_sham_done_task(unsigned long data)
862 if (test_and_clear_bit(FLAGS_OUTPUT_READY, &dd->flags))
863 goto finish;
864 } else if (test_bit(FLAGS_DMA_READY, &dd->flags)) {
865 - if (test_and_clear_bit(FLAGS_DMA_ACTIVE, &dd->flags)) {
866 + if (test_bit(FLAGS_DMA_ACTIVE, &dd->flags)) {
867 omap_sham_update_dma_stop(dd);
868 if (dd->err) {
869 err = dd->err;
870 diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
871 index d2d0ae445fd89..7c7d49a8a4034 100644
872 --- a/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
873 +++ b/drivers/crypto/qat/qat_c3xxxvf/adf_c3xxxvf_hw_data.c
874 @@ -123,10 +123,10 @@ void adf_init_hw_data_c3xxxiov(struct adf_hw_device_data *hw_data)
875 hw_data->enable_error_correction = adf_vf_void_noop;
876 hw_data->init_admin_comms = adf_vf_int_noop;
877 hw_data->exit_admin_comms = adf_vf_void_noop;
878 - hw_data->send_admin_init = adf_vf2pf_init;
879 + hw_data->send_admin_init = adf_vf2pf_notify_init;
880 hw_data->init_arb = adf_vf_int_noop;
881 hw_data->exit_arb = adf_vf_void_noop;
882 - hw_data->disable_iov = adf_vf2pf_shutdown;
883 + hw_data->disable_iov = adf_vf2pf_notify_shutdown;
884 hw_data->get_accel_mask = get_accel_mask;
885 hw_data->get_ae_mask = get_ae_mask;
886 hw_data->get_num_accels = get_num_accels;
887 diff --git a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
888 index 38e4bc04f407b..90e8a7564756b 100644
889 --- a/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
890 +++ b/drivers/crypto/qat/qat_c62xvf/adf_c62xvf_hw_data.c
891 @@ -123,10 +123,10 @@ void adf_init_hw_data_c62xiov(struct adf_hw_device_data *hw_data)
892 hw_data->enable_error_correction = adf_vf_void_noop;
893 hw_data->init_admin_comms = adf_vf_int_noop;
894 hw_data->exit_admin_comms = adf_vf_void_noop;
895 - hw_data->send_admin_init = adf_vf2pf_init;
896 + hw_data->send_admin_init = adf_vf2pf_notify_init;
897 hw_data->init_arb = adf_vf_int_noop;
898 hw_data->exit_arb = adf_vf_void_noop;
899 - hw_data->disable_iov = adf_vf2pf_shutdown;
900 + hw_data->disable_iov = adf_vf2pf_notify_shutdown;
901 hw_data->get_accel_mask = get_accel_mask;
902 hw_data->get_ae_mask = get_ae_mask;
903 hw_data->get_num_accels = get_num_accels;
904 diff --git a/drivers/crypto/qat/qat_common/adf_common_drv.h b/drivers/crypto/qat/qat_common/adf_common_drv.h
905 index 0d596a99f5645..88c8831503e4a 100644
906 --- a/drivers/crypto/qat/qat_common/adf_common_drv.h
907 +++ b/drivers/crypto/qat/qat_common/adf_common_drv.h
908 @@ -239,8 +239,8 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev,
909 void adf_enable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
910 void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev);
911
912 -int adf_vf2pf_init(struct adf_accel_dev *accel_dev);
913 -void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev);
914 +int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev);
915 +void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev);
916 int adf_init_pf_wq(void);
917 void adf_exit_pf_wq(void);
918 int adf_init_vf_wq(void);
919 @@ -263,12 +263,12 @@ static inline void adf_disable_pf2vf_interrupts(struct adf_accel_dev *accel_dev)
920 {
921 }
922
923 -static inline int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
924 +static inline int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
925 {
926 return 0;
927 }
928
929 -static inline void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
930 +static inline void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
931 {
932 }
933
934 diff --git a/drivers/crypto/qat/qat_common/adf_init.c b/drivers/crypto/qat/qat_common/adf_init.c
935 index 888c6675e7e54..03856cc604b6f 100644
936 --- a/drivers/crypto/qat/qat_common/adf_init.c
937 +++ b/drivers/crypto/qat/qat_common/adf_init.c
938 @@ -101,6 +101,7 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
939 struct service_hndl *service;
940 struct list_head *list_itr;
941 struct adf_hw_device_data *hw_data = accel_dev->hw_device;
942 + int ret;
943
944 if (!hw_data) {
945 dev_err(&GET_DEV(accel_dev),
946 @@ -167,9 +168,9 @@ int adf_dev_init(struct adf_accel_dev *accel_dev)
947 }
948
949 hw_data->enable_error_correction(accel_dev);
950 - hw_data->enable_vf2pf_comms(accel_dev);
951 + ret = hw_data->enable_vf2pf_comms(accel_dev);
952
953 - return 0;
954 + return ret;
955 }
956 EXPORT_SYMBOL_GPL(adf_dev_init);
957
958 diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c
959 index 2c0be14309cfa..7877ba6772203 100644
960 --- a/drivers/crypto/qat/qat_common/adf_isr.c
961 +++ b/drivers/crypto/qat/qat_common/adf_isr.c
962 @@ -59,6 +59,8 @@
963 #include "adf_transport_access_macros.h"
964 #include "adf_transport_internal.h"
965
966 +#define ADF_MAX_NUM_VFS 32
967 +
968 static int adf_enable_msix(struct adf_accel_dev *accel_dev)
969 {
970 struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev;
971 @@ -111,7 +113,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
972 struct adf_bar *pmisc =
973 &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
974 void __iomem *pmisc_bar_addr = pmisc->virt_addr;
975 - u32 vf_mask;
976 + unsigned long vf_mask;
977
978 /* Get the interrupt sources triggered by VFs */
979 vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
980 @@ -132,8 +134,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
981 * unless the VF is malicious and is attempting to
982 * flood the host OS with VF2PF interrupts.
983 */
984 - for_each_set_bit(i, (const unsigned long *)&vf_mask,
985 - (sizeof(vf_mask) * BITS_PER_BYTE)) {
986 + for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) {
987 vf_info = accel_dev->pf.vf_info + i;
988
989 if (!__ratelimit(&vf_info->vf2pf_ratelimit)) {
990 diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
991 index b3875fdf6cd72..c64481160b711 100644
992 --- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
993 +++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
994 @@ -231,7 +231,6 @@ int adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
995
996 return ret;
997 }
998 -EXPORT_SYMBOL_GPL(adf_iov_putmsg);
999
1000 void adf_vf2pf_req_hndl(struct adf_accel_vf_info *vf_info)
1001 {
1002 @@ -361,6 +360,8 @@ static int adf_vf2pf_request_version(struct adf_accel_dev *accel_dev)
1003 msg |= ADF_PFVF_COMPATIBILITY_VERSION << ADF_VF2PF_COMPAT_VER_REQ_SHIFT;
1004 BUILD_BUG_ON(ADF_PFVF_COMPATIBILITY_VERSION > 255);
1005
1006 + reinit_completion(&accel_dev->vf.iov_msg_completion);
1007 +
1008 /* Send request from VF to PF */
1009 ret = adf_iov_putmsg(accel_dev, msg, 0);
1010 if (ret) {
1011 diff --git a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1012 index cd5f37dffe8a6..1830194567e84 100644
1013 --- a/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1014 +++ b/drivers/crypto/qat/qat_common/adf_vf2pf_msg.c
1015 @@ -49,14 +49,14 @@
1016 #include "adf_pf2vf_msg.h"
1017
1018 /**
1019 - * adf_vf2pf_init() - send init msg to PF
1020 + * adf_vf2pf_notify_init() - send init msg to PF
1021 * @accel_dev: Pointer to acceleration VF device.
1022 *
1023 * Function sends an init messge from the VF to a PF
1024 *
1025 * Return: 0 on success, error code otherwise.
1026 */
1027 -int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
1028 +int adf_vf2pf_notify_init(struct adf_accel_dev *accel_dev)
1029 {
1030 u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
1031 (ADF_VF2PF_MSGTYPE_INIT << ADF_VF2PF_MSGTYPE_SHIFT));
1032 @@ -69,17 +69,17 @@ int adf_vf2pf_init(struct adf_accel_dev *accel_dev)
1033 set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status);
1034 return 0;
1035 }
1036 -EXPORT_SYMBOL_GPL(adf_vf2pf_init);
1037 +EXPORT_SYMBOL_GPL(adf_vf2pf_notify_init);
1038
1039 /**
1040 - * adf_vf2pf_shutdown() - send shutdown msg to PF
1041 + * adf_vf2pf_notify_shutdown() - send shutdown msg to PF
1042 * @accel_dev: Pointer to acceleration VF device.
1043 *
1044 * Function sends a shutdown messge from the VF to a PF
1045 *
1046 * Return: void
1047 */
1048 -void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
1049 +void adf_vf2pf_notify_shutdown(struct adf_accel_dev *accel_dev)
1050 {
1051 u32 msg = (ADF_VF2PF_MSGORIGIN_SYSTEM |
1052 (ADF_VF2PF_MSGTYPE_SHUTDOWN << ADF_VF2PF_MSGTYPE_SHIFT));
1053 @@ -89,4 +89,4 @@ void adf_vf2pf_shutdown(struct adf_accel_dev *accel_dev)
1054 dev_err(&GET_DEV(accel_dev),
1055 "Failed to send Shutdown event to PF\n");
1056 }
1057 -EXPORT_SYMBOL_GPL(adf_vf2pf_shutdown);
1058 +EXPORT_SYMBOL_GPL(adf_vf2pf_notify_shutdown);
1059 diff --git a/drivers/crypto/qat/qat_common/adf_vf_isr.c b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1060 index 4c1217ba83ae8..36db3c443e7e4 100644
1061 --- a/drivers/crypto/qat/qat_common/adf_vf_isr.c
1062 +++ b/drivers/crypto/qat/qat_common/adf_vf_isr.c
1063 @@ -203,6 +203,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1064 struct adf_bar *pmisc =
1065 &GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
1066 void __iomem *pmisc_bar_addr = pmisc->virt_addr;
1067 + bool handled = false;
1068 u32 v_int;
1069
1070 /* Read VF INT source CSR to determine the source of VF interrupt */
1071 @@ -215,7 +216,7 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1072
1073 /* Schedule tasklet to handle interrupt BH */
1074 tasklet_hi_schedule(&accel_dev->vf.pf2vf_bh_tasklet);
1075 - return IRQ_HANDLED;
1076 + handled = true;
1077 }
1078
1079 /* Check bundle interrupt */
1080 @@ -227,10 +228,10 @@ static irqreturn_t adf_isr(int irq, void *privdata)
1081 WRITE_CSR_INT_FLAG_AND_COL(bank->csr_addr, bank->bank_number,
1082 0);
1083 tasklet_hi_schedule(&bank->resp_handler);
1084 - return IRQ_HANDLED;
1085 + handled = true;
1086 }
1087
1088 - return IRQ_NONE;
1089 + return handled ? IRQ_HANDLED : IRQ_NONE;
1090 }
1091
1092 static int adf_request_msi_irq(struct adf_accel_dev *accel_dev)
1093 diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1094 index a3b4dd8099a7b..3a8361c83f0b1 100644
1095 --- a/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1096 +++ b/drivers/crypto/qat/qat_dh895xccvf/adf_dh895xccvf_hw_data.c
1097 @@ -123,10 +123,10 @@ void adf_init_hw_data_dh895xcciov(struct adf_hw_device_data *hw_data)
1098 hw_data->enable_error_correction = adf_vf_void_noop;
1099 hw_data->init_admin_comms = adf_vf_int_noop;
1100 hw_data->exit_admin_comms = adf_vf_void_noop;
1101 - hw_data->send_admin_init = adf_vf2pf_init;
1102 + hw_data->send_admin_init = adf_vf2pf_notify_init;
1103 hw_data->init_arb = adf_vf_int_noop;
1104 hw_data->exit_arb = adf_vf_void_noop;
1105 - hw_data->disable_iov = adf_vf2pf_shutdown;
1106 + hw_data->disable_iov = adf_vf2pf_notify_shutdown;
1107 hw_data->get_accel_mask = get_accel_mask;
1108 hw_data->get_ae_mask = get_ae_mask;
1109 hw_data->get_num_accels = get_num_accels;
1110 diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
1111 index f4a6be76468d5..15eb1501915ca 100644
1112 --- a/drivers/crypto/talitos.c
1113 +++ b/drivers/crypto/talitos.c
1114 @@ -816,7 +816,11 @@ static void talitos_unregister_rng(struct device *dev)
1115 * HMAC_SNOOP_NO_AFEA (HSNA) instead of type IPSEC_ESP
1116 */
1117 #define TALITOS_CRA_PRIORITY_AEAD_HSNA (TALITOS_CRA_PRIORITY - 1)
1118 +#ifdef CONFIG_CRYPTO_DEV_TALITOS_SEC2
1119 #define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA512_BLOCK_SIZE)
1120 +#else
1121 +#define TALITOS_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + SHA256_BLOCK_SIZE)
1122 +#endif
1123 #define TALITOS_MAX_IV_LENGTH 16 /* max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
1124
1125 struct talitos_ctx {
1126 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1127 index 91d367399956e..a334eb7dbff4d 100644
1128 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1129 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
1130 @@ -339,7 +339,7 @@ static void amdgpu_i2c_put_byte(struct amdgpu_i2c_chan *i2c_bus,
1131 void
1132 amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connector)
1133 {
1134 - u8 val;
1135 + u8 val = 0;
1136
1137 if (!amdgpu_connector->router.ddc_valid)
1138 return;
1139 diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
1140 index ec572f8389edb..3a75586c1989b 100644
1141 --- a/drivers/gpu/drm/msm/dsi/dsi.c
1142 +++ b/drivers/gpu/drm/msm/dsi/dsi.c
1143 @@ -36,8 +36,10 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
1144 }
1145
1146 phy_pdev = of_find_device_by_node(phy_node);
1147 - if (phy_pdev)
1148 + if (phy_pdev) {
1149 msm_dsi->phy = platform_get_drvdata(phy_pdev);
1150 + msm_dsi->phy_dev = &phy_pdev->dev;
1151 + }
1152
1153 of_node_put(phy_node);
1154
1155 @@ -46,8 +48,6 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
1156 return -EPROBE_DEFER;
1157 }
1158
1159 - msm_dsi->phy_dev = get_device(&phy_pdev->dev);
1160 -
1161 return 0;
1162 }
1163
1164 diff --git a/drivers/i2c/busses/i2c-highlander.c b/drivers/i2c/busses/i2c-highlander.c
1165 index 56dc69e7349fc..9ad031ea33009 100644
1166 --- a/drivers/i2c/busses/i2c-highlander.c
1167 +++ b/drivers/i2c/busses/i2c-highlander.c
1168 @@ -382,7 +382,7 @@ static int highlander_i2c_probe(struct platform_device *pdev)
1169 platform_set_drvdata(pdev, dev);
1170
1171 dev->irq = platform_get_irq(pdev, 0);
1172 - if (iic_force_poll)
1173 + if (dev->irq < 0 || iic_force_poll)
1174 dev->irq = 0;
1175
1176 if (dev->irq) {
1177 diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
1178 index 85cbe4b555786..d4fe7ccccb226 100644
1179 --- a/drivers/i2c/busses/i2c-iop3xx.c
1180 +++ b/drivers/i2c/busses/i2c-iop3xx.c
1181 @@ -456,16 +456,14 @@ iop3xx_i2c_probe(struct platform_device *pdev)
1182
1183 irq = platform_get_irq(pdev, 0);
1184 if (irq < 0) {
1185 - ret = -ENXIO;
1186 + ret = irq;
1187 goto unmap;
1188 }
1189 ret = request_irq(irq, iop3xx_i2c_irq_handler, 0,
1190 pdev->name, adapter_data);
1191
1192 - if (ret) {
1193 - ret = -EIO;
1194 + if (ret)
1195 goto unmap;
1196 - }
1197
1198 memcpy(new_adapter->name, pdev->name, strlen(pdev->name));
1199 new_adapter->owner = THIS_MODULE;
1200 diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
1201 index 4a7d9bc2142ba..0f905f8387f2f 100644
1202 --- a/drivers/i2c/busses/i2c-mt65xx.c
1203 +++ b/drivers/i2c/busses/i2c-mt65xx.c
1204 @@ -708,7 +708,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
1205 return PTR_ERR(i2c->pdmabase);
1206
1207 irq = platform_get_irq(pdev, 0);
1208 - if (irq <= 0)
1209 + if (irq < 0)
1210 return irq;
1211
1212 init_completion(&i2c->msg_complete);
1213 diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
1214 index acccdfb954207..3814c160ff174 100644
1215 --- a/drivers/i2c/busses/i2c-s3c2410.c
1216 +++ b/drivers/i2c/busses/i2c-s3c2410.c
1217 @@ -1181,7 +1181,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1218 */
1219 if (!(i2c->quirks & QUIRK_POLL)) {
1220 i2c->irq = ret = platform_get_irq(pdev, 0);
1221 - if (ret <= 0) {
1222 + if (ret < 0) {
1223 dev_err(&pdev->dev, "cannot find IRQ\n");
1224 clk_unprepare(i2c->clk);
1225 return ret;
1226 diff --git a/drivers/iio/dac/ad5624r_spi.c b/drivers/iio/dac/ad5624r_spi.c
1227 index 5489ec43b95d7..e5cefdb674f80 100644
1228 --- a/drivers/iio/dac/ad5624r_spi.c
1229 +++ b/drivers/iio/dac/ad5624r_spi.c
1230 @@ -231,7 +231,7 @@ static int ad5624r_probe(struct spi_device *spi)
1231 if (!indio_dev)
1232 return -ENOMEM;
1233 st = iio_priv(indio_dev);
1234 - st->reg = devm_regulator_get(&spi->dev, "vcc");
1235 + st->reg = devm_regulator_get_optional(&spi->dev, "vref");
1236 if (!IS_ERR(st->reg)) {
1237 ret = regulator_enable(st->reg);
1238 if (ret)
1239 @@ -242,6 +242,22 @@ static int ad5624r_probe(struct spi_device *spi)
1240 goto error_disable_reg;
1241
1242 voltage_uv = ret;
1243 + } else {
1244 + if (PTR_ERR(st->reg) != -ENODEV)
1245 + return PTR_ERR(st->reg);
1246 + /* Backwards compatibility. This naming is not correct */
1247 + st->reg = devm_regulator_get_optional(&spi->dev, "vcc");
1248 + if (!IS_ERR(st->reg)) {
1249 + ret = regulator_enable(st->reg);
1250 + if (ret)
1251 + return ret;
1252 +
1253 + ret = regulator_get_voltage(st->reg);
1254 + if (ret < 0)
1255 + goto error_disable_reg;
1256 +
1257 + voltage_uv = ret;
1258 + }
1259 }
1260
1261 spi_set_drvdata(spi, indio_dev);
1262 diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
1263 index c799071be66fc..45996c51a3018 100644
1264 --- a/drivers/media/i2c/tc358743.c
1265 +++ b/drivers/media/i2c/tc358743.c
1266 @@ -237,7 +237,7 @@ static void i2c_wr16(struct v4l2_subdev *sd, u16 reg, u16 val)
1267
1268 static void i2c_wr16_and_or(struct v4l2_subdev *sd, u16 reg, u16 mask, u16 val)
1269 {
1270 - i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 2) & mask) | val, 2);
1271 + i2c_wrreg(sd, reg, (i2c_rdreg(sd, reg, 1) & mask) | val, 1);
1272 }
1273
1274 static u32 i2c_rd32(struct v4l2_subdev *sd, u16 reg)
1275 diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c
1276 index 63dace8198b0b..b3810b85e7d5f 100644
1277 --- a/drivers/media/rc/rc-loopback.c
1278 +++ b/drivers/media/rc/rc-loopback.c
1279 @@ -55,7 +55,7 @@ static int loop_set_tx_mask(struct rc_dev *dev, u32 mask)
1280
1281 if ((mask & (RXMASK_REGULAR | RXMASK_LEARNING)) != mask) {
1282 dprintk("invalid tx mask: %u\n", mask);
1283 - return -EINVAL;
1284 + return 2;
1285 }
1286
1287 dprintk("setting tx mask: %u\n", mask);
1288 diff --git a/drivers/media/usb/dvb-usb/nova-t-usb2.c b/drivers/media/usb/dvb-usb/nova-t-usb2.c
1289 index 1babd33419106..016a6d1ad279b 100644
1290 --- a/drivers/media/usb/dvb-usb/nova-t-usb2.c
1291 +++ b/drivers/media/usb/dvb-usb/nova-t-usb2.c
1292 @@ -133,7 +133,7 @@ ret:
1293
1294 static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
1295 {
1296 - int i;
1297 + int i, ret;
1298 u8 b;
1299
1300 mac[0] = 0x00;
1301 @@ -142,7 +142,9 @@ static int nova_t_read_mac_address (struct dvb_usb_device *d, u8 mac[6])
1302
1303 /* this is a complete guess, but works for my box */
1304 for (i = 136; i < 139; i++) {
1305 - dibusb_read_eeprom_byte(d,i, &b);
1306 + ret = dibusb_read_eeprom_byte(d, i, &b);
1307 + if (ret)
1308 + return ret;
1309
1310 mac[5 - (i - 136)] = b;
1311 }
1312 diff --git a/drivers/media/usb/dvb-usb/vp702x.c b/drivers/media/usb/dvb-usb/vp702x.c
1313 index 40de33de90a7a..5c3b0a7ca27e1 100644
1314 --- a/drivers/media/usb/dvb-usb/vp702x.c
1315 +++ b/drivers/media/usb/dvb-usb/vp702x.c
1316 @@ -294,16 +294,22 @@ static int vp702x_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1317 static int vp702x_read_mac_addr(struct dvb_usb_device *d,u8 mac[6])
1318 {
1319 u8 i, *buf;
1320 + int ret;
1321 struct vp702x_device_state *st = d->priv;
1322
1323 mutex_lock(&st->buf_mutex);
1324 buf = st->buf;
1325 - for (i = 6; i < 12; i++)
1326 - vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1, &buf[i - 6], 1);
1327 + for (i = 6; i < 12; i++) {
1328 + ret = vp702x_usb_in_op(d, READ_EEPROM_REQ, i, 1,
1329 + &buf[i - 6], 1);
1330 + if (ret < 0)
1331 + goto err;
1332 + }
1333
1334 memcpy(mac, buf, 6);
1335 +err:
1336 mutex_unlock(&st->buf_mutex);
1337 - return 0;
1338 + return ret;
1339 }
1340
1341 static int vp702x_frontend_attach(struct dvb_usb_adapter *adap)
1342 diff --git a/drivers/media/usb/go7007/go7007-driver.c b/drivers/media/usb/go7007/go7007-driver.c
1343 index 05b1126f263ef..d861d7225f49d 100644
1344 --- a/drivers/media/usb/go7007/go7007-driver.c
1345 +++ b/drivers/media/usb/go7007/go7007-driver.c
1346 @@ -698,49 +698,23 @@ struct go7007 *go7007_alloc(const struct go7007_board_info *board,
1347 struct device *dev)
1348 {
1349 struct go7007 *go;
1350 - int i;
1351
1352 go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
1353 if (go == NULL)
1354 return NULL;
1355 go->dev = dev;
1356 go->board_info = board;
1357 - go->board_id = 0;
1358 go->tuner_type = -1;
1359 - go->channel_number = 0;
1360 - go->name[0] = 0;
1361 mutex_init(&go->hw_lock);
1362 init_waitqueue_head(&go->frame_waitq);
1363 spin_lock_init(&go->spinlock);
1364 go->status = STATUS_INIT;
1365 - memset(&go->i2c_adapter, 0, sizeof(go->i2c_adapter));
1366 - go->i2c_adapter_online = 0;
1367 - go->interrupt_available = 0;
1368 init_waitqueue_head(&go->interrupt_waitq);
1369 - go->input = 0;
1370 go7007_update_board(go);
1371 - go->encoder_h_halve = 0;
1372 - go->encoder_v_halve = 0;
1373 - go->encoder_subsample = 0;
1374 go->format = V4L2_PIX_FMT_MJPEG;
1375 go->bitrate = 1500000;
1376 go->fps_scale = 1;
1377 - go->pali = 0;
1378 go->aspect_ratio = GO7007_RATIO_1_1;
1379 - go->gop_size = 0;
1380 - go->ipb = 0;
1381 - go->closed_gop = 0;
1382 - go->repeat_seqhead = 0;
1383 - go->seq_header_enable = 0;
1384 - go->gop_header_enable = 0;
1385 - go->dvd_mode = 0;
1386 - go->interlace_coding = 0;
1387 - for (i = 0; i < 4; ++i)
1388 - go->modet[i].enable = 0;
1389 - for (i = 0; i < 1624; ++i)
1390 - go->modet_map[i] = 0;
1391 - go->audio_deliver = NULL;
1392 - go->audio_enabled = 0;
1393
1394 return go;
1395 }
1396 diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c
1397 index f9844f87467b4..969a80855518f 100644
1398 --- a/drivers/media/usb/stkwebcam/stk-webcam.c
1399 +++ b/drivers/media/usb/stkwebcam/stk-webcam.c
1400 @@ -1362,7 +1362,7 @@ static int stk_camera_probe(struct usb_interface *interface,
1401 if (!dev->isoc_ep) {
1402 STK_ERROR("Could not find isoc-in endpoint");
1403 err = -ENODEV;
1404 - goto error;
1405 + goto error_put;
1406 }
1407 dev->vsettings.palette = V4L2_PIX_FMT_RGB565;
1408 dev->vsettings.mode = MODE_VGA;
1409 @@ -1375,10 +1375,12 @@ static int stk_camera_probe(struct usb_interface *interface,
1410
1411 err = stk_register_video_device(dev);
1412 if (err)
1413 - goto error;
1414 + goto error_put;
1415
1416 return 0;
1417
1418 +error_put:
1419 + usb_put_intf(interface);
1420 error:
1421 v4l2_ctrl_handler_free(hdl);
1422 v4l2_device_unregister(&dev->v4l2_dev);
1423 diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
1424 index 6a19cf94705b1..4a270f88aa18c 100644
1425 --- a/drivers/media/usb/uvc/uvc_v4l2.c
1426 +++ b/drivers/media/usb/uvc/uvc_v4l2.c
1427 @@ -881,8 +881,8 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
1428 {
1429 struct uvc_fh *handle = fh;
1430 struct uvc_video_chain *chain = handle->chain;
1431 + u8 *buf;
1432 int ret;
1433 - u8 i;
1434
1435 if (chain->selector == NULL ||
1436 (chain->dev->quirks & UVC_QUIRK_IGNORE_SELECTOR_UNIT)) {
1437 @@ -890,22 +890,27 @@ static int uvc_ioctl_g_input(struct file *file, void *fh, unsigned int *input)
1438 return 0;
1439 }
1440
1441 + buf = kmalloc(1, GFP_KERNEL);
1442 + if (!buf)
1443 + return -ENOMEM;
1444 +
1445 ret = uvc_query_ctrl(chain->dev, UVC_GET_CUR, chain->selector->id,
1446 chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1447 - &i, 1);
1448 - if (ret < 0)
1449 - return ret;
1450 + buf, 1);
1451 + if (!ret)
1452 + *input = *buf - 1;
1453
1454 - *input = i - 1;
1455 - return 0;
1456 + kfree(buf);
1457 +
1458 + return ret;
1459 }
1460
1461 static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
1462 {
1463 struct uvc_fh *handle = fh;
1464 struct uvc_video_chain *chain = handle->chain;
1465 + u8 *buf;
1466 int ret;
1467 - u32 i;
1468
1469 ret = uvc_acquire_privileges(handle);
1470 if (ret < 0)
1471 @@ -921,10 +926,17 @@ static int uvc_ioctl_s_input(struct file *file, void *fh, unsigned int input)
1472 if (input >= chain->selector->bNrInPins)
1473 return -EINVAL;
1474
1475 - i = input + 1;
1476 - return uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
1477 - chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1478 - &i, 1);
1479 + buf = kmalloc(1, GFP_KERNEL);
1480 + if (!buf)
1481 + return -ENOMEM;
1482 +
1483 + *buf = input + 1;
1484 + ret = uvc_query_ctrl(chain->dev, UVC_SET_CUR, chain->selector->id,
1485 + chain->dev->intfnum, UVC_SU_INPUT_SELECT_CONTROL,
1486 + buf, 1);
1487 + kfree(buf);
1488 +
1489 + return ret;
1490 }
1491
1492 static int uvc_ioctl_queryctrl(struct file *file, void *fh,
1493 diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
1494 index 2f212bdc187a4..83484c43b1dc6 100644
1495 --- a/drivers/mfd/ab8500-core.c
1496 +++ b/drivers/mfd/ab8500-core.c
1497 @@ -489,7 +489,7 @@ static int ab8500_handle_hierarchical_line(struct ab8500 *ab8500,
1498 if (line == AB8540_INT_GPIO43F || line == AB8540_INT_GPIO44F)
1499 line += 1;
1500
1501 - handle_nested_irq(irq_create_mapping(ab8500->domain, line));
1502 + handle_nested_irq(irq_find_mapping(ab8500->domain, line));
1503 }
1504
1505 return 0;
1506 diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
1507 index b0c7bcdaf5df5..61fb4873c0613 100644
1508 --- a/drivers/mfd/stmpe.c
1509 +++ b/drivers/mfd/stmpe.c
1510 @@ -1033,7 +1033,7 @@ static irqreturn_t stmpe_irq(int irq, void *data)
1511
1512 if (variant->id_val == STMPE801_ID ||
1513 variant->id_val == STMPE1600_ID) {
1514 - int base = irq_create_mapping(stmpe->domain, 0);
1515 + int base = irq_find_mapping(stmpe->domain, 0);
1516
1517 handle_nested_irq(base);
1518 return IRQ_HANDLED;
1519 @@ -1061,7 +1061,7 @@ static irqreturn_t stmpe_irq(int irq, void *data)
1520 while (status) {
1521 int bit = __ffs(status);
1522 int line = bank * 8 + bit;
1523 - int nestedirq = irq_create_mapping(stmpe->domain, line);
1524 + int nestedirq = irq_find_mapping(stmpe->domain, line);
1525
1526 handle_nested_irq(nestedirq);
1527 status &= ~(1 << bit);
1528 diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
1529 index 274bf39968aaa..96187c1e5f8f2 100644
1530 --- a/drivers/mfd/tc3589x.c
1531 +++ b/drivers/mfd/tc3589x.c
1532 @@ -187,7 +187,7 @@ again:
1533
1534 while (status) {
1535 int bit = __ffs(status);
1536 - int virq = irq_create_mapping(tc3589x->domain, bit);
1537 + int virq = irq_find_mapping(tc3589x->domain, bit);
1538
1539 handle_nested_irq(virq);
1540 status &= ~(1 << bit);
1541 diff --git a/drivers/mfd/wm8994-irq.c b/drivers/mfd/wm8994-irq.c
1542 index 18710f3b5c534..2c58d9b99a394 100644
1543 --- a/drivers/mfd/wm8994-irq.c
1544 +++ b/drivers/mfd/wm8994-irq.c
1545 @@ -159,7 +159,7 @@ static irqreturn_t wm8994_edge_irq(int irq, void *data)
1546 struct wm8994 *wm8994 = data;
1547
1548 while (gpio_get_value_cansleep(wm8994->pdata.irq_gpio))
1549 - handle_nested_irq(irq_create_mapping(wm8994->edge_irq, 0));
1550 + handle_nested_irq(irq_find_mapping(wm8994->edge_irq, 0));
1551
1552 return IRQ_HANDLED;
1553 }
1554 diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
1555 index 9c8887d3a4b9c..67863ec9231e8 100644
1556 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
1557 +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
1558 @@ -2344,7 +2344,8 @@ int vmci_qp_broker_map(struct vmci_handle handle,
1559 is_local = entry->qp.flags & VMCI_QPFLAG_LOCAL;
1560 result = VMCI_SUCCESS;
1561
1562 - if (context_id != VMCI_HOST_CONTEXT_ID) {
1563 + if (context_id != VMCI_HOST_CONTEXT_ID &&
1564 + !QPBROKERSTATE_HAS_MEM(entry)) {
1565 struct vmci_qp_page_store page_store;
1566
1567 page_store.pages = guest_mem;
1568 @@ -2454,7 +2455,8 @@ int vmci_qp_broker_unmap(struct vmci_handle handle,
1569
1570 is_local = entry->qp.flags & VMCI_QPFLAG_LOCAL;
1571
1572 - if (context_id != VMCI_HOST_CONTEXT_ID) {
1573 + if (context_id != VMCI_HOST_CONTEXT_ID &&
1574 + QPBROKERSTATE_HAS_MEM(entry)) {
1575 qp_acquire_queue_mutex(entry->produce_q);
1576 result = qp_save_headers(entry);
1577 if (result < VMCI_SUCCESS)
1578 diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
1579 index c6b91efaa9568..209bdf0317b34 100644
1580 --- a/drivers/mmc/host/dw_mmc.c
1581 +++ b/drivers/mmc/host/dw_mmc.c
1582 @@ -762,6 +762,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
1583 int ret = 0;
1584
1585 /* Set external dma config: burst size, burst width */
1586 + memset(&cfg, 0, sizeof(cfg));
1587 cfg.dst_addr = host->phy_regs + fifo_offset;
1588 cfg.src_addr = cfg.dst_addr;
1589 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1590 diff --git a/drivers/mmc/host/moxart-mmc.c b/drivers/mmc/host/moxart-mmc.c
1591 index bbad309679cf8..41a5493cb68d8 100644
1592 --- a/drivers/mmc/host/moxart-mmc.c
1593 +++ b/drivers/mmc/host/moxart-mmc.c
1594 @@ -633,6 +633,7 @@ static int moxart_probe(struct platform_device *pdev)
1595 host->dma_chan_tx, host->dma_chan_rx);
1596 host->have_dma = true;
1597
1598 + memset(&cfg, 0, sizeof(cfg));
1599 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1600 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1601
1602 diff --git a/drivers/mmc/host/rtsx_pci_sdmmc.c b/drivers/mmc/host/rtsx_pci_sdmmc.c
1603 index 3ccaa1415f33b..efd995e3cb0b9 100644
1604 --- a/drivers/mmc/host/rtsx_pci_sdmmc.c
1605 +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c
1606 @@ -552,9 +552,22 @@ static int sd_write_long_data(struct realtek_pci_sdmmc *host,
1607 return 0;
1608 }
1609
1610 +static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
1611 +{
1612 + rtsx_pci_write_register(host->pcr, SD_CFG1,
1613 + SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
1614 +}
1615 +
1616 +static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
1617 +{
1618 + rtsx_pci_write_register(host->pcr, SD_CFG1,
1619 + SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
1620 +}
1621 +
1622 static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
1623 {
1624 struct mmc_data *data = mrq->data;
1625 + int err;
1626
1627 if (host->sg_count < 0) {
1628 data->error = host->sg_count;
1629 @@ -563,22 +576,19 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
1630 return data->error;
1631 }
1632
1633 - if (data->flags & MMC_DATA_READ)
1634 - return sd_read_long_data(host, mrq);
1635 + if (data->flags & MMC_DATA_READ) {
1636 + if (host->initial_mode)
1637 + sd_disable_initial_mode(host);
1638
1639 - return sd_write_long_data(host, mrq);
1640 -}
1641 + err = sd_read_long_data(host, mrq);
1642
1643 -static inline void sd_enable_initial_mode(struct realtek_pci_sdmmc *host)
1644 -{
1645 - rtsx_pci_write_register(host->pcr, SD_CFG1,
1646 - SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_128);
1647 -}
1648 + if (host->initial_mode)
1649 + sd_enable_initial_mode(host);
1650
1651 -static inline void sd_disable_initial_mode(struct realtek_pci_sdmmc *host)
1652 -{
1653 - rtsx_pci_write_register(host->pcr, SD_CFG1,
1654 - SD_CLK_DIVIDE_MASK, SD_CLK_DIVIDE_0);
1655 + return err;
1656 + }
1657 +
1658 + return sd_write_long_data(host, mrq);
1659 }
1660
1661 static void sd_normal_rw(struct realtek_pci_sdmmc *host,
1662 diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
1663 index 45495bc1a70e2..bcae07e60574f 100644
1664 --- a/drivers/mtd/nand/atmel_nand.c
1665 +++ b/drivers/mtd/nand/atmel_nand.c
1666 @@ -2334,7 +2334,6 @@ err_nand_ioremap:
1667 static int atmel_nand_remove(struct platform_device *pdev)
1668 {
1669 struct atmel_nand_host *host = platform_get_drvdata(pdev);
1670 - struct mtd_info *mtd = nand_to_mtd(&host->nand_chip);
1671
1672 nand_release(&host->nand_chip);
1673
1674 diff --git a/drivers/mtd/nand/cafe_nand.c b/drivers/mtd/nand/cafe_nand.c
1675 index c16e740c01c38..894d771c87aab 100644
1676 --- a/drivers/mtd/nand/cafe_nand.c
1677 +++ b/drivers/mtd/nand/cafe_nand.c
1678 @@ -700,7 +700,7 @@ static int cafe_nand_probe(struct pci_dev *pdev,
1679 "CAFE NAND", mtd);
1680 if (err) {
1681 dev_warn(&pdev->dev, "Could not register IRQ %d\n", pdev->irq);
1682 - goto out_ior;
1683 + goto out_free_rs;
1684 }
1685
1686 /* Disable master reset, enable NAND clock */
1687 @@ -808,6 +808,8 @@ static int cafe_nand_probe(struct pci_dev *pdev,
1688 /* Disable NAND IRQ in global IRQ mask register */
1689 cafe_writel(cafe, ~1 & cafe_readl(cafe, GLOBAL_IRQ_MASK), GLOBAL_IRQ_MASK);
1690 free_irq(pdev->irq, mtd);
1691 + out_free_rs:
1692 + free_rs(cafe->rs);
1693 out_ior:
1694 pci_iounmap(pdev, cafe->mmio);
1695 out_free_mtd:
1696 diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c
1697 index b6867a8915dac..4b8f95ecd0561 100644
1698 --- a/drivers/net/dsa/b53/b53_common.c
1699 +++ b/drivers/net/dsa/b53/b53_common.c
1700 @@ -1798,9 +1798,8 @@ static int b53_switch_init(struct b53_device *dev)
1701 dev->cpu_port = 5;
1702 }
1703
1704 - /* cpu port is always last */
1705 - dev->num_ports = dev->cpu_port + 1;
1706 dev->enabled_ports |= BIT(dev->cpu_port);
1707 + dev->num_ports = fls(dev->enabled_ports);
1708
1709 dev->ports = devm_kzalloc(dev->dev,
1710 sizeof(struct b53_port) * dev->num_ports,
1711 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1712 index 545b59ff5d7e7..2f2e60f9b8842 100644
1713 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1714 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
1715 @@ -1241,7 +1241,7 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
1716
1717 /* SR-IOV capability was enabled but there are no VFs*/
1718 if (iov->total == 0) {
1719 - err = -EINVAL;
1720 + err = 0;
1721 goto failed;
1722 }
1723
1724 diff --git a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
1725 index f5f1b0b51ebd2..79eb2257a30e6 100644
1726 --- a/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
1727 +++ b/drivers/net/ethernet/chelsio/cxgb/cxgb2.c
1728 @@ -1133,6 +1133,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1729 if (!adapter->registered_device_map) {
1730 pr_err("%s: could not register any net devices\n",
1731 pci_name(pdev));
1732 + err = -EINVAL;
1733 goto out_release_adapter_res;
1734 }
1735
1736 diff --git a/drivers/net/ethernet/qlogic/qed/qed_main.c b/drivers/net/ethernet/qlogic/qed/qed_main.c
1737 index 708117fc6f733..7669d36151c6e 100644
1738 --- a/drivers/net/ethernet/qlogic/qed/qed_main.c
1739 +++ b/drivers/net/ethernet/qlogic/qed/qed_main.c
1740 @@ -374,7 +374,12 @@ static int qed_enable_msix(struct qed_dev *cdev,
1741 rc = cnt;
1742 }
1743
1744 - if (rc > 0) {
1745 + /* For VFs, we should return with an error in case we didn't get the
1746 + * exact number of msix vectors as we requested.
1747 + * Not doing that will lead to a crash when starting queues for
1748 + * this VF.
1749 + */
1750 + if ((IS_PF(cdev) && rc > 0) || (IS_VF(cdev) && rc == cnt)) {
1751 /* MSI-x configuration was achieved */
1752 int_params->out.int_mode = QED_INT_MODE_MSIX;
1753 int_params->out.num_vectors = rc;
1754 diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c
1755 index 9b1920b58594a..d21a73bc4cde2 100644
1756 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c
1757 +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c
1758 @@ -3145,6 +3145,7 @@ static void qede_sync_free_irqs(struct qede_dev *edev)
1759 }
1760
1761 edev->int_info.used_cnt = 0;
1762 + edev->int_info.msix_cnt = 0;
1763 }
1764
1765 static int qede_req_msix_irqs(struct qede_dev *edev)
1766 @@ -3644,7 +3645,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode)
1767
1768 err4:
1769 qede_sync_free_irqs(edev);
1770 - memset(&edev->int_info.msix_cnt, 0, sizeof(struct qed_int_info));
1771 err3:
1772 qede_napi_disable_remove(edev);
1773 err2:
1774 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
1775 index be41e4c77b657..eff587c6e9be8 100644
1776 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
1777 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_init.c
1778 @@ -440,7 +440,6 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter)
1779 QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c, 1);
1780 msleep(20);
1781
1782 - qlcnic_rom_unlock(adapter);
1783 /* big hammer don't reset CAM block on reset */
1784 QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff);
1785
1786 diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
1787 index 5ef5d728c2505..065a631238632 100644
1788 --- a/drivers/net/ethernet/rdc/r6040.c
1789 +++ b/drivers/net/ethernet/rdc/r6040.c
1790 @@ -133,6 +133,8 @@
1791 #define PHY_ST 0x8A /* PHY status register */
1792 #define MAC_SM 0xAC /* MAC status machine */
1793 #define MAC_SM_RST 0x0002 /* MAC status machine reset */
1794 +#define MD_CSC 0xb6 /* MDC speed control register */
1795 +#define MD_CSC_DEFAULT 0x0030
1796 #define MAC_ID 0xBE /* Identifier register */
1797
1798 #define TX_DCNT 0x80 /* TX descriptor count */
1799 @@ -368,8 +370,9 @@ static void r6040_reset_mac(struct r6040_private *lp)
1800 {
1801 void __iomem *ioaddr = lp->base;
1802 int limit = MAC_DEF_TIMEOUT;
1803 - u16 cmd;
1804 + u16 cmd, md_csc;
1805
1806 + md_csc = ioread16(ioaddr + MD_CSC);
1807 iowrite16(MAC_RST, ioaddr + MCR1);
1808 while (limit--) {
1809 cmd = ioread16(ioaddr + MCR1);
1810 @@ -381,6 +384,10 @@ static void r6040_reset_mac(struct r6040_private *lp)
1811 iowrite16(MAC_SM_RST, ioaddr + MAC_SM);
1812 iowrite16(0, ioaddr + MAC_SM);
1813 mdelay(5);
1814 +
1815 + /* Restore MDIO clock frequency */
1816 + if (md_csc != MD_CSC_DEFAULT)
1817 + iowrite16(md_csc, ioaddr + MD_CSC);
1818 }
1819
1820 static void r6040_init_mac_regs(struct net_device *dev)
1821 diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
1822 index 468f02beccee4..3bfae675b43a4 100644
1823 --- a/drivers/net/ethernet/renesas/sh_eth.c
1824 +++ b/drivers/net/ethernet/renesas/sh_eth.c
1825 @@ -2333,6 +2333,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1826 else
1827 txdesc->status |= cpu_to_le32(TD_TACT);
1828
1829 + wmb(); /* cur_tx must be incremented after TACT bit was set */
1830 mdp->cur_tx++;
1831
1832 if (!(sh_eth_read(ndev, EDTRR) & sh_eth_get_edtrr_trns(mdp)))
1833 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
1834 index f4ff43a1b5ba0..d8c40b68bc96f 100644
1835 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
1836 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
1837 @@ -300,10 +300,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
1838 val &= ~NSS_COMMON_GMAC_CTL_PHY_IFACE_SEL;
1839 break;
1840 default:
1841 - dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
1842 - phy_modes(gmac->phy_mode));
1843 - err = -EINVAL;
1844 - goto err_remove_config_dt;
1845 + goto err_unsupported_phy;
1846 }
1847 regmap_write(gmac->nss_common, NSS_COMMON_GMAC_CTL(gmac->id), val);
1848
1849 @@ -320,10 +317,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
1850 NSS_COMMON_CLK_SRC_CTRL_OFFSET(gmac->id);
1851 break;
1852 default:
1853 - dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
1854 - phy_modes(gmac->phy_mode));
1855 - err = -EINVAL;
1856 - goto err_remove_config_dt;
1857 + goto err_unsupported_phy;
1858 }
1859 regmap_write(gmac->nss_common, NSS_COMMON_CLK_SRC_CTRL, val);
1860
1861 @@ -340,8 +334,7 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
1862 NSS_COMMON_CLK_GATE_GMII_TX_EN(gmac->id);
1863 break;
1864 default:
1865 - /* We don't get here; the switch above will have errored out */
1866 - unreachable();
1867 + goto err_unsupported_phy;
1868 }
1869 regmap_write(gmac->nss_common, NSS_COMMON_CLK_GATE, val);
1870
1871 @@ -372,6 +365,11 @@ static int ipq806x_gmac_probe(struct platform_device *pdev)
1872
1873 return 0;
1874
1875 +err_unsupported_phy:
1876 + dev_err(&pdev->dev, "Unsupported PHY mode: \"%s\"\n",
1877 + phy_modes(gmac->phy_mode));
1878 + err = -EINVAL;
1879 +
1880 err_remove_config_dt:
1881 stmmac_remove_config_dt(pdev, plat_dat);
1882
1883 diff --git a/drivers/net/ethernet/wiznet/w5100.c b/drivers/net/ethernet/wiznet/w5100.c
1884 index d2349a1bc6bae..ae357aecb1ebf 100644
1885 --- a/drivers/net/ethernet/wiznet/w5100.c
1886 +++ b/drivers/net/ethernet/wiznet/w5100.c
1887 @@ -1060,6 +1060,8 @@ static int w5100_mmio_probe(struct platform_device *pdev)
1888 mac_addr = data->mac_addr;
1889
1890 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1891 + if (!mem)
1892 + return -EINVAL;
1893 if (resource_size(mem) < W5100_BUS_DIRECT_SIZE)
1894 ops = &w5100_mmio_indirect_ops;
1895 else
1896 diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
1897 index 9ba36c930ce3b..af9a6a878b233 100644
1898 --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
1899 +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
1900 @@ -735,10 +735,8 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
1901 /* Kick off the transfer */
1902 lp->dma_out(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */
1903
1904 - if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1)) {
1905 - netdev_info(ndev, "%s -> netif_stop_queue\n", __func__);
1906 + if (temac_check_tx_bd_space(lp, MAX_SKB_FRAGS + 1))
1907 netif_stop_queue(ndev);
1908 - }
1909
1910 return NETDEV_TX_OK;
1911 }
1912 diff --git a/drivers/net/phy/dp83640_reg.h b/drivers/net/phy/dp83640_reg.h
1913 index e7fe411170034..f7ad94773d81e 100644
1914 --- a/drivers/net/phy/dp83640_reg.h
1915 +++ b/drivers/net/phy/dp83640_reg.h
1916 @@ -4,7 +4,7 @@
1917 #ifndef HAVE_DP83640_REGISTERS
1918 #define HAVE_DP83640_REGISTERS
1919
1920 -#define PAGE0 0x0000
1921 +/* #define PAGE0 0x0000 */
1922 #define PHYCR2 0x001c /* PHY Control Register 2 */
1923
1924 #define PAGE4 0x0004
1925 diff --git a/drivers/net/usb/cdc_mbim.c b/drivers/net/usb/cdc_mbim.c
1926 index 4c8baba729339..d86132d41416d 100644
1927 --- a/drivers/net/usb/cdc_mbim.c
1928 +++ b/drivers/net/usb/cdc_mbim.c
1929 @@ -647,6 +647,11 @@ static const struct usb_device_id mbim_devs[] = {
1930 .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
1931 },
1932
1933 + /* Telit LN920 */
1934 + { USB_DEVICE_AND_INTERFACE_INFO(0x1bc7, 0x1061, USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
1935 + .driver_info = (unsigned long)&cdc_mbim_info_avoid_altsetting_toggle,
1936 + },
1937 +
1938 /* default entry */
1939 { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MBIM, USB_CDC_PROTO_NONE),
1940 .driver_info = (unsigned long)&cdc_mbim_info_zlp,
1941 diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h
1942 index da7a7c8dafb26..135600405dd09 100644
1943 --- a/drivers/net/wireless/ath/ath.h
1944 +++ b/drivers/net/wireless/ath/ath.h
1945 @@ -199,12 +199,13 @@ struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
1946 bool ath_is_mybeacon(struct ath_common *common, struct ieee80211_hdr *hdr);
1947
1948 void ath_hw_setbssidmask(struct ath_common *common);
1949 -void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key);
1950 +void ath_key_delete(struct ath_common *common, u8 hw_key_idx);
1951 int ath_key_config(struct ath_common *common,
1952 struct ieee80211_vif *vif,
1953 struct ieee80211_sta *sta,
1954 struct ieee80211_key_conf *key);
1955 bool ath_hw_keyreset(struct ath_common *common, u16 entry);
1956 +bool ath_hw_keysetmac(struct ath_common *common, u16 entry, const u8 *mac);
1957 void ath_hw_cycle_counters_update(struct ath_common *common);
1958 int32_t ath_hw_get_listen_time(struct ath_common *common);
1959
1960 diff --git a/drivers/net/wireless/ath/ath5k/mac80211-ops.c b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
1961 index 16e052d02c940..0f4836fc3b7c1 100644
1962 --- a/drivers/net/wireless/ath/ath5k/mac80211-ops.c
1963 +++ b/drivers/net/wireless/ath/ath5k/mac80211-ops.c
1964 @@ -522,7 +522,7 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
1965 }
1966 break;
1967 case DISABLE_KEY:
1968 - ath_key_delete(common, key);
1969 + ath_key_delete(common, key->hw_key_idx);
1970 break;
1971 default:
1972 ret = -EINVAL;
1973 diff --git a/drivers/net/wireless/ath/ath6kl/wmi.c b/drivers/net/wireless/ath/ath6kl/wmi.c
1974 index 73eab12cb3bda..9c2d26b12b699 100644
1975 --- a/drivers/net/wireless/ath/ath6kl/wmi.c
1976 +++ b/drivers/net/wireless/ath/ath6kl/wmi.c
1977 @@ -2513,8 +2513,10 @@ static int ath6kl_wmi_sync_point(struct wmi *wmi, u8 if_idx)
1978 goto free_data_skb;
1979
1980 for (index = 0; index < num_pri_streams; index++) {
1981 - if (WARN_ON(!data_sync_bufs[index].skb))
1982 + if (WARN_ON(!data_sync_bufs[index].skb)) {
1983 + ret = -ENOMEM;
1984 goto free_data_skb;
1985 + }
1986
1987 ep_id = ath6kl_ac2_endpoint_id(wmi->parent_dev,
1988 data_sync_bufs[index].
1989 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1990 index 7eff6f8023d82..969a2a581b0cd 100644
1991 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1992 +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
1993 @@ -3346,7 +3346,8 @@ found:
1994 "Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n",
1995 cptr, code, reference, length, major, minor);
1996 if ((!AR_SREV_9485(ah) && length >= 1024) ||
1997 - (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485)) {
1998 + (AR_SREV_9485(ah) && length > EEPROM_DATA_LEN_9485) ||
1999 + (length > cptr)) {
2000 ath_dbg(common, EEPROM, "Skipping bad header\n");
2001 cptr -= COMP_HDR_LEN;
2002 continue;
2003 diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2004 index a553c91d41a14..7d670a71b7b8b 100644
2005 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2006 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
2007 @@ -1460,7 +1460,7 @@ static int ath9k_htc_set_key(struct ieee80211_hw *hw,
2008 }
2009 break;
2010 case DISABLE_KEY:
2011 - ath_key_delete(common, key);
2012 + ath_key_delete(common, key->hw_key_idx);
2013 break;
2014 default:
2015 ret = -EINVAL;
2016 diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
2017 index 9d664398a41b2..b707c14dab6f7 100644
2018 --- a/drivers/net/wireless/ath/ath9k/hw.c
2019 +++ b/drivers/net/wireless/ath/ath9k/hw.c
2020 @@ -1595,7 +1595,6 @@ static void ath9k_hw_apply_gpio_override(struct ath_hw *ah)
2021 ath9k_hw_gpio_request_out(ah, i, NULL,
2022 AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
2023 ath9k_hw_set_gpio(ah, i, !!(ah->gpio_val & BIT(i)));
2024 - ath9k_hw_gpio_free(ah, i);
2025 }
2026 }
2027
2028 @@ -2702,14 +2701,17 @@ static void ath9k_hw_gpio_cfg_output_mux(struct ath_hw *ah, u32 gpio, u32 type)
2029 static void ath9k_hw_gpio_cfg_soc(struct ath_hw *ah, u32 gpio, bool out,
2030 const char *label)
2031 {
2032 + int err;
2033 +
2034 if (ah->caps.gpio_requested & BIT(gpio))
2035 return;
2036
2037 - /* may be requested by BSP, free anyway */
2038 - gpio_free(gpio);
2039 -
2040 - if (gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label))
2041 + err = gpio_request_one(gpio, out ? GPIOF_OUT_INIT_LOW : GPIOF_IN, label);
2042 + if (err) {
2043 + ath_err(ath9k_hw_common(ah), "request GPIO%d failed:%d\n",
2044 + gpio, err);
2045 return;
2046 + }
2047
2048 ah->caps.gpio_requested |= BIT(gpio);
2049 }
2050 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
2051 index 9cbca1229bac0..eec60abe3b96c 100644
2052 --- a/drivers/net/wireless/ath/ath9k/hw.h
2053 +++ b/drivers/net/wireless/ath/ath9k/hw.h
2054 @@ -815,6 +815,7 @@ struct ath_hw {
2055 struct ath9k_pacal_info pacal_info;
2056 struct ar5416Stats stats;
2057 struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES];
2058 + DECLARE_BITMAP(pending_del_keymap, ATH_KEYMAX);
2059
2060 enum ath9k_int imask;
2061 u32 imrs2_reg;
2062 diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
2063 index 454bf16d6b304..7776f4a8630e4 100644
2064 --- a/drivers/net/wireless/ath/ath9k/main.c
2065 +++ b/drivers/net/wireless/ath/ath9k/main.c
2066 @@ -821,12 +821,80 @@ exit:
2067 ieee80211_free_txskb(hw, skb);
2068 }
2069
2070 +static bool ath9k_txq_list_has_key(struct list_head *txq_list, u32 keyix)
2071 +{
2072 + struct ath_buf *bf;
2073 + struct ieee80211_tx_info *txinfo;
2074 + struct ath_frame_info *fi;
2075 +
2076 + list_for_each_entry(bf, txq_list, list) {
2077 + if (bf->bf_state.stale || !bf->bf_mpdu)
2078 + continue;
2079 +
2080 + txinfo = IEEE80211_SKB_CB(bf->bf_mpdu);
2081 + fi = (struct ath_frame_info *)&txinfo->rate_driver_data[0];
2082 + if (fi->keyix == keyix)
2083 + return true;
2084 + }
2085 +
2086 + return false;
2087 +}
2088 +
2089 +static bool ath9k_txq_has_key(struct ath_softc *sc, u32 keyix)
2090 +{
2091 + struct ath_hw *ah = sc->sc_ah;
2092 + int i;
2093 + struct ath_txq *txq;
2094 + bool key_in_use = false;
2095 +
2096 + for (i = 0; !key_in_use && i < ATH9K_NUM_TX_QUEUES; i++) {
2097 + if (!ATH_TXQ_SETUP(sc, i))
2098 + continue;
2099 + txq = &sc->tx.txq[i];
2100 + if (!txq->axq_depth)
2101 + continue;
2102 + if (!ath9k_hw_numtxpending(ah, txq->axq_qnum))
2103 + continue;
2104 +
2105 + ath_txq_lock(sc, txq);
2106 + key_in_use = ath9k_txq_list_has_key(&txq->axq_q, keyix);
2107 + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) {
2108 + int idx = txq->txq_tailidx;
2109 +
2110 + while (!key_in_use &&
2111 + !list_empty(&txq->txq_fifo[idx])) {
2112 + key_in_use = ath9k_txq_list_has_key(
2113 + &txq->txq_fifo[idx], keyix);
2114 + INCR(idx, ATH_TXFIFO_DEPTH);
2115 + }
2116 + }
2117 + ath_txq_unlock(sc, txq);
2118 + }
2119 +
2120 + return key_in_use;
2121 +}
2122 +
2123 +static void ath9k_pending_key_del(struct ath_softc *sc, u8 keyix)
2124 +{
2125 + struct ath_hw *ah = sc->sc_ah;
2126 + struct ath_common *common = ath9k_hw_common(ah);
2127 +
2128 + if (!test_bit(keyix, ah->pending_del_keymap) ||
2129 + ath9k_txq_has_key(sc, keyix))
2130 + return;
2131 +
2132 + /* No more TXQ frames point to this key cache entry, so delete it. */
2133 + clear_bit(keyix, ah->pending_del_keymap);
2134 + ath_key_delete(common, keyix);
2135 +}
2136 +
2137 static void ath9k_stop(struct ieee80211_hw *hw)
2138 {
2139 struct ath_softc *sc = hw->priv;
2140 struct ath_hw *ah = sc->sc_ah;
2141 struct ath_common *common = ath9k_hw_common(ah);
2142 bool prev_idle;
2143 + int i;
2144
2145 ath9k_deinit_channel_context(sc);
2146
2147 @@ -894,6 +962,14 @@ static void ath9k_stop(struct ieee80211_hw *hw)
2148
2149 spin_unlock_bh(&sc->sc_pcu_lock);
2150
2151 + for (i = 0; i < ATH_KEYMAX; i++)
2152 + ath9k_pending_key_del(sc, i);
2153 +
2154 + /* Clear key cache entries explicitly to get rid of any potentially
2155 + * remaining keys.
2156 + */
2157 + ath9k_cmn_init_crypto(sc->sc_ah);
2158 +
2159 ath9k_ps_restore(sc);
2160
2161 sc->ps_idle = prev_idle;
2162 @@ -1539,12 +1615,11 @@ static void ath9k_del_ps_key(struct ath_softc *sc,
2163 {
2164 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
2165 struct ath_node *an = (struct ath_node *) sta->drv_priv;
2166 - struct ieee80211_key_conf ps_key = { .hw_key_idx = an->ps_key };
2167
2168 if (!an->ps_key)
2169 return;
2170
2171 - ath_key_delete(common, &ps_key);
2172 + ath_key_delete(common, an->ps_key);
2173 an->ps_key = 0;
2174 an->key_idx[0] = 0;
2175 }
2176 @@ -1706,6 +1781,12 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
2177 if (sta)
2178 an = (struct ath_node *)sta->drv_priv;
2179
2180 + /* Delete pending key cache entries if no more frames are pointing to
2181 + * them in TXQs.
2182 + */
2183 + for (i = 0; i < ATH_KEYMAX; i++)
2184 + ath9k_pending_key_del(sc, i);
2185 +
2186 switch (cmd) {
2187 case SET_KEY:
2188 if (sta)
2189 @@ -1735,7 +1816,15 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
2190 }
2191 break;
2192 case DISABLE_KEY:
2193 - ath_key_delete(common, key);
2194 + if (ath9k_txq_has_key(sc, key->hw_key_idx)) {
2195 + /* Delay key cache entry deletion until there are no
2196 + * remaining TXQ frames pointing to this entry.
2197 + */
2198 + set_bit(key->hw_key_idx, sc->sc_ah->pending_del_keymap);
2199 + ath_hw_keysetmac(common, key->hw_key_idx, NULL);
2200 + } else {
2201 + ath_key_delete(common, key->hw_key_idx);
2202 + }
2203 if (an) {
2204 for (i = 0; i < ARRAY_SIZE(an->key_idx); i++) {
2205 if (an->key_idx[i] != key->hw_key_idx)
2206 diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c
2207 index 1816b4e7dc264..61b59a804e308 100644
2208 --- a/drivers/net/wireless/ath/key.c
2209 +++ b/drivers/net/wireless/ath/key.c
2210 @@ -84,8 +84,7 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry)
2211 }
2212 EXPORT_SYMBOL(ath_hw_keyreset);
2213
2214 -static bool ath_hw_keysetmac(struct ath_common *common,
2215 - u16 entry, const u8 *mac)
2216 +bool ath_hw_keysetmac(struct ath_common *common, u16 entry, const u8 *mac)
2217 {
2218 u32 macHi, macLo;
2219 u32 unicast_flag = AR_KEYTABLE_VALID;
2220 @@ -125,6 +124,7 @@ static bool ath_hw_keysetmac(struct ath_common *common,
2221
2222 return true;
2223 }
2224 +EXPORT_SYMBOL(ath_hw_keysetmac);
2225
2226 static bool ath_hw_set_keycache_entry(struct ath_common *common, u16 entry,
2227 const struct ath_keyval *k,
2228 @@ -581,29 +581,38 @@ EXPORT_SYMBOL(ath_key_config);
2229 /*
2230 * Delete Key.
2231 */
2232 -void ath_key_delete(struct ath_common *common, struct ieee80211_key_conf *key)
2233 +void ath_key_delete(struct ath_common *common, u8 hw_key_idx)
2234 {
2235 - ath_hw_keyreset(common, key->hw_key_idx);
2236 - if (key->hw_key_idx < IEEE80211_WEP_NKID)
2237 + /* Leave CCMP and TKIP (main key) configured to avoid disabling
2238 + * encryption for potentially pending frames already in a TXQ with the
2239 + * keyix pointing to this key entry. Instead, only clear the MAC address
2240 + * to prevent RX processing from using this key cache entry.
2241 + */
2242 + if (test_bit(hw_key_idx, common->ccmp_keymap) ||
2243 + test_bit(hw_key_idx, common->tkip_keymap))
2244 + ath_hw_keysetmac(common, hw_key_idx, NULL);
2245 + else
2246 + ath_hw_keyreset(common, hw_key_idx);
2247 + if (hw_key_idx < IEEE80211_WEP_NKID)
2248 return;
2249
2250 - clear_bit(key->hw_key_idx, common->keymap);
2251 - clear_bit(key->hw_key_idx, common->ccmp_keymap);
2252 - if (key->cipher != WLAN_CIPHER_SUITE_TKIP)
2253 + clear_bit(hw_key_idx, common->keymap);
2254 + clear_bit(hw_key_idx, common->ccmp_keymap);
2255 + if (!test_bit(hw_key_idx, common->tkip_keymap))
2256 return;
2257
2258 - clear_bit(key->hw_key_idx + 64, common->keymap);
2259 + clear_bit(hw_key_idx + 64, common->keymap);
2260
2261 - clear_bit(key->hw_key_idx, common->tkip_keymap);
2262 - clear_bit(key->hw_key_idx + 64, common->tkip_keymap);
2263 + clear_bit(hw_key_idx, common->tkip_keymap);
2264 + clear_bit(hw_key_idx + 64, common->tkip_keymap);
2265
2266 if (!(common->crypt_caps & ATH_CRYPT_CAP_MIC_COMBINED)) {
2267 - ath_hw_keyreset(common, key->hw_key_idx + 32);
2268 - clear_bit(key->hw_key_idx + 32, common->keymap);
2269 - clear_bit(key->hw_key_idx + 64 + 32, common->keymap);
2270 + ath_hw_keyreset(common, hw_key_idx + 32);
2271 + clear_bit(hw_key_idx + 32, common->keymap);
2272 + clear_bit(hw_key_idx + 64 + 32, common->keymap);
2273
2274 - clear_bit(key->hw_key_idx + 32, common->tkip_keymap);
2275 - clear_bit(key->hw_key_idx + 64 + 32, common->tkip_keymap);
2276 + clear_bit(hw_key_idx + 32, common->tkip_keymap);
2277 + clear_bit(hw_key_idx + 64 + 32, common->tkip_keymap);
2278 }
2279 }
2280 EXPORT_SYMBOL(ath_key_delete);
2281 diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
2282 index e2bce9385eda6..c87f27d3ee31f 100644
2283 --- a/drivers/nvme/host/pci.c
2284 +++ b/drivers/nvme/host/pci.c
2285 @@ -1927,7 +1927,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2286
2287 result = nvme_dev_map(dev);
2288 if (result)
2289 - goto free;
2290 + goto put_pci;
2291
2292 INIT_WORK(&dev->reset_work, nvme_reset_work);
2293 INIT_WORK(&dev->remove_work, nvme_remove_dead_ctrl_work);
2294 @@ -1938,7 +1938,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2295
2296 result = nvme_setup_prp_pools(dev);
2297 if (result)
2298 - goto put_pci;
2299 + goto unmap;
2300
2301 result = nvme_init_ctrl(&dev->ctrl, &pdev->dev, &nvme_pci_ctrl_ops,
2302 id->driver_data);
2303 @@ -1953,9 +1953,10 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2304
2305 release_pools:
2306 nvme_release_prp_pools(dev);
2307 + unmap:
2308 + nvme_dev_unmap(dev);
2309 put_pci:
2310 put_device(dev->dev);
2311 - nvme_dev_unmap(dev);
2312 free:
2313 kfree(dev->queues);
2314 kfree(dev);
2315 diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c
2316 index 2e21af43d91ea..b6d808037045d 100644
2317 --- a/drivers/parport/ieee1284_ops.c
2318 +++ b/drivers/parport/ieee1284_ops.c
2319 @@ -534,7 +534,7 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port,
2320 goto out;
2321
2322 /* Yield the port for a while. */
2323 - if (count && dev->port->irq != PARPORT_IRQ_NONE) {
2324 + if (dev->port->irq != PARPORT_IRQ_NONE) {
2325 parport_release (dev);
2326 schedule_timeout_interruptible(msecs_to_jiffies(40));
2327 parport_claim_or_block (dev);
2328 diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
2329 index 77810f4240492..97c3515e3b543 100644
2330 --- a/drivers/pci/msi.c
2331 +++ b/drivers/pci/msi.c
2332 @@ -777,6 +777,9 @@ static void msix_mask_all(void __iomem *base, int tsize)
2333 u32 ctrl = PCI_MSIX_ENTRY_CTRL_MASKBIT;
2334 int i;
2335
2336 + if (pci_msi_ignore_mask)
2337 + return;
2338 +
2339 for (i = 0; i < tsize; i++, base += PCI_MSIX_ENTRY_SIZE)
2340 writel(ctrl, base + PCI_MSIX_ENTRY_VECTOR_CTRL);
2341 }
2342 diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
2343 index e09653c73ab4b..2cf13578fe754 100644
2344 --- a/drivers/pci/pci.c
2345 +++ b/drivers/pci/pci.c
2346 @@ -1384,11 +1384,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
2347 * so that things like MSI message writing will behave as expected
2348 * (e.g. if the device really is in D0 at enable time).
2349 */
2350 - if (dev->pm_cap) {
2351 - u16 pmcsr;
2352 - pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
2353 - dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
2354 - }
2355 + pci_update_current_state(dev, dev->current_state);
2356
2357 if (atomic_inc_return(&dev->enable_cnt) > 1)
2358 return 0; /* already enabled */
2359 @@ -1926,7 +1922,14 @@ int __pci_enable_wake(struct pci_dev *dev, pci_power_t state,
2360 if (enable) {
2361 int error;
2362
2363 - if (pci_pme_capable(dev, state))
2364 + /*
2365 + * Enable PME signaling if the device can signal PME from
2366 + * D3cold regardless of whether or not it can signal PME from
2367 + * the current target state, because that will allow it to
2368 + * signal PME when the hierarchy above it goes into D3cold and
2369 + * the device itself ends up in D3cold as a result of that.
2370 + */
2371 + if (pci_pme_capable(dev, state) || pci_pme_capable(dev, PCI_D3cold))
2372 pci_pme_active(dev, true);
2373 else
2374 ret = 1;
2375 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2376 index 096ba11ac1058..66e5bb7bfb67b 100644
2377 --- a/drivers/pci/quirks.c
2378 +++ b/drivers/pci/quirks.c
2379 @@ -2994,12 +2994,13 @@ static void fixup_mpss_256(struct pci_dev *dev)
2380 {
2381 dev->pcie_mpss = 1; /* 256 bytes */
2382 }
2383 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2384 - PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
2385 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2386 - PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
2387 -DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SOLARFLARE,
2388 - PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
2389 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2390 + PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0, fixup_mpss_256);
2391 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2392 + PCI_DEVICE_ID_SOLARFLARE_SFC4000A_1, fixup_mpss_256);
2393 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SOLARFLARE,
2394 + PCI_DEVICE_ID_SOLARFLARE_SFC4000B, fixup_mpss_256);
2395 +DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ASMEDIA, 0x0612, fixup_mpss_256);
2396
2397 /* Intel 5000 and 5100 Memory controllers have an errata with read completion
2398 * coalescing (which is enabled by default on some BIOSes) and MPS of 256B.
2399 diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c
2400 index 7958250856d36..f602176eb8b04 100644
2401 --- a/drivers/pci/syscall.c
2402 +++ b/drivers/pci/syscall.c
2403 @@ -23,8 +23,10 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
2404 long err;
2405 int cfg_ret;
2406
2407 + err = -EPERM;
2408 + dev = NULL;
2409 if (!capable(CAP_SYS_ADMIN))
2410 - return -EPERM;
2411 + goto error;
2412
2413 err = -ENODEV;
2414 dev = pci_get_bus_and_slot(bus, dfn);
2415 diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
2416 index 8769a579ecb13..01f42090cd036 100644
2417 --- a/drivers/pinctrl/pinctrl-single.c
2418 +++ b/drivers/pinctrl/pinctrl-single.c
2419 @@ -1335,6 +1335,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
2420
2421 if (PCS_HAS_PINCONF) {
2422 dev_err(pcs->dev, "pinconf not supported\n");
2423 + res = -ENOTSUPP;
2424 goto free_pingroups;
2425 }
2426
2427 diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c
2428 index d225a835a64cf..c1879e40d7187 100644
2429 --- a/drivers/platform/chrome/cros_ec_proto.c
2430 +++ b/drivers/platform/chrome/cros_ec_proto.c
2431 @@ -183,6 +183,15 @@ static int cros_ec_host_command_proto_query(struct cros_ec_device *ec_dev,
2432 msg->insize = sizeof(struct ec_response_get_protocol_info);
2433
2434 ret = send_command(ec_dev, msg);
2435 + /*
2436 + * Send command once again when timeout occurred.
2437 + * Fingerprint MCU (FPMCU) is restarted during system boot which
2438 + * introduces small window in which FPMCU won't respond for any
2439 + * messages sent by kernel. There is no need to wait before next
2440 + * attempt because we waited at least EC_MSG_DEADLINE_MS.
2441 + */
2442 + if (ret == -ETIMEDOUT)
2443 + ret = send_command(ec_dev, msg);
2444
2445 if (ret < 0) {
2446 dev_dbg(ec_dev->dev,
2447 diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
2448 index 089056cb8e73a..85e6c9bacf067 100644
2449 --- a/drivers/power/supply/axp288_fuel_gauge.c
2450 +++ b/drivers/power/supply/axp288_fuel_gauge.c
2451 @@ -169,7 +169,7 @@ static int fuel_gauge_reg_readb(struct axp288_fg_info *info, int reg)
2452 }
2453
2454 if (ret < 0) {
2455 - dev_err(&info->pdev->dev, "axp288 reg read err:%d\n", ret);
2456 + dev_err(&info->pdev->dev, "Error reading reg 0x%02x err: %d\n", reg, ret);
2457 return ret;
2458 }
2459
2460 @@ -183,7 +183,7 @@ static int fuel_gauge_reg_writeb(struct axp288_fg_info *info, int reg, u8 val)
2461 ret = regmap_write(info->regmap, reg, (unsigned int)val);
2462
2463 if (ret < 0)
2464 - dev_err(&info->pdev->dev, "axp288 reg write err:%d\n", ret);
2465 + dev_err(&info->pdev->dev, "Error writing reg 0x%02x err: %d\n", reg, ret);
2466
2467 return ret;
2468 }
2469 diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c
2470 index da7a75f824891..f18d845b3b92d 100644
2471 --- a/drivers/power/supply/max17042_battery.c
2472 +++ b/drivers/power/supply/max17042_battery.c
2473 @@ -644,7 +644,7 @@ static inline void max17042_override_por_values(struct max17042_chip *chip)
2474 struct max17042_config_data *config = chip->pdata->config_data;
2475
2476 max17042_override_por(map, MAX17042_TGAIN, config->tgain);
2477 - max17042_override_por(map, MAx17042_TOFF, config->toff);
2478 + max17042_override_por(map, MAX17042_TOFF, config->toff);
2479 max17042_override_por(map, MAX17042_CGAIN, config->cgain);
2480 max17042_override_por(map, MAX17042_COFF, config->coff);
2481
2482 @@ -760,8 +760,12 @@ static irqreturn_t max17042_thread_handler(int id, void *dev)
2483 {
2484 struct max17042_chip *chip = dev;
2485 u32 val;
2486 + int ret;
2487 +
2488 + ret = regmap_read(chip->regmap, MAX17042_STATUS, &val);
2489 + if (ret)
2490 + return IRQ_HANDLED;
2491
2492 - regmap_read(chip->regmap, MAX17042_STATUS, &val);
2493 if ((val & STATUS_INTR_SOCMIN_BIT) ||
2494 (val & STATUS_INTR_SOCMAX_BIT)) {
2495 dev_info(&chip->client->dev, "SOC threshold INTR\n");
2496 diff --git a/drivers/rtc/rtc-tps65910.c b/drivers/rtc/rtc-tps65910.c
2497 index 5a3d53caa485f..74ddd2ab3fced 100644
2498 --- a/drivers/rtc/rtc-tps65910.c
2499 +++ b/drivers/rtc/rtc-tps65910.c
2500 @@ -332,6 +332,6 @@ static struct platform_driver tps65910_rtc_driver = {
2501 };
2502
2503 module_platform_driver(tps65910_rtc_driver);
2504 -MODULE_ALIAS("platform:rtc-tps65910");
2505 +MODULE_ALIAS("platform:tps65910-rtc");
2506 MODULE_AUTHOR("Venu Byravarasu <vbyravarasu@nvidia.com>");
2507 MODULE_LICENSE("GPL");
2508 diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
2509 index b9b4491d732ab..72a66f1130174 100644
2510 --- a/drivers/scsi/BusLogic.c
2511 +++ b/drivers/scsi/BusLogic.c
2512 @@ -3597,7 +3597,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
2513 if (buf[0] != '\n' || len > 1)
2514 printk("%sscsi%d: %s", blogic_msglevelmap[msglevel], adapter->host_no, buf);
2515 } else
2516 - printk("%s", buf);
2517 + pr_cont("%s", buf);
2518 } else {
2519 if (begin) {
2520 if (adapter != NULL && adapter->adapter_initd)
2521 @@ -3605,7 +3605,7 @@ static void blogic_msg(enum blogic_msglevel msglevel, char *fmt,
2522 else
2523 printk("%s%s", blogic_msglevelmap[msglevel], buf);
2524 } else
2525 - printk("%s", buf);
2526 + pr_cont("%s", buf);
2527 }
2528 begin = (buf[len - 1] == '\n');
2529 }
2530 diff --git a/drivers/soc/qcom/smsm.c b/drivers/soc/qcom/smsm.c
2531 index d0337b2a71c81..783cb3364599b 100644
2532 --- a/drivers/soc/qcom/smsm.c
2533 +++ b/drivers/soc/qcom/smsm.c
2534 @@ -117,7 +117,7 @@ struct smsm_entry {
2535 DECLARE_BITMAP(irq_enabled, 32);
2536 DECLARE_BITMAP(irq_rising, 32);
2537 DECLARE_BITMAP(irq_falling, 32);
2538 - u32 last_value;
2539 + unsigned long last_value;
2540
2541 u32 *remote_state;
2542 u32 *subscription;
2543 @@ -212,8 +212,7 @@ static irqreturn_t smsm_intr(int irq, void *data)
2544 u32 val;
2545
2546 val = readl(entry->remote_state);
2547 - changed = val ^ entry->last_value;
2548 - entry->last_value = val;
2549 + changed = val ^ xchg(&entry->last_value, val);
2550
2551 for_each_set_bit(i, entry->irq_enabled, 32) {
2552 if (!(changed & BIT(i)))
2553 @@ -274,6 +273,12 @@ static void smsm_unmask_irq(struct irq_data *irqd)
2554 struct qcom_smsm *smsm = entry->smsm;
2555 u32 val;
2556
2557 + /* Make sure our last cached state is up-to-date */
2558 + if (readl(entry->remote_state) & BIT(irq))
2559 + set_bit(irq, &entry->last_value);
2560 + else
2561 + clear_bit(irq, &entry->last_value);
2562 +
2563 set_bit(irq, entry->irq_enabled);
2564
2565 if (entry->subscription) {
2566 diff --git a/drivers/spi/spi-pic32.c b/drivers/spi/spi-pic32.c
2567 index 9a97ad973c416..021dddf484e5b 100644
2568 --- a/drivers/spi/spi-pic32.c
2569 +++ b/drivers/spi/spi-pic32.c
2570 @@ -369,6 +369,7 @@ static int pic32_spi_dma_config(struct pic32_spi *pic32s, u32 dma_width)
2571 struct dma_slave_config cfg;
2572 int ret;
2573
2574 + memset(&cfg, 0, sizeof(cfg));
2575 cfg.device_fc = true;
2576 cfg.src_addr = pic32s->dma_base + buf_offset;
2577 cfg.dst_addr = pic32s->dma_base + buf_offset;
2578 diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
2579 index 86dc411016105..1e2b33912a8a4 100644
2580 --- a/drivers/staging/board/board.c
2581 +++ b/drivers/staging/board/board.c
2582 @@ -139,6 +139,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc)
2583 static int board_staging_add_dev_domain(struct platform_device *pdev,
2584 const char *domain)
2585 {
2586 + struct device *dev = &pdev->dev;
2587 struct of_phandle_args pd_args;
2588 struct device_node *np;
2589
2590 @@ -151,7 +152,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev,
2591 pd_args.np = np;
2592 pd_args.args_count = 0;
2593
2594 - return of_genpd_add_device(&pd_args, &pdev->dev);
2595 + /* Initialization similar to device_pm_init_common() */
2596 + spin_lock_init(&dev->power.lock);
2597 + dev->power.early_init = true;
2598 +
2599 + return of_genpd_add_device(&pd_args, dev);
2600 }
2601 #else
2602 static inline int board_staging_add_dev_domain(struct platform_device *pdev,
2603 diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
2604 index 81c46f4d0935a..16d2036018e27 100644
2605 --- a/drivers/staging/ks7010/ks7010_sdio.c
2606 +++ b/drivers/staging/ks7010/ks7010_sdio.c
2607 @@ -1037,9 +1037,9 @@ static int ks7010_sdio_probe(struct sdio_func *func,
2608 memset(&priv->wstats, 0, sizeof(priv->wstats));
2609
2610 /* sleep mode */
2611 + atomic_set(&priv->sleepstatus.status, 0);
2612 atomic_set(&priv->sleepstatus.doze_request, 0);
2613 atomic_set(&priv->sleepstatus.wakeup_request, 0);
2614 - atomic_set(&priv->sleepstatus.wakeup_request, 0);
2615
2616 trx_device_init(priv);
2617 hostif_init(priv);
2618 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
2619 index 96ce6bd1cc6f6..4b6f93067ae49 100644
2620 --- a/drivers/tty/hvc/hvsi.c
2621 +++ b/drivers/tty/hvc/hvsi.c
2622 @@ -1051,7 +1051,7 @@ static const struct tty_operations hvsi_ops = {
2623
2624 static int __init hvsi_init(void)
2625 {
2626 - int i;
2627 + int i, ret;
2628
2629 hvsi_driver = alloc_tty_driver(hvsi_count);
2630 if (!hvsi_driver)
2631 @@ -1082,12 +1082,25 @@ static int __init hvsi_init(void)
2632 }
2633 hvsi_wait = wait_for_state; /* irqs active now */
2634
2635 - if (tty_register_driver(hvsi_driver))
2636 - panic("Couldn't register hvsi console driver\n");
2637 + ret = tty_register_driver(hvsi_driver);
2638 + if (ret) {
2639 + pr_err("Couldn't register hvsi console driver\n");
2640 + goto err_free_irq;
2641 + }
2642
2643 printk(KERN_DEBUG "HVSI: registered %i devices\n", hvsi_count);
2644
2645 return 0;
2646 +err_free_irq:
2647 + hvsi_wait = poll_for_state;
2648 + for (i = 0; i < hvsi_count; i++) {
2649 + struct hvsi_struct *hp = &hvsi_ports[i];
2650 +
2651 + free_irq(hp->virq, hp);
2652 + }
2653 + tty_driver_kref_put(hvsi_driver);
2654 +
2655 + return ret;
2656 }
2657 device_initcall(hvsi_init);
2658
2659 diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
2660 index a9c46e10d204c..550f2f0523d84 100644
2661 --- a/drivers/tty/serial/8250/8250_pci.c
2662 +++ b/drivers/tty/serial/8250/8250_pci.c
2663 @@ -73,7 +73,7 @@ static void moan_device(const char *str, struct pci_dev *dev)
2664
2665 static int
2666 setup_port(struct serial_private *priv, struct uart_8250_port *port,
2667 - int bar, int offset, int regshift)
2668 + u8 bar, unsigned int offset, int regshift)
2669 {
2670 struct pci_dev *dev = priv->dev;
2671
2672 diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
2673 index 611bc05565719..460c35b2b54d9 100644
2674 --- a/drivers/tty/serial/8250/8250_port.c
2675 +++ b/drivers/tty/serial/8250/8250_port.c
2676 @@ -125,7 +125,8 @@ static const struct serial8250_config uart_config[] = {
2677 .name = "16C950/954",
2678 .fifo_size = 128,
2679 .tx_loadsz = 128,
2680 - .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
2681 + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01,
2682 + .rxtrig_bytes = {16, 32, 112, 120},
2683 /* UART_CAP_EFR breaks billionon CF bluetooth card. */
2684 .flags = UART_CAP_FIFO | UART_CAP_SLEEP,
2685 },
2686 diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
2687 index c6fdd6369534c..96e01bf4599c9 100644
2688 --- a/drivers/tty/serial/jsm/jsm_neo.c
2689 +++ b/drivers/tty/serial/jsm/jsm_neo.c
2690 @@ -827,7 +827,9 @@ static void neo_parse_isr(struct jsm_board *brd, u32 port)
2691 /* Parse any modem signal changes */
2692 jsm_dbg(INTR, &ch->ch_bd->pci_dev,
2693 "MOD_STAT: sending to parse_modem_sigs\n");
2694 + spin_lock_irqsave(&ch->uart_port.lock, lock_flags);
2695 neo_parse_modem(ch, readb(&ch->ch_neo_uart->msr));
2696 + spin_unlock_irqrestore(&ch->uart_port.lock, lock_flags);
2697 }
2698 }
2699
2700 diff --git a/drivers/tty/serial/jsm/jsm_tty.c b/drivers/tty/serial/jsm/jsm_tty.c
2701 index ec7d8383900fc..7c790ff6b5116 100644
2702 --- a/drivers/tty/serial/jsm/jsm_tty.c
2703 +++ b/drivers/tty/serial/jsm/jsm_tty.c
2704 @@ -195,6 +195,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)
2705
2706 static int jsm_tty_open(struct uart_port *port)
2707 {
2708 + unsigned long lock_flags;
2709 struct jsm_board *brd;
2710 struct jsm_channel *channel =
2711 container_of(port, struct jsm_channel, uart_port);
2712 @@ -248,6 +249,7 @@ static int jsm_tty_open(struct uart_port *port)
2713 channel->ch_cached_lsr = 0;
2714 channel->ch_stops_sent = 0;
2715
2716 + spin_lock_irqsave(&port->lock, lock_flags);
2717 termios = &port->state->port.tty->termios;
2718 channel->ch_c_cflag = termios->c_cflag;
2719 channel->ch_c_iflag = termios->c_iflag;
2720 @@ -267,6 +269,7 @@ static int jsm_tty_open(struct uart_port *port)
2721 jsm_carrier(channel);
2722
2723 channel->ch_open_count++;
2724 + spin_unlock_irqrestore(&port->lock, lock_flags);
2725
2726 jsm_dbg(OPEN, &channel->ch_bd->pci_dev, "finish\n");
2727 return 0;
2728 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
2729 index e16a74b68cd0f..f755bfbe0f3bf 100644
2730 --- a/drivers/tty/tty_io.c
2731 +++ b/drivers/tty/tty_io.c
2732 @@ -2312,8 +2312,6 @@ static int tty_fasync(int fd, struct file *filp, int on)
2733 * Locking:
2734 * Called functions take tty_ldiscs_lock
2735 * current->signal->tty check is safe without locks
2736 - *
2737 - * FIXME: may race normal receive processing
2738 */
2739
2740 static int tiocsti(struct tty_struct *tty, char __user *p)
2741 @@ -2329,8 +2327,10 @@ static int tiocsti(struct tty_struct *tty, char __user *p)
2742 ld = tty_ldisc_ref_wait(tty);
2743 if (!ld)
2744 return -EIO;
2745 + tty_buffer_lock_exclusive(tty->port);
2746 if (ld->ops->receive_buf)
2747 ld->ops->receive_buf(tty, &ch, &mbz, 1);
2748 + tty_buffer_unlock_exclusive(tty->port);
2749 tty_ldisc_deref(ld);
2750 return 0;
2751 }
2752 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
2753 index f33635ab967f7..438efa36552c8 100644
2754 --- a/drivers/usb/gadget/composite.c
2755 +++ b/drivers/usb/gadget/composite.c
2756 @@ -481,7 +481,7 @@ static u8 encode_bMaxPower(enum usb_device_speed speed,
2757 {
2758 unsigned val;
2759
2760 - if (c->MaxPower)
2761 + if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
2762 val = c->MaxPower;
2763 else
2764 val = CONFIG_USB_GADGET_VBUS_DRAW;
2765 @@ -886,7 +886,11 @@ static int set_config(struct usb_composite_dev *cdev,
2766 }
2767
2768 /* when we return, be sure our power usage is valid */
2769 - power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW;
2770 + if (c->MaxPower || (c->bmAttributes & USB_CONFIG_ATT_SELFPOWER))
2771 + power = c->MaxPower;
2772 + else
2773 + power = CONFIG_USB_GADGET_VBUS_DRAW;
2774 +
2775 if (gadget->speed < USB_SPEED_SUPER)
2776 power = min(power, 500U);
2777 else
2778 diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
2779 index 589d1f5fb575a..5d72872310e72 100644
2780 --- a/drivers/usb/gadget/function/u_ether.c
2781 +++ b/drivers/usb/gadget/function/u_ether.c
2782 @@ -499,8 +499,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
2783 }
2784 spin_unlock_irqrestore(&dev->lock, flags);
2785
2786 - if (skb && !in) {
2787 - dev_kfree_skb_any(skb);
2788 + if (!in) {
2789 + if (skb)
2790 + dev_kfree_skb_any(skb);
2791 return NETDEV_TX_OK;
2792 }
2793
2794 diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c
2795 index 8bc78418d40e4..cd92cda03d710 100644
2796 --- a/drivers/usb/gadget/udc/at91_udc.c
2797 +++ b/drivers/usb/gadget/udc/at91_udc.c
2798 @@ -1895,7 +1895,9 @@ static int at91udc_probe(struct platform_device *pdev)
2799 clk_disable(udc->iclk);
2800
2801 /* request UDC and maybe VBUS irqs */
2802 - udc->udp_irq = platform_get_irq(pdev, 0);
2803 + udc->udp_irq = retval = platform_get_irq(pdev, 0);
2804 + if (retval < 0)
2805 + goto err_unprepare_iclk;
2806 retval = devm_request_irq(dev, udc->udp_irq, at91_udc_irq, 0,
2807 driver_name, udc);
2808 if (retval) {
2809 diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c
2810 index b9e19a5913224..d75c6449616bd 100644
2811 --- a/drivers/usb/gadget/udc/mv_u3d_core.c
2812 +++ b/drivers/usb/gadget/udc/mv_u3d_core.c
2813 @@ -1912,14 +1912,6 @@ static int mv_u3d_probe(struct platform_device *dev)
2814 goto err_get_irq;
2815 }
2816 u3d->irq = r->start;
2817 - if (request_irq(u3d->irq, mv_u3d_irq,
2818 - IRQF_SHARED, driver_name, u3d)) {
2819 - u3d->irq = 0;
2820 - dev_err(&dev->dev, "Request irq %d for u3d failed\n",
2821 - u3d->irq);
2822 - retval = -ENODEV;
2823 - goto err_request_irq;
2824 - }
2825
2826 /* initialize gadget structure */
2827 u3d->gadget.ops = &mv_u3d_ops; /* usb_gadget_ops */
2828 @@ -1932,6 +1924,15 @@ static int mv_u3d_probe(struct platform_device *dev)
2829
2830 mv_u3d_eps_init(u3d);
2831
2832 + if (request_irq(u3d->irq, mv_u3d_irq,
2833 + IRQF_SHARED, driver_name, u3d)) {
2834 + u3d->irq = 0;
2835 + dev_err(&dev->dev, "Request irq %d for u3d failed\n",
2836 + u3d->irq);
2837 + retval = -ENODEV;
2838 + goto err_request_irq;
2839 + }
2840 +
2841 /* external vbus detection */
2842 if (u3d->vbus) {
2843 u3d->clock_gating = 1;
2844 @@ -1955,8 +1956,8 @@ static int mv_u3d_probe(struct platform_device *dev)
2845
2846 err_unregister:
2847 free_irq(u3d->irq, u3d);
2848 -err_request_irq:
2849 err_get_irq:
2850 +err_request_irq:
2851 kfree(u3d->status_req);
2852 err_alloc_status_req:
2853 kfree(u3d->eps);
2854 diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
2855 index ee8d5faa01947..3eecf47d4e89b 100644
2856 --- a/drivers/usb/host/ehci-orion.c
2857 +++ b/drivers/usb/host/ehci-orion.c
2858 @@ -218,8 +218,11 @@ static int ehci_orion_drv_probe(struct platform_device *pdev)
2859 * the clock does not exists.
2860 */
2861 priv->clk = devm_clk_get(&pdev->dev, NULL);
2862 - if (!IS_ERR(priv->clk))
2863 - clk_prepare_enable(priv->clk);
2864 + if (!IS_ERR(priv->clk)) {
2865 + err = clk_prepare_enable(priv->clk);
2866 + if (err)
2867 + goto err_put_hcd;
2868 + }
2869
2870 priv->phy = devm_phy_optional_get(&pdev->dev, "usb");
2871 if (IS_ERR(priv->phy)) {
2872 @@ -280,6 +283,7 @@ err_phy_init:
2873 err_phy_get:
2874 if (!IS_ERR(priv->clk))
2875 clk_disable_unprepare(priv->clk);
2876 +err_put_hcd:
2877 usb_put_hcd(hcd);
2878 err:
2879 dev_err(&pdev->dev, "init %s fail, %d\n",
2880 diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
2881 index 15249e664b89e..f0ec538a8813b 100644
2882 --- a/drivers/usb/host/fotg210-hcd.c
2883 +++ b/drivers/usb/host/fotg210-hcd.c
2884 @@ -2537,11 +2537,6 @@ retry_xacterr:
2885 return count;
2886 }
2887
2888 -/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
2889 -#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
2890 -/* ... and packet size, for any kind of endpoint descriptor */
2891 -#define max_packet(wMaxPacketSize) ((wMaxPacketSize) & 0x07ff)
2892 -
2893 /* reverse of qh_urb_transaction: free a list of TDs.
2894 * used for cleanup after errors, before HC sees an URB's TDs.
2895 */
2896 @@ -2627,7 +2622,7 @@ static struct list_head *qh_urb_transaction(struct fotg210_hcd *fotg210,
2897 token |= (1 /* "in" */ << 8);
2898 /* else it's already initted to "out" pid (0 << 8) */
2899
2900 - maxpacket = max_packet(usb_maxpacket(urb->dev, urb->pipe, !is_input));
2901 + maxpacket = usb_maxpacket(urb->dev, urb->pipe, !is_input);
2902
2903 /*
2904 * buffer gets wrapped in one or more qtds;
2905 @@ -2741,9 +2736,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
2906 gfp_t flags)
2907 {
2908 struct fotg210_qh *qh = fotg210_qh_alloc(fotg210, flags);
2909 + struct usb_host_endpoint *ep;
2910 u32 info1 = 0, info2 = 0;
2911 int is_input, type;
2912 int maxp = 0;
2913 + int mult;
2914 struct usb_tt *tt = urb->dev->tt;
2915 struct fotg210_qh_hw *hw;
2916
2917 @@ -2758,14 +2755,15 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
2918
2919 is_input = usb_pipein(urb->pipe);
2920 type = usb_pipetype(urb->pipe);
2921 - maxp = usb_maxpacket(urb->dev, urb->pipe, !is_input);
2922 + ep = usb_pipe_endpoint(urb->dev, urb->pipe);
2923 + maxp = usb_endpoint_maxp(&ep->desc);
2924 + mult = usb_endpoint_maxp_mult(&ep->desc);
2925
2926 /* 1024 byte maxpacket is a hardware ceiling. High bandwidth
2927 * acts like up to 3KB, but is built from smaller packets.
2928 */
2929 - if (max_packet(maxp) > 1024) {
2930 - fotg210_dbg(fotg210, "bogus qh maxpacket %d\n",
2931 - max_packet(maxp));
2932 + if (maxp > 1024) {
2933 + fotg210_dbg(fotg210, "bogus qh maxpacket %d\n", maxp);
2934 goto done;
2935 }
2936
2937 @@ -2779,8 +2777,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
2938 */
2939 if (type == PIPE_INTERRUPT) {
2940 qh->usecs = NS_TO_US(usb_calc_bus_time(USB_SPEED_HIGH,
2941 - is_input, 0,
2942 - hb_mult(maxp) * max_packet(maxp)));
2943 + is_input, 0, mult * maxp));
2944 qh->start = NO_FRAME;
2945
2946 if (urb->dev->speed == USB_SPEED_HIGH) {
2947 @@ -2817,7 +2814,7 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
2948 think_time = tt ? tt->think_time : 0;
2949 qh->tt_usecs = NS_TO_US(think_time +
2950 usb_calc_bus_time(urb->dev->speed,
2951 - is_input, 0, max_packet(maxp)));
2952 + is_input, 0, maxp));
2953 qh->period = urb->interval;
2954 if (qh->period > fotg210->periodic_size) {
2955 qh->period = fotg210->periodic_size;
2956 @@ -2880,11 +2877,11 @@ static struct fotg210_qh *qh_make(struct fotg210_hcd *fotg210, struct urb *urb,
2957 * to help them do so. So now people expect to use
2958 * such nonconformant devices with Linux too; sigh.
2959 */
2960 - info1 |= max_packet(maxp) << 16;
2961 + info1 |= maxp << 16;
2962 info2 |= (FOTG210_TUNE_MULT_HS << 30);
2963 } else { /* PIPE_INTERRUPT */
2964 - info1 |= max_packet(maxp) << 16;
2965 - info2 |= hb_mult(maxp) << 30;
2966 + info1 |= maxp << 16;
2967 + info2 |= mult << 30;
2968 }
2969 break;
2970 default:
2971 @@ -3954,6 +3951,7 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
2972 int is_input;
2973 long bandwidth;
2974 unsigned multi;
2975 + struct usb_host_endpoint *ep;
2976
2977 /*
2978 * this might be a "high bandwidth" highspeed endpoint,
2979 @@ -3961,14 +3959,14 @@ static void iso_stream_init(struct fotg210_hcd *fotg210,
2980 */
2981 epnum = usb_pipeendpoint(pipe);
2982 is_input = usb_pipein(pipe) ? USB_DIR_IN : 0;
2983 - maxp = usb_maxpacket(dev, pipe, !is_input);
2984 + ep = usb_pipe_endpoint(dev, pipe);
2985 + maxp = usb_endpoint_maxp(&ep->desc);
2986 if (is_input)
2987 buf1 = (1 << 11);
2988 else
2989 buf1 = 0;
2990
2991 - maxp = max_packet(maxp);
2992 - multi = hb_mult(maxp);
2993 + multi = usb_endpoint_maxp_mult(&ep->desc);
2994 buf1 |= maxp;
2995 maxp *= multi;
2996
2997 @@ -4490,13 +4488,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)
2998
2999 /* HC need not update length with this error */
3000 if (!(t & FOTG210_ISOC_BABBLE)) {
3001 - desc->actual_length =
3002 - fotg210_itdlen(urb, desc, t);
3003 + desc->actual_length = FOTG210_ITD_LENGTH(t);
3004 urb->actual_length += desc->actual_length;
3005 }
3006 } else if (likely((t & FOTG210_ISOC_ACTIVE) == 0)) {
3007 desc->status = 0;
3008 - desc->actual_length = fotg210_itdlen(urb, desc, t);
3009 + desc->actual_length = FOTG210_ITD_LENGTH(t);
3010 urb->actual_length += desc->actual_length;
3011 } else {
3012 /* URB was too late */
3013 diff --git a/drivers/usb/host/fotg210.h b/drivers/usb/host/fotg210.h
3014 index b5cfa7aeb277c..1a3f94123c885 100644
3015 --- a/drivers/usb/host/fotg210.h
3016 +++ b/drivers/usb/host/fotg210.h
3017 @@ -682,11 +682,6 @@ static inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210)
3018 return fotg210_readl(fotg210, &fotg210->regs->frame_index);
3019 }
3020
3021 -#define fotg210_itdlen(urb, desc, t) ({ \
3022 - usb_pipein((urb)->pipe) ? \
3023 - (desc)->length - FOTG210_ITD_LENGTH(t) : \
3024 - FOTG210_ITD_LENGTH(t); \
3025 -})
3026 /*-------------------------------------------------------------------------*/
3027
3028 #endif /* __LINUX_FOTG210_H */
3029 diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
3030 index cfcfadfc94fc2..9c9e97294c18d 100644
3031 --- a/drivers/usb/host/ohci-tmio.c
3032 +++ b/drivers/usb/host/ohci-tmio.c
3033 @@ -202,6 +202,9 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
3034 if (!cell)
3035 return -EINVAL;
3036
3037 + if (irq < 0)
3038 + return irq;
3039 +
3040 hcd = usb_create_hcd(&ohci_tmio_hc_driver, &dev->dev, dev_name(&dev->dev));
3041 if (!hcd) {
3042 ret = -ENOMEM;
3043 diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
3044 index ec00eff017942..2df61fff8ae32 100644
3045 --- a/drivers/usb/host/xhci.c
3046 +++ b/drivers/usb/host/xhci.c
3047 @@ -4419,19 +4419,19 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci,
3048 {
3049 unsigned long long timeout_ns;
3050
3051 - if (xhci->quirks & XHCI_INTEL_HOST)
3052 - timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
3053 - else
3054 - timeout_ns = udev->u1_params.sel;
3055 -
3056 /* Prevent U1 if service interval is shorter than U1 exit latency */
3057 if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
3058 - if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
3059 + if (xhci_service_interval_to_ns(desc) <= udev->u1_params.mel) {
3060 dev_dbg(&udev->dev, "Disable U1, ESIT shorter than exit latency\n");
3061 return USB3_LPM_DISABLED;
3062 }
3063 }
3064
3065 + if (xhci->quirks & XHCI_INTEL_HOST)
3066 + timeout_ns = xhci_calculate_intel_u1_timeout(udev, desc);
3067 + else
3068 + timeout_ns = udev->u1_params.sel;
3069 +
3070 /* The U1 timeout is encoded in 1us intervals.
3071 * Don't return a timeout of zero, because that's USB3_LPM_DISABLED.
3072 */
3073 @@ -4483,19 +4483,19 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci,
3074 {
3075 unsigned long long timeout_ns;
3076
3077 - if (xhci->quirks & XHCI_INTEL_HOST)
3078 - timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
3079 - else
3080 - timeout_ns = udev->u2_params.sel;
3081 -
3082 /* Prevent U2 if service interval is shorter than U2 exit latency */
3083 if (usb_endpoint_xfer_int(desc) || usb_endpoint_xfer_isoc(desc)) {
3084 - if (xhci_service_interval_to_ns(desc) <= timeout_ns) {
3085 + if (xhci_service_interval_to_ns(desc) <= udev->u2_params.mel) {
3086 dev_dbg(&udev->dev, "Disable U2, ESIT shorter than exit latency\n");
3087 return USB3_LPM_DISABLED;
3088 }
3089 }
3090
3091 + if (xhci->quirks & XHCI_INTEL_HOST)
3092 + timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
3093 + else
3094 + timeout_ns = udev->u2_params.sel;
3095 +
3096 /* The U2 timeout is encoded in 256us intervals */
3097 timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000);
3098 /* If the necessary timeout value is bigger than what we can set in the
3099 diff --git a/drivers/usb/phy/phy-fsl-usb.c b/drivers/usb/phy/phy-fsl-usb.c
3100 index 85d031ce85c1f..63798de8b5ae2 100644
3101 --- a/drivers/usb/phy/phy-fsl-usb.c
3102 +++ b/drivers/usb/phy/phy-fsl-usb.c
3103 @@ -891,6 +891,8 @@ int usb_otg_start(struct platform_device *pdev)
3104
3105 /* request irq */
3106 p_otg->irq = platform_get_irq(pdev, 0);
3107 + if (p_otg->irq < 0)
3108 + return p_otg->irq;
3109 status = request_irq(p_otg->irq, fsl_otg_isr,
3110 IRQF_SHARED, driver_name, p_otg);
3111 if (status) {
3112 diff --git a/drivers/usb/phy/phy-isp1301.c b/drivers/usb/phy/phy-isp1301.c
3113 index b3b33cf7ddf60..f333024660b4d 100644
3114 --- a/drivers/usb/phy/phy-isp1301.c
3115 +++ b/drivers/usb/phy/phy-isp1301.c
3116 @@ -136,7 +136,7 @@ static int isp1301_remove(struct i2c_client *client)
3117 static struct i2c_driver isp1301_driver = {
3118 .driver = {
3119 .name = DRV_NAME,
3120 - .of_match_table = of_match_ptr(isp1301_of_match),
3121 + .of_match_table = isp1301_of_match,
3122 },
3123 .probe = isp1301_probe,
3124 .remove = isp1301_remove,
3125 diff --git a/drivers/usb/phy/phy-tahvo.c b/drivers/usb/phy/phy-tahvo.c
3126 index 335a1ef352242..ec86eedd789bc 100644
3127 --- a/drivers/usb/phy/phy-tahvo.c
3128 +++ b/drivers/usb/phy/phy-tahvo.c
3129 @@ -404,7 +404,9 @@ static int tahvo_usb_probe(struct platform_device *pdev)
3130
3131 dev_set_drvdata(&pdev->dev, tu);
3132
3133 - tu->irq = platform_get_irq(pdev, 0);
3134 + tu->irq = ret = platform_get_irq(pdev, 0);
3135 + if (ret < 0)
3136 + return ret;
3137 ret = request_threaded_irq(tu->irq, NULL, tahvo_usb_vbus_interrupt,
3138 IRQF_ONESHOT,
3139 "tahvo-vbus", tu);
3140 diff --git a/drivers/usb/phy/phy-twl6030-usb.c b/drivers/usb/phy/phy-twl6030-usb.c
3141 index cf0b67433ac95..ccb36e2409530 100644
3142 --- a/drivers/usb/phy/phy-twl6030-usb.c
3143 +++ b/drivers/usb/phy/phy-twl6030-usb.c
3144 @@ -352,6 +352,11 @@ static int twl6030_usb_probe(struct platform_device *pdev)
3145 twl->irq2 = platform_get_irq(pdev, 1);
3146 twl->linkstat = MUSB_UNKNOWN;
3147
3148 + if (twl->irq1 < 0)
3149 + return twl->irq1;
3150 + if (twl->irq2 < 0)
3151 + return twl->irq2;
3152 +
3153 twl->comparator.set_vbus = twl6030_set_vbus;
3154 twl->comparator.start_srp = twl6030_start_srp;
3155
3156 diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
3157 index b16e37f43247b..1278d6ce97b9d 100644
3158 --- a/drivers/usb/serial/mos7720.c
3159 +++ b/drivers/usb/serial/mos7720.c
3160 @@ -229,8 +229,10 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
3161 int status;
3162
3163 buf = kmalloc(1, GFP_KERNEL);
3164 - if (!buf)
3165 + if (!buf) {
3166 + *data = 0;
3167 return -ENOMEM;
3168 + }
3169
3170 status = usb_control_msg(usbdev, pipe, request, requesttype, value,
3171 index, buf, 1, MOS_WDR_TIMEOUT);
3172 diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
3173 index fb7b03029b8e6..91ccf57759aeb 100644
3174 --- a/drivers/usb/usbip/vhci_hcd.c
3175 +++ b/drivers/usb/usbip/vhci_hcd.c
3176 @@ -762,8 +762,32 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
3177 spin_lock(&vdev->priv_lock);
3178
3179 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
3180 + struct urb *urb;
3181 +
3182 + /* give back urb of unsent unlink request */
3183 pr_info("unlink cleanup tx %lu\n", unlink->unlink_seqnum);
3184 +
3185 + urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
3186 + if (!urb) {
3187 + list_del(&unlink->list);
3188 + kfree(unlink);
3189 + continue;
3190 + }
3191 +
3192 + urb->status = -ENODEV;
3193 +
3194 + usb_hcd_unlink_urb_from_ep(hcd, urb);
3195 +
3196 list_del(&unlink->list);
3197 +
3198 + spin_unlock(&vdev->priv_lock);
3199 + spin_unlock_irqrestore(&vhci->lock, flags);
3200 +
3201 + usb_hcd_giveback_urb(hcd, urb, urb->status);
3202 +
3203 + spin_lock_irqsave(&vhci->lock, flags);
3204 + spin_lock(&vdev->priv_lock);
3205 +
3206 kfree(unlink);
3207 }
3208
3209 diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig
3210 index da6e2ce77495b..e5156b3486695 100644
3211 --- a/drivers/vfio/Kconfig
3212 +++ b/drivers/vfio/Kconfig
3213 @@ -31,7 +31,7 @@ menuconfig VFIO
3214
3215 If you don't know what to do here, say N.
3216
3217 -menuconfig VFIO_NOIOMMU
3218 +config VFIO_NOIOMMU
3219 bool "VFIO No-IOMMU support"
3220 depends on VFIO
3221 help
3222 diff --git a/drivers/video/fbdev/asiliantfb.c b/drivers/video/fbdev/asiliantfb.c
3223 index 91eea4583382d..ceb579eff1eab 100644
3224 --- a/drivers/video/fbdev/asiliantfb.c
3225 +++ b/drivers/video/fbdev/asiliantfb.c
3226 @@ -227,6 +227,9 @@ static int asiliantfb_check_var(struct fb_var_screeninfo *var,
3227 {
3228 unsigned long Ftarget, ratio, remainder;
3229
3230 + if (!var->pixclock)
3231 + return -EINVAL;
3232 +
3233 ratio = 1000000 / var->pixclock;
3234 remainder = 1000000 % var->pixclock;
3235 Ftarget = 1000000 * ratio + (1000000 * remainder) / var->pixclock;
3236 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
3237 index 16f5f56332433..e83b7ca500b73 100644
3238 --- a/drivers/video/fbdev/core/fbmem.c
3239 +++ b/drivers/video/fbdev/core/fbmem.c
3240 @@ -32,6 +32,7 @@
3241 #include <linux/device.h>
3242 #include <linux/efi.h>
3243 #include <linux/fb.h>
3244 +#include <linux/overflow.h>
3245
3246 #include <asm/fb.h>
3247
3248 @@ -981,6 +982,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
3249 if ((var->activate & FB_ACTIVATE_FORCE) ||
3250 memcmp(&info->var, var, sizeof(struct fb_var_screeninfo))) {
3251 u32 activate = var->activate;
3252 + u32 unused;
3253
3254 /* When using FOURCC mode, make sure the red, green, blue and
3255 * transp fields are set to 0.
3256 @@ -1005,6 +1007,11 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
3257 if (var->xres < 8 || var->yres < 8)
3258 return -EINVAL;
3259
3260 + /* Too huge resolution causes multiplication overflow. */
3261 + if (check_mul_overflow(var->xres, var->yres, &unused) ||
3262 + check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))
3263 + return -EINVAL;
3264 +
3265 ret = info->fbops->fb_check_var(var, info);
3266
3267 if (ret)
3268 diff --git a/drivers/video/fbdev/kyro/fbdev.c b/drivers/video/fbdev/kyro/fbdev.c
3269 index f77478fb3d14a..0b844f6d8a30b 100644
3270 --- a/drivers/video/fbdev/kyro/fbdev.c
3271 +++ b/drivers/video/fbdev/kyro/fbdev.c
3272 @@ -372,6 +372,11 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight
3273 /* probably haven't called CreateOverlay yet */
3274 return -EINVAL;
3275
3276 + if (ulWidth == 0 || ulWidth == 0xffffffff ||
3277 + ulHeight == 0 || ulHeight == 0xffffffff ||
3278 + (x < 2 && ulWidth + 2 == 0))
3279 + return -EINVAL;
3280 +
3281 /* Stop Ramdac Output */
3282 DisableRamdacOutput(deviceInfo.pSTGReg);
3283
3284 @@ -394,6 +399,9 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
3285 {
3286 struct kyrofb_info *par = info->par;
3287
3288 + if (!var->pixclock)
3289 + return -EINVAL;
3290 +
3291 if (var->bits_per_pixel != 16 && var->bits_per_pixel != 32) {
3292 printk(KERN_WARNING "kyrofb: depth not supported: %u\n", var->bits_per_pixel);
3293 return -EINVAL;
3294 diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c
3295 index 2ef26ad993413..69f3acd405c55 100644
3296 --- a/drivers/video/fbdev/riva/fbdev.c
3297 +++ b/drivers/video/fbdev/riva/fbdev.c
3298 @@ -1088,6 +1088,9 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
3299 int mode_valid = 0;
3300
3301 NVTRACE_ENTER();
3302 + if (!var->pixclock)
3303 + return -EINVAL;
3304 +
3305 switch (var->bits_per_pixel) {
3306 case 1 ... 8:
3307 var->red.offset = var->green.offset = var->blue.offset = 0;
3308 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
3309 index b744e7d33d87f..26866785e1c77 100644
3310 --- a/fs/btrfs/inode.c
3311 +++ b/fs/btrfs/inode.c
3312 @@ -484,7 +484,7 @@ again:
3313 * inode has not been flagged as nocompress. This flag can
3314 * change at any time if we discover bad compression ratios.
3315 */
3316 - if (nr_pages > 1 && inode_need_compress(inode)) {
3317 + if (inode_need_compress(inode)) {
3318 WARN_ON(pages);
3319 pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
3320 if (!pages) {
3321 diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
3322 index 942874257a092..e5e7801457280 100644
3323 --- a/fs/cifs/cifs_unicode.c
3324 +++ b/fs/cifs/cifs_unicode.c
3325 @@ -367,14 +367,9 @@ cifs_strndup_from_utf16(const char *src, const int maxlen,
3326 if (!dst)
3327 return NULL;
3328 cifs_from_utf16(dst, (__le16 *) src, len, maxlen, codepage,
3329 - NO_MAP_UNI_RSVD);
3330 + NO_MAP_UNI_RSVD);
3331 } else {
3332 - len = strnlen(src, maxlen);
3333 - len++;
3334 - dst = kmalloc(len, GFP_KERNEL);
3335 - if (!dst)
3336 - return NULL;
3337 - strlcpy(dst, src, len);
3338 + dst = kstrndup(src, maxlen, GFP_KERNEL);
3339 }
3340
3341 return dst;
3342 diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
3343 index bb208076cb71a..aeec5a896ea64 100644
3344 --- a/fs/cifs/sess.c
3345 +++ b/fs/cifs/sess.c
3346 @@ -602,7 +602,7 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)
3347 return 0;
3348
3349 out_free_smb_buf:
3350 - kfree(smb_buf);
3351 + cifs_small_buf_release(smb_buf);
3352 sess_data->iov[0].iov_base = NULL;
3353 sess_data->iov[0].iov_len = 0;
3354 sess_data->buf0_type = CIFS_NO_BUFFER;
3355 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
3356 index 5bf62bdd84b87..a0f20a048347c 100644
3357 --- a/fs/ext4/inline.c
3358 +++ b/fs/ext4/inline.c
3359 @@ -747,6 +747,12 @@ int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
3360 ext4_write_lock_xattr(inode, &no_expand);
3361 BUG_ON(!ext4_has_inline_data(inode));
3362
3363 + /*
3364 + * ei->i_inline_off may have changed since ext4_write_begin()
3365 + * called ext4_try_to_write_inline_data()
3366 + */
3367 + (void) ext4_find_inline_data_nolock(inode);
3368 +
3369 kaddr = kmap_atomic(page);
3370 ext4_write_inline_data(inode, &iloc, kaddr, pos, len);
3371 kunmap_atomic(kaddr);
3372 diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
3373 index 2524807ee0703..a6d962323790c 100644
3374 --- a/fs/gfs2/acl.c
3375 +++ b/fs/gfs2/acl.c
3376 @@ -86,19 +86,6 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
3377 char *data;
3378 const char *name = gfs2_acl_name(type);
3379
3380 - if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode)))
3381 - return -E2BIG;
3382 -
3383 - if (type == ACL_TYPE_ACCESS) {
3384 - umode_t mode = inode->i_mode;
3385 -
3386 - error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
3387 - if (error)
3388 - return error;
3389 - if (mode != inode->i_mode)
3390 - mark_inode_dirty(inode);
3391 - }
3392 -
3393 if (acl) {
3394 len = posix_acl_to_xattr(&init_user_ns, acl, NULL, 0);
3395 if (len == 0)
3396 @@ -130,6 +117,9 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
3397 bool need_unlock = false;
3398 int ret;
3399
3400 + if (acl && acl->a_count > GFS2_ACL_MAX_ENTRIES(GFS2_SB(inode)))
3401 + return -E2BIG;
3402 +
3403 ret = gfs2_rsqa_alloc(ip);
3404 if (ret)
3405 return ret;
3406 @@ -140,7 +130,18 @@ int gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
3407 return ret;
3408 need_unlock = true;
3409 }
3410 + if (type == ACL_TYPE_ACCESS && acl) {
3411 + umode_t mode = inode->i_mode;
3412 +
3413 + ret = posix_acl_update_mode(inode, &inode->i_mode, &acl);
3414 + if (ret)
3415 + goto unlock;
3416 + if (mode != inode->i_mode)
3417 + mark_inode_dirty(inode);
3418 + }
3419 +
3420 ret = __gfs2_set_acl(inode, acl, type);
3421 +unlock:
3422 if (need_unlock)
3423 gfs2_glock_dq_uninit(&gh);
3424 return ret;
3425 diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
3426 index 3cbc9147286dd..da9f979118524 100644
3427 --- a/fs/gfs2/lock_dlm.c
3428 +++ b/fs/gfs2/lock_dlm.c
3429 @@ -296,6 +296,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
3430 gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
3431 gfs2_update_request_times(gl);
3432
3433 + /* don't want to call dlm if we've unmounted the lock protocol */
3434 + if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) {
3435 + gfs2_glock_free(gl);
3436 + return;
3437 + }
3438 /* don't want to skip dlm_unlock writing the lvb when lock has one */
3439
3440 if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
3441 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
3442 index 71d1c25f360d1..8c7f9ea251e52 100644
3443 --- a/fs/udf/misc.c
3444 +++ b/fs/udf/misc.c
3445 @@ -175,13 +175,22 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
3446 else
3447 offset = le32_to_cpu(eahd->appAttrLocation);
3448
3449 - while (offset < iinfo->i_lenEAttr) {
3450 + while (offset + sizeof(*gaf) < iinfo->i_lenEAttr) {
3451 + uint32_t attrLength;
3452 +
3453 gaf = (struct genericFormat *)&ea[offset];
3454 + attrLength = le32_to_cpu(gaf->attrLength);
3455 +
3456 + /* Detect undersized elements and buffer overflows */
3457 + if ((attrLength < sizeof(*gaf)) ||
3458 + (attrLength > (iinfo->i_lenEAttr - offset)))
3459 + break;
3460 +
3461 if (le32_to_cpu(gaf->attrType) == type &&
3462 gaf->attrSubtype == subtype)
3463 return gaf;
3464 else
3465 - offset += le32_to_cpu(gaf->attrLength);
3466 + offset += attrLength;
3467 }
3468 }
3469
3470 diff --git a/fs/udf/super.c b/fs/udf/super.c
3471 index c8c037e8e57b5..cf2e770080f9b 100644
3472 --- a/fs/udf/super.c
3473 +++ b/fs/udf/super.c
3474 @@ -115,16 +115,10 @@ struct logicalVolIntegrityDescImpUse *udf_sb_lvidiu(struct super_block *sb)
3475 return NULL;
3476 lvid = (struct logicalVolIntegrityDesc *)UDF_SB(sb)->s_lvid_bh->b_data;
3477 partnum = le32_to_cpu(lvid->numOfPartitions);
3478 - if ((sb->s_blocksize - sizeof(struct logicalVolIntegrityDescImpUse) -
3479 - offsetof(struct logicalVolIntegrityDesc, impUse)) /
3480 - (2 * sizeof(uint32_t)) < partnum) {
3481 - udf_err(sb, "Logical volume integrity descriptor corrupted "
3482 - "(numOfPartitions = %u)!\n", partnum);
3483 - return NULL;
3484 - }
3485 /* The offset is to skip freeSpaceTable and sizeTable arrays */
3486 offset = partnum * 2 * sizeof(uint32_t);
3487 - return (struct logicalVolIntegrityDescImpUse *)&(lvid->impUse[offset]);
3488 + return (struct logicalVolIntegrityDescImpUse *)
3489 + (((uint8_t *)(lvid + 1)) + offset);
3490 }
3491
3492 /* UDF filesystem type */
3493 @@ -1571,6 +1565,7 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_
3494 struct udf_sb_info *sbi = UDF_SB(sb);
3495 struct logicalVolIntegrityDesc *lvid;
3496 int indirections = 0;
3497 + u32 parts, impuselen;
3498
3499 while (++indirections <= UDF_MAX_LVID_NESTING) {
3500 final_bh = NULL;
3501 @@ -1597,15 +1592,27 @@ static void udf_load_logicalvolint(struct super_block *sb, struct kernel_extent_
3502
3503 lvid = (struct logicalVolIntegrityDesc *)final_bh->b_data;
3504 if (lvid->nextIntegrityExt.extLength == 0)
3505 - return;
3506 + goto check;
3507
3508 loc = leea_to_cpu(lvid->nextIntegrityExt);
3509 }
3510
3511 udf_warn(sb, "Too many LVID indirections (max %u), ignoring.\n",
3512 UDF_MAX_LVID_NESTING);
3513 +out_err:
3514 brelse(sbi->s_lvid_bh);
3515 sbi->s_lvid_bh = NULL;
3516 + return;
3517 +check:
3518 + parts = le32_to_cpu(lvid->numOfPartitions);
3519 + impuselen = le32_to_cpu(lvid->lengthOfImpUse);
3520 + if (parts >= sb->s_blocksize || impuselen >= sb->s_blocksize ||
3521 + sizeof(struct logicalVolIntegrityDesc) + impuselen +
3522 + 2 * parts * sizeof(u32) > sb->s_blocksize) {
3523 + udf_warn(sb, "Corrupted LVID (parts=%u, impuselen=%u), "
3524 + "ignoring.\n", parts, impuselen);
3525 + goto out_err;
3526 + }
3527 }
3528
3529
3530 diff --git a/include/crypto/public_key.h b/include/crypto/public_key.h
3531 index 882ca0e1e7a59..d8435eac37293 100644
3532 --- a/include/crypto/public_key.h
3533 +++ b/include/crypto/public_key.h
3534 @@ -35,9 +35,9 @@ extern void public_key_free(struct public_key *key);
3535 struct public_key_signature {
3536 struct asymmetric_key_id *auth_ids[2];
3537 u8 *s; /* Signature */
3538 - u32 s_size; /* Number of bytes in signature */
3539 u8 *digest;
3540 - u8 digest_size; /* Number of bytes in digest */
3541 + u32 s_size; /* Number of bytes in signature */
3542 + u32 digest_size; /* Number of bytes in digest */
3543 const char *pkey_algo;
3544 const char *hash_algo;
3545 };
3546 diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
3547 index 6417bc845db56..4b377186fddd3 100644
3548 --- a/include/linux/hugetlb.h
3549 +++ b/include/linux/hugetlb.h
3550 @@ -482,6 +482,11 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
3551
3552 void hugetlb_report_usage(struct seq_file *m, struct mm_struct *mm);
3553
3554 +static inline void hugetlb_count_init(struct mm_struct *mm)
3555 +{
3556 + atomic_long_set(&mm->hugetlb_usage, 0);
3557 +}
3558 +
3559 static inline void hugetlb_count_add(long l, struct mm_struct *mm)
3560 {
3561 atomic_long_add(l, &mm->hugetlb_usage);
3562 @@ -527,6 +532,10 @@ static inline spinlock_t *huge_pte_lockptr(struct hstate *h,
3563 return &mm->page_table_lock;
3564 }
3565
3566 +static inline void hugetlb_count_init(struct mm_struct *mm)
3567 +{
3568 +}
3569 +
3570 static inline void hugetlb_report_usage(struct seq_file *f, struct mm_struct *m)
3571 {
3572 }
3573 diff --git a/include/linux/pci.h b/include/linux/pci.h
3574 index b9ac0ba812211..7563261bed885 100644
3575 --- a/include/linux/pci.h
3576 +++ b/include/linux/pci.h
3577 @@ -1552,8 +1552,9 @@ static inline int pci_enable_device(struct pci_dev *dev) { return -EIO; }
3578 static inline void pci_disable_device(struct pci_dev *dev) { }
3579 static inline int pci_assign_resource(struct pci_dev *dev, int i)
3580 { return -EBUSY; }
3581 -static inline int __pci_register_driver(struct pci_driver *drv,
3582 - struct module *owner)
3583 +static inline int __must_check __pci_register_driver(struct pci_driver *drv,
3584 + struct module *owner,
3585 + const char *mod_name)
3586 { return 0; }
3587 static inline int pci_register_driver(struct pci_driver *drv)
3588 { return 0; }
3589 diff --git a/include/linux/power/max17042_battery.h b/include/linux/power/max17042_battery.h
3590 index 522757ac9cd4d..890f53881fad8 100644
3591 --- a/include/linux/power/max17042_battery.h
3592 +++ b/include/linux/power/max17042_battery.h
3593 @@ -75,7 +75,7 @@ enum max17042_register {
3594 MAX17042_RelaxCFG = 0x2A,
3595 MAX17042_MiscCFG = 0x2B,
3596 MAX17042_TGAIN = 0x2C,
3597 - MAx17042_TOFF = 0x2D,
3598 + MAX17042_TOFF = 0x2D,
3599 MAX17042_CGAIN = 0x2E,
3600 MAX17042_COFF = 0x2F,
3601
3602 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
3603 index 67b798b7115d8..dab550cf29c12 100644
3604 --- a/include/linux/skbuff.h
3605 +++ b/include/linux/skbuff.h
3606 @@ -1613,7 +1613,7 @@ static inline void __skb_insert(struct sk_buff *newsk,
3607 newsk->next = next;
3608 newsk->prev = prev;
3609 next->prev = prev->next = newsk;
3610 - list->qlen++;
3611 + WRITE_ONCE(list->qlen, list->qlen + 1);
3612 }
3613
3614 static inline void __skb_queue_splice(const struct sk_buff_head *list,
3615 diff --git a/include/uapi/linux/serial_reg.h b/include/uapi/linux/serial_reg.h
3616 index b4c04842a8c08..bad5c56a78a2d 100644
3617 --- a/include/uapi/linux/serial_reg.h
3618 +++ b/include/uapi/linux/serial_reg.h
3619 @@ -61,6 +61,7 @@
3620 * ST16C654: 8 16 56 60 8 16 32 56 PORT_16654
3621 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750
3622 * TI16C752: 8 16 56 60 8 16 32 56
3623 + * OX16C950: 16 32 112 120 16 32 64 112 PORT_16C950
3624 * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA
3625 */
3626 #define UART_FCR_R_TRIG_00 0x00
3627 diff --git a/kernel/events/core.c b/kernel/events/core.c
3628 index 7615a97a3511d..e56a74fd5c814 100644
3629 --- a/kernel/events/core.c
3630 +++ b/kernel/events/core.c
3631 @@ -8115,7 +8115,7 @@ static void perf_event_addr_filters_apply(struct perf_event *event)
3632 if (task == TASK_TOMBSTONE)
3633 return;
3634
3635 - mm = get_task_mm(event->ctx->task);
3636 + mm = get_task_mm(task);
3637 if (!mm)
3638 goto restart;
3639
3640 diff --git a/kernel/fork.c b/kernel/fork.c
3641 index 91349fd3e162d..bcb851299b3fe 100644
3642 --- a/kernel/fork.c
3643 +++ b/kernel/fork.c
3644 @@ -789,6 +789,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
3645 mm->pmd_huge_pte = NULL;
3646 #endif
3647 mm_init_uprobes_state(mm);
3648 + hugetlb_count_init(mm);
3649
3650 if (current->mm) {
3651 mm->flags = current->mm->flags & MMF_INIT_MASK;
3652 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
3653 index 0eab538841fd4..64b91b8d4d840 100644
3654 --- a/kernel/pid_namespace.c
3655 +++ b/kernel/pid_namespace.c
3656 @@ -52,7 +52,7 @@ static struct kmem_cache *create_pid_cachep(int nr_ids)
3657 snprintf(pcache->name, sizeof(pcache->name), "pid_%d", nr_ids);
3658 cachep = kmem_cache_create(pcache->name,
3659 sizeof(struct pid) + (nr_ids - 1) * sizeof(struct upid),
3660 - 0, SLAB_HWCACHE_ALIGN, NULL);
3661 + 0, SLAB_HWCACHE_ALIGN | SLAB_ACCOUNT, NULL);
3662 if (cachep == NULL)
3663 goto err_cachep;
3664
3665 diff --git a/lib/test_bpf.c b/lib/test_bpf.c
3666 index 960d4d627361e..0c62275630fac 100644
3667 --- a/lib/test_bpf.c
3668 +++ b/lib/test_bpf.c
3669 @@ -4295,8 +4295,8 @@ static struct bpf_test tests[] = {
3670 .u.insns_int = {
3671 BPF_LD_IMM64(R0, 0),
3672 BPF_LD_IMM64(R1, 0xffffffffffffffffLL),
3673 - BPF_STX_MEM(BPF_W, R10, R1, -40),
3674 - BPF_LDX_MEM(BPF_W, R0, R10, -40),
3675 + BPF_STX_MEM(BPF_DW, R10, R1, -40),
3676 + BPF_LDX_MEM(BPF_DW, R0, R10, -40),
3677 BPF_EXIT_INSN(),
3678 },
3679 INTERNAL,
3680 @@ -5744,7 +5744,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)
3681 u64 duration;
3682 u32 ret;
3683
3684 - if (test->test[i].data_size == 0 &&
3685 + /*
3686 + * NOTE: Several sub-tests may be present, in which case
3687 + * a zero {data_size, result} tuple indicates the end of
3688 + * the sub-test array. The first test is always run,
3689 + * even if both data_size and result happen to be zero.
3690 + */
3691 + if (i > 0 &&
3692 + test->test[i].data_size == 0 &&
3693 test->test[i].result == 0)
3694 break;
3695
3696 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
3697 index d05133b37b173..59bb2b9ec0e2e 100644
3698 --- a/mm/kmemleak.c
3699 +++ b/mm/kmemleak.c
3700 @@ -1442,7 +1442,7 @@ static void kmemleak_scan(void)
3701 if (page_count(page) == 0)
3702 continue;
3703 scan_block(page, page + 1, NULL);
3704 - if (!(pfn % (MAX_SCAN_SIZE / sizeof(*page))))
3705 + if (!(pfn & 63))
3706 cond_resched();
3707 }
3708 }
3709 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
3710 index b0c451e3b59f3..babcbd8b94ea8 100644
3711 --- a/mm/page_alloc.c
3712 +++ b/mm/page_alloc.c
3713 @@ -814,7 +814,7 @@ static inline void __free_one_page(struct page *page,
3714 struct page *buddy;
3715 unsigned int max_order;
3716
3717 - max_order = min_t(unsigned int, MAX_ORDER, pageblock_order + 1);
3718 + max_order = min_t(unsigned int, MAX_ORDER - 1, pageblock_order);
3719
3720 VM_BUG_ON(!zone_is_initialized(zone));
3721 VM_BUG_ON_PAGE(page->flags & PAGE_FLAGS_CHECK_AT_PREP, page);
3722 @@ -829,7 +829,7 @@ static inline void __free_one_page(struct page *page,
3723 VM_BUG_ON_PAGE(bad_range(zone, page), page);
3724
3725 continue_merging:
3726 - while (order < max_order - 1) {
3727 + while (order < max_order) {
3728 buddy_idx = __find_buddy_index(page_idx, order);
3729 buddy = page + (buddy_idx - page_idx);
3730 if (!page_is_buddy(page, buddy, order))
3731 @@ -850,7 +850,7 @@ continue_merging:
3732 page_idx = combined_idx;
3733 order++;
3734 }
3735 - if (max_order < MAX_ORDER) {
3736 + if (order < MAX_ORDER - 1) {
3737 /* If we are here, it means order is >= pageblock_order.
3738 * We want to prevent merge between freepages on isolate
3739 * pageblock and normal pageblock. Without this, pageblock
3740 @@ -871,7 +871,7 @@ continue_merging:
3741 is_migrate_isolate(buddy_mt)))
3742 goto done_merging;
3743 }
3744 - max_order++;
3745 + max_order = order + 1;
3746 goto continue_merging;
3747 }
3748
3749 diff --git a/net/bluetooth/cmtp/cmtp.h b/net/bluetooth/cmtp/cmtp.h
3750 index c32638dddbf94..f6b9dc4e408f2 100644
3751 --- a/net/bluetooth/cmtp/cmtp.h
3752 +++ b/net/bluetooth/cmtp/cmtp.h
3753 @@ -26,7 +26,7 @@
3754 #include <linux/types.h>
3755 #include <net/bluetooth/bluetooth.h>
3756
3757 -#define BTNAMSIZ 18
3758 +#define BTNAMSIZ 21
3759
3760 /* CMTP ioctl defines */
3761 #define CMTPCONNADD _IOW('C', 200, int)
3762 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
3763 index 8517da7f282ed..b43f31203a430 100644
3764 --- a/net/bluetooth/hci_core.c
3765 +++ b/net/bluetooth/hci_core.c
3766 @@ -1223,6 +1223,12 @@ int hci_inquiry(void __user *arg)
3767 goto done;
3768 }
3769
3770 + /* Restrict maximum inquiry length to 60 seconds */
3771 + if (ir.length > 60) {
3772 + err = -EINVAL;
3773 + goto done;
3774 + }
3775 +
3776 hci_dev_lock(hdev);
3777 if (inquiry_cache_age(hdev) > INQUIRY_CACHE_AGE_MAX ||
3778 inquiry_cache_empty(hdev) || ir.flags & IREQ_CACHE_FLUSH) {
3779 @@ -1546,6 +1552,14 @@ int hci_dev_do_close(struct hci_dev *hdev)
3780 hci_request_cancel_all(hdev);
3781 hci_req_sync_lock(hdev);
3782
3783 + if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
3784 + !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
3785 + test_bit(HCI_UP, &hdev->flags)) {
3786 + /* Execute vendor specific shutdown routine */
3787 + if (hdev->shutdown)
3788 + hdev->shutdown(hdev);
3789 + }
3790 +
3791 if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
3792 cancel_delayed_work_sync(&hdev->cmd_timer);
3793 hci_req_sync_unlock(hdev);
3794 diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
3795 index 44eeb27e341af..f9484755a9baf 100644
3796 --- a/net/bluetooth/hci_event.c
3797 +++ b/net/bluetooth/hci_event.c
3798 @@ -3761,6 +3761,21 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,
3799
3800 switch (ev->status) {
3801 case 0x00:
3802 + /* The synchronous connection complete event should only be
3803 + * sent once per new connection. Receiving a successful
3804 + * complete event when the connection status is already
3805 + * BT_CONNECTED means that the device is misbehaving and sent
3806 + * multiple complete event packets for the same new connection.
3807 + *
3808 + * Registering the device more than once can corrupt kernel
3809 + * memory, hence upon detecting this invalid event, we report
3810 + * an error and ignore the packet.
3811 + */
3812 + if (conn->state == BT_CONNECTED) {
3813 + bt_dev_err(hdev, "Ignoring connect complete event for existing connection");
3814 + goto unlock;
3815 + }
3816 +
3817 conn->handle = __le16_to_cpu(ev->handle);
3818 conn->state = BT_CONNECTED;
3819 conn->type = ev->link_type;
3820 diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
3821 index 95fd7a837dc5c..77f88c7df6053 100644
3822 --- a/net/bluetooth/sco.c
3823 +++ b/net/bluetooth/sco.c
3824 @@ -83,7 +83,6 @@ static void sco_sock_timeout(unsigned long arg)
3825 sk->sk_state_change(sk);
3826 bh_unlock_sock(sk);
3827
3828 - sco_sock_kill(sk);
3829 sock_put(sk);
3830 }
3831
3832 @@ -175,7 +174,6 @@ static void sco_conn_del(struct hci_conn *hcon, int err)
3833 sco_sock_clear_timer(sk);
3834 sco_chan_del(sk, err);
3835 bh_unlock_sock(sk);
3836 - sco_sock_kill(sk);
3837 sock_put(sk);
3838 }
3839
3840 @@ -210,44 +208,32 @@ static int sco_chan_add(struct sco_conn *conn, struct sock *sk,
3841 return err;
3842 }
3843
3844 -static int sco_connect(struct sock *sk)
3845 +static int sco_connect(struct hci_dev *hdev, struct sock *sk)
3846 {
3847 struct sco_conn *conn;
3848 struct hci_conn *hcon;
3849 - struct hci_dev *hdev;
3850 int err, type;
3851
3852 BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
3853
3854 - hdev = hci_get_route(&sco_pi(sk)->dst, &sco_pi(sk)->src, BDADDR_BREDR);
3855 - if (!hdev)
3856 - return -EHOSTUNREACH;
3857 -
3858 - hci_dev_lock(hdev);
3859 -
3860 if (lmp_esco_capable(hdev) && !disable_esco)
3861 type = ESCO_LINK;
3862 else
3863 type = SCO_LINK;
3864
3865 if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
3866 - (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev))) {
3867 - err = -EOPNOTSUPP;
3868 - goto done;
3869 - }
3870 + (!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)))
3871 + return -EOPNOTSUPP;
3872
3873 hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
3874 sco_pi(sk)->setting);
3875 - if (IS_ERR(hcon)) {
3876 - err = PTR_ERR(hcon);
3877 - goto done;
3878 - }
3879 + if (IS_ERR(hcon))
3880 + return PTR_ERR(hcon);
3881
3882 conn = sco_conn_add(hcon);
3883 if (!conn) {
3884 hci_conn_drop(hcon);
3885 - err = -ENOMEM;
3886 - goto done;
3887 + return -ENOMEM;
3888 }
3889
3890 /* Update source addr of the socket */
3891 @@ -255,7 +241,7 @@ static int sco_connect(struct sock *sk)
3892
3893 err = sco_chan_add(conn, sk, NULL);
3894 if (err)
3895 - goto done;
3896 + return err;
3897
3898 if (hcon->state == BT_CONNECTED) {
3899 sco_sock_clear_timer(sk);
3900 @@ -265,9 +251,6 @@ static int sco_connect(struct sock *sk)
3901 sco_sock_set_timer(sk, sk->sk_sndtimeo);
3902 }
3903
3904 -done:
3905 - hci_dev_unlock(hdev);
3906 - hci_dev_put(hdev);
3907 return err;
3908 }
3909
3910 @@ -392,8 +375,7 @@ static void sco_sock_cleanup_listen(struct sock *parent)
3911 */
3912 static void sco_sock_kill(struct sock *sk)
3913 {
3914 - if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket ||
3915 - sock_flag(sk, SOCK_DEAD))
3916 + if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
3917 return;
3918
3919 BT_DBG("sk %p state %d", sk, sk->sk_state);
3920 @@ -445,7 +427,6 @@ static void sco_sock_close(struct sock *sk)
3921 lock_sock(sk);
3922 __sco_sock_close(sk);
3923 release_sock(sk);
3924 - sco_sock_kill(sk);
3925 }
3926
3927 static void sco_sock_init(struct sock *sk, struct sock *parent)
3928 @@ -555,6 +536,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
3929 {
3930 struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
3931 struct sock *sk = sock->sk;
3932 + struct hci_dev *hdev;
3933 int err;
3934
3935 BT_DBG("sk %p", sk);
3936 @@ -569,12 +551,19 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
3937 if (sk->sk_type != SOCK_SEQPACKET)
3938 return -EINVAL;
3939
3940 + hdev = hci_get_route(&sa->sco_bdaddr, &sco_pi(sk)->src, BDADDR_BREDR);
3941 + if (!hdev)
3942 + return -EHOSTUNREACH;
3943 + hci_dev_lock(hdev);
3944 +
3945 lock_sock(sk);
3946
3947 /* Set destination address and psm */
3948 bacpy(&sco_pi(sk)->dst, &sa->sco_bdaddr);
3949
3950 - err = sco_connect(sk);
3951 + err = sco_connect(hdev, sk);
3952 + hci_dev_unlock(hdev);
3953 + hci_dev_put(hdev);
3954 if (err)
3955 goto done;
3956
3957 @@ -763,6 +752,11 @@ static void sco_conn_defer_accept(struct hci_conn *conn, u16 setting)
3958 cp.max_latency = cpu_to_le16(0xffff);
3959 cp.retrans_effort = 0xff;
3960 break;
3961 + default:
3962 + /* use CVSD settings as fallback */
3963 + cp.max_latency = cpu_to_le16(0xffff);
3964 + cp.retrans_effort = 0xff;
3965 + break;
3966 }
3967
3968 hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ,
3969 diff --git a/net/caif/chnl_net.c b/net/caif/chnl_net.c
3970 index 3408ed51b611c..12063f3338972 100644
3971 --- a/net/caif/chnl_net.c
3972 +++ b/net/caif/chnl_net.c
3973 @@ -55,20 +55,6 @@ struct chnl_net {
3974 enum caif_states state;
3975 };
3976
3977 -static void robust_list_del(struct list_head *delete_node)
3978 -{
3979 - struct list_head *list_node;
3980 - struct list_head *n;
3981 - ASSERT_RTNL();
3982 - list_for_each_safe(list_node, n, &chnl_net_list) {
3983 - if (list_node == delete_node) {
3984 - list_del(list_node);
3985 - return;
3986 - }
3987 - }
3988 - WARN_ON(1);
3989 -}
3990 -
3991 static int chnl_recv_cb(struct cflayer *layr, struct cfpkt *pkt)
3992 {
3993 struct sk_buff *skb;
3994 @@ -370,6 +356,7 @@ static int chnl_net_init(struct net_device *dev)
3995 ASSERT_RTNL();
3996 priv = netdev_priv(dev);
3997 strncpy(priv->name, dev->name, sizeof(priv->name));
3998 + INIT_LIST_HEAD(&priv->list_field);
3999 return 0;
4000 }
4001
4002 @@ -378,7 +365,7 @@ static void chnl_net_uninit(struct net_device *dev)
4003 struct chnl_net *priv;
4004 ASSERT_RTNL();
4005 priv = netdev_priv(dev);
4006 - robust_list_del(&priv->list_field);
4007 + list_del_init(&priv->list_field);
4008 }
4009
4010 static const struct net_device_ops netdev_ops = {
4011 @@ -541,7 +528,7 @@ static void __exit chnl_exit_module(void)
4012 rtnl_lock();
4013 list_for_each_safe(list_node, _tmp, &chnl_net_list) {
4014 dev = list_entry(list_node, struct chnl_net, list_field);
4015 - list_del(list_node);
4016 + list_del_init(list_node);
4017 delete_device(dev);
4018 }
4019 rtnl_unlock();
4020 diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
4021 index 26b0f70d2f1c9..6b04cbd008425 100644
4022 --- a/net/core/flow_dissector.c
4023 +++ b/net/core/flow_dissector.c
4024 @@ -176,8 +176,10 @@ ip:
4025 FLOW_DISSECTOR_KEY_IPV4_ADDRS,
4026 target_container);
4027
4028 - memcpy(&key_addrs->v4addrs, &iph->saddr,
4029 - sizeof(key_addrs->v4addrs));
4030 + memcpy(&key_addrs->v4addrs.src, &iph->saddr,
4031 + sizeof(key_addrs->v4addrs.src));
4032 + memcpy(&key_addrs->v4addrs.dst, &iph->daddr,
4033 + sizeof(key_addrs->v4addrs.dst));
4034 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
4035 }
4036
4037 @@ -216,8 +218,10 @@ ipv6:
4038 FLOW_DISSECTOR_KEY_IPV6_ADDRS,
4039 target_container);
4040
4041 - memcpy(&key_addrs->v6addrs, &iph->saddr,
4042 - sizeof(key_addrs->v6addrs));
4043 + memcpy(&key_addrs->v6addrs.src, &iph->saddr,
4044 + sizeof(key_addrs->v6addrs.src));
4045 + memcpy(&key_addrs->v6addrs.dst, &iph->daddr,
4046 + sizeof(key_addrs->v6addrs.dst));
4047 key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
4048 }
4049
4050 diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c
4051 index 62522b8d2f971..010ff46529088 100644
4052 --- a/net/dccp/minisocks.c
4053 +++ b/net/dccp/minisocks.c
4054 @@ -98,6 +98,8 @@ struct sock *dccp_create_openreq_child(const struct sock *sk,
4055 newdp->dccps_role = DCCP_ROLE_SERVER;
4056 newdp->dccps_hc_rx_ackvec = NULL;
4057 newdp->dccps_service_list = NULL;
4058 + newdp->dccps_hc_rx_ccid = NULL;
4059 + newdp->dccps_hc_tx_ccid = NULL;
4060 newdp->dccps_service = dreq->dreq_service;
4061 newdp->dccps_timestamp_echo = dreq->dreq_timestamp_echo;
4062 newdp->dccps_timestamp_time = dreq->dreq_timestamp_time;
4063 diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
4064 index 27518ea7ec3c8..e27ebd00bff26 100644
4065 --- a/net/ipv4/icmp.c
4066 +++ b/net/ipv4/icmp.c
4067 @@ -460,6 +460,23 @@ static int icmp_multipath_hash_skb(const struct sk_buff *skb)
4068
4069 #endif
4070
4071 +/*
4072 + * The device used for looking up which routing table to use for sending an ICMP
4073 + * error is preferably the source whenever it is set, which should ensure the
4074 + * icmp error can be sent to the source host, else lookup using the routing
4075 + * table of the destination device, else use the main routing table (index 0).
4076 + */
4077 +static struct net_device *icmp_get_route_lookup_dev(struct sk_buff *skb)
4078 +{
4079 + struct net_device *route_lookup_dev = NULL;
4080 +
4081 + if (skb->dev)
4082 + route_lookup_dev = skb->dev;
4083 + else if (skb_dst(skb))
4084 + route_lookup_dev = skb_dst(skb)->dev;
4085 + return route_lookup_dev;
4086 +}
4087 +
4088 static struct rtable *icmp_route_lookup(struct net *net,
4089 struct flowi4 *fl4,
4090 struct sk_buff *skb_in,
4091 @@ -468,6 +485,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
4092 int type, int code,
4093 struct icmp_bxm *param)
4094 {
4095 + struct net_device *route_lookup_dev;
4096 struct rtable *rt, *rt2;
4097 struct flowi4 fl4_dec;
4098 int err;
4099 @@ -481,7 +499,8 @@ static struct rtable *icmp_route_lookup(struct net *net,
4100 fl4->flowi4_proto = IPPROTO_ICMP;
4101 fl4->fl4_icmp_type = type;
4102 fl4->fl4_icmp_code = code;
4103 - fl4->flowi4_oif = l3mdev_master_ifindex(skb_dst(skb_in)->dev);
4104 + route_lookup_dev = icmp_get_route_lookup_dev(skb_in);
4105 + fl4->flowi4_oif = l3mdev_master_ifindex(route_lookup_dev);
4106
4107 security_skb_classify_flow(skb_in, flowi4_to_flowi(fl4));
4108 rt = __ip_route_output_key_hash(net, fl4,
4109 @@ -506,7 +525,7 @@ static struct rtable *icmp_route_lookup(struct net *net,
4110 if (err)
4111 goto relookup_failed;
4112
4113 - if (inet_addr_type_dev_table(net, skb_dst(skb_in)->dev,
4114 + if (inet_addr_type_dev_table(net, route_lookup_dev,
4115 fl4_dec.saddr) == RTN_LOCAL) {
4116 rt2 = __ip_route_output_key(net, &fl4_dec);
4117 if (IS_ERR(rt2))
4118 diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
4119 index f4a827964b685..381fc854ad199 100644
4120 --- a/net/ipv4/igmp.c
4121 +++ b/net/ipv4/igmp.c
4122 @@ -2685,6 +2685,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
4123 rv = 1;
4124 } else if (im) {
4125 if (src_addr) {
4126 + spin_lock_bh(&im->lock);
4127 for (psf = im->sources; psf; psf = psf->sf_next) {
4128 if (psf->sf_inaddr == src_addr)
4129 break;
4130 @@ -2695,6 +2696,7 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
4131 im->sfcount[MCAST_EXCLUDE];
4132 else
4133 rv = im->sfcount[MCAST_EXCLUDE] != 0;
4134 + spin_unlock_bh(&im->lock);
4135 } else
4136 rv = 1; /* unspecified source; tentatively allow */
4137 }
4138 diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
4139 index 3164bae4024a4..589fd0904e0de 100644
4140 --- a/net/ipv4/ip_output.c
4141 +++ b/net/ipv4/ip_output.c
4142 @@ -393,8 +393,9 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4)
4143 {
4144 BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) !=
4145 offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr));
4146 - memcpy(&iph->saddr, &fl4->saddr,
4147 - sizeof(fl4->saddr) + sizeof(fl4->daddr));
4148 +
4149 + iph->saddr = fl4->saddr;
4150 + iph->daddr = fl4->daddr;
4151 }
4152
4153 /* Note: skb->sk can be different from sk, in case of tunnels */
4154 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
4155 index 5350e1b61c06b..f05b8d63dba38 100644
4156 --- a/net/ipv4/route.c
4157 +++ b/net/ipv4/route.c
4158 @@ -597,18 +597,25 @@ static void fnhe_flush_routes(struct fib_nh_exception *fnhe)
4159 }
4160 }
4161
4162 -static struct fib_nh_exception *fnhe_oldest(struct fnhe_hash_bucket *hash)
4163 +static void fnhe_remove_oldest(struct fnhe_hash_bucket *hash)
4164 {
4165 - struct fib_nh_exception *fnhe, *oldest;
4166 + struct fib_nh_exception __rcu **fnhe_p, **oldest_p;
4167 + struct fib_nh_exception *fnhe, *oldest = NULL;
4168
4169 - oldest = rcu_dereference(hash->chain);
4170 - for (fnhe = rcu_dereference(oldest->fnhe_next); fnhe;
4171 - fnhe = rcu_dereference(fnhe->fnhe_next)) {
4172 - if (time_before(fnhe->fnhe_stamp, oldest->fnhe_stamp))
4173 + for (fnhe_p = &hash->chain; ; fnhe_p = &fnhe->fnhe_next) {
4174 + fnhe = rcu_dereference_protected(*fnhe_p,
4175 + lockdep_is_held(&fnhe_lock));
4176 + if (!fnhe)
4177 + break;
4178 + if (!oldest ||
4179 + time_before(fnhe->fnhe_stamp, oldest->fnhe_stamp)) {
4180 oldest = fnhe;
4181 + oldest_p = fnhe_p;
4182 + }
4183 }
4184 fnhe_flush_routes(oldest);
4185 - return oldest;
4186 + *oldest_p = oldest->fnhe_next;
4187 + kfree_rcu(oldest, rcu);
4188 }
4189
4190 static inline u32 fnhe_hashfun(__be32 daddr)
4191 @@ -685,16 +692,21 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
4192 if (rt)
4193 fill_route_from_fnhe(rt, fnhe);
4194 } else {
4195 - if (depth > FNHE_RECLAIM_DEPTH)
4196 - fnhe = fnhe_oldest(hash);
4197 - else {
4198 - fnhe = kzalloc(sizeof(*fnhe), GFP_ATOMIC);
4199 - if (!fnhe)
4200 - goto out_unlock;
4201 -
4202 - fnhe->fnhe_next = hash->chain;
4203 - rcu_assign_pointer(hash->chain, fnhe);
4204 + /* Randomize max depth to avoid some side channels attacks. */
4205 + int max_depth = FNHE_RECLAIM_DEPTH +
4206 + prandom_u32_max(FNHE_RECLAIM_DEPTH);
4207 +
4208 + while (depth > max_depth) {
4209 + fnhe_remove_oldest(hash);
4210 + depth--;
4211 }
4212 +
4213 + fnhe = kzalloc(sizeof(*fnhe), GFP_ATOMIC);
4214 + if (!fnhe)
4215 + goto out_unlock;
4216 +
4217 + fnhe->fnhe_next = hash->chain;
4218 +
4219 fnhe->fnhe_genid = genid;
4220 fnhe->fnhe_daddr = daddr;
4221 fnhe->fnhe_gw = gw;
4222 @@ -702,6 +714,8 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
4223 fnhe->fnhe_mtu_locked = lock;
4224 fnhe->fnhe_expires = expires;
4225
4226 + rcu_assign_pointer(hash->chain, fnhe);
4227 +
4228 /* Exception created; mark the cached routes for the nexthop
4229 * stale, so anyone caching it rechecks if this exception
4230 * applies to them.
4231 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
4232 index d05135ea3c289..01c73775ed007 100644
4233 --- a/net/ipv4/tcp_input.c
4234 +++ b/net/ipv4/tcp_input.c
4235 @@ -1220,7 +1220,7 @@ static u8 tcp_sacktag_one(struct sock *sk,
4236 if (dup_sack && (sacked & TCPCB_RETRANS)) {
4237 if (tp->undo_marker && tp->undo_retrans > 0 &&
4238 after(end_seq, tp->undo_marker))
4239 - tp->undo_retrans--;
4240 + tp->undo_retrans = max_t(int, 0, tp->undo_retrans - pcount);
4241 if (sacked & TCPCB_SACKED_ACKED)
4242 state->reord = min(fack_count, state->reord);
4243 }
4244 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
4245 index 10860c089fda2..6f895694cca1c 100644
4246 --- a/net/ipv4/tcp_ipv4.c
4247 +++ b/net/ipv4/tcp_ipv4.c
4248 @@ -2068,6 +2068,7 @@ static void *tcp_get_idx(struct seq_file *seq, loff_t pos)
4249 static void *tcp_seek_last_pos(struct seq_file *seq)
4250 {
4251 struct tcp_iter_state *st = seq->private;
4252 + int bucket = st->bucket;
4253 int offset = st->offset;
4254 int orig_num = st->num;
4255 void *rc = NULL;
4256 @@ -2078,7 +2079,7 @@ static void *tcp_seek_last_pos(struct seq_file *seq)
4257 break;
4258 st->state = TCP_SEQ_STATE_LISTENING;
4259 rc = listening_get_next(seq, NULL);
4260 - while (offset-- && rc)
4261 + while (offset-- && rc && bucket == st->bucket)
4262 rc = listening_get_next(seq, rc);
4263 if (rc)
4264 break;
4265 @@ -2089,7 +2090,7 @@ static void *tcp_seek_last_pos(struct seq_file *seq)
4266 if (st->bucket > tcp_hashinfo.ehash_mask)
4267 break;
4268 rc = established_get_first(seq);
4269 - while (offset-- && rc)
4270 + while (offset-- && rc && bucket == st->bucket)
4271 rc = established_get_next(seq, rc);
4272 }
4273
4274 diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
4275 index 15f8bd0364c24..f55ba81462541 100644
4276 --- a/net/l2tp/l2tp_core.c
4277 +++ b/net/l2tp/l2tp_core.c
4278 @@ -994,8 +994,10 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
4279 }
4280
4281 if (tunnel->version == L2TP_HDR_VER_3 &&
4282 - l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr))
4283 + l2tp_v3_ensure_opt_in_linear(session, skb, &ptr, &optr)) {
4284 + l2tp_session_dec_refcount(session);
4285 goto error;
4286 + }
4287
4288 l2tp_recv_common(session, skb, ptr, optr, hdrflags, length, payload_hook);
4289 l2tp_session_dec_refcount(session);
4290 diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c
4291 index 7fd1104ba9007..422fac2a4a3c8 100644
4292 --- a/net/netlabel/netlabel_cipso_v4.c
4293 +++ b/net/netlabel/netlabel_cipso_v4.c
4294 @@ -163,8 +163,8 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
4295 return -ENOMEM;
4296 doi_def->map.std = kzalloc(sizeof(*doi_def->map.std), GFP_KERNEL);
4297 if (doi_def->map.std == NULL) {
4298 - ret_val = -ENOMEM;
4299 - goto add_std_failure;
4300 + kfree(doi_def);
4301 + return -ENOMEM;
4302 }
4303 doi_def->type = CIPSO_V4_MAP_TRANS;
4304
4305 @@ -205,14 +205,14 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
4306 }
4307 doi_def->map.std->lvl.local = kcalloc(doi_def->map.std->lvl.local_size,
4308 sizeof(u32),
4309 - GFP_KERNEL);
4310 + GFP_KERNEL | __GFP_NOWARN);
4311 if (doi_def->map.std->lvl.local == NULL) {
4312 ret_val = -ENOMEM;
4313 goto add_std_failure;
4314 }
4315 doi_def->map.std->lvl.cipso = kcalloc(doi_def->map.std->lvl.cipso_size,
4316 sizeof(u32),
4317 - GFP_KERNEL);
4318 + GFP_KERNEL | __GFP_NOWARN);
4319 if (doi_def->map.std->lvl.cipso == NULL) {
4320 ret_val = -ENOMEM;
4321 goto add_std_failure;
4322 @@ -279,7 +279,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
4323 doi_def->map.std->cat.local = kcalloc(
4324 doi_def->map.std->cat.local_size,
4325 sizeof(u32),
4326 - GFP_KERNEL);
4327 + GFP_KERNEL | __GFP_NOWARN);
4328 if (doi_def->map.std->cat.local == NULL) {
4329 ret_val = -ENOMEM;
4330 goto add_std_failure;
4331 @@ -287,7 +287,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,
4332 doi_def->map.std->cat.cipso = kcalloc(
4333 doi_def->map.std->cat.cipso_size,
4334 sizeof(u32),
4335 - GFP_KERNEL);
4336 + GFP_KERNEL | __GFP_NOWARN);
4337 if (doi_def->map.std->cat.cipso == NULL) {
4338 ret_val = -ENOMEM;
4339 goto add_std_failure;
4340 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
4341 index 541410f1c3b74..453b0efdc0d71 100644
4342 --- a/net/netlink/af_netlink.c
4343 +++ b/net/netlink/af_netlink.c
4344 @@ -2409,13 +2409,15 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
4345 /* errors reported via destination sk->sk_err, but propagate
4346 * delivery errors if NETLINK_BROADCAST_ERROR flag is set */
4347 err = nlmsg_multicast(sk, skb, exclude_portid, group, flags);
4348 + if (err == -ESRCH)
4349 + err = 0;
4350 }
4351
4352 if (report) {
4353 int err2;
4354
4355 err2 = nlmsg_unicast(sk, skb, portid);
4356 - if (!err || err == -ESRCH)
4357 + if (!err)
4358 err = err2;
4359 }
4360
4361 diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
4362 index 18904313bd4e6..5d3698199757a 100644
4363 --- a/net/sched/cls_flower.c
4364 +++ b/net/sched/cls_flower.c
4365 @@ -445,6 +445,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
4366
4367 if (tb[TCA_FLOWER_KEY_IPV4_SRC] || tb[TCA_FLOWER_KEY_IPV4_DST]) {
4368 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
4369 + mask->control.addr_type = ~0;
4370 fl_set_key_val(tb, &key->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC,
4371 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK,
4372 sizeof(key->ipv4.src));
4373 @@ -453,6 +454,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
4374 sizeof(key->ipv4.dst));
4375 } else if (tb[TCA_FLOWER_KEY_IPV6_SRC] || tb[TCA_FLOWER_KEY_IPV6_DST]) {
4376 key->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
4377 + mask->control.addr_type = ~0;
4378 fl_set_key_val(tb, &key->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC,
4379 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK,
4380 sizeof(key->ipv6.src));
4381 @@ -480,6 +482,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
4382 if (tb[TCA_FLOWER_KEY_ENC_IPV4_SRC] ||
4383 tb[TCA_FLOWER_KEY_ENC_IPV4_DST]) {
4384 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
4385 + mask->enc_control.addr_type = ~0;
4386 fl_set_key_val(tb, &key->enc_ipv4.src,
4387 TCA_FLOWER_KEY_ENC_IPV4_SRC,
4388 &mask->enc_ipv4.src,
4389 @@ -495,6 +498,7 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
4390 if (tb[TCA_FLOWER_KEY_ENC_IPV6_SRC] ||
4391 tb[TCA_FLOWER_KEY_ENC_IPV6_DST]) {
4392 key->enc_control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
4393 + mask->enc_control.addr_type = ~0;
4394 fl_set_key_val(tb, &key->enc_ipv6.src,
4395 TCA_FLOWER_KEY_ENC_IPV6_SRC,
4396 &mask->enc_ipv6.src,
4397 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
4398 index 85ad23d9a8a9b..5a7041c34c7b1 100644
4399 --- a/net/sunrpc/auth_gss/svcauth_gss.c
4400 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
4401 @@ -1853,7 +1853,7 @@ gss_svc_init_net(struct net *net)
4402 goto out2;
4403 return 0;
4404 out2:
4405 - destroy_use_gss_proxy_proc_entry(net);
4406 + rsi_cache_destroy_net(net);
4407 out1:
4408 rsc_cache_destroy_net(net);
4409 return rv;
4410 diff --git a/net/tipc/socket.c b/net/tipc/socket.c
4411 index 6077850774454..9f39276e5d4e2 100644
4412 --- a/net/tipc/socket.c
4413 +++ b/net/tipc/socket.c
4414 @@ -1755,7 +1755,7 @@ static int tipc_backlog_rcv(struct sock *sk, struct sk_buff *skb)
4415 static void tipc_sk_enqueue(struct sk_buff_head *inputq, struct sock *sk,
4416 u32 dport, struct sk_buff_head *xmitq)
4417 {
4418 - unsigned long time_limit = jiffies + 2;
4419 + unsigned long time_limit = jiffies + usecs_to_jiffies(20000);
4420 struct sk_buff *skb;
4421 unsigned int lim;
4422 atomic_t *dcnt;
4423 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
4424 index bfdfb958a37d6..2c643e1919aab 100644
4425 --- a/net/unix/af_unix.c
4426 +++ b/net/unix/af_unix.c
4427 @@ -2694,7 +2694,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
4428
4429 other = unix_peer(sk);
4430 if (other && unix_peer(other) != sk &&
4431 - unix_recvq_full(other) &&
4432 + unix_recvq_full_lockless(other) &&
4433 unix_dgram_peer_wake_me(sk, other))
4434 writable = 0;
4435
4436 diff --git a/security/integrity/ima/ima_mok.c b/security/integrity/ima/ima_mok.c
4437 index 74a2799574642..315a638ec8d13 100644
4438 --- a/security/integrity/ima/ima_mok.c
4439 +++ b/security/integrity/ima/ima_mok.c
4440 @@ -25,7 +25,7 @@ struct key *ima_blacklist_keyring;
4441 /*
4442 * Allocate the IMA blacklist keyring
4443 */
4444 -__init int ima_mok_init(void)
4445 +static __init int ima_mok_init(void)
4446 {
4447 pr_notice("Allocating IMA blacklist keyring.\n");
4448
4449 diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
4450 index e5d5c7fb2dace..b25cc69ef7ba9 100644
4451 --- a/security/smack/smack_access.c
4452 +++ b/security/smack/smack_access.c
4453 @@ -90,23 +90,22 @@ int log_policy = SMACK_AUDIT_DENIED;
4454 int smk_access_entry(char *subject_label, char *object_label,
4455 struct list_head *rule_list)
4456 {
4457 - int may = -ENOENT;
4458 struct smack_rule *srp;
4459
4460 list_for_each_entry_rcu(srp, rule_list, list) {
4461 if (srp->smk_object->smk_known == object_label &&
4462 srp->smk_subject->smk_known == subject_label) {
4463 - may = srp->smk_access;
4464 - break;
4465 + int may = srp->smk_access;
4466 + /*
4467 + * MAY_WRITE implies MAY_LOCK.
4468 + */
4469 + if ((may & MAY_WRITE) == MAY_WRITE)
4470 + may |= MAY_LOCK;
4471 + return may;
4472 }
4473 }
4474
4475 - /*
4476 - * MAY_WRITE implies MAY_LOCK.
4477 - */
4478 - if ((may & MAY_WRITE) == MAY_WRITE)
4479 - may |= MAY_LOCK;
4480 - return may;
4481 + return -ENOENT;
4482 }
4483
4484 /**
4485 diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
4486 index f0052c06d0651..a479f21f49c5b 100644
4487 --- a/sound/core/pcm_lib.c
4488 +++ b/sound/core/pcm_lib.c
4489 @@ -1830,7 +1830,7 @@ static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream,
4490 channels = params_channels(params);
4491 frame_size = snd_pcm_format_size(format, channels);
4492 if (frame_size > 0)
4493 - params->fifo_size /= (unsigned)frame_size;
4494 + params->fifo_size /= frame_size;
4495 }
4496 return 0;
4497 }
4498 diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
4499 index c17f262f0834b..18e002fef401d 100644
4500 --- a/sound/soc/intel/boards/bytcr_rt5640.c
4501 +++ b/sound/soc/intel/boards/bytcr_rt5640.c
4502 @@ -172,9 +172,6 @@ static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = {
4503 static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
4504 {"Headphone", NULL, "Platform Clock"},
4505 {"Headset Mic", NULL, "Platform Clock"},
4506 - {"Internal Mic", NULL, "Platform Clock"},
4507 - {"Speaker", NULL, "Platform Clock"},
4508 -
4509 {"Headset Mic", NULL, "MICBIAS1"},
4510 {"IN2P", NULL, "Headset Mic"},
4511 {"Headphone", NULL, "HPOL"},
4512 @@ -182,19 +179,23 @@ static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = {
4513 };
4514
4515 static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic1_map[] = {
4516 + {"Internal Mic", NULL, "Platform Clock"},
4517 {"DMIC1", NULL, "Internal Mic"},
4518 };
4519
4520 static const struct snd_soc_dapm_route byt_rt5640_intmic_dmic2_map[] = {
4521 + {"Internal Mic", NULL, "Platform Clock"},
4522 {"DMIC2", NULL, "Internal Mic"},
4523 };
4524
4525 static const struct snd_soc_dapm_route byt_rt5640_intmic_in1_map[] = {
4526 + {"Internal Mic", NULL, "Platform Clock"},
4527 {"Internal Mic", NULL, "MICBIAS1"},
4528 {"IN1P", NULL, "Internal Mic"},
4529 };
4530
4531 static const struct snd_soc_dapm_route byt_rt5640_intmic_in3_map[] = {
4532 + {"Internal Mic", NULL, "Platform Clock"},
4533 {"Internal Mic", NULL, "MICBIAS1"},
4534 {"IN3P", NULL, "Internal Mic"},
4535 };
4536 @@ -236,6 +237,7 @@ static const struct snd_soc_dapm_route byt_rt5640_ssp0_aif2_map[] = {
4537 };
4538
4539 static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
4540 + {"Speaker", NULL, "Platform Clock"},
4541 {"Speaker", NULL, "SPOLP"},
4542 {"Speaker", NULL, "SPOLN"},
4543 {"Speaker", NULL, "SPORP"},
4544 @@ -243,6 +245,7 @@ static const struct snd_soc_dapm_route byt_rt5640_stereo_spk_map[] = {
4545 };
4546
4547 static const struct snd_soc_dapm_route byt_rt5640_mono_spk_map[] = {
4548 + {"Speaker", NULL, "Platform Clock"},
4549 {"Speaker", NULL, "SPOLP"},
4550 {"Speaker", NULL, "SPOLN"},
4551 };