Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Thu, 04 Oct 2018 10:40:33
Message-Id: 1538649600.a8f461abd40e77004316d61525d65e25fc114e93.mpagano@gentoo
1 commit: a8f461abd40e77004316d61525d65e25fc114e93
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Oct 4 10:40:00 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 4 10:40:00 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=a8f461ab
7
8 Linux patch 4.9.131
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1130_linux-4.9.131.patch | 2733 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2737 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 776fab9..5b6207f 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -563,6 +563,10 @@ Patch: 1129_linux-4.9.130.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.9.130
23
24 +Patch: 1130_linux-4.9.131.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.9.131
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1130_linux-4.9.131.patch b/1130_linux-4.9.131.patch
33 new file mode 100644
34 index 0000000..118d823
35 --- /dev/null
36 +++ b/1130_linux-4.9.131.patch
37 @@ -0,0 +1,2733 @@
38 +diff --git a/Documentation/hwmon/ina2xx b/Documentation/hwmon/ina2xx
39 +index cfd31d94c872..f8bf14055c2f 100644
40 +--- a/Documentation/hwmon/ina2xx
41 ++++ b/Documentation/hwmon/ina2xx
42 +@@ -32,7 +32,7 @@ Supported chips:
43 + Datasheet: Publicly available at the Texas Instruments website
44 + http://www.ti.com/
45 +
46 +-Author: Lothar Felten <l-felten@××.com>
47 ++Author: Lothar Felten <lothar.felten@×××××.com>
48 +
49 + Description
50 + -----------
51 +diff --git a/Makefile b/Makefile
52 +index b98e04a5e1e5..73c4e9a8c127 100644
53 +--- a/Makefile
54 ++++ b/Makefile
55 +@@ -1,6 +1,6 @@
56 + VERSION = 4
57 + PATCHLEVEL = 9
58 +-SUBLEVEL = 130
59 ++SUBLEVEL = 131
60 + EXTRAVERSION =
61 + NAME = Roaring Lionus
62 +
63 +diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
64 +index ce54a70b7695..a1a928064b53 100644
65 +--- a/arch/arm/boot/dts/dra7.dtsi
66 ++++ b/arch/arm/boot/dts/dra7.dtsi
67 +@@ -1770,7 +1770,7 @@
68 + };
69 + };
70 +
71 +- dcan1: can@481cc000 {
72 ++ dcan1: can@4ae3c000 {
73 + compatible = "ti,dra7-d_can";
74 + ti,hwmods = "dcan1";
75 + reg = <0x4ae3c000 0x2000>;
76 +@@ -1780,7 +1780,7 @@
77 + status = "disabled";
78 + };
79 +
80 +- dcan2: can@481d0000 {
81 ++ dcan2: can@48480000 {
82 + compatible = "ti,dra7-d_can";
83 + ti,hwmods = "dcan2";
84 + reg = <0x48480000 0x2000>;
85 +diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c
86 +index f39bd51bce18..faaf7c3aaf9f 100644
87 +--- a/arch/arm/mach-mvebu/pmsu.c
88 ++++ b/arch/arm/mach-mvebu/pmsu.c
89 +@@ -116,8 +116,8 @@ void mvebu_pmsu_set_cpu_boot_addr(int hw_cpu, void *boot_addr)
90 + PMSU_BOOT_ADDR_REDIRECT_OFFSET(hw_cpu));
91 + }
92 +
93 +-extern unsigned char mvebu_boot_wa_start;
94 +-extern unsigned char mvebu_boot_wa_end;
95 ++extern unsigned char mvebu_boot_wa_start[];
96 ++extern unsigned char mvebu_boot_wa_end[];
97 +
98 + /*
99 + * This function sets up the boot address workaround needed for SMP
100 +@@ -130,7 +130,7 @@ int mvebu_setup_boot_addr_wa(unsigned int crypto_eng_target,
101 + phys_addr_t resume_addr_reg)
102 + {
103 + void __iomem *sram_virt_base;
104 +- u32 code_len = &mvebu_boot_wa_end - &mvebu_boot_wa_start;
105 ++ u32 code_len = mvebu_boot_wa_end - mvebu_boot_wa_start;
106 +
107 + mvebu_mbus_del_window(BOOTROM_BASE, BOOTROM_SIZE);
108 + mvebu_mbus_add_window_by_id(crypto_eng_target, crypto_eng_attribute,
109 +diff --git a/arch/arm/mach-omap2/omap_hwmod_reset.c b/arch/arm/mach-omap2/omap_hwmod_reset.c
110 +index b68f9c0aff0b..d5ddba00bb73 100644
111 +--- a/arch/arm/mach-omap2/omap_hwmod_reset.c
112 ++++ b/arch/arm/mach-omap2/omap_hwmod_reset.c
113 +@@ -92,11 +92,13 @@ static void omap_rtc_wait_not_busy(struct omap_hwmod *oh)
114 + */
115 + void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
116 + {
117 +- local_irq_disable();
118 ++ unsigned long flags;
119 ++
120 ++ local_irq_save(flags);
121 + omap_rtc_wait_not_busy(oh);
122 + omap_hwmod_write(OMAP_RTC_KICK0_VALUE, oh, OMAP_RTC_KICK0_REG);
123 + omap_hwmod_write(OMAP_RTC_KICK1_VALUE, oh, OMAP_RTC_KICK1_REG);
124 +- local_irq_enable();
125 ++ local_irq_restore(flags);
126 + }
127 +
128 + /**
129 +@@ -110,9 +112,11 @@ void omap_hwmod_rtc_unlock(struct omap_hwmod *oh)
130 + */
131 + void omap_hwmod_rtc_lock(struct omap_hwmod *oh)
132 + {
133 +- local_irq_disable();
134 ++ unsigned long flags;
135 ++
136 ++ local_irq_save(flags);
137 + omap_rtc_wait_not_busy(oh);
138 + omap_hwmod_write(0x0, oh, OMAP_RTC_KICK0_REG);
139 + omap_hwmod_write(0x0, oh, OMAP_RTC_KICK1_REG);
140 +- local_irq_enable();
141 ++ local_irq_restore(flags);
142 + }
143 +diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
144 +index fe39e6841326..ba0d52c22b50 100644
145 +--- a/arch/arm64/include/asm/kvm_emulate.h
146 ++++ b/arch/arm64/include/asm/kvm_emulate.h
147 +@@ -42,6 +42,11 @@ void kvm_inject_vabt(struct kvm_vcpu *vcpu);
148 + void kvm_inject_dabt(struct kvm_vcpu *vcpu, unsigned long addr);
149 + void kvm_inject_pabt(struct kvm_vcpu *vcpu, unsigned long addr);
150 +
151 ++static inline bool vcpu_el1_is_32bit(struct kvm_vcpu *vcpu)
152 ++{
153 ++ return !(vcpu->arch.hcr_el2 & HCR_RW);
154 ++}
155 ++
156 + static inline void vcpu_reset_hcr(struct kvm_vcpu *vcpu)
157 + {
158 + vcpu->arch.hcr_el2 = HCR_GUEST_FLAGS;
159 +diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c
160 +index d3e0a2ffb383..e41a7b4f3a9b 100644
161 +--- a/arch/arm64/kvm/guest.c
162 ++++ b/arch/arm64/kvm/guest.c
163 +@@ -57,6 +57,45 @@ static u64 core_reg_offset_from_id(u64 id)
164 + return id & ~(KVM_REG_ARCH_MASK | KVM_REG_SIZE_MASK | KVM_REG_ARM_CORE);
165 + }
166 +
167 ++static int validate_core_offset(const struct kvm_one_reg *reg)
168 ++{
169 ++ u64 off = core_reg_offset_from_id(reg->id);
170 ++ int size;
171 ++
172 ++ switch (off) {
173 ++ case KVM_REG_ARM_CORE_REG(regs.regs[0]) ...
174 ++ KVM_REG_ARM_CORE_REG(regs.regs[30]):
175 ++ case KVM_REG_ARM_CORE_REG(regs.sp):
176 ++ case KVM_REG_ARM_CORE_REG(regs.pc):
177 ++ case KVM_REG_ARM_CORE_REG(regs.pstate):
178 ++ case KVM_REG_ARM_CORE_REG(sp_el1):
179 ++ case KVM_REG_ARM_CORE_REG(elr_el1):
180 ++ case KVM_REG_ARM_CORE_REG(spsr[0]) ...
181 ++ KVM_REG_ARM_CORE_REG(spsr[KVM_NR_SPSR - 1]):
182 ++ size = sizeof(__u64);
183 ++ break;
184 ++
185 ++ case KVM_REG_ARM_CORE_REG(fp_regs.vregs[0]) ...
186 ++ KVM_REG_ARM_CORE_REG(fp_regs.vregs[31]):
187 ++ size = sizeof(__uint128_t);
188 ++ break;
189 ++
190 ++ case KVM_REG_ARM_CORE_REG(fp_regs.fpsr):
191 ++ case KVM_REG_ARM_CORE_REG(fp_regs.fpcr):
192 ++ size = sizeof(__u32);
193 ++ break;
194 ++
195 ++ default:
196 ++ return -EINVAL;
197 ++ }
198 ++
199 ++ if (KVM_REG_SIZE(reg->id) == size &&
200 ++ IS_ALIGNED(off, size / sizeof(__u32)))
201 ++ return 0;
202 ++
203 ++ return -EINVAL;
204 ++}
205 ++
206 + static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
207 + {
208 + /*
209 +@@ -76,6 +115,9 @@ static int get_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
210 + (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs)
211 + return -ENOENT;
212 +
213 ++ if (validate_core_offset(reg))
214 ++ return -EINVAL;
215 ++
216 + if (copy_to_user(uaddr, ((u32 *)regs) + off, KVM_REG_SIZE(reg->id)))
217 + return -EFAULT;
218 +
219 +@@ -98,6 +140,9 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
220 + (off + (KVM_REG_SIZE(reg->id) / sizeof(__u32))) >= nr_regs)
221 + return -ENOENT;
222 +
223 ++ if (validate_core_offset(reg))
224 ++ return -EINVAL;
225 ++
226 + if (KVM_REG_SIZE(reg->id) > sizeof(tmp))
227 + return -EINVAL;
228 +
229 +@@ -107,17 +152,25 @@ static int set_core_reg(struct kvm_vcpu *vcpu, const struct kvm_one_reg *reg)
230 + }
231 +
232 + if (off == KVM_REG_ARM_CORE_REG(regs.pstate)) {
233 +- u32 mode = (*(u32 *)valp) & COMPAT_PSR_MODE_MASK;
234 ++ u64 mode = (*(u64 *)valp) & COMPAT_PSR_MODE_MASK;
235 + switch (mode) {
236 + case COMPAT_PSR_MODE_USR:
237 ++ if (!system_supports_32bit_el0())
238 ++ return -EINVAL;
239 ++ break;
240 + case COMPAT_PSR_MODE_FIQ:
241 + case COMPAT_PSR_MODE_IRQ:
242 + case COMPAT_PSR_MODE_SVC:
243 + case COMPAT_PSR_MODE_ABT:
244 + case COMPAT_PSR_MODE_UND:
245 ++ if (!vcpu_el1_is_32bit(vcpu))
246 ++ return -EINVAL;
247 ++ break;
248 + case PSR_MODE_EL0t:
249 + case PSR_MODE_EL1t:
250 + case PSR_MODE_EL1h:
251 ++ if (vcpu_el1_is_32bit(vcpu))
252 ++ return -EINVAL;
253 + break;
254 + default:
255 + err = -EINVAL;
256 +diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
257 +index 2694d078741d..9dafd7af39b8 100644
258 +--- a/arch/powerpc/kernel/machine_kexec.c
259 ++++ b/arch/powerpc/kernel/machine_kexec.c
260 +@@ -186,7 +186,12 @@ void __init reserve_crashkernel(void)
261 + (unsigned long)(crashk_res.start >> 20),
262 + (unsigned long)(memblock_phys_mem_size() >> 20));
263 +
264 +- memblock_reserve(crashk_res.start, crash_size);
265 ++ if (!memblock_is_region_memory(crashk_res.start, crash_size) ||
266 ++ memblock_reserve(crashk_res.start, crash_size)) {
267 ++ pr_err("Failed to reserve memory for crashkernel!\n");
268 ++ crashk_res.start = crashk_res.end = 0;
269 ++ return;
270 ++ }
271 + }
272 +
273 + int overlaps_crashkernel(unsigned long start, unsigned long size)
274 +diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
275 +index f52cc6fd4290..8015e40bc7ee 100644
276 +--- a/arch/powerpc/platforms/powernv/pci-ioda.c
277 ++++ b/arch/powerpc/platforms/powernv/pci-ioda.c
278 +@@ -2623,7 +2623,7 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
279 + level_shift = entries_shift + 3;
280 + level_shift = max_t(unsigned, level_shift, PAGE_SHIFT);
281 +
282 +- if ((level_shift - 3) * levels + page_shift >= 60)
283 ++ if ((level_shift - 3) * levels + page_shift >= 55)
284 + return -EINVAL;
285 +
286 + /* Allocate TCE table */
287 +diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c
288 +index 02042b6b66bf..e6665a6e105e 100644
289 +--- a/arch/s390/mm/extmem.c
290 ++++ b/arch/s390/mm/extmem.c
291 +@@ -79,7 +79,7 @@ struct qin64 {
292 + struct dcss_segment {
293 + struct list_head list;
294 + char dcss_name[8];
295 +- char res_name[15];
296 ++ char res_name[16];
297 + unsigned long start_addr;
298 + unsigned long end;
299 + atomic_t ref_count;
300 +@@ -432,7 +432,7 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long
301 + memcpy(&seg->res_name, seg->dcss_name, 8);
302 + EBCASC(seg->res_name, 8);
303 + seg->res_name[8] = '\0';
304 +- strncat(seg->res_name, " (DCSS)", 7);
305 ++ strlcat(seg->res_name, " (DCSS)", sizeof(seg->res_name));
306 + seg->res->name = seg->res_name;
307 + rc = seg->vm_segtype;
308 + if (rc == SEG_TYPE_SC ||
309 +diff --git a/arch/s390/mm/pgalloc.c b/arch/s390/mm/pgalloc.c
310 +index 995f78532cc2..781a044e1702 100644
311 +--- a/arch/s390/mm/pgalloc.c
312 ++++ b/arch/s390/mm/pgalloc.c
313 +@@ -26,7 +26,7 @@ static struct ctl_table page_table_sysctl[] = {
314 + .data = &page_table_allocate_pgste,
315 + .maxlen = sizeof(int),
316 + .mode = S_IRUGO | S_IWUSR,
317 +- .proc_handler = proc_dointvec,
318 ++ .proc_handler = proc_dointvec_minmax,
319 + .extra1 = &page_table_allocate_pgste_min,
320 + .extra2 = &page_table_allocate_pgste_max,
321 + },
322 +diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
323 +index 76c1d85e749b..870e941c1947 100644
324 +--- a/arch/x86/entry/entry_64.S
325 ++++ b/arch/x86/entry/entry_64.S
326 +@@ -91,7 +91,7 @@ ENDPROC(native_usergs_sysret64)
327 + .endm
328 +
329 + .macro TRACE_IRQS_IRETQ_DEBUG
330 +- bt $9, EFLAGS(%rsp) /* interrupts off? */
331 ++ btl $9, EFLAGS(%rsp) /* interrupts off? */
332 + jnc 1f
333 + TRACE_IRQS_ON_DEBUG
334 + 1:
335 +@@ -485,7 +485,7 @@ retint_kernel:
336 + #ifdef CONFIG_PREEMPT
337 + /* Interrupts are off */
338 + /* Check if we need preemption */
339 +- bt $9, EFLAGS(%rsp) /* were interrupts off? */
340 ++ btl $9, EFLAGS(%rsp) /* were interrupts off? */
341 + jnc 1f
342 + 0: cmpl $0, PER_CPU_VAR(__preempt_count)
343 + jnz 1f
344 +diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c
345 +index 5d103a87e984..2c3c7abf678b 100644
346 +--- a/arch/x86/events/intel/lbr.c
347 ++++ b/arch/x86/events/intel/lbr.c
348 +@@ -342,7 +342,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
349 +
350 + mask = x86_pmu.lbr_nr - 1;
351 + tos = task_ctx->tos;
352 +- for (i = 0; i < tos; i++) {
353 ++ for (i = 0; i < task_ctx->valid_lbrs; i++) {
354 + lbr_idx = (tos - i) & mask;
355 + wrlbr_from(lbr_idx, task_ctx->lbr_from[i]);
356 + wrlbr_to (lbr_idx, task_ctx->lbr_to[i]);
357 +@@ -350,6 +350,15 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
358 + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
359 + wrmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
360 + }
361 ++
362 ++ for (; i < x86_pmu.lbr_nr; i++) {
363 ++ lbr_idx = (tos - i) & mask;
364 ++ wrlbr_from(lbr_idx, 0);
365 ++ wrlbr_to(lbr_idx, 0);
366 ++ if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
367 ++ wrmsrl(MSR_LBR_INFO_0 + lbr_idx, 0);
368 ++ }
369 ++
370 + wrmsrl(x86_pmu.lbr_tos, tos);
371 + task_ctx->lbr_stack_state = LBR_NONE;
372 + }
373 +@@ -357,7 +366,7 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
374 + static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx)
375 + {
376 + unsigned lbr_idx, mask;
377 +- u64 tos;
378 ++ u64 tos, from;
379 + int i;
380 +
381 + if (task_ctx->lbr_callstack_users == 0) {
382 +@@ -367,13 +376,17 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx)
383 +
384 + mask = x86_pmu.lbr_nr - 1;
385 + tos = intel_pmu_lbr_tos();
386 +- for (i = 0; i < tos; i++) {
387 ++ for (i = 0; i < x86_pmu.lbr_nr; i++) {
388 + lbr_idx = (tos - i) & mask;
389 +- task_ctx->lbr_from[i] = rdlbr_from(lbr_idx);
390 ++ from = rdlbr_from(lbr_idx);
391 ++ if (!from)
392 ++ break;
393 ++ task_ctx->lbr_from[i] = from;
394 + task_ctx->lbr_to[i] = rdlbr_to(lbr_idx);
395 + if (x86_pmu.intel_cap.lbr_format == LBR_FORMAT_INFO)
396 + rdmsrl(MSR_LBR_INFO_0 + lbr_idx, task_ctx->lbr_info[i]);
397 + }
398 ++ task_ctx->valid_lbrs = i;
399 + task_ctx->tos = tos;
400 + task_ctx->lbr_stack_state = LBR_VALID;
401 + }
402 +@@ -522,7 +535,7 @@ static void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc)
403 + */
404 + static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
405 + {
406 +- bool need_info = false;
407 ++ bool need_info = false, call_stack = false;
408 + unsigned long mask = x86_pmu.lbr_nr - 1;
409 + int lbr_format = x86_pmu.intel_cap.lbr_format;
410 + u64 tos = intel_pmu_lbr_tos();
411 +@@ -533,7 +546,7 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
412 + if (cpuc->lbr_sel) {
413 + need_info = !(cpuc->lbr_sel->config & LBR_NO_INFO);
414 + if (cpuc->lbr_sel->config & LBR_CALL_STACK)
415 +- num = tos;
416 ++ call_stack = true;
417 + }
418 +
419 + for (i = 0; i < num; i++) {
420 +@@ -546,6 +559,13 @@ static void intel_pmu_lbr_read_64(struct cpu_hw_events *cpuc)
421 + from = rdlbr_from(lbr_idx);
422 + to = rdlbr_to(lbr_idx);
423 +
424 ++ /*
425 ++ * Read LBR call stack entries
426 ++ * until invalid entry (0s) is detected.
427 ++ */
428 ++ if (call_stack && !from)
429 ++ break;
430 ++
431 + if (lbr_format == LBR_FORMAT_INFO && need_info) {
432 + u64 info;
433 +
434 +diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h
435 +index f3563179290b..1bfebbc4d156 100644
436 +--- a/arch/x86/events/perf_event.h
437 ++++ b/arch/x86/events/perf_event.h
438 +@@ -633,6 +633,7 @@ struct x86_perf_task_context {
439 + u64 lbr_to[MAX_LBR_ENTRIES];
440 + u64 lbr_info[MAX_LBR_ENTRIES];
441 + int tos;
442 ++ int valid_lbrs;
443 + int lbr_callstack_users;
444 + int lbr_stack_state;
445 + };
446 +diff --git a/arch/x86/kernel/tsc_msr.c b/arch/x86/kernel/tsc_msr.c
447 +index 0fe720d64fef..3f818ce985c0 100644
448 +--- a/arch/x86/kernel/tsc_msr.c
449 ++++ b/arch/x86/kernel/tsc_msr.c
450 +@@ -12,6 +12,7 @@
451 + #include <asm/setup.h>
452 + #include <asm/apic.h>
453 + #include <asm/param.h>
454 ++#include <asm/tsc.h>
455 +
456 + #define MAX_NUM_FREQS 9
457 +
458 +diff --git a/arch/x86/mm/numa_emulation.c b/arch/x86/mm/numa_emulation.c
459 +index a8f90ce3dedf..dc6d99017f3f 100644
460 +--- a/arch/x86/mm/numa_emulation.c
461 ++++ b/arch/x86/mm/numa_emulation.c
462 +@@ -60,7 +60,7 @@ static int __init emu_setup_memblk(struct numa_meminfo *ei,
463 + eb->nid = nid;
464 +
465 + if (emu_nid_to_phys[nid] == NUMA_NO_NODE)
466 +- emu_nid_to_phys[nid] = nid;
467 ++ emu_nid_to_phys[nid] = pb->nid;
468 +
469 + pb->start += size;
470 + if (pb->start >= pb->end) {
471 +diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
472 +index 860c9e5dfd7a..3bc0e76eaaef 100644
473 +--- a/crypto/ablkcipher.c
474 ++++ b/crypto/ablkcipher.c
475 +@@ -367,6 +367,7 @@ static int crypto_ablkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
476 + strncpy(rblkcipher.type, "ablkcipher", sizeof(rblkcipher.type));
477 + strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<default>",
478 + sizeof(rblkcipher.geniv));
479 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
480 +
481 + rblkcipher.blocksize = alg->cra_blocksize;
482 + rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
483 +@@ -441,6 +442,7 @@ static int crypto_givcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
484 + strncpy(rblkcipher.type, "givcipher", sizeof(rblkcipher.type));
485 + strncpy(rblkcipher.geniv, alg->cra_ablkcipher.geniv ?: "<built-in>",
486 + sizeof(rblkcipher.geniv));
487 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
488 +
489 + rblkcipher.blocksize = alg->cra_blocksize;
490 + rblkcipher.min_keysize = alg->cra_ablkcipher.min_keysize;
491 +diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
492 +index 27f98666763a..59a0936ed8bc 100644
493 +--- a/crypto/blkcipher.c
494 ++++ b/crypto/blkcipher.c
495 +@@ -510,6 +510,7 @@ static int crypto_blkcipher_report(struct sk_buff *skb, struct crypto_alg *alg)
496 + strncpy(rblkcipher.type, "blkcipher", sizeof(rblkcipher.type));
497 + strncpy(rblkcipher.geniv, alg->cra_blkcipher.geniv ?: "<default>",
498 + sizeof(rblkcipher.geniv));
499 ++ rblkcipher.geniv[sizeof(rblkcipher.geniv) - 1] = '\0';
500 +
501 + rblkcipher.blocksize = alg->cra_blocksize;
502 + rblkcipher.min_keysize = alg->cra_blkcipher.min_keysize;
503 +diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
504 +index e3d8e4ced4a2..a321d7d849c6 100644
505 +--- a/drivers/block/floppy.c
506 ++++ b/drivers/block/floppy.c
507 +@@ -3459,6 +3459,9 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
508 + (struct floppy_struct **)&outparam);
509 + if (ret)
510 + return ret;
511 ++ memcpy(&inparam.g, outparam,
512 ++ offsetof(struct floppy_struct, name));
513 ++ outparam = &inparam.g;
514 + break;
515 + case FDMSGON:
516 + UDP->flags |= FTD_MSG;
517 +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
518 +index 44bccb1afa06..8dce1a890078 100644
519 +--- a/drivers/bluetooth/btusb.c
520 ++++ b/drivers/bluetooth/btusb.c
521 +@@ -349,6 +349,7 @@ static const struct usb_device_id blacklist_table[] = {
522 + { USB_DEVICE(0x7392, 0xa611), .driver_info = BTUSB_REALTEK },
523 +
524 + /* Additional Realtek 8723DE Bluetooth devices */
525 ++ { USB_DEVICE(0x0bda, 0xb009), .driver_info = BTUSB_REALTEK },
526 + { USB_DEVICE(0x2ff8, 0xb011), .driver_info = BTUSB_REALTEK },
527 +
528 + /* Additional Realtek 8821AE Bluetooth devices */
529 +diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
530 +index 4e0f8e720ad9..40d792e96b75 100644
531 +--- a/drivers/edac/edac_mc_sysfs.c
532 ++++ b/drivers/edac/edac_mc_sysfs.c
533 +@@ -1059,14 +1059,14 @@ int __init edac_mc_sysfs_init(void)
534 +
535 + err = device_add(mci_pdev);
536 + if (err < 0)
537 +- goto out_dev_free;
538 ++ goto out_put_device;
539 +
540 + edac_dbg(0, "device %s created\n", dev_name(mci_pdev));
541 +
542 + return 0;
543 +
544 +- out_dev_free:
545 +- kfree(mci_pdev);
546 ++ out_put_device:
547 ++ put_device(mci_pdev);
548 + out:
549 + return err;
550 + }
551 +diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
552 +index 8a68a5e943ea..b60932026e34 100644
553 +--- a/drivers/edac/i7core_edac.c
554 ++++ b/drivers/edac/i7core_edac.c
555 +@@ -1177,15 +1177,14 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
556 +
557 + rc = device_add(pvt->addrmatch_dev);
558 + if (rc < 0)
559 +- return rc;
560 ++ goto err_put_addrmatch;
561 +
562 + if (!pvt->is_registered) {
563 + pvt->chancounts_dev = kzalloc(sizeof(*pvt->chancounts_dev),
564 + GFP_KERNEL);
565 + if (!pvt->chancounts_dev) {
566 +- put_device(pvt->addrmatch_dev);
567 +- device_del(pvt->addrmatch_dev);
568 +- return -ENOMEM;
569 ++ rc = -ENOMEM;
570 ++ goto err_del_addrmatch;
571 + }
572 +
573 + pvt->chancounts_dev->type = &all_channel_counts_type;
574 +@@ -1199,9 +1198,18 @@ static int i7core_create_sysfs_devices(struct mem_ctl_info *mci)
575 +
576 + rc = device_add(pvt->chancounts_dev);
577 + if (rc < 0)
578 +- return rc;
579 ++ goto err_put_chancounts;
580 + }
581 + return 0;
582 ++
583 ++err_put_chancounts:
584 ++ put_device(pvt->chancounts_dev);
585 ++err_del_addrmatch:
586 ++ device_del(pvt->addrmatch_dev);
587 ++err_put_addrmatch:
588 ++ put_device(pvt->addrmatch_dev);
589 ++
590 ++ return rc;
591 + }
592 +
593 + static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
594 +@@ -1211,11 +1219,11 @@ static void i7core_delete_sysfs_devices(struct mem_ctl_info *mci)
595 + edac_dbg(1, "\n");
596 +
597 + if (!pvt->is_registered) {
598 +- put_device(pvt->chancounts_dev);
599 + device_del(pvt->chancounts_dev);
600 ++ put_device(pvt->chancounts_dev);
601 + }
602 +- put_device(pvt->addrmatch_dev);
603 + device_del(pvt->addrmatch_dev);
604 ++ put_device(pvt->addrmatch_dev);
605 + }
606 +
607 + /****************************************************************************
608 +diff --git a/drivers/gpio/gpio-menz127.c b/drivers/gpio/gpio-menz127.c
609 +index a1210e330571..95061d25895b 100644
610 +--- a/drivers/gpio/gpio-menz127.c
611 ++++ b/drivers/gpio/gpio-menz127.c
612 +@@ -56,9 +56,9 @@ static int men_z127_debounce(struct gpio_chip *gc, unsigned gpio,
613 + rnd = fls(debounce) - 1;
614 +
615 + if (rnd && (debounce & BIT(rnd - 1)))
616 +- debounce = round_up(debounce, MEN_Z127_DB_MIN_US);
617 ++ debounce = roundup(debounce, MEN_Z127_DB_MIN_US);
618 + else
619 +- debounce = round_down(debounce, MEN_Z127_DB_MIN_US);
620 ++ debounce = rounddown(debounce, MEN_Z127_DB_MIN_US);
621 +
622 + if (debounce > MEN_Z127_DB_MAX_US)
623 + debounce = MEN_Z127_DB_MAX_US;
624 +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
625 +index 564362e8b486..c8a5cf5365a9 100644
626 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
627 ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
628 +@@ -5551,6 +5551,11 @@ static int gfx_v8_0_set_powergating_state(void *handle,
629 + if (!(adev->pg_flags & AMD_PG_SUPPORT_GFX_PG))
630 + return 0;
631 +
632 ++ if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_SMG |
633 ++ AMD_PG_SUPPORT_RLC_SMU_HS |
634 ++ AMD_PG_SUPPORT_CP |
635 ++ AMD_PG_SUPPORT_GFX_DMG))
636 ++ adev->gfx.rlc.funcs->enter_safe_mode(adev);
637 + switch (adev->asic_type) {
638 + case CHIP_CARRIZO:
639 + case CHIP_STONEY:
640 +@@ -5586,7 +5591,11 @@ static int gfx_v8_0_set_powergating_state(void *handle,
641 + default:
642 + break;
643 + }
644 +-
645 ++ if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_SMG |
646 ++ AMD_PG_SUPPORT_RLC_SMU_HS |
647 ++ AMD_PG_SUPPORT_CP |
648 ++ AMD_PG_SUPPORT_GFX_DMG))
649 ++ adev->gfx.rlc.funcs->exit_safe_mode(adev);
650 + return 0;
651 + }
652 +
653 +diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
654 +index 71d2856222fa..f61c489e5f6d 100644
655 +--- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
656 ++++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c
657 +@@ -1350,8 +1350,6 @@ static int kv_dpm_enable(struct amdgpu_device *adev)
658 + return ret;
659 + }
660 +
661 +- kv_update_current_ps(adev, adev->pm.dpm.boot_ps);
662 +-
663 + if (adev->irq.installed &&
664 + amdgpu_is_internal_thermal_sensor(adev->pm.int_thermal_type)) {
665 + ret = kv_set_thermal_temperature_range(adev, KV_TEMP_RANGE_MIN, KV_TEMP_RANGE_MAX);
666 +@@ -3086,7 +3084,7 @@ static int kv_dpm_hw_init(void *handle)
667 + else
668 + adev->pm.dpm_enabled = true;
669 + mutex_unlock(&adev->pm.mutex);
670 +-
671 ++ amdgpu_pm_compute_clocks(adev);
672 + return ret;
673 + }
674 +
675 +diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
676 +index 3fa8320e49c1..4826befc1bc3 100644
677 +--- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c
678 ++++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c
679 +@@ -6959,7 +6959,6 @@ static int si_dpm_enable(struct amdgpu_device *adev)
680 +
681 + si_enable_auto_throttle_source(adev, AMDGPU_DPM_AUTO_THROTTLE_SRC_THERMAL, true);
682 + si_thermal_start_thermal_controller(adev);
683 +- ni_update_current_ps(adev, boot_ps);
684 +
685 + return 0;
686 + }
687 +@@ -7836,7 +7835,7 @@ static int si_dpm_hw_init(void *handle)
688 + else
689 + adev->pm.dpm_enabled = true;
690 + mutex_unlock(&adev->pm.mutex);
691 +-
692 ++ amdgpu_pm_compute_clocks(adev);
693 + return ret;
694 + }
695 +
696 +diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
697 +index aad2f4a2a0ef..97828faf2a1f 100644
698 +--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
699 ++++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
700 +@@ -283,7 +283,6 @@ static int sun4i_drv_add_endpoints(struct device *dev,
701 + remote = of_graph_get_remote_port_parent(ep);
702 + if (!remote) {
703 + DRM_DEBUG_DRIVER("Error retrieving the output node\n");
704 +- of_node_put(remote);
705 + continue;
706 + }
707 +
708 +@@ -297,11 +296,13 @@ static int sun4i_drv_add_endpoints(struct device *dev,
709 +
710 + if (of_graph_parse_endpoint(ep, &endpoint)) {
711 + DRM_DEBUG_DRIVER("Couldn't parse endpoint\n");
712 ++ of_node_put(remote);
713 + continue;
714 + }
715 +
716 + if (!endpoint.id) {
717 + DRM_DEBUG_DRIVER("Endpoint is our panel... skipping\n");
718 ++ of_node_put(remote);
719 + continue;
720 + }
721 + }
722 +diff --git a/drivers/hid/hid-ntrig.c b/drivers/hid/hid-ntrig.c
723 +index 1b0084d4af2e..28373dab60ae 100644
724 +--- a/drivers/hid/hid-ntrig.c
725 ++++ b/drivers/hid/hid-ntrig.c
726 +@@ -955,6 +955,8 @@ static int ntrig_probe(struct hid_device *hdev, const struct hid_device_id *id)
727 +
728 + ret = sysfs_create_group(&hdev->dev.kobj,
729 + &ntrig_attribute_group);
730 ++ if (ret)
731 ++ hid_err(hdev, "cannot create sysfs group\n");
732 +
733 + return 0;
734 + err_free:
735 +diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
736 +index 3cefd1aeb24f..9c262d955331 100644
737 +--- a/drivers/hwmon/adt7475.c
738 ++++ b/drivers/hwmon/adt7475.c
739 +@@ -274,14 +274,18 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
740 + return clamp_val(reg, 0, 1023) & (0xff << 2);
741 + }
742 +
743 +-static u16 adt7475_read_word(struct i2c_client *client, int reg)
744 ++static int adt7475_read_word(struct i2c_client *client, int reg)
745 + {
746 +- u16 val;
747 ++ int val1, val2;
748 +
749 +- val = i2c_smbus_read_byte_data(client, reg);
750 +- val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
751 ++ val1 = i2c_smbus_read_byte_data(client, reg);
752 ++ if (val1 < 0)
753 ++ return val1;
754 ++ val2 = i2c_smbus_read_byte_data(client, reg + 1);
755 ++ if (val2 < 0)
756 ++ return val2;
757 +
758 +- return val;
759 ++ return val1 | (val2 << 8);
760 + }
761 +
762 + static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
763 +diff --git a/drivers/hwmon/ina2xx.c b/drivers/hwmon/ina2xx.c
764 +index ac63e562071f..9ac6e1673375 100644
765 +--- a/drivers/hwmon/ina2xx.c
766 ++++ b/drivers/hwmon/ina2xx.c
767 +@@ -17,7 +17,7 @@
768 + * Bi-directional Current/Power Monitor with I2C Interface
769 + * Datasheet: http://www.ti.com/product/ina230
770 + *
771 +- * Copyright (C) 2012 Lothar Felten <l-felten@××.com>
772 ++ * Copyright (C) 2012 Lothar Felten <lothar.felten@×××××.com>
773 + * Thanks to Jan Volkering
774 + *
775 + * This program is free software; you can redistribute it and/or modify
776 +@@ -328,6 +328,15 @@ static int ina2xx_set_shunt(struct ina2xx_data *data, long val)
777 + return 0;
778 + }
779 +
780 ++static ssize_t ina2xx_show_shunt(struct device *dev,
781 ++ struct device_attribute *da,
782 ++ char *buf)
783 ++{
784 ++ struct ina2xx_data *data = dev_get_drvdata(dev);
785 ++
786 ++ return snprintf(buf, PAGE_SIZE, "%li\n", data->rshunt);
787 ++}
788 ++
789 + static ssize_t ina2xx_store_shunt(struct device *dev,
790 + struct device_attribute *da,
791 + const char *buf, size_t count)
792 +@@ -402,7 +411,7 @@ static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, ina2xx_show_value, NULL,
793 +
794 + /* shunt resistance */
795 + static SENSOR_DEVICE_ATTR(shunt_resistor, S_IRUGO | S_IWUSR,
796 +- ina2xx_show_value, ina2xx_store_shunt,
797 ++ ina2xx_show_shunt, ina2xx_store_shunt,
798 + INA2XX_CALIBRATION);
799 +
800 + /* update interval (ina226 only) */
801 +diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
802 +index 663017f1d078..26f1691f67ab 100644
803 +--- a/drivers/i2c/busses/i2c-i801.c
804 ++++ b/drivers/i2c/busses/i2c-i801.c
805 +@@ -1408,6 +1408,13 @@ static void i801_add_tco(struct i801_priv *priv)
806 + }
807 +
808 + #ifdef CONFIG_ACPI
809 ++static bool i801_acpi_is_smbus_ioport(const struct i801_priv *priv,
810 ++ acpi_physical_address address)
811 ++{
812 ++ return address >= priv->smba &&
813 ++ address <= pci_resource_end(priv->pci_dev, SMBBAR);
814 ++}
815 ++
816 + static acpi_status
817 + i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
818 + u64 *value, void *handler_context, void *region_context)
819 +@@ -1423,7 +1430,7 @@ i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits,
820 + */
821 + mutex_lock(&priv->acpi_lock);
822 +
823 +- if (!priv->acpi_reserved) {
824 ++ if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) {
825 + priv->acpi_reserved = true;
826 +
827 + dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n");
828 +diff --git a/drivers/infiniband/core/rw.c b/drivers/infiniband/core/rw.c
829 +index dbfd854c32c9..1d90a122fe5e 100644
830 +--- a/drivers/infiniband/core/rw.c
831 ++++ b/drivers/infiniband/core/rw.c
832 +@@ -87,7 +87,7 @@ static int rdma_rw_init_one_mr(struct ib_qp *qp, u8 port_num,
833 + }
834 +
835 + ret = ib_map_mr_sg(reg->mr, sg, nents, &offset, PAGE_SIZE);
836 +- if (ret < nents) {
837 ++ if (ret < 0 || ret < nents) {
838 + ib_mr_pool_put(qp, &qp->rdma_mrs, reg->mr);
839 + return -EINVAL;
840 + }
841 +diff --git a/drivers/infiniband/hw/hfi1/pio.c b/drivers/infiniband/hw/hfi1/pio.c
842 +index d89b8745d4c1..c2982bbc82b3 100644
843 +--- a/drivers/infiniband/hw/hfi1/pio.c
844 ++++ b/drivers/infiniband/hw/hfi1/pio.c
845 +@@ -88,6 +88,7 @@ void pio_send_control(struct hfi1_devdata *dd, int op)
846 + unsigned long flags;
847 + int write = 1; /* write sendctrl back */
848 + int flush = 0; /* re-read sendctrl to make sure it is flushed */
849 ++ int i;
850 +
851 + spin_lock_irqsave(&dd->sendctrl_lock, flags);
852 +
853 +@@ -97,9 +98,13 @@ void pio_send_control(struct hfi1_devdata *dd, int op)
854 + reg |= SEND_CTRL_SEND_ENABLE_SMASK;
855 + /* Fall through */
856 + case PSC_DATA_VL_ENABLE:
857 ++ mask = 0;
858 ++ for (i = 0; i < ARRAY_SIZE(dd->vld); i++)
859 ++ if (!dd->vld[i].mtu)
860 ++ mask |= BIT_ULL(i);
861 + /* Disallow sending on VLs not enabled */
862 +- mask = (((~0ull) << num_vls) & SEND_CTRL_UNSUPPORTED_VL_MASK) <<
863 +- SEND_CTRL_UNSUPPORTED_VL_SHIFT;
864 ++ mask = (mask & SEND_CTRL_UNSUPPORTED_VL_MASK) <<
865 ++ SEND_CTRL_UNSUPPORTED_VL_SHIFT;
866 + reg = (reg & ~SEND_CTRL_UNSUPPORTED_VL_SMASK) | mask;
867 + break;
868 + case PSC_GLOBAL_DISABLE:
869 +diff --git a/drivers/infiniband/hw/hfi1/user_sdma.c b/drivers/infiniband/hw/hfi1/user_sdma.c
870 +index 77697d690f3e..018a41562704 100644
871 +--- a/drivers/infiniband/hw/hfi1/user_sdma.c
872 ++++ b/drivers/infiniband/hw/hfi1/user_sdma.c
873 +@@ -956,7 +956,7 @@ static int user_sdma_send_pkts(struct user_sdma_request *req, unsigned maxpkts)
874 + if (ACCESS_ONCE(iovec->offset) == iovec->iov.iov_len) {
875 + if (++req->iov_idx == req->data_iovs) {
876 + ret = -EFAULT;
877 +- goto free_txreq;
878 ++ goto free_tx;
879 + }
880 + iovec = &req->iovs[req->iov_idx];
881 + WARN_ON(iovec->offset);
882 +diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
883 +index 01a380efea6b..14ddb7506085 100644
884 +--- a/drivers/infiniband/hw/hfi1/verbs.c
885 ++++ b/drivers/infiniband/hw/hfi1/verbs.c
886 +@@ -1511,12 +1511,18 @@ static int hfi1_check_ah(struct ib_device *ibdev, struct ib_ah_attr *ah_attr)
887 + struct hfi1_pportdata *ppd;
888 + struct hfi1_devdata *dd;
889 + u8 sc5;
890 ++ u8 sl;
891 +
892 + /* test the mapping for validity */
893 + ibp = to_iport(ibdev, ah_attr->port_num);
894 + ppd = ppd_from_ibp(ibp);
895 +- sc5 = ibp->sl_to_sc[ah_attr->sl];
896 + dd = dd_from_ppd(ppd);
897 ++
898 ++ sl = ah_attr->sl;
899 ++ if (sl >= ARRAY_SIZE(ibp->sl_to_sc))
900 ++ return -EINVAL;
901 ++
902 ++ sc5 = ibp->sl_to_sc[sl];
903 + if (sc_to_vlt(dd, sc5) > num_vls && sc_to_vlt(dd, sc5) != 0xf)
904 + return -EINVAL;
905 + return 0;
906 +diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
907 +index 463ea592a42a..646359025574 100644
908 +--- a/drivers/infiniband/ulp/srp/ib_srp.c
909 ++++ b/drivers/infiniband/ulp/srp/ib_srp.c
910 +@@ -2639,7 +2639,7 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
911 + {
912 + struct srp_target_port *target = host_to_target(scmnd->device->host);
913 + struct srp_rdma_ch *ch;
914 +- int i;
915 ++ int i, j;
916 + u8 status;
917 +
918 + shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
919 +@@ -2653,8 +2653,8 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
920 +
921 + for (i = 0; i < target->ch_count; i++) {
922 + ch = &target->ch[i];
923 +- for (i = 0; i < target->req_ring_size; ++i) {
924 +- struct srp_request *req = &ch->req_ring[i];
925 ++ for (j = 0; j < target->req_ring_size; ++j) {
926 ++ struct srp_request *req = &ch->req_ring[j];
927 +
928 + srp_finish_req(ch, req, scmnd->device, DID_RESET << 16);
929 + }
930 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
931 +index 4e77adbfa835..c120afd9c46a 100644
932 +--- a/drivers/input/mouse/elantech.c
933 ++++ b/drivers/input/mouse/elantech.c
934 +@@ -1176,6 +1176,8 @@ static const struct dmi_system_id elantech_dmi_has_middle_button[] = {
935 + static const char * const middle_button_pnp_ids[] = {
936 + "LEN2131", /* ThinkPad P52 w/ NFC */
937 + "LEN2132", /* ThinkPad P52 */
938 ++ "LEN2133", /* ThinkPad P72 w/ NFC */
939 ++ "LEN2134", /* ThinkPad P72 */
940 + NULL
941 + };
942 +
943 +diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
944 +index 0c910a863581..16199b36a11e 100644
945 +--- a/drivers/iommu/amd_iommu.c
946 ++++ b/drivers/iommu/amd_iommu.c
947 +@@ -2452,9 +2452,9 @@ static void __unmap_single(struct dma_ops_domain *dma_dom,
948 + }
949 +
950 + if (amd_iommu_unmap_flush) {
951 +- dma_ops_free_iova(dma_dom, dma_addr, pages);
952 + domain_flush_tlb(&dma_dom->domain);
953 + domain_flush_complete(&dma_dom->domain);
954 ++ dma_ops_free_iova(dma_dom, dma_addr, pages);
955 + } else {
956 + queue_add(dma_dom, dma_addr, pages);
957 + }
958 +diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
959 +index fcc2b5746a9f..e870b09b2c84 100644
960 +--- a/drivers/md/md-cluster.c
961 ++++ b/drivers/md/md-cluster.c
962 +@@ -302,15 +302,6 @@ static void recover_bitmaps(struct md_thread *thread)
963 + while (cinfo->recovery_map) {
964 + slot = fls64((u64)cinfo->recovery_map) - 1;
965 +
966 +- /* Clear suspend_area associated with the bitmap */
967 +- spin_lock_irq(&cinfo->suspend_lock);
968 +- list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
969 +- if (slot == s->slot) {
970 +- list_del(&s->list);
971 +- kfree(s);
972 +- }
973 +- spin_unlock_irq(&cinfo->suspend_lock);
974 +-
975 + snprintf(str, 64, "bitmap%04d", slot);
976 + bm_lockres = lockres_init(mddev, str, NULL, 1);
977 + if (!bm_lockres) {
978 +@@ -329,6 +320,16 @@ static void recover_bitmaps(struct md_thread *thread)
979 + pr_err("md-cluster: Could not copy data from bitmap %d\n", slot);
980 + goto clear_bit;
981 + }
982 ++
983 ++ /* Clear suspend_area associated with the bitmap */
984 ++ spin_lock_irq(&cinfo->suspend_lock);
985 ++ list_for_each_entry_safe(s, tmp, &cinfo->suspend_list, list)
986 ++ if (slot == s->slot) {
987 ++ list_del(&s->list);
988 ++ kfree(s);
989 ++ }
990 ++ spin_unlock_irq(&cinfo->suspend_lock);
991 ++
992 + if (hi > 0) {
993 + if (lo < mddev->recovery_cp)
994 + mddev->recovery_cp = lo;
995 +diff --git a/drivers/media/i2c/soc_camera/ov772x.c b/drivers/media/i2c/soc_camera/ov772x.c
996 +index 7e68762b3a4b..fa1cb246a66a 100644
997 +--- a/drivers/media/i2c/soc_camera/ov772x.c
998 ++++ b/drivers/media/i2c/soc_camera/ov772x.c
999 +@@ -834,7 +834,7 @@ static int ov772x_set_params(struct ov772x_priv *priv,
1000 + * set COM8
1001 + */
1002 + if (priv->band_filter) {
1003 +- ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, 1);
1004 ++ ret = ov772x_mask_set(client, COM8, BNDF_ON_OFF, BNDF_ON_OFF);
1005 + if (!ret)
1006 + ret = ov772x_mask_set(client, BDBASE,
1007 + 0xff, 256 - priv->band_filter);
1008 +diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c
1009 +index 400ce0cb0c0d..e00fa03ddc3e 100644
1010 +--- a/drivers/media/platform/exynos4-is/fimc-isp-video.c
1011 ++++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c
1012 +@@ -384,12 +384,17 @@ static void __isp_video_try_fmt(struct fimc_isp *isp,
1013 + struct v4l2_pix_format_mplane *pixm,
1014 + const struct fimc_fmt **fmt)
1015 + {
1016 +- *fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2);
1017 ++ const struct fimc_fmt *__fmt;
1018 ++
1019 ++ __fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2);
1020 ++
1021 ++ if (fmt)
1022 ++ *fmt = __fmt;
1023 +
1024 + pixm->colorspace = V4L2_COLORSPACE_SRGB;
1025 + pixm->field = V4L2_FIELD_NONE;
1026 +- pixm->num_planes = (*fmt)->memplanes;
1027 +- pixm->pixelformat = (*fmt)->fourcc;
1028 ++ pixm->num_planes = __fmt->memplanes;
1029 ++ pixm->pixelformat = __fmt->fourcc;
1030 + /*
1031 + * TODO: double check with the docmentation these width/height
1032 + * constraints are correct.
1033 +diff --git a/drivers/media/platform/fsl-viu.c b/drivers/media/platform/fsl-viu.c
1034 +index ae8c6b35a357..7f0ed5a26da9 100644
1035 +--- a/drivers/media/platform/fsl-viu.c
1036 ++++ b/drivers/media/platform/fsl-viu.c
1037 +@@ -1417,7 +1417,7 @@ static int viu_of_probe(struct platform_device *op)
1038 + sizeof(struct viu_reg), DRV_NAME)) {
1039 + dev_err(&op->dev, "Error while requesting mem region\n");
1040 + ret = -EBUSY;
1041 +- goto err;
1042 ++ goto err_irq;
1043 + }
1044 +
1045 + /* remap registers */
1046 +@@ -1425,7 +1425,7 @@ static int viu_of_probe(struct platform_device *op)
1047 + if (!viu_regs) {
1048 + dev_err(&op->dev, "Can't map register set\n");
1049 + ret = -ENOMEM;
1050 +- goto err;
1051 ++ goto err_irq;
1052 + }
1053 +
1054 + /* Prepare our private structure */
1055 +@@ -1433,7 +1433,7 @@ static int viu_of_probe(struct platform_device *op)
1056 + if (!viu_dev) {
1057 + dev_err(&op->dev, "Can't allocate private structure\n");
1058 + ret = -ENOMEM;
1059 +- goto err;
1060 ++ goto err_irq;
1061 + }
1062 +
1063 + viu_dev->vr = viu_regs;
1064 +@@ -1449,16 +1449,21 @@ static int viu_of_probe(struct platform_device *op)
1065 + ret = v4l2_device_register(viu_dev->dev, &viu_dev->v4l2_dev);
1066 + if (ret < 0) {
1067 + dev_err(&op->dev, "v4l2_device_register() failed: %d\n", ret);
1068 +- goto err;
1069 ++ goto err_irq;
1070 + }
1071 +
1072 + ad = i2c_get_adapter(0);
1073 ++ if (!ad) {
1074 ++ ret = -EFAULT;
1075 ++ dev_err(&op->dev, "couldn't get i2c adapter\n");
1076 ++ goto err_v4l2;
1077 ++ }
1078 +
1079 + v4l2_ctrl_handler_init(&viu_dev->hdl, 5);
1080 + if (viu_dev->hdl.error) {
1081 + ret = viu_dev->hdl.error;
1082 + dev_err(&op->dev, "couldn't register control\n");
1083 +- goto err_vdev;
1084 ++ goto err_i2c;
1085 + }
1086 + /* This control handler will inherit the control(s) from the
1087 + sub-device(s). */
1088 +@@ -1476,7 +1481,7 @@ static int viu_of_probe(struct platform_device *op)
1089 + vdev = video_device_alloc();
1090 + if (vdev == NULL) {
1091 + ret = -ENOMEM;
1092 +- goto err_vdev;
1093 ++ goto err_hdl;
1094 + }
1095 +
1096 + *vdev = viu_template;
1097 +@@ -1497,7 +1502,7 @@ static int viu_of_probe(struct platform_device *op)
1098 + ret = video_register_device(viu_dev->vdev, VFL_TYPE_GRABBER, -1);
1099 + if (ret < 0) {
1100 + video_device_release(viu_dev->vdev);
1101 +- goto err_vdev;
1102 ++ goto err_unlock;
1103 + }
1104 +
1105 + /* enable VIU clock */
1106 +@@ -1505,12 +1510,12 @@ static int viu_of_probe(struct platform_device *op)
1107 + if (IS_ERR(clk)) {
1108 + dev_err(&op->dev, "failed to lookup the clock!\n");
1109 + ret = PTR_ERR(clk);
1110 +- goto err_clk;
1111 ++ goto err_vdev;
1112 + }
1113 + ret = clk_prepare_enable(clk);
1114 + if (ret) {
1115 + dev_err(&op->dev, "failed to enable the clock!\n");
1116 +- goto err_clk;
1117 ++ goto err_vdev;
1118 + }
1119 + viu_dev->clk = clk;
1120 +
1121 +@@ -1521,7 +1526,7 @@ static int viu_of_probe(struct platform_device *op)
1122 + if (request_irq(viu_dev->irq, viu_intr, 0, "viu", (void *)viu_dev)) {
1123 + dev_err(&op->dev, "Request VIU IRQ failed.\n");
1124 + ret = -ENODEV;
1125 +- goto err_irq;
1126 ++ goto err_clk;
1127 + }
1128 +
1129 + mutex_unlock(&viu_dev->lock);
1130 +@@ -1529,16 +1534,19 @@ static int viu_of_probe(struct platform_device *op)
1131 + dev_info(&op->dev, "Freescale VIU Video Capture Board\n");
1132 + return ret;
1133 +
1134 +-err_irq:
1135 +- clk_disable_unprepare(viu_dev->clk);
1136 + err_clk:
1137 +- video_unregister_device(viu_dev->vdev);
1138 ++ clk_disable_unprepare(viu_dev->clk);
1139 + err_vdev:
1140 +- v4l2_ctrl_handler_free(&viu_dev->hdl);
1141 ++ video_unregister_device(viu_dev->vdev);
1142 ++err_unlock:
1143 + mutex_unlock(&viu_dev->lock);
1144 ++err_hdl:
1145 ++ v4l2_ctrl_handler_free(&viu_dev->hdl);
1146 ++err_i2c:
1147 + i2c_put_adapter(ad);
1148 ++err_v4l2:
1149 + v4l2_device_unregister(&viu_dev->v4l2_dev);
1150 +-err:
1151 ++err_irq:
1152 + irq_dispose_mapping(viu_irq);
1153 + return ret;
1154 + }
1155 +diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
1156 +index 15a86bb4e61c..1e98b4845ea1 100644
1157 +--- a/drivers/media/platform/omap3isp/isp.c
1158 ++++ b/drivers/media/platform/omap3isp/isp.c
1159 +@@ -304,7 +304,7 @@ static struct clk *isp_xclk_src_get(struct of_phandle_args *clkspec, void *data)
1160 + static int isp_xclk_init(struct isp_device *isp)
1161 + {
1162 + struct device_node *np = isp->dev->of_node;
1163 +- struct clk_init_data init;
1164 ++ struct clk_init_data init = { 0 };
1165 + unsigned int i;
1166 +
1167 + for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i)
1168 +diff --git a/drivers/media/platform/s3c-camif/camif-capture.c b/drivers/media/platform/s3c-camif/camif-capture.c
1169 +index 5c9db0910a76..d9710b5dd375 100644
1170 +--- a/drivers/media/platform/s3c-camif/camif-capture.c
1171 ++++ b/drivers/media/platform/s3c-camif/camif-capture.c
1172 +@@ -117,6 +117,8 @@ static int sensor_set_power(struct camif_dev *camif, int on)
1173 +
1174 + if (camif->sensor.power_count == !on)
1175 + err = v4l2_subdev_call(sensor->sd, core, s_power, on);
1176 ++ if (err == -ENOIOCTLCMD)
1177 ++ err = 0;
1178 + if (!err)
1179 + sensor->power_count += on ? 1 : -1;
1180 +
1181 +diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c
1182 +index 0426b210383b..ee88ae83230c 100644
1183 +--- a/drivers/media/usb/tm6000/tm6000-dvb.c
1184 ++++ b/drivers/media/usb/tm6000/tm6000-dvb.c
1185 +@@ -273,6 +273,11 @@ static int register_dvb(struct tm6000_core *dev)
1186 +
1187 + ret = dvb_register_adapter(&dvb->adapter, "Trident TVMaster 6000 DVB-T",
1188 + THIS_MODULE, &dev->udev->dev, adapter_nr);
1189 ++ if (ret < 0) {
1190 ++ pr_err("tm6000: couldn't register the adapter!\n");
1191 ++ goto err;
1192 ++ }
1193 ++
1194 + dvb->adapter.priv = dev;
1195 +
1196 + if (dvb->frontend) {
1197 +diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c
1198 +index b5589d5f5da4..48503f30b3a2 100644
1199 +--- a/drivers/media/usb/uvc/uvc_video.c
1200 ++++ b/drivers/media/usb/uvc/uvc_video.c
1201 +@@ -163,14 +163,27 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream,
1202 + }
1203 + }
1204 +
1205 ++static size_t uvc_video_ctrl_size(struct uvc_streaming *stream)
1206 ++{
1207 ++ /*
1208 ++ * Return the size of the video probe and commit controls, which depends
1209 ++ * on the protocol version.
1210 ++ */
1211 ++ if (stream->dev->uvc_version < 0x0110)
1212 ++ return 26;
1213 ++ else if (stream->dev->uvc_version < 0x0150)
1214 ++ return 34;
1215 ++ else
1216 ++ return 48;
1217 ++}
1218 ++
1219 + static int uvc_get_video_ctrl(struct uvc_streaming *stream,
1220 + struct uvc_streaming_control *ctrl, int probe, __u8 query)
1221 + {
1222 ++ __u16 size = uvc_video_ctrl_size(stream);
1223 + __u8 *data;
1224 +- __u16 size;
1225 + int ret;
1226 +
1227 +- size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
1228 + if ((stream->dev->quirks & UVC_QUIRK_PROBE_DEF) &&
1229 + query == UVC_GET_DEF)
1230 + return -EIO;
1231 +@@ -225,7 +238,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream,
1232 + ctrl->dwMaxVideoFrameSize = get_unaligned_le32(&data[18]);
1233 + ctrl->dwMaxPayloadTransferSize = get_unaligned_le32(&data[22]);
1234 +
1235 +- if (size == 34) {
1236 ++ if (size >= 34) {
1237 + ctrl->dwClockFrequency = get_unaligned_le32(&data[26]);
1238 + ctrl->bmFramingInfo = data[30];
1239 + ctrl->bPreferedVersion = data[31];
1240 +@@ -254,11 +267,10 @@ out:
1241 + static int uvc_set_video_ctrl(struct uvc_streaming *stream,
1242 + struct uvc_streaming_control *ctrl, int probe)
1243 + {
1244 ++ __u16 size = uvc_video_ctrl_size(stream);
1245 + __u8 *data;
1246 +- __u16 size;
1247 + int ret;
1248 +
1249 +- size = stream->dev->uvc_version >= 0x0110 ? 34 : 26;
1250 + data = kzalloc(size, GFP_KERNEL);
1251 + if (data == NULL)
1252 + return -ENOMEM;
1253 +@@ -275,7 +287,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream,
1254 + put_unaligned_le32(ctrl->dwMaxVideoFrameSize, &data[18]);
1255 + put_unaligned_le32(ctrl->dwMaxPayloadTransferSize, &data[22]);
1256 +
1257 +- if (size == 34) {
1258 ++ if (size >= 34) {
1259 + put_unaligned_le32(ctrl->dwClockFrequency, &data[26]);
1260 + data[30] = ctrl->bmFramingInfo;
1261 + data[31] = ctrl->bPreferedVersion;
1262 +diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c
1263 +index 8d3171c6bee8..567d86835f00 100644
1264 +--- a/drivers/media/v4l2-core/v4l2-event.c
1265 ++++ b/drivers/media/v4l2-core/v4l2-event.c
1266 +@@ -119,14 +119,6 @@ static void __v4l2_event_queue_fh(struct v4l2_fh *fh, const struct v4l2_event *e
1267 + if (sev == NULL)
1268 + return;
1269 +
1270 +- /*
1271 +- * If the event has been added to the fh->subscribed list, but its
1272 +- * add op has not completed yet elems will be 0, treat this as
1273 +- * not being subscribed.
1274 +- */
1275 +- if (!sev->elems)
1276 +- return;
1277 +-
1278 + /* Increase event sequence number on fh. */
1279 + fh->sequence++;
1280 +
1281 +@@ -212,6 +204,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
1282 + struct v4l2_subscribed_event *sev, *found_ev;
1283 + unsigned long flags;
1284 + unsigned i;
1285 ++ int ret = 0;
1286 +
1287 + if (sub->type == V4L2_EVENT_ALL)
1288 + return -EINVAL;
1289 +@@ -229,31 +222,36 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
1290 + sev->flags = sub->flags;
1291 + sev->fh = fh;
1292 + sev->ops = ops;
1293 ++ sev->elems = elems;
1294 ++
1295 ++ mutex_lock(&fh->subscribe_lock);
1296 +
1297 + spin_lock_irqsave(&fh->vdev->fh_lock, flags);
1298 + found_ev = v4l2_event_subscribed(fh, sub->type, sub->id);
1299 +- if (!found_ev)
1300 +- list_add(&sev->list, &fh->subscribed);
1301 + spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
1302 +
1303 + if (found_ev) {
1304 ++ /* Already listening */
1305 + kfree(sev);
1306 +- return 0; /* Already listening */
1307 ++ goto out_unlock;
1308 + }
1309 +
1310 + if (sev->ops && sev->ops->add) {
1311 +- int ret = sev->ops->add(sev, elems);
1312 ++ ret = sev->ops->add(sev, elems);
1313 + if (ret) {
1314 +- sev->ops = NULL;
1315 +- v4l2_event_unsubscribe(fh, sub);
1316 +- return ret;
1317 ++ kfree(sev);
1318 ++ goto out_unlock;
1319 + }
1320 + }
1321 +
1322 +- /* Mark as ready for use */
1323 +- sev->elems = elems;
1324 ++ spin_lock_irqsave(&fh->vdev->fh_lock, flags);
1325 ++ list_add(&sev->list, &fh->subscribed);
1326 ++ spin_unlock_irqrestore(&fh->vdev->fh_lock, flags);
1327 +
1328 +- return 0;
1329 ++out_unlock:
1330 ++ mutex_unlock(&fh->subscribe_lock);
1331 ++
1332 ++ return ret;
1333 + }
1334 + EXPORT_SYMBOL_GPL(v4l2_event_subscribe);
1335 +
1336 +@@ -292,6 +290,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
1337 + return 0;
1338 + }
1339 +
1340 ++ mutex_lock(&fh->subscribe_lock);
1341 ++
1342 + spin_lock_irqsave(&fh->vdev->fh_lock, flags);
1343 +
1344 + sev = v4l2_event_subscribed(fh, sub->type, sub->id);
1345 +@@ -309,6 +309,8 @@ int v4l2_event_unsubscribe(struct v4l2_fh *fh,
1346 + if (sev && sev->ops && sev->ops->del)
1347 + sev->ops->del(sev);
1348 +
1349 ++ mutex_unlock(&fh->subscribe_lock);
1350 ++
1351 + kfree(sev);
1352 +
1353 + return 0;
1354 +diff --git a/drivers/media/v4l2-core/v4l2-fh.c b/drivers/media/v4l2-core/v4l2-fh.c
1355 +index c183f0996fa1..0c5e69070586 100644
1356 +--- a/drivers/media/v4l2-core/v4l2-fh.c
1357 ++++ b/drivers/media/v4l2-core/v4l2-fh.c
1358 +@@ -50,6 +50,7 @@ void v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
1359 + INIT_LIST_HEAD(&fh->available);
1360 + INIT_LIST_HEAD(&fh->subscribed);
1361 + fh->sequence = -1;
1362 ++ mutex_init(&fh->subscribe_lock);
1363 + }
1364 + EXPORT_SYMBOL_GPL(v4l2_fh_init);
1365 +
1366 +@@ -95,6 +96,7 @@ void v4l2_fh_exit(struct v4l2_fh *fh)
1367 + return;
1368 + v4l_disable_media_source(fh->vdev);
1369 + v4l2_event_unsubscribe_all(fh);
1370 ++ mutex_destroy(&fh->subscribe_lock);
1371 + fh->vdev = NULL;
1372 + }
1373 + EXPORT_SYMBOL_GPL(v4l2_fh_exit);
1374 +diff --git a/drivers/misc/tsl2550.c b/drivers/misc/tsl2550.c
1375 +index 87a13374fdc0..eb5761067310 100644
1376 +--- a/drivers/misc/tsl2550.c
1377 ++++ b/drivers/misc/tsl2550.c
1378 +@@ -177,7 +177,7 @@ static int tsl2550_calculate_lux(u8 ch0, u8 ch1)
1379 + } else
1380 + lux = 0;
1381 + else
1382 +- return -EAGAIN;
1383 ++ return 0;
1384 +
1385 + /* LUX range check */
1386 + return lux > TSL2550_MAX_LUX ? TSL2550_MAX_LUX : lux;
1387 +diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c
1388 +index f735ab4ba84e..5927db046a87 100644
1389 +--- a/drivers/misc/vmw_vmci/vmci_queue_pair.c
1390 ++++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c
1391 +@@ -755,7 +755,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
1392 + retval = get_user_pages_fast((uintptr_t) produce_uva,
1393 + produce_q->kernel_if->num_pages, 1,
1394 + produce_q->kernel_if->u.h.header_page);
1395 +- if (retval < produce_q->kernel_if->num_pages) {
1396 ++ if (retval < (int)produce_q->kernel_if->num_pages) {
1397 + pr_debug("get_user_pages_fast(produce) failed (retval=%d)",
1398 + retval);
1399 + qp_release_pages(produce_q->kernel_if->u.h.header_page,
1400 +@@ -767,7 +767,7 @@ static int qp_host_get_user_memory(u64 produce_uva,
1401 + retval = get_user_pages_fast((uintptr_t) consume_uva,
1402 + consume_q->kernel_if->num_pages, 1,
1403 + consume_q->kernel_if->u.h.header_page);
1404 +- if (retval < consume_q->kernel_if->num_pages) {
1405 ++ if (retval < (int)consume_q->kernel_if->num_pages) {
1406 + pr_debug("get_user_pages_fast(consume) failed (retval=%d)",
1407 + retval);
1408 + qp_release_pages(consume_q->kernel_if->u.h.header_page,
1409 +diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
1410 +index e093cbf26c8c..f9d68453c81d 100644
1411 +--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
1412 ++++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
1413 +@@ -213,10 +213,10 @@ struct hnae_desc_cb {
1414 +
1415 + /* priv data for the desc, e.g. skb when use with ip stack*/
1416 + void *priv;
1417 +- u16 page_offset;
1418 +- u16 reuse_flag;
1419 ++ u32 page_offset;
1420 ++ u32 length; /* length of the buffer */
1421 +
1422 +- u16 length; /* length of the buffer */
1423 ++ u16 reuse_flag;
1424 +
1425 + /* desc type, used by the ring user to mark the type of the priv data */
1426 + u16 type;
1427 +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1428 +index 111e1aab7d83..8a2a07e21324 100644
1429 +--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1430 ++++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
1431 +@@ -529,7 +529,7 @@ static void hns_nic_reuse_page(struct sk_buff *skb, int i,
1432 + }
1433 +
1434 + skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
1435 +- size - pull_len, truesize - pull_len);
1436 ++ size - pull_len, truesize);
1437 +
1438 + /* avoid re-using remote pages,flag default unreuse */
1439 + if (unlikely(page_to_nid(desc_cb->priv) != numa_node_id()))
1440 +diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
1441 +index 975eeb885ca2..e84574b1eae7 100644
1442 +--- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
1443 ++++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c
1444 +@@ -645,14 +645,14 @@ static int e1000_set_ringparam(struct net_device *netdev,
1445 + adapter->tx_ring = tx_old;
1446 + e1000_free_all_rx_resources(adapter);
1447 + e1000_free_all_tx_resources(adapter);
1448 +- kfree(tx_old);
1449 +- kfree(rx_old);
1450 + adapter->rx_ring = rxdr;
1451 + adapter->tx_ring = txdr;
1452 + err = e1000_up(adapter);
1453 + if (err)
1454 + goto err_setup;
1455 + }
1456 ++ kfree(tx_old);
1457 ++ kfree(rx_old);
1458 +
1459 + clear_bit(__E1000_RESETTING, &adapter->flags);
1460 + return 0;
1461 +@@ -665,7 +665,8 @@ err_setup_rx:
1462 + err_alloc_rx:
1463 + kfree(txdr);
1464 + err_alloc_tx:
1465 +- e1000_up(adapter);
1466 ++ if (netif_running(adapter->netdev))
1467 ++ e1000_up(adapter);
1468 + err_setup:
1469 + clear_bit(__E1000_RESETTING, &adapter->flags);
1470 + return err;
1471 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
1472 +index eaa242df4131..e175fcd73739 100644
1473 +--- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c
1474 ++++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c
1475 +@@ -97,18 +97,57 @@ int qed_mcp_free(struct qed_hwfn *p_hwfn)
1476 + return 0;
1477 + }
1478 +
1479 ++/* Maximum of 1 sec to wait for the SHMEM ready indication */
1480 ++#define QED_MCP_SHMEM_RDY_MAX_RETRIES 20
1481 ++#define QED_MCP_SHMEM_RDY_ITER_MS 50
1482 ++
1483 + static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
1484 + {
1485 + struct qed_mcp_info *p_info = p_hwfn->mcp_info;
1486 ++ u8 cnt = QED_MCP_SHMEM_RDY_MAX_RETRIES;
1487 ++ u8 msec = QED_MCP_SHMEM_RDY_ITER_MS;
1488 + u32 drv_mb_offsize, mfw_mb_offsize;
1489 + u32 mcp_pf_id = MCP_PF_ID(p_hwfn);
1490 +
1491 + p_info->public_base = qed_rd(p_hwfn, p_ptt, MISC_REG_SHARED_MEM_ADDR);
1492 +- if (!p_info->public_base)
1493 +- return 0;
1494 ++ if (!p_info->public_base) {
1495 ++ DP_NOTICE(p_hwfn,
1496 ++ "The address of the MCP scratch-pad is not configured\n");
1497 ++ return -EINVAL;
1498 ++ }
1499 +
1500 + p_info->public_base |= GRCBASE_MCP;
1501 +
1502 ++ /* Get the MFW MB address and number of supported messages */
1503 ++ mfw_mb_offsize = qed_rd(p_hwfn, p_ptt,
1504 ++ SECTION_OFFSIZE_ADDR(p_info->public_base,
1505 ++ PUBLIC_MFW_MB));
1506 ++ p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id);
1507 ++ p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt,
1508 ++ p_info->mfw_mb_addr +
1509 ++ offsetof(struct public_mfw_mb,
1510 ++ sup_msgs));
1511 ++
1512 ++ /* The driver can notify that there was an MCP reset, and might read the
1513 ++ * SHMEM values before the MFW has completed initializing them.
1514 ++ * To avoid this, the "sup_msgs" field in the MFW mailbox is used as a
1515 ++ * data ready indication.
1516 ++ */
1517 ++ while (!p_info->mfw_mb_length && --cnt) {
1518 ++ msleep(msec);
1519 ++ p_info->mfw_mb_length =
1520 ++ (u16)qed_rd(p_hwfn, p_ptt,
1521 ++ p_info->mfw_mb_addr +
1522 ++ offsetof(struct public_mfw_mb, sup_msgs));
1523 ++ }
1524 ++
1525 ++ if (!cnt) {
1526 ++ DP_NOTICE(p_hwfn,
1527 ++ "Failed to get the SHMEM ready notification after %d msec\n",
1528 ++ QED_MCP_SHMEM_RDY_MAX_RETRIES * msec);
1529 ++ return -EBUSY;
1530 ++ }
1531 ++
1532 + /* Calculate the driver and MFW mailbox address */
1533 + drv_mb_offsize = qed_rd(p_hwfn, p_ptt,
1534 + SECTION_OFFSIZE_ADDR(p_info->public_base,
1535 +@@ -118,13 +157,6 @@ static int qed_load_mcp_offsets(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
1536 + "drv_mb_offsiz = 0x%x, drv_mb_addr = 0x%x mcp_pf_id = 0x%x\n",
1537 + drv_mb_offsize, p_info->drv_mb_addr, mcp_pf_id);
1538 +
1539 +- /* Set the MFW MB address */
1540 +- mfw_mb_offsize = qed_rd(p_hwfn, p_ptt,
1541 +- SECTION_OFFSIZE_ADDR(p_info->public_base,
1542 +- PUBLIC_MFW_MB));
1543 +- p_info->mfw_mb_addr = SECTION_ADDR(mfw_mb_offsize, mcp_pf_id);
1544 +- p_info->mfw_mb_length = (u16)qed_rd(p_hwfn, p_ptt, p_info->mfw_mb_addr);
1545 +-
1546 + /* Get the current driver mailbox sequence before sending
1547 + * the first command
1548 + */
1549 +@@ -1198,31 +1230,61 @@ qed_mcp_send_drv_version(struct qed_hwfn *p_hwfn,
1550 + return rc;
1551 + }
1552 +
1553 ++/* A maximal 100 msec waiting time for the MCP to halt */
1554 ++#define QED_MCP_HALT_SLEEP_MS 10
1555 ++#define QED_MCP_HALT_MAX_RETRIES 10
1556 ++
1557 + int qed_mcp_halt(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
1558 + {
1559 +- u32 resp = 0, param = 0;
1560 ++ u32 resp = 0, param = 0, cpu_state, cnt = 0;
1561 + int rc;
1562 +
1563 + rc = qed_mcp_cmd(p_hwfn, p_ptt, DRV_MSG_CODE_MCP_HALT, 0, &resp,
1564 + &param);
1565 +- if (rc)
1566 ++ if (rc) {
1567 + DP_ERR(p_hwfn, "MCP response failure, aborting\n");
1568 ++ return rc;
1569 ++ }
1570 +
1571 +- return rc;
1572 ++ do {
1573 ++ msleep(QED_MCP_HALT_SLEEP_MS);
1574 ++ cpu_state = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_STATE);
1575 ++ if (cpu_state & MCP_REG_CPU_STATE_SOFT_HALTED)
1576 ++ break;
1577 ++ } while (++cnt < QED_MCP_HALT_MAX_RETRIES);
1578 ++
1579 ++ if (cnt == QED_MCP_HALT_MAX_RETRIES) {
1580 ++ DP_NOTICE(p_hwfn,
1581 ++ "Failed to halt the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n",
1582 ++ qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE), cpu_state);
1583 ++ return -EBUSY;
1584 ++ }
1585 ++
1586 ++ return 0;
1587 + }
1588 +
1589 ++#define QED_MCP_RESUME_SLEEP_MS 10
1590 ++
1591 + int qed_mcp_resume(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
1592 + {
1593 +- u32 value, cpu_mode;
1594 ++ u32 cpu_mode, cpu_state;
1595 +
1596 + qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_STATE, 0xffffffff);
1597 +
1598 +- value = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE);
1599 +- value &= ~MCP_REG_CPU_MODE_SOFT_HALT;
1600 +- qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_MODE, value);
1601 + cpu_mode = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_MODE);
1602 ++ cpu_mode &= ~MCP_REG_CPU_MODE_SOFT_HALT;
1603 ++ qed_wr(p_hwfn, p_ptt, MCP_REG_CPU_MODE, cpu_mode);
1604 ++ msleep(QED_MCP_RESUME_SLEEP_MS);
1605 ++ cpu_state = qed_rd(p_hwfn, p_ptt, MCP_REG_CPU_STATE);
1606 +
1607 +- return (cpu_mode & MCP_REG_CPU_MODE_SOFT_HALT) ? -EAGAIN : 0;
1608 ++ if (cpu_state & MCP_REG_CPU_STATE_SOFT_HALTED) {
1609 ++ DP_NOTICE(p_hwfn,
1610 ++ "Failed to resume the MCP [CPU_MODE = 0x%08x, CPU_STATE = 0x%08x]\n",
1611 ++ cpu_mode, cpu_state);
1612 ++ return -EBUSY;
1613 ++ }
1614 ++
1615 ++ return 0;
1616 + }
1617 +
1618 + int qed_mcp_set_led(struct qed_hwfn *p_hwfn,
1619 +diff --git a/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h b/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
1620 +index b414a0542177..56be1d6adfcc 100644
1621 +--- a/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
1622 ++++ b/drivers/net/ethernet/qlogic/qed/qed_reg_addr.h
1623 +@@ -510,6 +510,7 @@
1624 + 0
1625 + #define MCP_REG_CPU_STATE \
1626 + 0xe05004UL
1627 ++#define MCP_REG_CPU_STATE_SOFT_HALTED (0x1UL << 10)
1628 + #define MCP_REG_CPU_EVENT_MASK \
1629 + 0xe05008UL
1630 + #define PGLUE_B_REG_PF_BAR0_SIZE \
1631 +diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
1632 +index 2e5150b0b8d5..7a14e8170e82 100644
1633 +--- a/drivers/net/phy/xilinx_gmii2rgmii.c
1634 ++++ b/drivers/net/phy/xilinx_gmii2rgmii.c
1635 +@@ -40,8 +40,11 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
1636 + {
1637 + struct gmii2rgmii *priv = phydev->priv;
1638 + u16 val = 0;
1639 ++ int err;
1640 +
1641 +- priv->phy_drv->read_status(phydev);
1642 ++ err = priv->phy_drv->read_status(phydev);
1643 ++ if (err < 0)
1644 ++ return err;
1645 +
1646 + val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG);
1647 + val &= ~XILINX_GMII2RGMII_SPEED_MASK;
1648 +@@ -81,6 +84,11 @@ static int xgmiitorgmii_probe(struct mdio_device *mdiodev)
1649 + return -EPROBE_DEFER;
1650 + }
1651 +
1652 ++ if (!priv->phy_dev->drv) {
1653 ++ dev_info(dev, "Attached phy not ready\n");
1654 ++ return -EPROBE_DEFER;
1655 ++ }
1656 ++
1657 + priv->addr = mdiodev->addr;
1658 + priv->phy_drv = priv->phy_dev->drv;
1659 + memcpy(&priv->conv_phy_drv, priv->phy_dev->drv,
1660 +diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
1661 +index ba1fe61e6ea6..a3c218047597 100644
1662 +--- a/drivers/net/wireless/ath/ath10k/htt_rx.c
1663 ++++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
1664 +@@ -214,11 +214,12 @@ int ath10k_htt_rx_ring_refill(struct ath10k *ar)
1665 + spin_lock_bh(&htt->rx_ring.lock);
1666 + ret = ath10k_htt_rx_ring_fill_n(htt, (htt->rx_ring.fill_level -
1667 + htt->rx_ring.fill_cnt));
1668 +- spin_unlock_bh(&htt->rx_ring.lock);
1669 +
1670 + if (ret)
1671 + ath10k_htt_rx_ring_free(htt);
1672 +
1673 ++ spin_unlock_bh(&htt->rx_ring.lock);
1674 ++
1675 + return ret;
1676 + }
1677 +
1678 +@@ -230,7 +231,9 @@ void ath10k_htt_rx_free(struct ath10k_htt *htt)
1679 + skb_queue_purge(&htt->rx_in_ord_compl_q);
1680 + skb_queue_purge(&htt->tx_fetch_ind_q);
1681 +
1682 ++ spin_lock_bh(&htt->rx_ring.lock);
1683 + ath10k_htt_rx_ring_free(htt);
1684 ++ spin_unlock_bh(&htt->rx_ring.lock);
1685 +
1686 + dma_free_coherent(htt->ar->dev,
1687 + (htt->rx_ring.size *
1688 +diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
1689 +index 15b2350d9f45..c9f8847dc123 100644
1690 +--- a/drivers/net/wireless/rndis_wlan.c
1691 ++++ b/drivers/net/wireless/rndis_wlan.c
1692 +@@ -2921,6 +2921,8 @@ static void rndis_wlan_auth_indication(struct usbnet *usbdev,
1693 +
1694 + while (buflen >= sizeof(*auth_req)) {
1695 + auth_req = (void *)buf;
1696 ++ if (buflen < le32_to_cpu(auth_req->length))
1697 ++ return;
1698 + type = "unknown";
1699 + flags = le32_to_cpu(auth_req->flags);
1700 + pairwise_error = false;
1701 +diff --git a/drivers/net/wireless/ti/wlcore/cmd.c b/drivers/net/wireless/ti/wlcore/cmd.c
1702 +index 7f4da727bb7b..96f83f09b8c5 100644
1703 +--- a/drivers/net/wireless/ti/wlcore/cmd.c
1704 ++++ b/drivers/net/wireless/ti/wlcore/cmd.c
1705 +@@ -35,6 +35,7 @@
1706 + #include "wl12xx_80211.h"
1707 + #include "cmd.h"
1708 + #include "event.h"
1709 ++#include "ps.h"
1710 + #include "tx.h"
1711 + #include "hw_ops.h"
1712 +
1713 +@@ -191,6 +192,10 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
1714 +
1715 + timeout_time = jiffies + msecs_to_jiffies(WL1271_EVENT_TIMEOUT);
1716 +
1717 ++ ret = wl1271_ps_elp_wakeup(wl);
1718 ++ if (ret < 0)
1719 ++ return ret;
1720 ++
1721 + do {
1722 + if (time_after(jiffies, timeout_time)) {
1723 + wl1271_debug(DEBUG_CMD, "timeout waiting for event %d",
1724 +@@ -222,6 +227,7 @@ int wlcore_cmd_wait_for_event_or_timeout(struct wl1271 *wl,
1725 + } while (!event);
1726 +
1727 + out:
1728 ++ wl1271_ps_elp_sleep(wl);
1729 + kfree(events_vector);
1730 + return ret;
1731 + }
1732 +diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c
1733 +index 102f95a09460..e9e749f87517 100644
1734 +--- a/drivers/power/reset/vexpress-poweroff.c
1735 ++++ b/drivers/power/reset/vexpress-poweroff.c
1736 +@@ -35,6 +35,7 @@ static void vexpress_reset_do(struct device *dev, const char *what)
1737 + }
1738 +
1739 + static struct device *vexpress_power_off_device;
1740 ++static atomic_t vexpress_restart_nb_refcnt = ATOMIC_INIT(0);
1741 +
1742 + static void vexpress_power_off(void)
1743 + {
1744 +@@ -99,10 +100,13 @@ static int _vexpress_register_restart_handler(struct device *dev)
1745 + int err;
1746 +
1747 + vexpress_restart_device = dev;
1748 +- err = register_restart_handler(&vexpress_restart_nb);
1749 +- if (err) {
1750 +- dev_err(dev, "cannot register restart handler (err=%d)\n", err);
1751 +- return err;
1752 ++ if (atomic_inc_return(&vexpress_restart_nb_refcnt) == 1) {
1753 ++ err = register_restart_handler(&vexpress_restart_nb);
1754 ++ if (err) {
1755 ++ dev_err(dev, "cannot register restart handler (err=%d)\n", err);
1756 ++ atomic_dec(&vexpress_restart_nb_refcnt);
1757 ++ return err;
1758 ++ }
1759 + }
1760 + device_create_file(dev, &dev_attr_active);
1761 +
1762 +diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
1763 +index a74d8ca383a1..9e05ae0430a9 100644
1764 +--- a/drivers/power/supply/power_supply_core.c
1765 ++++ b/drivers/power/supply/power_supply_core.c
1766 +@@ -14,6 +14,7 @@
1767 + #include <linux/types.h>
1768 + #include <linux/init.h>
1769 + #include <linux/slab.h>
1770 ++#include <linux/delay.h>
1771 + #include <linux/device.h>
1772 + #include <linux/notifier.h>
1773 + #include <linux/err.h>
1774 +@@ -138,8 +139,13 @@ static void power_supply_deferred_register_work(struct work_struct *work)
1775 + struct power_supply *psy = container_of(work, struct power_supply,
1776 + deferred_register_work.work);
1777 +
1778 +- if (psy->dev.parent)
1779 +- mutex_lock(&psy->dev.parent->mutex);
1780 ++ if (psy->dev.parent) {
1781 ++ while (!mutex_trylock(&psy->dev.parent->mutex)) {
1782 ++ if (psy->removing)
1783 ++ return;
1784 ++ msleep(10);
1785 ++ }
1786 ++ }
1787 +
1788 + power_supply_changed(psy);
1789 +
1790 +@@ -944,6 +950,7 @@ EXPORT_SYMBOL_GPL(devm_power_supply_register_no_ws);
1791 + void power_supply_unregister(struct power_supply *psy)
1792 + {
1793 + WARN_ON(atomic_dec_return(&psy->use_cnt));
1794 ++ psy->removing = true;
1795 + cancel_work_sync(&psy->changed_work);
1796 + cancel_delayed_work_sync(&psy->deferred_register_work);
1797 + sysfs_remove_link(&psy->dev.kobj, "powers");
1798 +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
1799 +index 178fcda12cec..18d57c0efe9f 100644
1800 +--- a/drivers/regulator/core.c
1801 ++++ b/drivers/regulator/core.c
1802 +@@ -4054,13 +4054,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
1803 + !rdev->desc->fixed_uV)
1804 + rdev->is_switch = true;
1805 +
1806 ++ dev_set_drvdata(&rdev->dev, rdev);
1807 + ret = device_register(&rdev->dev);
1808 + if (ret != 0) {
1809 + put_device(&rdev->dev);
1810 + goto unset_supplies;
1811 + }
1812 +
1813 +- dev_set_drvdata(&rdev->dev, rdev);
1814 + rdev_init_debugfs(rdev);
1815 +
1816 + /* try to resolve regulators supply since a new one was registered */
1817 +diff --git a/drivers/scsi/bnx2i/bnx2i_hwi.c b/drivers/scsi/bnx2i/bnx2i_hwi.c
1818 +index 42921dbba927..4ca10501647b 100644
1819 +--- a/drivers/scsi/bnx2i/bnx2i_hwi.c
1820 ++++ b/drivers/scsi/bnx2i/bnx2i_hwi.c
1821 +@@ -2742,6 +2742,8 @@ int bnx2i_map_ep_dbell_regs(struct bnx2i_endpoint *ep)
1822 + BNX2X_DOORBELL_PCI_BAR);
1823 + reg_off = (1 << BNX2X_DB_SHIFT) * (cid_num & 0x1FFFF);
1824 + ep->qp.ctx_base = ioremap_nocache(reg_base + reg_off, 4);
1825 ++ if (!ep->qp.ctx_base)
1826 ++ return -ENOMEM;
1827 + goto arm_cq;
1828 + }
1829 +
1830 +diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
1831 +index d9534ee6ef52..e1730227b448 100644
1832 +--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
1833 ++++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
1834 +@@ -93,7 +93,7 @@ static int max_requests = IBMVSCSI_MAX_REQUESTS_DEFAULT;
1835 + static int max_events = IBMVSCSI_MAX_REQUESTS_DEFAULT + 2;
1836 + static int fast_fail = 1;
1837 + static int client_reserve = 1;
1838 +-static char partition_name[97] = "UNKNOWN";
1839 ++static char partition_name[96] = "UNKNOWN";
1840 + static unsigned int partition_number = -1;
1841 +
1842 + static struct scsi_transport_template *ibmvscsi_transport_template;
1843 +@@ -259,7 +259,7 @@ static void gather_partition_info(void)
1844 +
1845 + ppartition_name = of_get_property(of_root, "ibm,partition-name", NULL);
1846 + if (ppartition_name)
1847 +- strncpy(partition_name, ppartition_name,
1848 ++ strlcpy(partition_name, ppartition_name,
1849 + sizeof(partition_name));
1850 + p_number_ptr = of_get_property(of_root, "ibm,partition-no", NULL);
1851 + if (p_number_ptr)
1852 +diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
1853 +index 35cbd36f8d3b..090fdcdd15c9 100644
1854 +--- a/drivers/scsi/megaraid/megaraid_sas_base.c
1855 ++++ b/drivers/scsi/megaraid/megaraid_sas_base.c
1856 +@@ -6193,6 +6193,9 @@ megasas_resume(struct pci_dev *pdev)
1857 + goto fail_init_mfi;
1858 + }
1859 +
1860 ++ if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS)
1861 ++ goto fail_init_mfi;
1862 ++
1863 + tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
1864 + (unsigned long)instance);
1865 +
1866 +diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
1867 +index a816f07e168e..093c9cf92bfd 100644
1868 +--- a/drivers/spi/spi-rspi.c
1869 ++++ b/drivers/spi/spi-rspi.c
1870 +@@ -597,11 +597,13 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
1871 +
1872 + ret = wait_event_interruptible_timeout(rspi->wait,
1873 + rspi->dma_callbacked, HZ);
1874 +- if (ret > 0 && rspi->dma_callbacked)
1875 ++ if (ret > 0 && rspi->dma_callbacked) {
1876 + ret = 0;
1877 +- else if (!ret) {
1878 +- dev_err(&rspi->master->dev, "DMA timeout\n");
1879 +- ret = -ETIMEDOUT;
1880 ++ } else {
1881 ++ if (!ret) {
1882 ++ dev_err(&rspi->master->dev, "DMA timeout\n");
1883 ++ ret = -ETIMEDOUT;
1884 ++ }
1885 + if (tx)
1886 + dmaengine_terminate_all(rspi->master->dma_tx);
1887 + if (rx)
1888 +@@ -1313,12 +1315,36 @@ static const struct platform_device_id spi_driver_ids[] = {
1889 +
1890 + MODULE_DEVICE_TABLE(platform, spi_driver_ids);
1891 +
1892 ++#ifdef CONFIG_PM_SLEEP
1893 ++static int rspi_suspend(struct device *dev)
1894 ++{
1895 ++ struct platform_device *pdev = to_platform_device(dev);
1896 ++ struct rspi_data *rspi = platform_get_drvdata(pdev);
1897 ++
1898 ++ return spi_master_suspend(rspi->master);
1899 ++}
1900 ++
1901 ++static int rspi_resume(struct device *dev)
1902 ++{
1903 ++ struct platform_device *pdev = to_platform_device(dev);
1904 ++ struct rspi_data *rspi = platform_get_drvdata(pdev);
1905 ++
1906 ++ return spi_master_resume(rspi->master);
1907 ++}
1908 ++
1909 ++static SIMPLE_DEV_PM_OPS(rspi_pm_ops, rspi_suspend, rspi_resume);
1910 ++#define DEV_PM_OPS &rspi_pm_ops
1911 ++#else
1912 ++#define DEV_PM_OPS NULL
1913 ++#endif /* CONFIG_PM_SLEEP */
1914 ++
1915 + static struct platform_driver rspi_driver = {
1916 + .probe = rspi_probe,
1917 + .remove = rspi_remove,
1918 + .id_table = spi_driver_ids,
1919 + .driver = {
1920 + .name = "renesas_spi",
1921 ++ .pm = DEV_PM_OPS,
1922 + .of_match_table = of_match_ptr(rspi_of_match),
1923 + },
1924 + };
1925 +diff --git a/drivers/spi/spi-sh-msiof.c b/drivers/spi/spi-sh-msiof.c
1926 +index cbf02ebb30a2..711ea523b325 100644
1927 +--- a/drivers/spi/spi-sh-msiof.c
1928 ++++ b/drivers/spi/spi-sh-msiof.c
1929 +@@ -373,7 +373,8 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
1930 +
1931 + static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
1932 + {
1933 +- sh_msiof_write(p, STR, sh_msiof_read(p, STR));
1934 ++ sh_msiof_write(p, STR,
1935 ++ sh_msiof_read(p, STR) & ~(STR_TDREQ | STR_RDREQ));
1936 + }
1937 +
1938 + static void sh_msiof_spi_write_fifo_8(struct sh_msiof_spi_priv *p,
1939 +@@ -1275,12 +1276,37 @@ static const struct platform_device_id spi_driver_ids[] = {
1940 + };
1941 + MODULE_DEVICE_TABLE(platform, spi_driver_ids);
1942 +
1943 ++#ifdef CONFIG_PM_SLEEP
1944 ++static int sh_msiof_spi_suspend(struct device *dev)
1945 ++{
1946 ++ struct platform_device *pdev = to_platform_device(dev);
1947 ++ struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1948 ++
1949 ++ return spi_master_suspend(p->master);
1950 ++}
1951 ++
1952 ++static int sh_msiof_spi_resume(struct device *dev)
1953 ++{
1954 ++ struct platform_device *pdev = to_platform_device(dev);
1955 ++ struct sh_msiof_spi_priv *p = platform_get_drvdata(pdev);
1956 ++
1957 ++ return spi_master_resume(p->master);
1958 ++}
1959 ++
1960 ++static SIMPLE_DEV_PM_OPS(sh_msiof_spi_pm_ops, sh_msiof_spi_suspend,
1961 ++ sh_msiof_spi_resume);
1962 ++#define DEV_PM_OPS &sh_msiof_spi_pm_ops
1963 ++#else
1964 ++#define DEV_PM_OPS NULL
1965 ++#endif /* CONFIG_PM_SLEEP */
1966 ++
1967 + static struct platform_driver sh_msiof_spi_drv = {
1968 + .probe = sh_msiof_spi_probe,
1969 + .remove = sh_msiof_spi_remove,
1970 + .id_table = spi_driver_ids,
1971 + .driver = {
1972 + .name = "spi_sh_msiof",
1973 ++ .pm = DEV_PM_OPS,
1974 + .of_match_table = of_match_ptr(sh_msiof_match),
1975 + },
1976 + };
1977 +diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
1978 +index 85c91f58b42f..af2880d0c112 100644
1979 +--- a/drivers/spi/spi-tegra20-slink.c
1980 ++++ b/drivers/spi/spi-tegra20-slink.c
1981 +@@ -1063,6 +1063,24 @@ static int tegra_slink_probe(struct platform_device *pdev)
1982 + goto exit_free_master;
1983 + }
1984 +
1985 ++ /* disabled clock may cause interrupt storm upon request */
1986 ++ tspi->clk = devm_clk_get(&pdev->dev, NULL);
1987 ++ if (IS_ERR(tspi->clk)) {
1988 ++ ret = PTR_ERR(tspi->clk);
1989 ++ dev_err(&pdev->dev, "Can not get clock %d\n", ret);
1990 ++ goto exit_free_master;
1991 ++ }
1992 ++ ret = clk_prepare(tspi->clk);
1993 ++ if (ret < 0) {
1994 ++ dev_err(&pdev->dev, "Clock prepare failed %d\n", ret);
1995 ++ goto exit_free_master;
1996 ++ }
1997 ++ ret = clk_enable(tspi->clk);
1998 ++ if (ret < 0) {
1999 ++ dev_err(&pdev->dev, "Clock enable failed %d\n", ret);
2000 ++ goto exit_free_master;
2001 ++ }
2002 ++
2003 + spi_irq = platform_get_irq(pdev, 0);
2004 + tspi->irq = spi_irq;
2005 + ret = request_threaded_irq(tspi->irq, tegra_slink_isr,
2006 +@@ -1071,14 +1089,7 @@ static int tegra_slink_probe(struct platform_device *pdev)
2007 + if (ret < 0) {
2008 + dev_err(&pdev->dev, "Failed to register ISR for IRQ %d\n",
2009 + tspi->irq);
2010 +- goto exit_free_master;
2011 +- }
2012 +-
2013 +- tspi->clk = devm_clk_get(&pdev->dev, NULL);
2014 +- if (IS_ERR(tspi->clk)) {
2015 +- dev_err(&pdev->dev, "can not get clock\n");
2016 +- ret = PTR_ERR(tspi->clk);
2017 +- goto exit_free_irq;
2018 ++ goto exit_clk_disable;
2019 + }
2020 +
2021 + tspi->rst = devm_reset_control_get(&pdev->dev, "spi");
2022 +@@ -1138,6 +1149,8 @@ exit_rx_dma_free:
2023 + tegra_slink_deinit_dma_param(tspi, true);
2024 + exit_free_irq:
2025 + free_irq(spi_irq, tspi);
2026 ++exit_clk_disable:
2027 ++ clk_disable(tspi->clk);
2028 + exit_free_master:
2029 + spi_master_put(master);
2030 + return ret;
2031 +@@ -1150,6 +1163,8 @@ static int tegra_slink_remove(struct platform_device *pdev)
2032 +
2033 + free_irq(tspi->irq, tspi);
2034 +
2035 ++ clk_disable(tspi->clk);
2036 ++
2037 + if (tspi->tx_dma_chan)
2038 + tegra_slink_deinit_dma_param(tspi, false);
2039 +
2040 +diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
2041 +index 6d690e5fa9bb..c6314d1552ea 100644
2042 +--- a/drivers/staging/android/ashmem.c
2043 ++++ b/drivers/staging/android/ashmem.c
2044 +@@ -383,6 +383,12 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
2045 + goto out;
2046 + }
2047 +
2048 ++ /* requested mapping size larger than object size */
2049 ++ if (vma->vm_end - vma->vm_start > PAGE_ALIGN(asma->size)) {
2050 ++ ret = -EINVAL;
2051 ++ goto out;
2052 ++ }
2053 ++
2054 + /* requested protection bits must match our allowed protection mask */
2055 + if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask, 0)) &
2056 + calc_vm_prot_bits(PROT_MASK, 0))) {
2057 +diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c
2058 +index b0bbb36f8988..9e63bdf2afe7 100644
2059 +--- a/drivers/staging/rts5208/sd.c
2060 ++++ b/drivers/staging/rts5208/sd.c
2061 +@@ -4976,7 +4976,7 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip)
2062 + goto SD_Execute_Write_Cmd_Failed;
2063 + }
2064 +
2065 +- rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
2066 ++ retval = rtsx_write_register(chip, SD_BYTE_CNT_L, 0xFF, 0x00);
2067 + if (retval != STATUS_SUCCESS) {
2068 + rtsx_trace(chip);
2069 + goto SD_Execute_Write_Cmd_Failed;
2070 +diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c
2071 +index f06e74ea10d3..f0d97305575d 100644
2072 +--- a/drivers/target/iscsi/iscsi_target_auth.c
2073 ++++ b/drivers/target/iscsi/iscsi_target_auth.c
2074 +@@ -26,15 +26,6 @@
2075 + #include "iscsi_target_nego.h"
2076 + #include "iscsi_target_auth.h"
2077 +
2078 +-static void chap_binaryhex_to_asciihex(char *dst, char *src, int src_len)
2079 +-{
2080 +- int i;
2081 +-
2082 +- for (i = 0; i < src_len; i++) {
2083 +- sprintf(&dst[i*2], "%02x", (int) src[i] & 0xff);
2084 +- }
2085 +-}
2086 +-
2087 + static void chap_gen_challenge(
2088 + struct iscsi_conn *conn,
2089 + int caller,
2090 +@@ -47,7 +38,7 @@ static void chap_gen_challenge(
2091 + memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1);
2092 +
2093 + get_random_bytes(chap->challenge, CHAP_CHALLENGE_LENGTH);
2094 +- chap_binaryhex_to_asciihex(challenge_asciihex, chap->challenge,
2095 ++ bin2hex(challenge_asciihex, chap->challenge,
2096 + CHAP_CHALLENGE_LENGTH);
2097 + /*
2098 + * Set CHAP_C, and copy the generated challenge into c_str.
2099 +@@ -281,7 +272,7 @@ static int chap_server_compute_md5(
2100 + goto out;
2101 + }
2102 +
2103 +- chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE);
2104 ++ bin2hex(response, server_digest, MD5_SIGNATURE_SIZE);
2105 + pr_debug("[server] MD5 Server Digest: %s\n", response);
2106 +
2107 + if (memcmp(server_digest, client_digest, MD5_SIGNATURE_SIZE) != 0) {
2108 +@@ -403,7 +394,7 @@ static int chap_server_compute_md5(
2109 + /*
2110 + * Convert response from binary hex to ascii hext.
2111 + */
2112 +- chap_binaryhex_to_asciihex(response, digest, MD5_SIGNATURE_SIZE);
2113 ++ bin2hex(response, digest, MD5_SIGNATURE_SIZE);
2114 + *nr_out_len += sprintf(nr_out_ptr + *nr_out_len, "CHAP_R=0x%s",
2115 + response);
2116 + *nr_out_len += 1;
2117 +diff --git a/drivers/target/iscsi/iscsi_target_tpg.c b/drivers/target/iscsi/iscsi_target_tpg.c
2118 +index 63e1dcc5914d..761b065a40bb 100644
2119 +--- a/drivers/target/iscsi/iscsi_target_tpg.c
2120 ++++ b/drivers/target/iscsi/iscsi_target_tpg.c
2121 +@@ -637,8 +637,7 @@ int iscsit_ta_authentication(struct iscsi_portal_group *tpg, u32 authentication)
2122 + none = strstr(buf1, NONE);
2123 + if (none)
2124 + goto out;
2125 +- strncat(buf1, ",", strlen(","));
2126 +- strncat(buf1, NONE, strlen(NONE));
2127 ++ strlcat(buf1, "," NONE, sizeof(buf1));
2128 + if (iscsi_update_param_value(param, buf1) < 0)
2129 + return -EINVAL;
2130 + }
2131 +diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
2132 +index d04ec3b9e5ff..8a70b57d129c 100644
2133 +--- a/drivers/thermal/of-thermal.c
2134 ++++ b/drivers/thermal/of-thermal.c
2135 +@@ -278,10 +278,13 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz,
2136 +
2137 + mutex_lock(&tz->lock);
2138 +
2139 +- if (mode == THERMAL_DEVICE_ENABLED)
2140 ++ if (mode == THERMAL_DEVICE_ENABLED) {
2141 + tz->polling_delay = data->polling_delay;
2142 +- else
2143 ++ tz->passive_delay = data->passive_delay;
2144 ++ } else {
2145 + tz->polling_delay = 0;
2146 ++ tz->passive_delay = 0;
2147 ++ }
2148 +
2149 + mutex_unlock(&tz->lock);
2150 +
2151 +diff --git a/drivers/tty/serial/8250/serial_cs.c b/drivers/tty/serial/8250/serial_cs.c
2152 +index 933c2688dd7e..8106353ce7aa 100644
2153 +--- a/drivers/tty/serial/8250/serial_cs.c
2154 ++++ b/drivers/tty/serial/8250/serial_cs.c
2155 +@@ -637,8 +637,10 @@ static int serial_config(struct pcmcia_device *link)
2156 + (link->has_func_id) &&
2157 + (link->socket->pcmcia_pfc == 0) &&
2158 + ((link->func_id == CISTPL_FUNCID_MULTI) ||
2159 +- (link->func_id == CISTPL_FUNCID_SERIAL)))
2160 +- pcmcia_loop_config(link, serial_check_for_multi, info);
2161 ++ (link->func_id == CISTPL_FUNCID_SERIAL))) {
2162 ++ if (pcmcia_loop_config(link, serial_check_for_multi, info))
2163 ++ goto failed;
2164 ++ }
2165 +
2166 + /*
2167 + * Apply any multi-port quirk.
2168 +diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
2169 +index d3e3d42c0c12..0040c29f651a 100644
2170 +--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
2171 ++++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
2172 +@@ -1068,8 +1068,8 @@ static int poll_wait_key(char *obuf, struct uart_cpm_port *pinfo)
2173 + /* Get the address of the host memory buffer.
2174 + */
2175 + bdp = pinfo->rx_cur;
2176 +- while (bdp->cbd_sc & BD_SC_EMPTY)
2177 +- ;
2178 ++ if (bdp->cbd_sc & BD_SC_EMPTY)
2179 ++ return NO_POLL_CHAR;
2180 +
2181 + /* If the buffer address is in the CPM DPRAM, don't
2182 + * convert it.
2183 +@@ -1104,7 +1104,11 @@ static int cpm_get_poll_char(struct uart_port *port)
2184 + poll_chars = 0;
2185 + }
2186 + if (poll_chars <= 0) {
2187 +- poll_chars = poll_wait_key(poll_buf, pinfo);
2188 ++ int ret = poll_wait_key(poll_buf, pinfo);
2189 ++
2190 ++ if (ret == NO_POLL_CHAR)
2191 ++ return ret;
2192 ++ poll_chars = ret;
2193 + pollp = poll_buf;
2194 + }
2195 + poll_chars--;
2196 +diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
2197 +index 937f5e10f165..e2ec04904f54 100644
2198 +--- a/drivers/tty/serial/fsl_lpuart.c
2199 ++++ b/drivers/tty/serial/fsl_lpuart.c
2200 +@@ -833,7 +833,8 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
2201 + struct circ_buf *ring = &sport->rx_ring;
2202 + int ret, nent;
2203 + int bits, baud;
2204 +- struct tty_struct *tty = tty_port_tty_get(&sport->port.state->port);
2205 ++ struct tty_port *port = &sport->port.state->port;
2206 ++ struct tty_struct *tty = port->tty;
2207 + struct ktermios *termios = &tty->termios;
2208 +
2209 + baud = tty_get_baud_rate(tty);
2210 +diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
2211 +index b24edf634985..0d82be145c68 100644
2212 +--- a/drivers/tty/serial/imx.c
2213 ++++ b/drivers/tty/serial/imx.c
2214 +@@ -2197,6 +2197,14 @@ static int serial_imx_probe(struct platform_device *pdev)
2215 + ret);
2216 + return ret;
2217 + }
2218 ++
2219 ++ ret = devm_request_irq(&pdev->dev, rtsirq, imx_rtsint, 0,
2220 ++ dev_name(&pdev->dev), sport);
2221 ++ if (ret) {
2222 ++ dev_err(&pdev->dev, "failed to request rts irq: %d\n",
2223 ++ ret);
2224 ++ return ret;
2225 ++ }
2226 + } else {
2227 + ret = devm_request_irq(&pdev->dev, rxirq, imx_int, 0,
2228 + dev_name(&pdev->dev), sport);
2229 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
2230 +index adc0f78dc54d..9f001659807a 100644
2231 +--- a/drivers/usb/class/cdc-wdm.c
2232 ++++ b/drivers/usb/class/cdc-wdm.c
2233 +@@ -470,7 +470,7 @@ static int service_outstanding_interrupt(struct wdm_device *desc)
2234 +
2235 + set_bit(WDM_RESPONDING, &desc->flags);
2236 + spin_unlock_irq(&desc->iuspin);
2237 +- rv = usb_submit_urb(desc->response, GFP_ATOMIC);
2238 ++ rv = usb_submit_urb(desc->response, GFP_KERNEL);
2239 + spin_lock_irq(&desc->iuspin);
2240 + if (rv) {
2241 + dev_err(&desc->intf->dev,
2242 +diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
2243 +index 893ebae51029..988240e3cb58 100644
2244 +--- a/drivers/usb/core/devio.c
2245 ++++ b/drivers/usb/core/devio.c
2246 +@@ -1450,10 +1450,13 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
2247 + struct async *as = NULL;
2248 + struct usb_ctrlrequest *dr = NULL;
2249 + unsigned int u, totlen, isofrmlen;
2250 +- int i, ret, is_in, num_sgs = 0, ifnum = -1;
2251 ++ int i, ret, num_sgs = 0, ifnum = -1;
2252 + int number_of_packets = 0;
2253 + unsigned int stream_id = 0;
2254 + void *buf;
2255 ++ bool is_in;
2256 ++ bool allow_short = false;
2257 ++ bool allow_zero = false;
2258 + unsigned long mask = USBDEVFS_URB_SHORT_NOT_OK |
2259 + USBDEVFS_URB_BULK_CONTINUATION |
2260 + USBDEVFS_URB_NO_FSBR |
2261 +@@ -1487,6 +1490,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
2262 + u = 0;
2263 + switch (uurb->type) {
2264 + case USBDEVFS_URB_TYPE_CONTROL:
2265 ++ if (is_in)
2266 ++ allow_short = true;
2267 + if (!usb_endpoint_xfer_control(&ep->desc))
2268 + return -EINVAL;
2269 + /* min 8 byte setup packet */
2270 +@@ -1527,6 +1532,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
2271 + break;
2272 +
2273 + case USBDEVFS_URB_TYPE_BULK:
2274 ++ if (!is_in)
2275 ++ allow_zero = true;
2276 ++ else
2277 ++ allow_short = true;
2278 + switch (usb_endpoint_type(&ep->desc)) {
2279 + case USB_ENDPOINT_XFER_CONTROL:
2280 + case USB_ENDPOINT_XFER_ISOC:
2281 +@@ -1547,6 +1556,10 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
2282 + if (!usb_endpoint_xfer_int(&ep->desc))
2283 + return -EINVAL;
2284 + interrupt_urb:
2285 ++ if (!is_in)
2286 ++ allow_zero = true;
2287 ++ else
2288 ++ allow_short = true;
2289 + break;
2290 +
2291 + case USBDEVFS_URB_TYPE_ISO:
2292 +@@ -1691,16 +1704,21 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
2293 + u = (is_in ? URB_DIR_IN : URB_DIR_OUT);
2294 + if (uurb->flags & USBDEVFS_URB_ISO_ASAP)
2295 + u |= URB_ISO_ASAP;
2296 +- if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK && is_in)
2297 ++ if (allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
2298 + u |= URB_SHORT_NOT_OK;
2299 + if (uurb->flags & USBDEVFS_URB_NO_FSBR)
2300 + u |= URB_NO_FSBR;
2301 +- if (uurb->flags & USBDEVFS_URB_ZERO_PACKET)
2302 ++ if (allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
2303 + u |= URB_ZERO_PACKET;
2304 + if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT)
2305 + u |= URB_NO_INTERRUPT;
2306 + as->urb->transfer_flags = u;
2307 +
2308 ++ if (!allow_short && uurb->flags & USBDEVFS_URB_SHORT_NOT_OK)
2309 ++ dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_SHORT_NOT_OK.\n");
2310 ++ if (!allow_zero && uurb->flags & USBDEVFS_URB_ZERO_PACKET)
2311 ++ dev_warn(&ps->dev->dev, "Requested nonsensical USBDEVFS_URB_ZERO_PACKET.\n");
2312 ++
2313 + as->urb->transfer_buffer_length = uurb->buffer_length;
2314 + as->urb->setup_packet = (unsigned char *)dr;
2315 + dr = NULL;
2316 +diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
2317 +index 0bb380a9fcf7..e9d6cf146fcc 100644
2318 +--- a/drivers/usb/core/driver.c
2319 ++++ b/drivers/usb/core/driver.c
2320 +@@ -509,7 +509,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2321 + struct device *dev;
2322 + struct usb_device *udev;
2323 + int retval = 0;
2324 +- int lpm_disable_error = -ENODEV;
2325 +
2326 + if (!iface)
2327 + return -ENODEV;
2328 +@@ -530,16 +529,6 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2329 +
2330 + iface->condition = USB_INTERFACE_BOUND;
2331 +
2332 +- /* See the comment about disabling LPM in usb_probe_interface(). */
2333 +- if (driver->disable_hub_initiated_lpm) {
2334 +- lpm_disable_error = usb_unlocked_disable_lpm(udev);
2335 +- if (lpm_disable_error) {
2336 +- dev_err(&iface->dev, "%s Failed to disable LPM for driver %s\n.",
2337 +- __func__, driver->name);
2338 +- return -ENOMEM;
2339 +- }
2340 +- }
2341 +-
2342 + /* Claimed interfaces are initially inactive (suspended) and
2343 + * runtime-PM-enabled, but only if the driver has autosuspend
2344 + * support. Otherwise they are marked active, to prevent the
2345 +@@ -558,9 +547,20 @@ int usb_driver_claim_interface(struct usb_driver *driver,
2346 + if (device_is_registered(dev))
2347 + retval = device_bind_driver(dev);
2348 +
2349 +- /* Attempt to re-enable USB3 LPM, if the disable was successful. */
2350 +- if (!lpm_disable_error)
2351 +- usb_unlocked_enable_lpm(udev);
2352 ++ if (retval) {
2353 ++ dev->driver = NULL;
2354 ++ usb_set_intfdata(iface, NULL);
2355 ++ iface->needs_remote_wakeup = 0;
2356 ++ iface->condition = USB_INTERFACE_UNBOUND;
2357 ++
2358 ++ /*
2359 ++ * Unbound interfaces are always runtime-PM-disabled
2360 ++ * and runtime-PM-suspended
2361 ++ */
2362 ++ if (driver->supports_autosuspend)
2363 ++ pm_runtime_disable(dev);
2364 ++ pm_runtime_set_suspended(dev);
2365 ++ }
2366 +
2367 + return retval;
2368 + }
2369 +diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
2370 +index eaf1c3b06f02..891261b43c67 100644
2371 +--- a/drivers/usb/core/usb.c
2372 ++++ b/drivers/usb/core/usb.c
2373 +@@ -91,6 +91,8 @@ struct usb_host_interface *usb_find_alt_setting(
2374 + struct usb_interface_cache *intf_cache = NULL;
2375 + int i;
2376 +
2377 ++ if (!config)
2378 ++ return NULL;
2379 + for (i = 0; i < config->desc.bNumInterfaces; i++) {
2380 + if (config->intf_cache[i]->altsetting[0].desc.bInterfaceNumber
2381 + == iface_num) {
2382 +diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
2383 +index 813035f51fe7..7d252678c55a 100644
2384 +--- a/drivers/usb/serial/kobil_sct.c
2385 ++++ b/drivers/usb/serial/kobil_sct.c
2386 +@@ -408,12 +408,20 @@ static int kobil_tiocmget(struct tty_struct *tty)
2387 + transfer_buffer_length,
2388 + KOBIL_TIMEOUT);
2389 +
2390 +- dev_dbg(&port->dev, "%s - Send get_status_line_state URB returns: %i. Statusline: %02x\n",
2391 +- __func__, result, transfer_buffer[0]);
2392 ++ dev_dbg(&port->dev, "Send get_status_line_state URB returns: %i\n",
2393 ++ result);
2394 ++ if (result < 1) {
2395 ++ if (result >= 0)
2396 ++ result = -EIO;
2397 ++ goto out_free;
2398 ++ }
2399 ++
2400 ++ dev_dbg(&port->dev, "Statusline: %02x\n", transfer_buffer[0]);
2401 +
2402 + result = 0;
2403 + if ((transfer_buffer[0] & SUSBCR_GSL_DSR) != 0)
2404 + result = TIOCM_DSR;
2405 ++out_free:
2406 + kfree(transfer_buffer);
2407 + return result;
2408 + }
2409 +diff --git a/drivers/usb/wusbcore/security.c b/drivers/usb/wusbcore/security.c
2410 +index 8c9421b69da0..6bf86ca950b3 100644
2411 +--- a/drivers/usb/wusbcore/security.c
2412 ++++ b/drivers/usb/wusbcore/security.c
2413 +@@ -230,7 +230,7 @@ int wusb_dev_sec_add(struct wusbhc *wusbhc,
2414 +
2415 + result = usb_get_descriptor(usb_dev, USB_DT_SECURITY,
2416 + 0, secd, sizeof(*secd));
2417 +- if (result < sizeof(*secd)) {
2418 ++ if (result < (int)sizeof(*secd)) {
2419 + dev_err(dev, "Can't read security descriptor or "
2420 + "not enough data: %d\n", result);
2421 + goto out;
2422 +diff --git a/drivers/uwb/hwa-rc.c b/drivers/uwb/hwa-rc.c
2423 +index 9a53912bdfe9..5d3ba747ae17 100644
2424 +--- a/drivers/uwb/hwa-rc.c
2425 ++++ b/drivers/uwb/hwa-rc.c
2426 +@@ -873,6 +873,7 @@ error_get_version:
2427 + error_rc_add:
2428 + usb_put_intf(iface);
2429 + usb_put_dev(hwarc->usb_dev);
2430 ++ kfree(hwarc);
2431 + error_alloc:
2432 + uwb_rc_put(uwb_rc);
2433 + error_rc_alloc:
2434 +diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
2435 +index fdcbe0f2814f..c19c96840480 100644
2436 +--- a/fs/ext4/xattr.c
2437 ++++ b/fs/ext4/xattr.c
2438 +@@ -1426,6 +1426,11 @@ static int ext4_xattr_make_inode_space(handle_t *handle, struct inode *inode,
2439 + last = IFIRST(header);
2440 + /* Find the entry best suited to be pushed into EA block */
2441 + for (; !IS_LAST_ENTRY(last); last = EXT4_XATTR_NEXT(last)) {
2442 ++ /* never move system.data out of the inode */
2443 ++ if ((last->e_name_len == 4) &&
2444 ++ (last->e_name_index == EXT4_XATTR_INDEX_SYSTEM) &&
2445 ++ !memcmp(last->e_name, "data", 4))
2446 ++ continue;
2447 + total_size =
2448 + EXT4_XATTR_SIZE(le32_to_cpu(last->e_value_size)) +
2449 + EXT4_XATTR_LEN(last->e_name_len);
2450 +diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
2451 +index eef0caf6e67d..e9495516527d 100644
2452 +--- a/fs/nfsd/nfs4proc.c
2453 ++++ b/fs/nfsd/nfs4proc.c
2454 +@@ -1725,6 +1725,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
2455 + if (status) {
2456 + op = &args->ops[0];
2457 + op->status = status;
2458 ++ resp->opcnt = 1;
2459 + goto encode_op;
2460 + }
2461 +
2462 +diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h
2463 +index ca1d2cc2cdfa..18863d56273c 100644
2464 +--- a/include/linux/arm-smccc.h
2465 ++++ b/include/linux/arm-smccc.h
2466 +@@ -199,47 +199,57 @@ asmlinkage void __arm_smccc_hvc(unsigned long a0, unsigned long a1,
2467 +
2468 + #define __declare_arg_0(a0, res) \
2469 + struct arm_smccc_res *___res = res; \
2470 +- register u32 r0 asm("r0") = a0; \
2471 ++ register unsigned long r0 asm("r0") = (u32)a0; \
2472 + register unsigned long r1 asm("r1"); \
2473 + register unsigned long r2 asm("r2"); \
2474 + register unsigned long r3 asm("r3")
2475 +
2476 + #define __declare_arg_1(a0, a1, res) \
2477 ++ typeof(a1) __a1 = a1; \
2478 + struct arm_smccc_res *___res = res; \
2479 +- register u32 r0 asm("r0") = a0; \
2480 +- register typeof(a1) r1 asm("r1") = a1; \
2481 ++ register unsigned long r0 asm("r0") = (u32)a0; \
2482 ++ register unsigned long r1 asm("r1") = __a1; \
2483 + register unsigned long r2 asm("r2"); \
2484 + register unsigned long r3 asm("r3")
2485 +
2486 + #define __declare_arg_2(a0, a1, a2, res) \
2487 ++ typeof(a1) __a1 = a1; \
2488 ++ typeof(a2) __a2 = a2; \
2489 + struct arm_smccc_res *___res = res; \
2490 +- register u32 r0 asm("r0") = a0; \
2491 +- register typeof(a1) r1 asm("r1") = a1; \
2492 +- register typeof(a2) r2 asm("r2") = a2; \
2493 ++ register unsigned long r0 asm("r0") = (u32)a0; \
2494 ++ register unsigned long r1 asm("r1") = __a1; \
2495 ++ register unsigned long r2 asm("r2") = __a2; \
2496 + register unsigned long r3 asm("r3")
2497 +
2498 + #define __declare_arg_3(a0, a1, a2, a3, res) \
2499 ++ typeof(a1) __a1 = a1; \
2500 ++ typeof(a2) __a2 = a2; \
2501 ++ typeof(a3) __a3 = a3; \
2502 + struct arm_smccc_res *___res = res; \
2503 +- register u32 r0 asm("r0") = a0; \
2504 +- register typeof(a1) r1 asm("r1") = a1; \
2505 +- register typeof(a2) r2 asm("r2") = a2; \
2506 +- register typeof(a3) r3 asm("r3") = a3
2507 ++ register unsigned long r0 asm("r0") = (u32)a0; \
2508 ++ register unsigned long r1 asm("r1") = __a1; \
2509 ++ register unsigned long r2 asm("r2") = __a2; \
2510 ++ register unsigned long r3 asm("r3") = __a3
2511 +
2512 + #define __declare_arg_4(a0, a1, a2, a3, a4, res) \
2513 ++ typeof(a4) __a4 = a4; \
2514 + __declare_arg_3(a0, a1, a2, a3, res); \
2515 +- register typeof(a4) r4 asm("r4") = a4
2516 ++ register unsigned long r4 asm("r4") = __a4
2517 +
2518 + #define __declare_arg_5(a0, a1, a2, a3, a4, a5, res) \
2519 ++ typeof(a5) __a5 = a5; \
2520 + __declare_arg_4(a0, a1, a2, a3, a4, res); \
2521 +- register typeof(a5) r5 asm("r5") = a5
2522 ++ register unsigned long r5 asm("r5") = __a5
2523 +
2524 + #define __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res) \
2525 ++ typeof(a6) __a6 = a6; \
2526 + __declare_arg_5(a0, a1, a2, a3, a4, a5, res); \
2527 +- register typeof(a6) r6 asm("r6") = a6
2528 ++ register unsigned long r6 asm("r6") = __a6
2529 +
2530 + #define __declare_arg_7(a0, a1, a2, a3, a4, a5, a6, a7, res) \
2531 ++ typeof(a7) __a7 = a7; \
2532 + __declare_arg_6(a0, a1, a2, a3, a4, a5, a6, res); \
2533 +- register typeof(a7) r7 asm("r7") = a7
2534 ++ register unsigned long r7 asm("r7") = __a7
2535 +
2536 + #define ___declare_args(count, ...) __declare_arg_ ## count(__VA_ARGS__)
2537 + #define __declare_args(count, ...) ___declare_args(count, __VA_ARGS__)
2538 +diff --git a/include/linux/platform_data/ina2xx.h b/include/linux/platform_data/ina2xx.h
2539 +index 9abc0ca7259b..9f0aa1b48c78 100644
2540 +--- a/include/linux/platform_data/ina2xx.h
2541 ++++ b/include/linux/platform_data/ina2xx.h
2542 +@@ -1,7 +1,7 @@
2543 + /*
2544 + * Driver for Texas Instruments INA219, INA226 power monitor chips
2545 + *
2546 +- * Copyright (C) 2012 Lothar Felten <l-felten@××.com>
2547 ++ * Copyright (C) 2012 Lothar Felten <lothar.felten@×××××.com>
2548 + *
2549 + * This program is free software; you can redistribute it and/or modify
2550 + * it under the terms of the GNU General Public License version 2 as
2551 +diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
2552 +index 3965503315ef..ad97baf7b8de 100644
2553 +--- a/include/linux/power_supply.h
2554 ++++ b/include/linux/power_supply.h
2555 +@@ -249,6 +249,7 @@ struct power_supply {
2556 + spinlock_t changed_lock;
2557 + bool changed;
2558 + bool initialized;
2559 ++ bool removing;
2560 + atomic_t use_cnt;
2561 + #ifdef CONFIG_THERMAL
2562 + struct thermal_zone_device *tzd;
2563 +diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
2564 +index 75f56c2ef2d4..b6a59e8cd855 100644
2565 +--- a/include/linux/slub_def.h
2566 ++++ b/include/linux/slub_def.h
2567 +@@ -67,7 +67,8 @@ struct kmem_cache {
2568 + int size; /* The size of an object including meta data */
2569 + int object_size; /* The size of an object without meta data */
2570 + int offset; /* Free pointer offset. */
2571 +- int cpu_partial; /* Number of per cpu partial objects to keep around */
2572 ++ /* Number of per cpu partial objects to keep around */
2573 ++ unsigned int cpu_partial;
2574 + struct kmem_cache_order_objects oo;
2575 +
2576 + /* Allocation and freeing of slabs */
2577 +diff --git a/include/media/v4l2-fh.h b/include/media/v4l2-fh.h
2578 +index e19e6246e21c..d2671606cb5d 100644
2579 +--- a/include/media/v4l2-fh.h
2580 ++++ b/include/media/v4l2-fh.h
2581 +@@ -42,10 +42,13 @@ struct v4l2_ctrl_handler;
2582 + * @prio: priority of the file handler, as defined by &enum v4l2_priority
2583 + *
2584 + * @wait: event' s wait queue
2585 ++ * @subscribe_lock: serialise changes to the subscribed list; guarantee that
2586 ++ * the add and del event callbacks are orderly called
2587 + * @subscribed: list of subscribed events
2588 + * @available: list of events waiting to be dequeued
2589 + * @navailable: number of available events at @available list
2590 + * @sequence: event sequence number
2591 ++ *
2592 + * @m2m_ctx: pointer to &struct v4l2_m2m_ctx
2593 + */
2594 + struct v4l2_fh {
2595 +@@ -56,6 +59,7 @@ struct v4l2_fh {
2596 +
2597 + /* Events */
2598 + wait_queue_head_t wait;
2599 ++ struct mutex subscribe_lock;
2600 + struct list_head subscribed;
2601 + struct list_head available;
2602 + unsigned int navailable;
2603 +diff --git a/kernel/module.c b/kernel/module.c
2604 +index 0651f2d25fc9..2325c9821f2a 100644
2605 +--- a/kernel/module.c
2606 ++++ b/kernel/module.c
2607 +@@ -4011,7 +4011,7 @@ static unsigned long mod_find_symname(struct module *mod, const char *name)
2608 +
2609 + for (i = 0; i < kallsyms->num_symtab; i++)
2610 + if (strcmp(name, symname(kallsyms, i)) == 0 &&
2611 +- kallsyms->symtab[i].st_info != 'U')
2612 ++ kallsyms->symtab[i].st_shndx != SHN_UNDEF)
2613 + return kallsyms->symtab[i].st_value;
2614 + return 0;
2615 + }
2616 +@@ -4057,6 +4057,10 @@ int module_kallsyms_on_each_symbol(int (*fn)(void *, const char *,
2617 + if (mod->state == MODULE_STATE_UNFORMED)
2618 + continue;
2619 + for (i = 0; i < kallsyms->num_symtab; i++) {
2620 ++
2621 ++ if (kallsyms->symtab[i].st_shndx == SHN_UNDEF)
2622 ++ continue;
2623 ++
2624 + ret = fn(data, symname(kallsyms, i),
2625 + mod, kallsyms->symtab[i].st_value);
2626 + if (ret != 0)
2627 +diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
2628 +index d67ef56ca9bc..a0ee81f49a87 100644
2629 +--- a/kernel/time/alarmtimer.c
2630 ++++ b/kernel/time/alarmtimer.c
2631 +@@ -786,7 +786,8 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags,
2632 + /* Convert (if necessary) to absolute time */
2633 + if (flags != TIMER_ABSTIME) {
2634 + ktime_t now = alarm_bases[type].gettime();
2635 +- exp = ktime_add(now, exp);
2636 ++
2637 ++ exp = ktime_add_safe(now, exp);
2638 + }
2639 +
2640 + if (alarmtimer_do_nsleep(&alarm, exp))
2641 +diff --git a/lib/klist.c b/lib/klist.c
2642 +index 0507fa5d84c5..f6b547812fe3 100644
2643 +--- a/lib/klist.c
2644 ++++ b/lib/klist.c
2645 +@@ -336,8 +336,9 @@ struct klist_node *klist_prev(struct klist_iter *i)
2646 + void (*put)(struct klist_node *) = i->i_klist->put;
2647 + struct klist_node *last = i->i_cur;
2648 + struct klist_node *prev;
2649 ++ unsigned long flags;
2650 +
2651 +- spin_lock(&i->i_klist->k_lock);
2652 ++ spin_lock_irqsave(&i->i_klist->k_lock, flags);
2653 +
2654 + if (last) {
2655 + prev = to_klist_node(last->n_node.prev);
2656 +@@ -356,7 +357,7 @@ struct klist_node *klist_prev(struct klist_iter *i)
2657 + prev = to_klist_node(prev->n_node.prev);
2658 + }
2659 +
2660 +- spin_unlock(&i->i_klist->k_lock);
2661 ++ spin_unlock_irqrestore(&i->i_klist->k_lock, flags);
2662 +
2663 + if (put && last)
2664 + put(last);
2665 +@@ -377,8 +378,9 @@ struct klist_node *klist_next(struct klist_iter *i)
2666 + void (*put)(struct klist_node *) = i->i_klist->put;
2667 + struct klist_node *last = i->i_cur;
2668 + struct klist_node *next;
2669 ++ unsigned long flags;
2670 +
2671 +- spin_lock(&i->i_klist->k_lock);
2672 ++ spin_lock_irqsave(&i->i_klist->k_lock, flags);
2673 +
2674 + if (last) {
2675 + next = to_klist_node(last->n_node.next);
2676 +@@ -397,7 +399,7 @@ struct klist_node *klist_next(struct klist_iter *i)
2677 + next = to_klist_node(next->n_node.next);
2678 + }
2679 +
2680 +- spin_unlock(&i->i_klist->k_lock);
2681 ++ spin_unlock_irqrestore(&i->i_klist->k_lock, flags);
2682 +
2683 + if (put && last)
2684 + put(last);
2685 +diff --git a/mm/slub.c b/mm/slub.c
2686 +index e0ce5dec84ba..131dee87a67c 100644
2687 +--- a/mm/slub.c
2688 ++++ b/mm/slub.c
2689 +@@ -1793,7 +1793,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n,
2690 + {
2691 + struct page *page, *page2;
2692 + void *object = NULL;
2693 +- int available = 0;
2694 ++ unsigned int available = 0;
2695 + int objects;
2696 +
2697 + /*
2698 +@@ -4870,10 +4870,10 @@ static ssize_t cpu_partial_show(struct kmem_cache *s, char *buf)
2699 + static ssize_t cpu_partial_store(struct kmem_cache *s, const char *buf,
2700 + size_t length)
2701 + {
2702 +- unsigned long objects;
2703 ++ unsigned int objects;
2704 + int err;
2705 +
2706 +- err = kstrtoul(buf, 10, &objects);
2707 ++ err = kstrtouint(buf, 10, &objects);
2708 + if (err)
2709 + return err;
2710 + if (objects && !kmem_cache_has_cpu_partial(s))
2711 +diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
2712 +index 79f1fa22509a..23654f1902f3 100644
2713 +--- a/net/6lowpan/iphc.c
2714 ++++ b/net/6lowpan/iphc.c
2715 +@@ -745,6 +745,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
2716 + hdr.hop_limit, &hdr.daddr);
2717 +
2718 + skb_push(skb, sizeof(hdr));
2719 ++ skb_reset_mac_header(skb);
2720 + skb_reset_network_header(skb);
2721 + skb_copy_to_linear_data(skb, &hdr, sizeof(hdr));
2722 +
2723 +diff --git a/sound/aoa/core/gpio-feature.c b/sound/aoa/core/gpio-feature.c
2724 +index 71960089e207..65557421fe0b 100644
2725 +--- a/sound/aoa/core/gpio-feature.c
2726 ++++ b/sound/aoa/core/gpio-feature.c
2727 +@@ -88,8 +88,10 @@ static struct device_node *get_gpio(char *name,
2728 + }
2729 +
2730 + reg = of_get_property(np, "reg", NULL);
2731 +- if (!reg)
2732 ++ if (!reg) {
2733 ++ of_node_put(np);
2734 + return NULL;
2735 ++ }
2736 +
2737 + *gpioptr = *reg;
2738 +
2739 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
2740 +index 4e331dd5ff47..f913809a7de3 100644
2741 +--- a/sound/pci/hda/hda_intel.c
2742 ++++ b/sound/pci/hda/hda_intel.c
2743 +@@ -2349,7 +2349,8 @@ static const struct pci_device_id azx_ids[] = {
2744 + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
2745 + /* AMD Raven */
2746 + { PCI_DEVICE(0x1022, 0x15e3),
2747 +- .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
2748 ++ .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB |
2749 ++ AZX_DCAPS_PM_RUNTIME },
2750 + /* ATI HDMI */
2751 + { PCI_DEVICE(0x1002, 0x0002),
2752 + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2753 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
2754 +index 0b5d132bc3dd..8bfc534e3b34 100644
2755 +--- a/sound/soc/soc-dapm.c
2756 ++++ b/sound/soc/soc-dapm.c
2757 +@@ -3913,6 +3913,13 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card)
2758 + continue;
2759 + }
2760 +
2761 ++ /* let users know there is no DAI to link */
2762 ++ if (!dai_w->priv) {
2763 ++ dev_dbg(card->dev, "dai widget %s has no DAI\n",
2764 ++ dai_w->name);
2765 ++ continue;
2766 ++ }
2767 ++
2768 + dai = dai_w->priv;
2769 +
2770 + /* ...find all widgets with the same stream and link them */