Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Thu, 30 Nov 2017 12:26:02
Message-Id: 1512044380.593e35d016571ad38b9f87465ac74b1b3e213e85.alicef@gentoo
1 commit: 593e35d016571ad38b9f87465ac74b1b3e213e85
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 30 12:19:40 2017 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 30 12:19:40 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=593e35d0
7
8 linux kernel 4.4.103
9
10 0000_README | 4 +
11 1102_linux-4.4.103.patch | 3056 ++++++++++++++++++++++++++++++++++++++++++++++
12 2 files changed, 3060 insertions(+)
13
14 diff --git a/0000_README b/0000_README
15 index 069312b..21ecaf0 100644
16 --- a/0000_README
17 +++ b/0000_README
18 @@ -451,6 +451,10 @@ Patch: 1101_linux-4.4.102.patch
19 From: http://www.kernel.org
20 Desc: Linux 4.4.102
21
22 +Patch: 1102_linux-4.4.103.patch
23 +From: http://www.kernel.org
24 +Desc: Linux 4.4.103
25 +
26 Patch: 1500_XATTR_USER_PREFIX.patch
27 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
28 Desc: Support for namespace user.pax.* on tmpfs.
29
30 diff --git a/1102_linux-4.4.103.patch b/1102_linux-4.4.103.patch
31 new file mode 100644
32 index 0000000..447afae
33 --- /dev/null
34 +++ b/1102_linux-4.4.103.patch
35 @@ -0,0 +1,3056 @@
36 +diff --git a/Makefile b/Makefile
37 +index 9e036fac9c04..f5a51cd7ca49 100644
38 +--- a/Makefile
39 ++++ b/Makefile
40 +@@ -1,6 +1,6 @@
41 + VERSION = 4
42 + PATCHLEVEL = 4
43 +-SUBLEVEL = 102
44 ++SUBLEVEL = 103
45 + EXTRAVERSION =
46 + NAME = Blurry Fish Butt
47 +
48 +diff --git a/arch/arm/mm/dump.c b/arch/arm/mm/dump.c
49 +index 9fe8e241335c..e1f6f0daa847 100644
50 +--- a/arch/arm/mm/dump.c
51 ++++ b/arch/arm/mm/dump.c
52 +@@ -126,8 +126,8 @@ static const struct prot_bits section_bits[] = {
53 + .val = PMD_SECT_USER,
54 + .set = "USR",
55 + }, {
56 +- .mask = L_PMD_SECT_RDONLY,
57 +- .val = L_PMD_SECT_RDONLY,
58 ++ .mask = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
59 ++ .val = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
60 + .set = "ro",
61 + .clear = "RW",
62 + #elif __LINUX_ARM_ARCH__ >= 6
63 +diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
64 +index 7f8cd1b3557f..c29ad610311b 100644
65 +--- a/arch/arm/mm/init.c
66 ++++ b/arch/arm/mm/init.c
67 +@@ -611,8 +611,8 @@ static struct section_perm ro_perms[] = {
68 + .start = (unsigned long)_stext,
69 + .end = (unsigned long)__init_begin,
70 + #ifdef CONFIG_ARM_LPAE
71 +- .mask = ~L_PMD_SECT_RDONLY,
72 +- .prot = L_PMD_SECT_RDONLY,
73 ++ .mask = ~(L_PMD_SECT_RDONLY | PMD_SECT_AP2),
74 ++ .prot = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
75 + #else
76 + .mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
77 + .prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,
78 +diff --git a/arch/mips/bcm47xx/leds.c b/arch/mips/bcm47xx/leds.c
79 +index d20ae63eb3c2..46abe9e4e0e0 100644
80 +--- a/arch/mips/bcm47xx/leds.c
81 ++++ b/arch/mips/bcm47xx/leds.c
82 +@@ -330,7 +330,7 @@ bcm47xx_leds_linksys_wrt54g3gv2[] __initconst = {
83 + /* Verified on: WRT54GS V1.0 */
84 + static const struct gpio_led
85 + bcm47xx_leds_linksys_wrt54g_type_0101[] __initconst = {
86 +- BCM47XX_GPIO_LED(0, "green", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF),
87 ++ BCM47XX_GPIO_LED(0, "green", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
88 + BCM47XX_GPIO_LED(1, "green", "power", 0, LEDS_GPIO_DEFSTATE_ON),
89 + BCM47XX_GPIO_LED(7, "green", "dmz", 1, LEDS_GPIO_DEFSTATE_OFF),
90 + };
91 +diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
92 +index 24c115a0721a..a3f38e6b7ea1 100644
93 +--- a/arch/mips/kernel/ptrace.c
94 ++++ b/arch/mips/kernel/ptrace.c
95 +@@ -650,6 +650,19 @@ static const struct user_regset_view user_mips64_view = {
96 + .n = ARRAY_SIZE(mips64_regsets),
97 + };
98 +
99 ++#ifdef CONFIG_MIPS32_N32
100 ++
101 ++static const struct user_regset_view user_mipsn32_view = {
102 ++ .name = "mipsn32",
103 ++ .e_flags = EF_MIPS_ABI2,
104 ++ .e_machine = ELF_ARCH,
105 ++ .ei_osabi = ELF_OSABI,
106 ++ .regsets = mips64_regsets,
107 ++ .n = ARRAY_SIZE(mips64_regsets),
108 ++};
109 ++
110 ++#endif /* CONFIG_MIPS32_N32 */
111 ++
112 + #endif /* CONFIG_64BIT */
113 +
114 + const struct user_regset_view *task_user_regset_view(struct task_struct *task)
115 +@@ -660,6 +673,10 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
116 + #ifdef CONFIG_MIPS32_O32
117 + if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
118 + return &user_mips_view;
119 ++#endif
120 ++#ifdef CONFIG_MIPS32_N32
121 ++ if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
122 ++ return &user_mipsn32_view;
123 + #endif
124 + return &user_mips64_view;
125 + #endif
126 +diff --git a/arch/mips/ralink/mt7620.c b/arch/mips/ralink/mt7620.c
127 +index 48d6349fd9d7..c5f45fc96c74 100644
128 +--- a/arch/mips/ralink/mt7620.c
129 ++++ b/arch/mips/ralink/mt7620.c
130 +@@ -141,8 +141,8 @@ static struct rt2880_pmx_func i2c_grp_mt7628[] = {
131 + FUNC("i2c", 0, 4, 2),
132 + };
133 +
134 +-static struct rt2880_pmx_func refclk_grp_mt7628[] = { FUNC("reclk", 0, 36, 1) };
135 +-static struct rt2880_pmx_func perst_grp_mt7628[] = { FUNC("perst", 0, 37, 1) };
136 ++static struct rt2880_pmx_func refclk_grp_mt7628[] = { FUNC("refclk", 0, 37, 1) };
137 ++static struct rt2880_pmx_func perst_grp_mt7628[] = { FUNC("perst", 0, 36, 1) };
138 + static struct rt2880_pmx_func wdt_grp_mt7628[] = { FUNC("wdt", 0, 38, 1) };
139 + static struct rt2880_pmx_func spi_grp_mt7628[] = { FUNC("spi", 0, 7, 4) };
140 +
141 +diff --git a/arch/parisc/kernel/syscall.S b/arch/parisc/kernel/syscall.S
142 +index c6b855f7892c..9f22195b90ed 100644
143 +--- a/arch/parisc/kernel/syscall.S
144 ++++ b/arch/parisc/kernel/syscall.S
145 +@@ -688,15 +688,15 @@ cas_action:
146 + /* ELF32 Process entry path */
147 + lws_compare_and_swap_2:
148 + #ifdef CONFIG_64BIT
149 +- /* Clip the input registers */
150 ++ /* Clip the input registers. We don't need to clip %r23 as we
151 ++ only use it for word operations */
152 + depdi 0, 31, 32, %r26
153 + depdi 0, 31, 32, %r25
154 + depdi 0, 31, 32, %r24
155 +- depdi 0, 31, 32, %r23
156 + #endif
157 +
158 + /* Check the validity of the size pointer */
159 +- subi,>>= 4, %r23, %r0
160 ++ subi,>>= 3, %r23, %r0
161 + b,n lws_exit_nosys
162 +
163 + /* Jump to the functions which will load the old and new values into
164 +diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
165 +index cf8c7e4e0b21..984a54c85952 100644
166 +--- a/arch/powerpc/kernel/signal.c
167 ++++ b/arch/powerpc/kernel/signal.c
168 +@@ -102,7 +102,7 @@ static void check_syscall_restart(struct pt_regs *regs, struct k_sigaction *ka,
169 + static void do_signal(struct pt_regs *regs)
170 + {
171 + sigset_t *oldset = sigmask_to_save();
172 +- struct ksignal ksig;
173 ++ struct ksignal ksig = { .sig = 0 };
174 + int ret;
175 + int is32 = is_32bit_task();
176 +
177 +diff --git a/arch/s390/include/asm/asm-prototypes.h b/arch/s390/include/asm/asm-prototypes.h
178 +new file mode 100644
179 +index 000000000000..2c3413b0ca52
180 +--- /dev/null
181 ++++ b/arch/s390/include/asm/asm-prototypes.h
182 +@@ -0,0 +1,8 @@
183 ++#ifndef _ASM_S390_PROTOTYPES_H
184 ++
185 ++#include <linux/kvm_host.h>
186 ++#include <linux/ftrace.h>
187 ++#include <asm/fpu/api.h>
188 ++#include <asm-generic/asm-prototypes.h>
189 ++
190 ++#endif /* _ASM_S390_PROTOTYPES_H */
191 +diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h
192 +index 12d45f0cfdd9..dde6b52359c5 100644
193 +--- a/arch/s390/include/asm/switch_to.h
194 ++++ b/arch/s390/include/asm/switch_to.h
195 +@@ -34,8 +34,8 @@ static inline void restore_access_regs(unsigned int *acrs)
196 + save_access_regs(&prev->thread.acrs[0]); \
197 + save_ri_cb(prev->thread.ri_cb); \
198 + } \
199 ++ update_cr_regs(next); \
200 + if (next->mm) { \
201 +- update_cr_regs(next); \
202 + set_cpu_flag(CIF_FPU); \
203 + restore_access_regs(&next->thread.acrs[0]); \
204 + restore_ri_cb(next->thread.ri_cb, prev->thread.ri_cb); \
205 +diff --git a/arch/s390/kernel/dis.c b/arch/s390/kernel/dis.c
206 +index 6e72961608f0..07477ba392b7 100644
207 +--- a/arch/s390/kernel/dis.c
208 ++++ b/arch/s390/kernel/dis.c
209 +@@ -1549,6 +1549,7 @@ static struct s390_insn opcode_e7[] = {
210 + { "vfsq", 0xce, INSTR_VRR_VV000MM },
211 + { "vfs", 0xe2, INSTR_VRR_VVV00MM },
212 + { "vftci", 0x4a, INSTR_VRI_VVIMM },
213 ++ { "", 0, INSTR_INVALID }
214 + };
215 +
216 + static struct s390_insn opcode_eb[] = {
217 +@@ -1961,7 +1962,7 @@ void show_code(struct pt_regs *regs)
218 + {
219 + char *mode = user_mode(regs) ? "User" : "Krnl";
220 + unsigned char code[64];
221 +- char buffer[64], *ptr;
222 ++ char buffer[128], *ptr;
223 + mm_segment_t old_fs;
224 + unsigned long addr;
225 + int start, end, opsize, hops, i;
226 +@@ -2024,7 +2025,7 @@ void show_code(struct pt_regs *regs)
227 + start += opsize;
228 + printk(buffer);
229 + ptr = buffer;
230 +- ptr += sprintf(ptr, "\n ");
231 ++ ptr += sprintf(ptr, "\n\t ");
232 + hops++;
233 + }
234 + printk("\n");
235 +diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
236 +index 3c31609df959..ee7b8e7ca4f8 100644
237 +--- a/arch/s390/kernel/early.c
238 ++++ b/arch/s390/kernel/early.c
239 +@@ -325,8 +325,10 @@ static __init void detect_machine_facilities(void)
240 + S390_lowcore.machine_flags |= MACHINE_FLAG_IDTE;
241 + if (test_facility(40))
242 + S390_lowcore.machine_flags |= MACHINE_FLAG_LPP;
243 +- if (test_facility(50) && test_facility(73))
244 ++ if (test_facility(50) && test_facility(73)) {
245 + S390_lowcore.machine_flags |= MACHINE_FLAG_TE;
246 ++ __ctl_set_bit(0, 55);
247 ++ }
248 + if (test_facility(51))
249 + S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_LC;
250 + if (test_facility(129)) {
251 +diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
252 +index 114ee8b96f17..efa035a31b98 100644
253 +--- a/arch/s390/kernel/process.c
254 ++++ b/arch/s390/kernel/process.c
255 +@@ -137,6 +137,7 @@ int copy_thread(unsigned long clone_flags, unsigned long new_stackp,
256 + memset(&p->thread.per_user, 0, sizeof(p->thread.per_user));
257 + memset(&p->thread.per_event, 0, sizeof(p->thread.per_event));
258 + clear_tsk_thread_flag(p, TIF_SINGLE_STEP);
259 ++ p->thread.per_flags = 0;
260 + /* Initialize per thread user and system timer values */
261 + ti = task_thread_info(p);
262 + ti->user_timer = 0;
263 +diff --git a/arch/s390/kernel/runtime_instr.c b/arch/s390/kernel/runtime_instr.c
264 +index fffa0e5462af..70cdb03d4acd 100644
265 +--- a/arch/s390/kernel/runtime_instr.c
266 ++++ b/arch/s390/kernel/runtime_instr.c
267 +@@ -47,11 +47,13 @@ void exit_thread_runtime_instr(void)
268 + {
269 + struct task_struct *task = current;
270 +
271 ++ preempt_disable();
272 + if (!task->thread.ri_cb)
273 + return;
274 + disable_runtime_instr();
275 + kfree(task->thread.ri_cb);
276 + task->thread.ri_cb = NULL;
277 ++ preempt_enable();
278 + }
279 +
280 + SYSCALL_DEFINE1(s390_runtime_instr, int, command)
281 +@@ -62,9 +64,7 @@ SYSCALL_DEFINE1(s390_runtime_instr, int, command)
282 + return -EOPNOTSUPP;
283 +
284 + if (command == S390_RUNTIME_INSTR_STOP) {
285 +- preempt_disable();
286 + exit_thread_runtime_instr();
287 +- preempt_enable();
288 + return 0;
289 + }
290 +
291 +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
292 +index 899c40f826dd..4e1b254c3695 100644
293 +--- a/arch/x86/kvm/svm.c
294 ++++ b/arch/x86/kvm/svm.c
295 +@@ -3114,6 +3114,13 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
296 + u32 ecx = msr->index;
297 + u64 data = msr->data;
298 + switch (ecx) {
299 ++ case MSR_IA32_CR_PAT:
300 ++ if (!kvm_mtrr_valid(vcpu, MSR_IA32_CR_PAT, data))
301 ++ return 1;
302 ++ vcpu->arch.pat = data;
303 ++ svm->vmcb->save.g_pat = data;
304 ++ mark_dirty(svm->vmcb, VMCB_NPT);
305 ++ break;
306 + case MSR_IA32_TSC:
307 + kvm_write_tsc(vcpu, msr);
308 + break;
309 +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
310 +index 9114588e3e61..67ba0d8f87c7 100644
311 +--- a/arch/x86/kvm/vmx.c
312 ++++ b/arch/x86/kvm/vmx.c
313 +@@ -10394,6 +10394,8 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
314 + vmcs_writel(GUEST_SYSENTER_EIP, vmcs12->host_ia32_sysenter_eip);
315 + vmcs_writel(GUEST_IDTR_BASE, vmcs12->host_idtr_base);
316 + vmcs_writel(GUEST_GDTR_BASE, vmcs12->host_gdtr_base);
317 ++ vmcs_write32(GUEST_IDTR_LIMIT, 0xFFFF);
318 ++ vmcs_write32(GUEST_GDTR_LIMIT, 0xFFFF);
319 +
320 + /* If not VM_EXIT_CLEAR_BNDCFGS, the L2 value propagates to L1. */
321 + if (vmcs12->vm_exit_controls & VM_EXIT_CLEAR_BNDCFGS)
322 +diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt
323 +index d388de72eaca..ec039f2a0c13 100644
324 +--- a/arch/x86/lib/x86-opcode-map.txt
325 ++++ b/arch/x86/lib/x86-opcode-map.txt
326 +@@ -833,7 +833,7 @@ EndTable
327 +
328 + GrpTable: Grp3_1
329 + 0: TEST Eb,Ib
330 +-1:
331 ++1: TEST Eb,Ib
332 + 2: NOT Eb
333 + 3: NEG Eb
334 + 4: MUL AL,Eb
335 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
336 +index 91a9e6af2ec4..75cced210b2a 100644
337 +--- a/drivers/ata/libata-eh.c
338 ++++ b/drivers/ata/libata-eh.c
339 +@@ -2245,8 +2245,8 @@ static void ata_eh_link_autopsy(struct ata_link *link)
340 + if (dev->flags & ATA_DFLAG_DUBIOUS_XFER)
341 + eflags |= ATA_EFLAG_DUBIOUS_XFER;
342 + ehc->i.action |= ata_eh_speed_down(dev, eflags, all_err_mask);
343 ++ trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
344 + }
345 +- trace_ata_eh_link_autopsy(dev, ehc->i.action, all_err_mask);
346 + DPRINTK("EXIT\n");
347 + }
348 +
349 +diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
350 +index f8580900c273..db6e7e57081c 100644
351 +--- a/drivers/base/power/opp/core.c
352 ++++ b/drivers/base/power/opp/core.c
353 +@@ -1205,6 +1205,7 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
354 + if (ret) {
355 + dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
356 + ret);
357 ++ of_node_put(np);
358 + goto free_table;
359 + }
360 + }
361 +diff --git a/drivers/clk/ti/clk-dra7-atl.c b/drivers/clk/ti/clk-dra7-atl.c
362 +index 2e14dfb588f4..7d060ffe8975 100644
363 +--- a/drivers/clk/ti/clk-dra7-atl.c
364 ++++ b/drivers/clk/ti/clk-dra7-atl.c
365 +@@ -265,7 +265,7 @@ static int of_dra7_atl_clk_probe(struct platform_device *pdev)
366 +
367 + /* Get configuration for the ATL instances */
368 + snprintf(prop, sizeof(prop), "atl%u", i);
369 +- cfg_node = of_find_node_by_name(node, prop);
370 ++ cfg_node = of_get_child_by_name(node, prop);
371 + if (cfg_node) {
372 + ret = of_property_read_u32(cfg_node, "bws",
373 + &cdesc->bws);
374 +@@ -278,6 +278,7 @@ static int of_dra7_atl_clk_probe(struct platform_device *pdev)
375 + atl_write(cinfo, DRA7_ATL_AWSMUX_REG(i),
376 + cdesc->aws);
377 + }
378 ++ of_node_put(cfg_node);
379 + }
380 +
381 + cdesc->probed = true;
382 +diff --git a/drivers/dma/zx296702_dma.c b/drivers/dma/zx296702_dma.c
383 +index 245d759d5ffc..6059d81e701a 100644
384 +--- a/drivers/dma/zx296702_dma.c
385 ++++ b/drivers/dma/zx296702_dma.c
386 +@@ -813,6 +813,7 @@ static int zx_dma_probe(struct platform_device *op)
387 + INIT_LIST_HEAD(&d->slave.channels);
388 + dma_cap_set(DMA_SLAVE, d->slave.cap_mask);
389 + dma_cap_set(DMA_MEMCPY, d->slave.cap_mask);
390 ++ dma_cap_set(DMA_CYCLIC, d->slave.cap_mask);
391 + dma_cap_set(DMA_PRIVATE, d->slave.cap_mask);
392 + d->slave.dev = &op->dev;
393 + d->slave.device_free_chan_resources = zx_dma_free_chan_resources;
394 +diff --git a/drivers/gpu/drm/armada/Makefile b/drivers/gpu/drm/armada/Makefile
395 +index ffd673615772..26412d2f8c98 100644
396 +--- a/drivers/gpu/drm/armada/Makefile
397 ++++ b/drivers/gpu/drm/armada/Makefile
398 +@@ -4,3 +4,5 @@ armada-y += armada_510.o
399 + armada-$(CONFIG_DEBUG_FS) += armada_debugfs.o
400 +
401 + obj-$(CONFIG_DRM_ARMADA) := armada.o
402 ++
403 ++CFLAGS_armada_trace.o := -I$(src)
404 +diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
405 +index 04de6fd88f8c..521b5bddb99c 100644
406 +--- a/drivers/gpu/drm/drm_mm.c
407 ++++ b/drivers/gpu/drm/drm_mm.c
408 +@@ -262,14 +262,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
409 +
410 + BUG_ON(!hole_node->hole_follows || node->allocated);
411 +
412 +- if (adj_start < start)
413 +- adj_start = start;
414 +- if (adj_end > end)
415 +- adj_end = end;
416 +-
417 + if (mm->color_adjust)
418 + mm->color_adjust(hole_node, color, &adj_start, &adj_end);
419 +
420 ++ adj_start = max(adj_start, start);
421 ++ adj_end = min(adj_end, end);
422 ++
423 + if (flags & DRM_MM_CREATE_TOP)
424 + adj_start = adj_end - size;
425 +
426 +@@ -475,17 +473,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
427 + flags & DRM_MM_SEARCH_BELOW) {
428 + u64 hole_size = adj_end - adj_start;
429 +
430 +- if (adj_start < start)
431 +- adj_start = start;
432 +- if (adj_end > end)
433 +- adj_end = end;
434 +-
435 + if (mm->color_adjust) {
436 + mm->color_adjust(entry, color, &adj_start, &adj_end);
437 + if (adj_end <= adj_start)
438 + continue;
439 + }
440 +
441 ++ adj_start = max(adj_start, start);
442 ++ adj_end = min(adj_end, end);
443 ++
444 + if (!check_free_hole(adj_start, adj_end, size, alignment))
445 + continue;
446 +
447 +diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c
448 +index fe89b6823217..263e97235ea0 100644
449 +--- a/drivers/iio/light/cm3232.c
450 ++++ b/drivers/iio/light/cm3232.c
451 +@@ -119,7 +119,7 @@ static int cm3232_reg_init(struct cm3232_chip *chip)
452 + if (ret < 0)
453 + dev_err(&chip->client->dev, "Error writing reg_cmd\n");
454 +
455 +- return 0;
456 ++ return ret;
457 + }
458 +
459 + /**
460 +diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
461 +index e397f1b0af09..9a99cee2665a 100644
462 +--- a/drivers/infiniband/ulp/srp/ib_srp.c
463 ++++ b/drivers/infiniband/ulp/srp/ib_srp.c
464 +@@ -670,12 +670,19 @@ static void srp_path_rec_completion(int status,
465 + static int srp_lookup_path(struct srp_rdma_ch *ch)
466 + {
467 + struct srp_target_port *target = ch->target;
468 +- int ret;
469 ++ int ret = -ENODEV;
470 +
471 + ch->path.numb_path = 1;
472 +
473 + init_completion(&ch->done);
474 +
475 ++ /*
476 ++ * Avoid that the SCSI host can be removed by srp_remove_target()
477 ++ * before srp_path_rec_completion() is called.
478 ++ */
479 ++ if (!scsi_host_get(target->scsi_host))
480 ++ goto out;
481 ++
482 + ch->path_query_id = ib_sa_path_rec_get(&srp_sa_client,
483 + target->srp_host->srp_dev->dev,
484 + target->srp_host->port,
485 +@@ -689,18 +696,24 @@ static int srp_lookup_path(struct srp_rdma_ch *ch)
486 + GFP_KERNEL,
487 + srp_path_rec_completion,
488 + ch, &ch->path_query);
489 +- if (ch->path_query_id < 0)
490 +- return ch->path_query_id;
491 ++ ret = ch->path_query_id;
492 ++ if (ret < 0)
493 ++ goto put;
494 +
495 + ret = wait_for_completion_interruptible(&ch->done);
496 + if (ret < 0)
497 +- return ret;
498 ++ goto put;
499 +
500 +- if (ch->status < 0)
501 ++ ret = ch->status;
502 ++ if (ret < 0)
503 + shost_printk(KERN_WARNING, target->scsi_host,
504 + PFX "Path record query failed\n");
505 +
506 +- return ch->status;
507 ++put:
508 ++ scsi_host_put(target->scsi_host);
509 ++
510 ++out:
511 ++ return ret;
512 + }
513 +
514 + static int srp_send_req(struct srp_rdma_ch *ch, bool multich)
515 +diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
516 +index eaabf3125846..c52131233ba7 100644
517 +--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
518 ++++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
519 +@@ -3425,7 +3425,7 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
520 + {
521 + const char *p;
522 + unsigned len, count, leading_zero_bytes;
523 +- int ret, rc;
524 ++ int ret;
525 +
526 + p = name;
527 + if (strncasecmp(p, "0x", 2) == 0)
528 +@@ -3437,10 +3437,9 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
529 + count = min(len / 2, 16U);
530 + leading_zero_bytes = 16 - count;
531 + memset(i_port_id, 0, leading_zero_bytes);
532 +- rc = hex2bin(i_port_id + leading_zero_bytes, p, count);
533 +- if (rc < 0)
534 +- pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc);
535 +- ret = 0;
536 ++ ret = hex2bin(i_port_id + leading_zero_bytes, p, count);
537 ++ if (ret < 0)
538 ++ pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret);
539 + out:
540 + return ret;
541 + }
542 +diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c
543 +index 8eeab72b93e2..ea47980949ef 100644
544 +--- a/drivers/md/bcache/alloc.c
545 ++++ b/drivers/md/bcache/alloc.c
546 +@@ -406,7 +406,8 @@ long bch_bucket_alloc(struct cache *ca, unsigned reserve, bool wait)
547 +
548 + finish_wait(&ca->set->bucket_wait, &w);
549 + out:
550 +- wake_up_process(ca->alloc_thread);
551 ++ if (ca->alloc_thread)
552 ++ wake_up_process(ca->alloc_thread);
553 +
554 + trace_bcache_alloc(ca, reserve);
555 +
556 +diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
557 +index cdceefd0e57d..2ec7f90e3455 100644
558 +--- a/drivers/md/dm-bufio.c
559 ++++ b/drivers/md/dm-bufio.c
560 +@@ -928,7 +928,8 @@ static void __get_memory_limit(struct dm_bufio_client *c,
561 + buffers = c->minimum_buffers;
562 +
563 + *limit_buffers = buffers;
564 +- *threshold_buffers = buffers * DM_BUFIO_WRITEBACK_PERCENT / 100;
565 ++ *threshold_buffers = mult_frac(buffers,
566 ++ DM_BUFIO_WRITEBACK_PERCENT, 100);
567 + }
568 +
569 + /*
570 +@@ -1829,19 +1830,15 @@ static int __init dm_bufio_init(void)
571 + memset(&dm_bufio_caches, 0, sizeof dm_bufio_caches);
572 + memset(&dm_bufio_cache_names, 0, sizeof dm_bufio_cache_names);
573 +
574 +- mem = (__u64)((totalram_pages - totalhigh_pages) *
575 +- DM_BUFIO_MEMORY_PERCENT / 100) << PAGE_SHIFT;
576 ++ mem = (__u64)mult_frac(totalram_pages - totalhigh_pages,
577 ++ DM_BUFIO_MEMORY_PERCENT, 100) << PAGE_SHIFT;
578 +
579 + if (mem > ULONG_MAX)
580 + mem = ULONG_MAX;
581 +
582 + #ifdef CONFIG_MMU
583 +- /*
584 +- * Get the size of vmalloc space the same way as VMALLOC_TOTAL
585 +- * in fs/proc/internal.h
586 +- */
587 +- if (mem > (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100)
588 +- mem = (VMALLOC_END - VMALLOC_START) * DM_BUFIO_VMALLOC_PERCENT / 100;
589 ++ if (mem > mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100))
590 ++ mem = mult_frac(VMALLOC_TOTAL, DM_BUFIO_VMALLOC_PERCENT, 100);
591 + #endif
592 +
593 + dm_bufio_default_cache_size = mem;
594 +diff --git a/drivers/md/dm.c b/drivers/md/dm.c
595 +index 320eb3c4bb6b..9ec6948e3b8b 100644
596 +--- a/drivers/md/dm.c
597 ++++ b/drivers/md/dm.c
598 +@@ -3507,11 +3507,15 @@ struct mapped_device *dm_get_from_kobject(struct kobject *kobj)
599 +
600 + md = container_of(kobj, struct mapped_device, kobj_holder.kobj);
601 +
602 +- if (test_bit(DMF_FREEING, &md->flags) ||
603 +- dm_deleting_md(md))
604 +- return NULL;
605 +-
606 ++ spin_lock(&_minor_lock);
607 ++ if (test_bit(DMF_FREEING, &md->flags) || dm_deleting_md(md)) {
608 ++ md = NULL;
609 ++ goto out;
610 ++ }
611 + dm_get(md);
612 ++out:
613 ++ spin_unlock(&_minor_lock);
614 ++
615 + return md;
616 + }
617 +
618 +diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
619 +index efc21b1da211..ca107033e429 100644
620 +--- a/drivers/media/rc/ir-lirc-codec.c
621 ++++ b/drivers/media/rc/ir-lirc-codec.c
622 +@@ -286,11 +286,14 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd,
623 + if (!dev->max_timeout)
624 + return -ENOSYS;
625 +
626 ++ /* Check for multiply overflow */
627 ++ if (val > U32_MAX / 1000)
628 ++ return -EINVAL;
629 ++
630 + tmp = val * 1000;
631 +
632 +- if (tmp < dev->min_timeout ||
633 +- tmp > dev->max_timeout)
634 +- return -EINVAL;
635 ++ if (tmp < dev->min_timeout || tmp > dev->max_timeout)
636 ++ return -EINVAL;
637 +
638 + dev->timeout = tmp;
639 + break;
640 +diff --git a/drivers/media/usb/as102/as102_fw.c b/drivers/media/usb/as102/as102_fw.c
641 +index 07d08c49f4d4..b2e16bb67572 100644
642 +--- a/drivers/media/usb/as102/as102_fw.c
643 ++++ b/drivers/media/usb/as102/as102_fw.c
644 +@@ -101,18 +101,23 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
645 + unsigned char *cmd,
646 + const struct firmware *firmware) {
647 +
648 +- struct as10x_fw_pkt_t fw_pkt;
649 ++ struct as10x_fw_pkt_t *fw_pkt;
650 + int total_read_bytes = 0, errno = 0;
651 + unsigned char addr_has_changed = 0;
652 +
653 ++ fw_pkt = kmalloc(sizeof(*fw_pkt), GFP_KERNEL);
654 ++ if (!fw_pkt)
655 ++ return -ENOMEM;
656 ++
657 ++
658 + for (total_read_bytes = 0; total_read_bytes < firmware->size; ) {
659 + int read_bytes = 0, data_len = 0;
660 +
661 + /* parse intel hex line */
662 + read_bytes = parse_hex_line(
663 + (u8 *) (firmware->data + total_read_bytes),
664 +- fw_pkt.raw.address,
665 +- fw_pkt.raw.data,
666 ++ fw_pkt->raw.address,
667 ++ fw_pkt->raw.data,
668 + &data_len,
669 + &addr_has_changed);
670 +
671 +@@ -122,28 +127,28 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
672 + /* detect the end of file */
673 + total_read_bytes += read_bytes;
674 + if (total_read_bytes == firmware->size) {
675 +- fw_pkt.u.request[0] = 0x00;
676 +- fw_pkt.u.request[1] = 0x03;
677 ++ fw_pkt->u.request[0] = 0x00;
678 ++ fw_pkt->u.request[1] = 0x03;
679 +
680 + /* send EOF command */
681 + errno = bus_adap->ops->upload_fw_pkt(bus_adap,
682 + (uint8_t *)
683 +- &fw_pkt, 2, 0);
684 ++ fw_pkt, 2, 0);
685 + if (errno < 0)
686 + goto error;
687 + } else {
688 + if (!addr_has_changed) {
689 + /* prepare command to send */
690 +- fw_pkt.u.request[0] = 0x00;
691 +- fw_pkt.u.request[1] = 0x01;
692 ++ fw_pkt->u.request[0] = 0x00;
693 ++ fw_pkt->u.request[1] = 0x01;
694 +
695 +- data_len += sizeof(fw_pkt.u.request);
696 +- data_len += sizeof(fw_pkt.raw.address);
697 ++ data_len += sizeof(fw_pkt->u.request);
698 ++ data_len += sizeof(fw_pkt->raw.address);
699 +
700 + /* send cmd to device */
701 + errno = bus_adap->ops->upload_fw_pkt(bus_adap,
702 + (uint8_t *)
703 +- &fw_pkt,
704 ++ fw_pkt,
705 + data_len,
706 + 0);
707 + if (errno < 0)
708 +@@ -152,6 +157,7 @@ static int as102_firmware_upload(struct as10x_bus_adapter_t *bus_adap,
709 + }
710 + }
711 + error:
712 ++ kfree(fw_pkt);
713 + return (errno == 0) ? total_read_bytes : errno;
714 + }
715 +
716 +diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
717 +index 2c5f76d588ac..04ae21278440 100644
718 +--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
719 ++++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
720 +@@ -1672,7 +1672,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
721 + nr = dev->devno;
722 +
723 + assoc_desc = udev->actconfig->intf_assoc[0];
724 +- if (assoc_desc->bFirstInterface != ifnum) {
725 ++ if (!assoc_desc || assoc_desc->bFirstInterface != ifnum) {
726 + dev_err(d, "Not found matching IAD interface\n");
727 + retval = -ENODEV;
728 + goto err_if;
729 +diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c
730 +index 4a1d9fdd14bb..523758e71fe6 100644
731 +--- a/drivers/media/v4l2-core/v4l2-ctrls.c
732 ++++ b/drivers/media/v4l2-core/v4l2-ctrls.c
733 +@@ -1200,6 +1200,16 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
734 + }
735 + EXPORT_SYMBOL(v4l2_ctrl_fill);
736 +
737 ++static u32 user_flags(const struct v4l2_ctrl *ctrl)
738 ++{
739 ++ u32 flags = ctrl->flags;
740 ++
741 ++ if (ctrl->is_ptr)
742 ++ flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
743 ++
744 ++ return flags;
745 ++}
746 ++
747 + static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 changes)
748 + {
749 + memset(ev->reserved, 0, sizeof(ev->reserved));
750 +@@ -1207,7 +1217,7 @@ static void fill_event(struct v4l2_event *ev, struct v4l2_ctrl *ctrl, u32 change
751 + ev->id = ctrl->id;
752 + ev->u.ctrl.changes = changes;
753 + ev->u.ctrl.type = ctrl->type;
754 +- ev->u.ctrl.flags = ctrl->flags;
755 ++ ev->u.ctrl.flags = user_flags(ctrl);
756 + if (ctrl->is_ptr)
757 + ev->u.ctrl.value64 = 0;
758 + else
759 +@@ -2536,10 +2546,8 @@ int v4l2_query_ext_ctrl(struct v4l2_ctrl_handler *hdl, struct v4l2_query_ext_ctr
760 + else
761 + qc->id = ctrl->id;
762 + strlcpy(qc->name, ctrl->name, sizeof(qc->name));
763 +- qc->flags = ctrl->flags;
764 ++ qc->flags = user_flags(ctrl);
765 + qc->type = ctrl->type;
766 +- if (ctrl->is_ptr)
767 +- qc->flags |= V4L2_CTRL_FLAG_HAS_PAYLOAD;
768 + qc->elem_size = ctrl->elem_size;
769 + qc->elems = ctrl->elems;
770 + qc->nr_of_dims = ctrl->nr_of_dims;
771 +diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
772 +index 8f8418d2ac4a..a0012c3cb4f6 100644
773 +--- a/drivers/net/ethernet/3com/typhoon.c
774 ++++ b/drivers/net/ethernet/3com/typhoon.c
775 +@@ -2366,9 +2366,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
776 + * 4) Get the hardware address.
777 + * 5) Put the card to sleep.
778 + */
779 +- if (typhoon_reset(ioaddr, WaitSleep) < 0) {
780 ++ err = typhoon_reset(ioaddr, WaitSleep);
781 ++ if (err < 0) {
782 + err_msg = "could not reset 3XP";
783 +- err = -EIO;
784 + goto error_out_dma;
785 + }
786 +
787 +@@ -2382,24 +2382,25 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
788 + typhoon_init_interface(tp);
789 + typhoon_init_rings(tp);
790 +
791 +- if(typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST) < 0) {
792 ++ err = typhoon_boot_3XP(tp, TYPHOON_STATUS_WAITING_FOR_HOST);
793 ++ if (err < 0) {
794 + err_msg = "cannot boot 3XP sleep image";
795 +- err = -EIO;
796 + goto error_out_reset;
797 + }
798 +
799 + INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_MAC_ADDRESS);
800 +- if(typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp) < 0) {
801 ++ err = typhoon_issue_command(tp, 1, &xp_cmd, 1, xp_resp);
802 ++ if (err < 0) {
803 + err_msg = "cannot read MAC address";
804 +- err = -EIO;
805 + goto error_out_reset;
806 + }
807 +
808 + *(__be16 *)&dev->dev_addr[0] = htons(le16_to_cpu(xp_resp[0].parm1));
809 + *(__be32 *)&dev->dev_addr[2] = htonl(le32_to_cpu(xp_resp[0].parm2));
810 +
811 +- if(!is_valid_ether_addr(dev->dev_addr)) {
812 ++ if (!is_valid_ether_addr(dev->dev_addr)) {
813 + err_msg = "Could not obtain valid ethernet address, aborting";
814 ++ err = -EIO;
815 + goto error_out_reset;
816 + }
817 +
818 +@@ -2407,7 +2408,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
819 + * later when we print out the version reported.
820 + */
821 + INIT_COMMAND_WITH_RESPONSE(&xp_cmd, TYPHOON_CMD_READ_VERSIONS);
822 +- if(typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp) < 0) {
823 ++ err = typhoon_issue_command(tp, 1, &xp_cmd, 3, xp_resp);
824 ++ if (err < 0) {
825 + err_msg = "Could not get Sleep Image version";
826 + goto error_out_reset;
827 + }
828 +@@ -2424,9 +2426,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
829 + if(xp_resp[0].numDesc != 0)
830 + tp->capabilities |= TYPHOON_WAKEUP_NEEDS_RESET;
831 +
832 +- if(typhoon_sleep(tp, PCI_D3hot, 0) < 0) {
833 ++ err = typhoon_sleep(tp, PCI_D3hot, 0);
834 ++ if (err < 0) {
835 + err_msg = "cannot put adapter to sleep";
836 +- err = -EIO;
837 + goto error_out_reset;
838 + }
839 +
840 +@@ -2449,7 +2451,8 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
841 + dev->features = dev->hw_features |
842 + NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_RXCSUM;
843 +
844 +- if(register_netdev(dev) < 0) {
845 ++ err = register_netdev(dev);
846 ++ if (err < 0) {
847 + err_msg = "unable to register netdev";
848 + goto error_out_reset;
849 + }
850 +diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
851 +index e59d7c283cd4..645ace74429e 100644
852 +--- a/drivers/net/ethernet/intel/e1000e/mac.c
853 ++++ b/drivers/net/ethernet/intel/e1000e/mac.c
854 +@@ -410,6 +410,9 @@ void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw)
855 + * Checks to see of the link status of the hardware has changed. If a
856 + * change in link status has been detected, then we read the PHY registers
857 + * to get the current speed/duplex if link exists.
858 ++ *
859 ++ * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link
860 ++ * up).
861 + **/
862 + s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
863 + {
864 +@@ -423,7 +426,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
865 + * Change or Rx Sequence Error interrupt.
866 + */
867 + if (!mac->get_link_status)
868 +- return 0;
869 ++ return 1;
870 +
871 + /* First we want to see if the MII Status Register reports
872 + * link. If so, then we want to get the current speed/duplex
873 +@@ -461,10 +464,12 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw)
874 + * different link partner.
875 + */
876 + ret_val = e1000e_config_fc_after_link_up(hw);
877 +- if (ret_val)
878 ++ if (ret_val) {
879 + e_dbg("Error configuring flow control\n");
880 ++ return ret_val;
881 ++ }
882 +
883 +- return ret_val;
884 ++ return 1;
885 + }
886 +
887 + /**
888 +diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
889 +index 80ec587d510e..5205f1ebe381 100644
890 +--- a/drivers/net/ethernet/intel/e1000e/netdev.c
891 ++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
892 +@@ -5017,7 +5017,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter)
893 + case e1000_media_type_copper:
894 + if (hw->mac.get_link_status) {
895 + ret_val = hw->mac.ops.check_for_link(hw);
896 +- link_active = !hw->mac.get_link_status;
897 ++ link_active = ret_val > 0;
898 + } else {
899 + link_active = true;
900 + }
901 +@@ -5035,7 +5035,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter)
902 + break;
903 + }
904 +
905 +- if ((ret_val == E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
906 ++ if ((ret_val == -E1000_ERR_PHY) && (hw->phy.type == e1000_phy_igp_3) &&
907 + (er32(CTRL) & E1000_PHY_CTRL_GBE_DISABLE)) {
908 + /* See e1000_kmrn_lock_loss_workaround_ich8lan() */
909 + e_info("Gigabit has been disabled, downgrading speed\n");
910 +diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c
911 +index de13aeacae97..8e674a0988b0 100644
912 +--- a/drivers/net/ethernet/intel/e1000e/phy.c
913 ++++ b/drivers/net/ethernet/intel/e1000e/phy.c
914 +@@ -1744,6 +1744,7 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
915 + s32 ret_val = 0;
916 + u16 i, phy_status;
917 +
918 ++ *success = false;
919 + for (i = 0; i < iterations; i++) {
920 + /* Some PHYs require the MII_BMSR register to be read
921 + * twice due to the link bit being sticky. No harm doing
922 +@@ -1763,16 +1764,16 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
923 + ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);
924 + if (ret_val)
925 + break;
926 +- if (phy_status & BMSR_LSTATUS)
927 ++ if (phy_status & BMSR_LSTATUS) {
928 ++ *success = true;
929 + break;
930 ++ }
931 + if (usec_interval >= 1000)
932 + msleep(usec_interval / 1000);
933 + else
934 + udelay(usec_interval);
935 + }
936 +
937 +- *success = (i < iterations);
938 +-
939 + return ret_val;
940 + }
941 +
942 +diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
943 +index 09281558bfbc..c21fa56afd7c 100644
944 +--- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c
945 ++++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c
946 +@@ -1226,7 +1226,7 @@ static bool fm10k_clean_tx_irq(struct fm10k_q_vector *q_vector,
947 + break;
948 +
949 + /* prevent any other reads prior to eop_desc */
950 +- read_barrier_depends();
951 ++ smp_rmb();
952 +
953 + /* if DD is not set pending work has not been completed */
954 + if (!(eop_desc->flags & FM10K_TXD_FLAG_DONE))
955 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
956 +index 4edbab6ca7ef..b5b228c9a030 100644
957 +--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
958 ++++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
959 +@@ -3595,7 +3595,7 @@ static bool i40e_clean_fdir_tx_irq(struct i40e_ring *tx_ring, int budget)
960 + break;
961 +
962 + /* prevent any other reads prior to eop_desc */
963 +- read_barrier_depends();
964 ++ smp_rmb();
965 +
966 + /* if the descriptor isn't done, no work yet to do */
967 + if (!(eop_desc->cmd_type_offset_bsz &
968 +diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
969 +index 26c55bba4bf3..6dcc3854844d 100644
970 +--- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c
971 ++++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c
972 +@@ -663,7 +663,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
973 + break;
974 +
975 + /* prevent any other reads prior to eop_desc */
976 +- read_barrier_depends();
977 ++ smp_rmb();
978 +
979 + /* we have caught up to head, no work left to do */
980 + if (tx_head == tx_desc)
981 +diff --git a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
982 +index 39db70a597ed..1ed27fcd5031 100644
983 +--- a/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
984 ++++ b/drivers/net/ethernet/intel/i40evf/i40e_txrx.c
985 +@@ -172,7 +172,7 @@ static bool i40e_clean_tx_irq(struct i40e_ring *tx_ring, int budget)
986 + break;
987 +
988 + /* prevent any other reads prior to eop_desc */
989 +- read_barrier_depends();
990 ++ smp_rmb();
991 +
992 + /* we have caught up to head, no work left to do */
993 + if (tx_head == tx_desc)
994 +diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
995 +index ff6e57d788eb..c55552c3d2f9 100644
996 +--- a/drivers/net/ethernet/intel/igb/igb_main.c
997 ++++ b/drivers/net/ethernet/intel/igb/igb_main.c
998 +@@ -6433,7 +6433,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)
999 + break;
1000 +
1001 + /* prevent any other reads prior to eop_desc */
1002 +- read_barrier_depends();
1003 ++ smp_rmb();
1004 +
1005 + /* if DD is not set pending work has not been completed */
1006 + if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)))
1007 +diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
1008 +index 297af801f051..519b72c41888 100644
1009 +--- a/drivers/net/ethernet/intel/igbvf/netdev.c
1010 ++++ b/drivers/net/ethernet/intel/igbvf/netdev.c
1011 +@@ -809,7 +809,7 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)
1012 + break;
1013 +
1014 + /* prevent any other reads prior to eop_desc */
1015 +- read_barrier_depends();
1016 ++ smp_rmb();
1017 +
1018 + /* if DD is not set pending work has not been completed */
1019 + if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)))
1020 +diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1021 +index 83645d8503d4..a5b443171b8b 100644
1022 +--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1023 ++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1024 +@@ -1114,7 +1114,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,
1025 + break;
1026 +
1027 + /* prevent any other reads prior to eop_desc */
1028 +- read_barrier_depends();
1029 ++ smp_rmb();
1030 +
1031 + /* if DD is not set pending work has not been completed */
1032 + if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)))
1033 +diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1034 +index 592ff237d692..50bbad37d640 100644
1035 +--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1036 ++++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1037 +@@ -312,7 +312,7 @@ static bool ixgbevf_clean_tx_irq(struct ixgbevf_q_vector *q_vector,
1038 + break;
1039 +
1040 + /* prevent any other reads prior to eop_desc */
1041 +- read_barrier_depends();
1042 ++ smp_rmb();
1043 +
1044 + /* if DD is not set pending work has not been completed */
1045 + if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD)))
1046 +diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c
1047 +index 05de75360fa4..ee638cb8b48f 100644
1048 +--- a/drivers/net/wireless/ath/ath10k/core.c
1049 ++++ b/drivers/net/wireless/ath/ath10k/core.c
1050 +@@ -548,8 +548,11 @@ static int ath10k_core_get_board_id_from_otp(struct ath10k *ar)
1051 + "boot get otp board id result 0x%08x board_id %d chip_id %d\n",
1052 + result, board_id, chip_id);
1053 +
1054 +- if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0)
1055 ++ if ((result & ATH10K_BMI_BOARD_ID_STATUS_MASK) != 0 ||
1056 ++ (board_id == 0)) {
1057 ++ ath10k_warn(ar, "board id is not exist in otp, ignore it\n");
1058 + return -EOPNOTSUPP;
1059 ++ }
1060 +
1061 + ar->id.bmi_ids_valid = true;
1062 + ar->id.bmi_board_id = board_id;
1063 +diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
1064 +index 6decf4a95ce1..bed8d89fe3a0 100644
1065 +--- a/drivers/net/wireless/ath/ath10k/mac.c
1066 ++++ b/drivers/net/wireless/ath/ath10k/mac.c
1067 +@@ -1127,6 +1127,36 @@ static int ath10k_monitor_recalc(struct ath10k *ar)
1068 + return ath10k_monitor_stop(ar);
1069 + }
1070 +
1071 ++static bool ath10k_mac_can_set_cts_prot(struct ath10k_vif *arvif)
1072 ++{
1073 ++ struct ath10k *ar = arvif->ar;
1074 ++
1075 ++ lockdep_assert_held(&ar->conf_mutex);
1076 ++
1077 ++ if (!arvif->is_started) {
1078 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "defer cts setup, vdev is not ready yet\n");
1079 ++ return false;
1080 ++ }
1081 ++
1082 ++ return true;
1083 ++}
1084 ++
1085 ++static int ath10k_mac_set_cts_prot(struct ath10k_vif *arvif)
1086 ++{
1087 ++ struct ath10k *ar = arvif->ar;
1088 ++ u32 vdev_param;
1089 ++
1090 ++ lockdep_assert_held(&ar->conf_mutex);
1091 ++
1092 ++ vdev_param = ar->wmi.vdev_param->protection_mode;
1093 ++
1094 ++ ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_protection %d\n",
1095 ++ arvif->vdev_id, arvif->use_cts_prot);
1096 ++
1097 ++ return ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
1098 ++ arvif->use_cts_prot ? 1 : 0);
1099 ++}
1100 ++
1101 + static int ath10k_recalc_rtscts_prot(struct ath10k_vif *arvif)
1102 + {
1103 + struct ath10k *ar = arvif->ar;
1104 +@@ -4180,7 +4210,8 @@ static int ath10k_mac_txpower_recalc(struct ath10k *ar)
1105 + lockdep_assert_held(&ar->conf_mutex);
1106 +
1107 + list_for_each_entry(arvif, &ar->arvifs, list) {
1108 +- WARN_ON(arvif->txpower < 0);
1109 ++ if (arvif->txpower <= 0)
1110 ++ continue;
1111 +
1112 + if (txpower == -1)
1113 + txpower = arvif->txpower;
1114 +@@ -4188,8 +4219,8 @@ static int ath10k_mac_txpower_recalc(struct ath10k *ar)
1115 + txpower = min(txpower, arvif->txpower);
1116 + }
1117 +
1118 +- if (WARN_ON(txpower == -1))
1119 +- return -EINVAL;
1120 ++ if (txpower == -1)
1121 ++ return 0;
1122 +
1123 + ret = ath10k_mac_txpower_setup(ar, txpower);
1124 + if (ret) {
1125 +@@ -4787,20 +4818,18 @@ static void ath10k_bss_info_changed(struct ieee80211_hw *hw,
1126 +
1127 + if (changed & BSS_CHANGED_ERP_CTS_PROT) {
1128 + arvif->use_cts_prot = info->use_cts_prot;
1129 +- ath10k_dbg(ar, ATH10K_DBG_MAC, "mac vdev %d cts_prot %d\n",
1130 +- arvif->vdev_id, info->use_cts_prot);
1131 +
1132 + ret = ath10k_recalc_rtscts_prot(arvif);
1133 + if (ret)
1134 + ath10k_warn(ar, "failed to recalculate rts/cts prot for vdev %d: %d\n",
1135 + arvif->vdev_id, ret);
1136 +
1137 +- vdev_param = ar->wmi.vdev_param->protection_mode;
1138 +- ret = ath10k_wmi_vdev_set_param(ar, arvif->vdev_id, vdev_param,
1139 +- info->use_cts_prot ? 1 : 0);
1140 +- if (ret)
1141 +- ath10k_warn(ar, "failed to set protection mode %d on vdev %i: %d\n",
1142 +- info->use_cts_prot, arvif->vdev_id, ret);
1143 ++ if (ath10k_mac_can_set_cts_prot(arvif)) {
1144 ++ ret = ath10k_mac_set_cts_prot(arvif);
1145 ++ if (ret)
1146 ++ ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
1147 ++ arvif->vdev_id, ret);
1148 ++ }
1149 + }
1150 +
1151 + if (changed & BSS_CHANGED_ERP_SLOT) {
1152 +@@ -6712,6 +6741,13 @@ ath10k_mac_op_assign_vif_chanctx(struct ieee80211_hw *hw,
1153 + arvif->is_up = true;
1154 + }
1155 +
1156 ++ if (ath10k_mac_can_set_cts_prot(arvif)) {
1157 ++ ret = ath10k_mac_set_cts_prot(arvif);
1158 ++ if (ret)
1159 ++ ath10k_warn(ar, "failed to set cts protection for vdev %d: %d\n",
1160 ++ arvif->vdev_id, ret);
1161 ++ }
1162 ++
1163 + mutex_unlock(&ar->conf_mutex);
1164 + return 0;
1165 +
1166 +diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
1167 +index 6fbd17b69469..02eea3c3b5d3 100644
1168 +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
1169 ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
1170 +@@ -1105,8 +1105,10 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1171 + struct ath10k_fw_stats_pdev *dst;
1172 +
1173 + src = data;
1174 +- if (data_len < sizeof(*src))
1175 ++ if (data_len < sizeof(*src)) {
1176 ++ kfree(tb);
1177 + return -EPROTO;
1178 ++ }
1179 +
1180 + data += sizeof(*src);
1181 + data_len -= sizeof(*src);
1182 +@@ -1126,8 +1128,10 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1183 + struct ath10k_fw_stats_vdev *dst;
1184 +
1185 + src = data;
1186 +- if (data_len < sizeof(*src))
1187 ++ if (data_len < sizeof(*src)) {
1188 ++ kfree(tb);
1189 + return -EPROTO;
1190 ++ }
1191 +
1192 + data += sizeof(*src);
1193 + data_len -= sizeof(*src);
1194 +@@ -1145,8 +1149,10 @@ static int ath10k_wmi_tlv_op_pull_fw_stats(struct ath10k *ar,
1195 + struct ath10k_fw_stats_peer *dst;
1196 +
1197 + src = data;
1198 +- if (data_len < sizeof(*src))
1199 ++ if (data_len < sizeof(*src)) {
1200 ++ kfree(tb);
1201 + return -EPROTO;
1202 ++ }
1203 +
1204 + data += sizeof(*src);
1205 + data_len -= sizeof(*src);
1206 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
1207 +index 0708eedd9671..1c69e8140d9d 100644
1208 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
1209 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
1210 +@@ -664,7 +664,7 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
1211 + struct rtl_priv *rtlpriv = rtl_priv(hw);
1212 + struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
1213 + struct sk_buff *skb = NULL;
1214 +-
1215 ++ bool rtstatus;
1216 + u32 totalpacketlen;
1217 + u8 u1rsvdpageloc[5] = { 0 };
1218 + bool b_dlok = false;
1219 +@@ -727,7 +727,9 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
1220 + memcpy((u8 *)skb_put(skb, totalpacketlen),
1221 + &reserved_page_packet, totalpacketlen);
1222 +
1223 +- b_dlok = true;
1224 ++ rtstatus = rtl_cmd_send_packet(hw, skb);
1225 ++ if (rtstatus)
1226 ++ b_dlok = true;
1227 +
1228 + if (b_dlok) {
1229 + RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD ,
1230 +diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
1231 +index bbb789f8990b..738d541a2255 100644
1232 +--- a/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
1233 ++++ b/drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c
1234 +@@ -1377,6 +1377,7 @@ static void _rtl8821ae_get_wakeup_reason(struct ieee80211_hw *hw)
1235 +
1236 + ppsc->wakeup_reason = 0;
1237 +
1238 ++ do_gettimeofday(&ts);
1239 + rtlhal->last_suspend_sec = ts.tv_sec;
1240 +
1241 + switch (fw_reason) {
1242 +diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
1243 +index 96526dcfdd37..ff7b9632ad61 100644
1244 +--- a/drivers/nvdimm/label.c
1245 ++++ b/drivers/nvdimm/label.c
1246 +@@ -823,7 +823,7 @@ static int init_labels(struct nd_mapping *nd_mapping, int num_labels)
1247 + nsindex = to_namespace_index(ndd, 0);
1248 + memset(nsindex, 0, ndd->nsarea.config_size);
1249 + for (i = 0; i < 2; i++) {
1250 +- int rc = nd_label_write_index(ndd, i, i*2, ND_NSINDEX_INIT);
1251 ++ int rc = nd_label_write_index(ndd, i, 3 - i, ND_NSINDEX_INIT);
1252 +
1253 + if (rc)
1254 + return rc;
1255 +diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
1256 +index aae7379af4e4..c2184104b789 100644
1257 +--- a/drivers/nvdimm/namespace_devs.c
1258 ++++ b/drivers/nvdimm/namespace_devs.c
1259 +@@ -1305,7 +1305,7 @@ static umode_t namespace_visible(struct kobject *kobj,
1260 + if (a == &dev_attr_resource.attr) {
1261 + if (is_namespace_blk(dev))
1262 + return 0;
1263 +- return a->mode;
1264 ++ return 0400;
1265 + }
1266 +
1267 + if (is_namespace_pmem(dev) || is_namespace_blk(dev)) {
1268 +diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
1269 +index b83df942794f..193ac13de49b 100644
1270 +--- a/drivers/pci/probe.c
1271 ++++ b/drivers/pci/probe.c
1272 +@@ -1414,8 +1414,16 @@ static void program_hpp_type0(struct pci_dev *dev, struct hpp_type0 *hpp)
1273 +
1274 + static void program_hpp_type1(struct pci_dev *dev, struct hpp_type1 *hpp)
1275 + {
1276 +- if (hpp)
1277 +- dev_warn(&dev->dev, "PCI-X settings not supported\n");
1278 ++ int pos;
1279 ++
1280 ++ if (!hpp)
1281 ++ return;
1282 ++
1283 ++ pos = pci_find_capability(dev, PCI_CAP_ID_PCIX);
1284 ++ if (!pos)
1285 ++ return;
1286 ++
1287 ++ dev_warn(&dev->dev, "PCI-X settings not supported\n");
1288 + }
1289 +
1290 + static bool pcie_root_rcb_set(struct pci_dev *dev)
1291 +@@ -1441,6 +1449,9 @@ static void program_hpp_type2(struct pci_dev *dev, struct hpp_type2 *hpp)
1292 + if (!hpp)
1293 + return;
1294 +
1295 ++ if (!pci_is_pcie(dev))
1296 ++ return;
1297 ++
1298 + if (hpp->revision > 1) {
1299 + dev_warn(&dev->dev, "PCIe settings rev %d not supported\n",
1300 + hpp->revision);
1301 +diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
1302 +index 8b9c2a38d1cc..b0a24dedd1ed 100644
1303 +--- a/drivers/spi/Kconfig
1304 ++++ b/drivers/spi/Kconfig
1305 +@@ -315,6 +315,7 @@ config SPI_FSL_SPI
1306 + config SPI_FSL_DSPI
1307 + tristate "Freescale DSPI controller"
1308 + select REGMAP_MMIO
1309 ++ depends on HAS_DMA
1310 + depends on SOC_VF610 || SOC_LS1021A || ARCH_LAYERSCAPE || COMPILE_TEST
1311 + help
1312 + This enables support for the Freescale DSPI controller in master
1313 +diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c
1314 +index e8d0ff2d5c9b..808d6ebf6c94 100644
1315 +--- a/drivers/staging/iio/cdc/ad7150.c
1316 ++++ b/drivers/staging/iio/cdc/ad7150.c
1317 +@@ -272,7 +272,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev,
1318 + error_ret:
1319 + mutex_unlock(&chip->state_lock);
1320 +
1321 +- return 0;
1322 ++ return ret;
1323 + }
1324 +
1325 + static int ad7150_read_event_value(struct iio_dev *indio_dev,
1326 +diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
1327 +index fd493412b172..bb73401f5761 100644
1328 +--- a/drivers/target/iscsi/iscsi_target.c
1329 ++++ b/drivers/target/iscsi/iscsi_target.c
1330 +@@ -1923,12 +1923,14 @@ attach:
1331 +
1332 + if (!(hdr->opcode & ISCSI_OP_IMMEDIATE)) {
1333 + int cmdsn_ret = iscsit_sequence_cmd(conn, cmd, buf, hdr->cmdsn);
1334 +- if (cmdsn_ret == CMDSN_HIGHER_THAN_EXP)
1335 ++ if (cmdsn_ret == CMDSN_HIGHER_THAN_EXP) {
1336 + out_of_order_cmdsn = 1;
1337 +- else if (cmdsn_ret == CMDSN_LOWER_THAN_EXP)
1338 ++ } else if (cmdsn_ret == CMDSN_LOWER_THAN_EXP) {
1339 ++ target_put_sess_cmd(&cmd->se_cmd);
1340 + return 0;
1341 +- else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER)
1342 ++ } else if (cmdsn_ret == CMDSN_ERROR_CANNOT_RECOVER) {
1343 + return -1;
1344 ++ }
1345 + }
1346 + iscsit_ack_from_expstatsn(conn, be32_to_cpu(hdr->exp_statsn));
1347 +
1348 +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
1349 +index a42054edd427..37abf881ca75 100644
1350 +--- a/drivers/target/target_core_transport.c
1351 ++++ b/drivers/target/target_core_transport.c
1352 +@@ -1970,6 +1970,8 @@ static void target_restart_delayed_cmds(struct se_device *dev)
1353 + list_del(&cmd->se_delayed_node);
1354 + spin_unlock(&dev->delayed_cmd_lock);
1355 +
1356 ++ cmd->transport_state |= CMD_T_SENT;
1357 ++
1358 + __target_execute_cmd(cmd, true);
1359 +
1360 + if (cmd->sam_task_attr == TCM_ORDERED_TAG)
1361 +@@ -2007,6 +2009,8 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
1362 + pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED\n",
1363 + dev->dev_cur_ordered_id);
1364 + }
1365 ++ cmd->se_cmd_flags &= ~SCF_TASK_ATTR_SET;
1366 ++
1367 + restart:
1368 + target_restart_delayed_cmds(dev);
1369 + }
1370 +diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
1371 +index e4110d6de0b5..da6cc25baaef 100644
1372 +--- a/drivers/vhost/scsi.c
1373 ++++ b/drivers/vhost/scsi.c
1374 +@@ -703,6 +703,7 @@ vhost_scsi_iov_to_sgl(struct vhost_scsi_cmd *cmd, bool write,
1375 + struct scatterlist *sg, int sg_count)
1376 + {
1377 + size_t off = iter->iov_offset;
1378 ++ struct scatterlist *p = sg;
1379 + int i, ret;
1380 +
1381 + for (i = 0; i < iter->nr_segs; i++) {
1382 +@@ -711,8 +712,8 @@ vhost_scsi_iov_to_sgl(struct vhost_scsi_cmd *cmd, bool write,
1383 +
1384 + ret = vhost_scsi_map_to_sgl(cmd, base, len, sg, write);
1385 + if (ret < 0) {
1386 +- for (i = 0; i < sg_count; i++) {
1387 +- struct page *page = sg_page(&sg[i]);
1388 ++ while (p < sg) {
1389 ++ struct page *page = sg_page(p++);
1390 + if (page)
1391 + put_page(page);
1392 + }
1393 +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
1394 +index 0e0eb10f82a0..816a0e08ef10 100644
1395 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
1396 ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
1397 +@@ -316,7 +316,7 @@ static int xenbus_write_transaction(unsigned msg_type,
1398 + rc = -ENOMEM;
1399 + goto out;
1400 + }
1401 +- } else if (msg_type == XS_TRANSACTION_END) {
1402 ++ } else if (u->u.msg.tx_id != 0) {
1403 + list_for_each_entry(trans, &u->transactions, list)
1404 + if (trans->handle.id == u->u.msg.tx_id)
1405 + break;
1406 +diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
1407 +index 511078586fa1..73f1d1b3a51c 100644
1408 +--- a/fs/9p/vfs_inode.c
1409 ++++ b/fs/9p/vfs_inode.c
1410 +@@ -483,6 +483,9 @@ static int v9fs_test_inode(struct inode *inode, void *data)
1411 +
1412 + if (v9inode->qid.type != st->qid.type)
1413 + return 0;
1414 ++
1415 ++ if (v9inode->qid.path != st->qid.path)
1416 ++ return 0;
1417 + return 1;
1418 + }
1419 +
1420 +diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
1421 +index cb899af1babc..0b88744c6446 100644
1422 +--- a/fs/9p/vfs_inode_dotl.c
1423 ++++ b/fs/9p/vfs_inode_dotl.c
1424 +@@ -87,6 +87,9 @@ static int v9fs_test_inode_dotl(struct inode *inode, void *data)
1425 +
1426 + if (v9inode->qid.type != st->qid.type)
1427 + return 0;
1428 ++
1429 ++ if (v9inode->qid.path != st->qid.path)
1430 ++ return 0;
1431 + return 1;
1432 + }
1433 +
1434 +diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
1435 +index 35b755e79c2d..fe6e7050fe50 100644
1436 +--- a/fs/autofs4/waitq.c
1437 ++++ b/fs/autofs4/waitq.c
1438 +@@ -87,7 +87,8 @@ static int autofs4_write(struct autofs_sb_info *sbi,
1439 + spin_unlock_irqrestore(&current->sighand->siglock, flags);
1440 + }
1441 +
1442 +- return (bytes > 0);
1443 ++ /* if 'wr' returned 0 (impossible) we assume -EIO (safe) */
1444 ++ return bytes == 0 ? 0 : wr < 0 ? wr : -EIO;
1445 + }
1446 +
1447 + static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
1448 +@@ -101,6 +102,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
1449 + } pkt;
1450 + struct file *pipe = NULL;
1451 + size_t pktsz;
1452 ++ int ret;
1453 +
1454 + DPRINTK("wait id = 0x%08lx, name = %.*s, type=%d",
1455 + (unsigned long) wq->wait_queue_token, wq->name.len, wq->name.name, type);
1456 +@@ -173,7 +175,18 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
1457 + mutex_unlock(&sbi->wq_mutex);
1458 +
1459 + if (autofs4_write(sbi, pipe, &pkt, pktsz))
1460 ++ switch (ret = autofs4_write(sbi, pipe, &pkt, pktsz)) {
1461 ++ case 0:
1462 ++ break;
1463 ++ case -ENOMEM:
1464 ++ case -ERESTARTSYS:
1465 ++ /* Just fail this one */
1466 ++ autofs4_wait_release(sbi, wq->wait_queue_token, ret);
1467 ++ break;
1468 ++ default:
1469 + autofs4_catatonic_mode(sbi);
1470 ++ break;
1471 ++ }
1472 + fput(pipe);
1473 + }
1474 +
1475 +diff --git a/fs/btrfs/uuid-tree.c b/fs/btrfs/uuid-tree.c
1476 +index 778282944530..837a9a8d579e 100644
1477 +--- a/fs/btrfs/uuid-tree.c
1478 ++++ b/fs/btrfs/uuid-tree.c
1479 +@@ -348,7 +348,5 @@ skip:
1480 +
1481 + out:
1482 + btrfs_free_path(path);
1483 +- if (ret)
1484 +- btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
1485 +- return 0;
1486 ++ return ret;
1487 + }
1488 +diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c
1489 +index 286f10b0363b..4f457d5c4933 100644
1490 +--- a/fs/ecryptfs/messaging.c
1491 ++++ b/fs/ecryptfs/messaging.c
1492 +@@ -442,15 +442,16 @@ void ecryptfs_release_messaging(void)
1493 + }
1494 + if (ecryptfs_daemon_hash) {
1495 + struct ecryptfs_daemon *daemon;
1496 ++ struct hlist_node *n;
1497 + int i;
1498 +
1499 + mutex_lock(&ecryptfs_daemon_hash_mux);
1500 + for (i = 0; i < (1 << ecryptfs_hash_bits); i++) {
1501 + int rc;
1502 +
1503 +- hlist_for_each_entry(daemon,
1504 +- &ecryptfs_daemon_hash[i],
1505 +- euid_chain) {
1506 ++ hlist_for_each_entry_safe(daemon, n,
1507 ++ &ecryptfs_daemon_hash[i],
1508 ++ euid_chain) {
1509 + rc = ecryptfs_exorcise_daemon(daemon);
1510 + if (rc)
1511 + printk(KERN_ERR "%s: Error whilst "
1512 +diff --git a/fs/ext4/crypto_key.c b/fs/ext4/crypto_key.c
1513 +index 9a1bc638abce..9308fe4b66e6 100644
1514 +--- a/fs/ext4/crypto_key.c
1515 ++++ b/fs/ext4/crypto_key.c
1516 +@@ -129,11 +129,9 @@ int ext4_get_encryption_info(struct inode *inode)
1517 + if (ei->i_crypt_info)
1518 + return 0;
1519 +
1520 +- if (!ext4_read_workqueue) {
1521 +- res = ext4_init_crypto();
1522 +- if (res)
1523 +- return res;
1524 +- }
1525 ++ res = ext4_init_crypto();
1526 ++ if (res)
1527 ++ return res;
1528 +
1529 + res = ext4_xattr_get(inode, EXT4_XATTR_INDEX_ENCRYPTION,
1530 + EXT4_XATTR_NAME_ENCRYPTION_CONTEXT,
1531 +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
1532 +index 61d5bfc7318c..31a3e480d484 100644
1533 +--- a/fs/ext4/extents.c
1534 ++++ b/fs/ext4/extents.c
1535 +@@ -4818,7 +4818,8 @@ static long ext4_zero_range(struct file *file, loff_t offset,
1536 + }
1537 +
1538 + if (!(mode & FALLOC_FL_KEEP_SIZE) &&
1539 +- offset + len > i_size_read(inode)) {
1540 ++ (offset + len > i_size_read(inode) ||
1541 ++ offset + len > EXT4_I(inode)->i_disksize)) {
1542 + new_size = offset + len;
1543 + ret = inode_newsize_ok(inode, new_size);
1544 + if (ret)
1545 +@@ -4994,7 +4995,8 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
1546 + }
1547 +
1548 + if (!(mode & FALLOC_FL_KEEP_SIZE) &&
1549 +- offset + len > i_size_read(inode)) {
1550 ++ (offset + len > i_size_read(inode) ||
1551 ++ offset + len > EXT4_I(inode)->i_disksize)) {
1552 + new_size = offset + len;
1553 + ret = inode_newsize_ok(inode, new_size);
1554 + if (ret)
1555 +diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
1556 +index 0ac4c1f73fbd..25177e6bd603 100644
1557 +--- a/fs/isofs/isofs.h
1558 ++++ b/fs/isofs/isofs.h
1559 +@@ -103,7 +103,7 @@ static inline unsigned int isonum_733(char *p)
1560 + /* Ignore bigendian datum due to broken mastering programs */
1561 + return get_unaligned_le32(p);
1562 + }
1563 +-extern int iso_date(char *, int);
1564 ++extern int iso_date(u8 *, int);
1565 +
1566 + struct inode; /* To make gcc happy */
1567 +
1568 +diff --git a/fs/isofs/rock.h b/fs/isofs/rock.h
1569 +index ed09e2b08637..f835976ce033 100644
1570 +--- a/fs/isofs/rock.h
1571 ++++ b/fs/isofs/rock.h
1572 +@@ -65,7 +65,7 @@ struct RR_PL_s {
1573 + };
1574 +
1575 + struct stamp {
1576 +- char time[7];
1577 ++ __u8 time[7]; /* actually 6 unsigned, 1 signed */
1578 + } __attribute__ ((packed));
1579 +
1580 + struct RR_TF_s {
1581 +diff --git a/fs/isofs/util.c b/fs/isofs/util.c
1582 +index 005a15cfd30a..37860fea364d 100644
1583 +--- a/fs/isofs/util.c
1584 ++++ b/fs/isofs/util.c
1585 +@@ -15,7 +15,7 @@
1586 + * to GMT. Thus we should always be correct.
1587 + */
1588 +
1589 +-int iso_date(char * p, int flag)
1590 ++int iso_date(u8 *p, int flag)
1591 + {
1592 + int year, month, day, hour, minute, second, tz;
1593 + int crtime;
1594 +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
1595 +index 8e425f2c5ddd..6fef53f18dcf 100644
1596 +--- a/fs/nfs/nfs4proc.c
1597 ++++ b/fs/nfs/nfs4proc.c
1598 +@@ -242,15 +242,12 @@ const u32 nfs4_fsinfo_bitmap[3] = { FATTR4_WORD0_MAXFILESIZE
1599 + };
1600 +
1601 + const u32 nfs4_fs_locations_bitmap[3] = {
1602 +- FATTR4_WORD0_TYPE
1603 +- | FATTR4_WORD0_CHANGE
1604 ++ FATTR4_WORD0_CHANGE
1605 + | FATTR4_WORD0_SIZE
1606 + | FATTR4_WORD0_FSID
1607 + | FATTR4_WORD0_FILEID
1608 + | FATTR4_WORD0_FS_LOCATIONS,
1609 +- FATTR4_WORD1_MODE
1610 +- | FATTR4_WORD1_NUMLINKS
1611 +- | FATTR4_WORD1_OWNER
1612 ++ FATTR4_WORD1_OWNER
1613 + | FATTR4_WORD1_OWNER_GROUP
1614 + | FATTR4_WORD1_RAWDEV
1615 + | FATTR4_WORD1_SPACE_USED
1616 +@@ -6351,9 +6348,7 @@ static int _nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
1617 + struct page *page)
1618 + {
1619 + struct nfs_server *server = NFS_SERVER(dir);
1620 +- u32 bitmask[3] = {
1621 +- [0] = FATTR4_WORD0_FSID | FATTR4_WORD0_FS_LOCATIONS,
1622 +- };
1623 ++ u32 bitmask[3];
1624 + struct nfs4_fs_locations_arg args = {
1625 + .dir_fh = NFS_FH(dir),
1626 + .name = name,
1627 +@@ -6372,12 +6367,15 @@ static int _nfs4_proc_fs_locations(struct rpc_clnt *client, struct inode *dir,
1628 +
1629 + dprintk("%s: start\n", __func__);
1630 +
1631 ++ bitmask[0] = nfs4_fattr_bitmap[0] | FATTR4_WORD0_FS_LOCATIONS;
1632 ++ bitmask[1] = nfs4_fattr_bitmap[1];
1633 ++
1634 + /* Ask for the fileid of the absent filesystem if mounted_on_fileid
1635 + * is not supported */
1636 + if (NFS_SERVER(dir)->attr_bitmask[1] & FATTR4_WORD1_MOUNTED_ON_FILEID)
1637 +- bitmask[1] |= FATTR4_WORD1_MOUNTED_ON_FILEID;
1638 ++ bitmask[0] &= ~FATTR4_WORD0_FILEID;
1639 + else
1640 +- bitmask[0] |= FATTR4_WORD0_FILEID;
1641 ++ bitmask[1] &= ~FATTR4_WORD1_MOUNTED_ON_FILEID;
1642 +
1643 + nfs_fattr_init(&fs_locations->fattr);
1644 + fs_locations->server = server;
1645 +diff --git a/fs/nfs/super.c b/fs/nfs/super.c
1646 +index f1268280244e..3149f7e58d6f 100644
1647 +--- a/fs/nfs/super.c
1648 ++++ b/fs/nfs/super.c
1649 +@@ -1322,7 +1322,7 @@ static int nfs_parse_mount_options(char *raw,
1650 + mnt->options |= NFS_OPTION_MIGRATION;
1651 + break;
1652 + case Opt_nomigration:
1653 +- mnt->options &= NFS_OPTION_MIGRATION;
1654 ++ mnt->options &= ~NFS_OPTION_MIGRATION;
1655 + break;
1656 +
1657 + /*
1658 +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
1659 +index ca9ebc3242d3..421935f3d909 100644
1660 +--- a/fs/nfsd/nfs4state.c
1661 ++++ b/fs/nfsd/nfs4state.c
1662 +@@ -3829,7 +3829,8 @@ static struct nfs4_delegation *find_deleg_stateid(struct nfs4_client *cl, statei
1663 + {
1664 + struct nfs4_stid *ret;
1665 +
1666 +- ret = find_stateid_by_type(cl, s, NFS4_DELEG_STID);
1667 ++ ret = find_stateid_by_type(cl, s,
1668 ++ NFS4_DELEG_STID|NFS4_REVOKED_DELEG_STID);
1669 + if (!ret)
1670 + return NULL;
1671 + return delegstateid(ret);
1672 +@@ -3852,6 +3853,12 @@ nfs4_check_deleg(struct nfs4_client *cl, struct nfsd4_open *open,
1673 + deleg = find_deleg_stateid(cl, &open->op_delegate_stateid);
1674 + if (deleg == NULL)
1675 + goto out;
1676 ++ if (deleg->dl_stid.sc_type == NFS4_REVOKED_DELEG_STID) {
1677 ++ nfs4_put_stid(&deleg->dl_stid);
1678 ++ if (cl->cl_minorversion)
1679 ++ status = nfserr_deleg_revoked;
1680 ++ goto out;
1681 ++ }
1682 + flags = share_access_to_flags(open->op_share_access);
1683 + status = nfs4_check_delegmode(deleg, flags);
1684 + if (status) {
1685 +@@ -4696,6 +4703,16 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
1686 + struct nfs4_stid **s, struct nfsd_net *nn)
1687 + {
1688 + __be32 status;
1689 ++ bool return_revoked = false;
1690 ++
1691 ++ /*
1692 ++ * only return revoked delegations if explicitly asked.
1693 ++ * otherwise we report revoked or bad_stateid status.
1694 ++ */
1695 ++ if (typemask & NFS4_REVOKED_DELEG_STID)
1696 ++ return_revoked = true;
1697 ++ else if (typemask & NFS4_DELEG_STID)
1698 ++ typemask |= NFS4_REVOKED_DELEG_STID;
1699 +
1700 + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid))
1701 + return nfserr_bad_stateid;
1702 +@@ -4710,6 +4727,12 @@ nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
1703 + *s = find_stateid_by_type(cstate->clp, stateid, typemask);
1704 + if (!*s)
1705 + return nfserr_bad_stateid;
1706 ++ if (((*s)->sc_type == NFS4_REVOKED_DELEG_STID) && !return_revoked) {
1707 ++ nfs4_put_stid(*s);
1708 ++ if (cstate->minorversion)
1709 ++ return nfserr_deleg_revoked;
1710 ++ return nfserr_bad_stateid;
1711 ++ }
1712 + return nfs_ok;
1713 + }
1714 +
1715 +diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
1716 +index 2f27c935bd57..34c22fe4eca0 100644
1717 +--- a/fs/nilfs2/segment.c
1718 ++++ b/fs/nilfs2/segment.c
1719 +@@ -1945,8 +1945,6 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci,
1720 + "failed to get inode block.\n");
1721 + return err;
1722 + }
1723 +- mark_buffer_dirty(ibh);
1724 +- nilfs_mdt_mark_dirty(ifile);
1725 + spin_lock(&nilfs->ns_inode_lock);
1726 + if (likely(!ii->i_bh))
1727 + ii->i_bh = ibh;
1728 +@@ -1955,6 +1953,10 @@ static int nilfs_segctor_collect_dirty_files(struct nilfs_sc_info *sci,
1729 + goto retry;
1730 + }
1731 +
1732 ++ // Always redirty the buffer to avoid race condition
1733 ++ mark_buffer_dirty(ii->i_bh);
1734 ++ nilfs_mdt_mark_dirty(ifile);
1735 ++
1736 + clear_bit(NILFS_I_QUEUED, &ii->i_state);
1737 + set_bit(NILFS_I_BUSY, &ii->i_state);
1738 + list_move_tail(&ii->i_dirty, &sci->sc_dirty_files);
1739 +diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h
1740 +index 5664ca07c9c7..a01a076ea060 100644
1741 +--- a/include/trace/events/sunrpc.h
1742 ++++ b/include/trace/events/sunrpc.h
1743 +@@ -455,20 +455,22 @@ TRACE_EVENT(svc_recv,
1744 + TP_ARGS(rqst, status),
1745 +
1746 + TP_STRUCT__entry(
1747 +- __field(struct sockaddr *, addr)
1748 + __field(__be32, xid)
1749 + __field(int, status)
1750 + __field(unsigned long, flags)
1751 ++ __dynamic_array(unsigned char, addr, rqst->rq_addrlen)
1752 + ),
1753 +
1754 + TP_fast_assign(
1755 +- __entry->addr = (struct sockaddr *)&rqst->rq_addr;
1756 + __entry->xid = status > 0 ? rqst->rq_xid : 0;
1757 + __entry->status = status;
1758 + __entry->flags = rqst->rq_flags;
1759 ++ memcpy(__get_dynamic_array(addr),
1760 ++ &rqst->rq_addr, rqst->rq_addrlen);
1761 + ),
1762 +
1763 +- TP_printk("addr=%pIScp xid=0x%x status=%d flags=%s", __entry->addr,
1764 ++ TP_printk("addr=%pIScp xid=0x%x status=%d flags=%s",
1765 ++ (struct sockaddr *)__get_dynamic_array(addr),
1766 + be32_to_cpu(__entry->xid), __entry->status,
1767 + show_rqstp_flags(__entry->flags))
1768 + );
1769 +@@ -480,22 +482,23 @@ DECLARE_EVENT_CLASS(svc_rqst_status,
1770 + TP_ARGS(rqst, status),
1771 +
1772 + TP_STRUCT__entry(
1773 +- __field(struct sockaddr *, addr)
1774 + __field(__be32, xid)
1775 +- __field(int, dropme)
1776 + __field(int, status)
1777 + __field(unsigned long, flags)
1778 ++ __dynamic_array(unsigned char, addr, rqst->rq_addrlen)
1779 + ),
1780 +
1781 + TP_fast_assign(
1782 +- __entry->addr = (struct sockaddr *)&rqst->rq_addr;
1783 + __entry->xid = rqst->rq_xid;
1784 + __entry->status = status;
1785 + __entry->flags = rqst->rq_flags;
1786 ++ memcpy(__get_dynamic_array(addr),
1787 ++ &rqst->rq_addr, rqst->rq_addrlen);
1788 + ),
1789 +
1790 + TP_printk("addr=%pIScp rq_xid=0x%x status=%d flags=%s",
1791 +- __entry->addr, be32_to_cpu(__entry->xid),
1792 ++ (struct sockaddr *)__get_dynamic_array(addr),
1793 ++ be32_to_cpu(__entry->xid),
1794 + __entry->status, show_rqstp_flags(__entry->flags))
1795 + );
1796 +
1797 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
1798 +index b5d372083624..15874a85ebcf 100644
1799 +--- a/kernel/sched/core.c
1800 ++++ b/kernel/sched/core.c
1801 +@@ -600,8 +600,7 @@ void resched_cpu(int cpu)
1802 + struct rq *rq = cpu_rq(cpu);
1803 + unsigned long flags;
1804 +
1805 +- if (!raw_spin_trylock_irqsave(&rq->lock, flags))
1806 +- return;
1807 ++ raw_spin_lock_irqsave(&rq->lock, flags);
1808 + resched_curr(rq);
1809 + raw_spin_unlock_irqrestore(&rq->lock, flags);
1810 + }
1811 +@@ -5908,6 +5907,12 @@ static int init_rootdomain(struct root_domain *rd)
1812 + if (!zalloc_cpumask_var(&rd->rto_mask, GFP_KERNEL))
1813 + goto free_dlo_mask;
1814 +
1815 ++#ifdef HAVE_RT_PUSH_IPI
1816 ++ rd->rto_cpu = -1;
1817 ++ raw_spin_lock_init(&rd->rto_lock);
1818 ++ init_irq_work(&rd->rto_push_work, rto_push_irq_work_func);
1819 ++#endif
1820 ++
1821 + init_dl_bw(&rd->dl_bw);
1822 + if (cpudl_init(&rd->cpudl) != 0)
1823 + goto free_dlo_mask;
1824 +diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
1825 +index 78ae5c1d9412..faa75afcb7fe 100644
1826 +--- a/kernel/sched/rt.c
1827 ++++ b/kernel/sched/rt.c
1828 +@@ -64,10 +64,6 @@ static void start_rt_bandwidth(struct rt_bandwidth *rt_b)
1829 + raw_spin_unlock(&rt_b->rt_runtime_lock);
1830 + }
1831 +
1832 +-#if defined(CONFIG_SMP) && defined(HAVE_RT_PUSH_IPI)
1833 +-static void push_irq_work_func(struct irq_work *work);
1834 +-#endif
1835 +-
1836 + void init_rt_rq(struct rt_rq *rt_rq)
1837 + {
1838 + struct rt_prio_array *array;
1839 +@@ -87,13 +83,6 @@ void init_rt_rq(struct rt_rq *rt_rq)
1840 + rt_rq->rt_nr_migratory = 0;
1841 + rt_rq->overloaded = 0;
1842 + plist_head_init(&rt_rq->pushable_tasks);
1843 +-
1844 +-#ifdef HAVE_RT_PUSH_IPI
1845 +- rt_rq->push_flags = 0;
1846 +- rt_rq->push_cpu = nr_cpu_ids;
1847 +- raw_spin_lock_init(&rt_rq->push_lock);
1848 +- init_irq_work(&rt_rq->push_work, push_irq_work_func);
1849 +-#endif
1850 + #endif /* CONFIG_SMP */
1851 + /* We start is dequeued state, because no RT tasks are queued */
1852 + rt_rq->rt_queued = 0;
1853 +@@ -1802,160 +1791,166 @@ static void push_rt_tasks(struct rq *rq)
1854 + }
1855 +
1856 + #ifdef HAVE_RT_PUSH_IPI
1857 ++
1858 + /*
1859 +- * The search for the next cpu always starts at rq->cpu and ends
1860 +- * when we reach rq->cpu again. It will never return rq->cpu.
1861 +- * This returns the next cpu to check, or nr_cpu_ids if the loop
1862 +- * is complete.
1863 ++ * When a high priority task schedules out from a CPU and a lower priority
1864 ++ * task is scheduled in, a check is made to see if there's any RT tasks
1865 ++ * on other CPUs that are waiting to run because a higher priority RT task
1866 ++ * is currently running on its CPU. In this case, the CPU with multiple RT
1867 ++ * tasks queued on it (overloaded) needs to be notified that a CPU has opened
1868 ++ * up that may be able to run one of its non-running queued RT tasks.
1869 ++ *
1870 ++ * All CPUs with overloaded RT tasks need to be notified as there is currently
1871 ++ * no way to know which of these CPUs have the highest priority task waiting
1872 ++ * to run. Instead of trying to take a spinlock on each of these CPUs,
1873 ++ * which has shown to cause large latency when done on machines with many
1874 ++ * CPUs, sending an IPI to the CPUs to have them push off the overloaded
1875 ++ * RT tasks waiting to run.
1876 ++ *
1877 ++ * Just sending an IPI to each of the CPUs is also an issue, as on large
1878 ++ * count CPU machines, this can cause an IPI storm on a CPU, especially
1879 ++ * if its the only CPU with multiple RT tasks queued, and a large number
1880 ++ * of CPUs scheduling a lower priority task at the same time.
1881 ++ *
1882 ++ * Each root domain has its own irq work function that can iterate over
1883 ++ * all CPUs with RT overloaded tasks. Since all CPUs with overloaded RT
1884 ++ * tassk must be checked if there's one or many CPUs that are lowering
1885 ++ * their priority, there's a single irq work iterator that will try to
1886 ++ * push off RT tasks that are waiting to run.
1887 ++ *
1888 ++ * When a CPU schedules a lower priority task, it will kick off the
1889 ++ * irq work iterator that will jump to each CPU with overloaded RT tasks.
1890 ++ * As it only takes the first CPU that schedules a lower priority task
1891 ++ * to start the process, the rto_start variable is incremented and if
1892 ++ * the atomic result is one, then that CPU will try to take the rto_lock.
1893 ++ * This prevents high contention on the lock as the process handles all
1894 ++ * CPUs scheduling lower priority tasks.
1895 ++ *
1896 ++ * All CPUs that are scheduling a lower priority task will increment the
1897 ++ * rt_loop_next variable. This will make sure that the irq work iterator
1898 ++ * checks all RT overloaded CPUs whenever a CPU schedules a new lower
1899 ++ * priority task, even if the iterator is in the middle of a scan. Incrementing
1900 ++ * the rt_loop_next will cause the iterator to perform another scan.
1901 + *
1902 +- * rq->rt.push_cpu holds the last cpu returned by this function,
1903 +- * or if this is the first instance, it must hold rq->cpu.
1904 + */
1905 + static int rto_next_cpu(struct rq *rq)
1906 + {
1907 +- int prev_cpu = rq->rt.push_cpu;
1908 ++ struct root_domain *rd = rq->rd;
1909 ++ int next;
1910 + int cpu;
1911 +
1912 +- cpu = cpumask_next(prev_cpu, rq->rd->rto_mask);
1913 +-
1914 + /*
1915 +- * If the previous cpu is less than the rq's CPU, then it already
1916 +- * passed the end of the mask, and has started from the beginning.
1917 +- * We end if the next CPU is greater or equal to rq's CPU.
1918 ++ * When starting the IPI RT pushing, the rto_cpu is set to -1,
1919 ++ * rt_next_cpu() will simply return the first CPU found in
1920 ++ * the rto_mask.
1921 ++ *
1922 ++ * If rto_next_cpu() is called with rto_cpu is a valid cpu, it
1923 ++ * will return the next CPU found in the rto_mask.
1924 ++ *
1925 ++ * If there are no more CPUs left in the rto_mask, then a check is made
1926 ++ * against rto_loop and rto_loop_next. rto_loop is only updated with
1927 ++ * the rto_lock held, but any CPU may increment the rto_loop_next
1928 ++ * without any locking.
1929 + */
1930 +- if (prev_cpu < rq->cpu) {
1931 +- if (cpu >= rq->cpu)
1932 +- return nr_cpu_ids;
1933 ++ for (;;) {
1934 +
1935 +- } else if (cpu >= nr_cpu_ids) {
1936 +- /*
1937 +- * We passed the end of the mask, start at the beginning.
1938 +- * If the result is greater or equal to the rq's CPU, then
1939 +- * the loop is finished.
1940 +- */
1941 +- cpu = cpumask_first(rq->rd->rto_mask);
1942 +- if (cpu >= rq->cpu)
1943 +- return nr_cpu_ids;
1944 +- }
1945 +- rq->rt.push_cpu = cpu;
1946 ++ /* When rto_cpu is -1 this acts like cpumask_first() */
1947 ++ cpu = cpumask_next(rd->rto_cpu, rd->rto_mask);
1948 +
1949 +- /* Return cpu to let the caller know if the loop is finished or not */
1950 +- return cpu;
1951 +-}
1952 ++ rd->rto_cpu = cpu;
1953 +
1954 +-static int find_next_push_cpu(struct rq *rq)
1955 +-{
1956 +- struct rq *next_rq;
1957 +- int cpu;
1958 ++ if (cpu < nr_cpu_ids)
1959 ++ return cpu;
1960 +
1961 +- while (1) {
1962 +- cpu = rto_next_cpu(rq);
1963 +- if (cpu >= nr_cpu_ids)
1964 +- break;
1965 +- next_rq = cpu_rq(cpu);
1966 ++ rd->rto_cpu = -1;
1967 +
1968 +- /* Make sure the next rq can push to this rq */
1969 +- if (next_rq->rt.highest_prio.next < rq->rt.highest_prio.curr)
1970 ++ /*
1971 ++ * ACQUIRE ensures we see the @rto_mask changes
1972 ++ * made prior to the @next value observed.
1973 ++ *
1974 ++ * Matches WMB in rt_set_overload().
1975 ++ */
1976 ++ next = atomic_read_acquire(&rd->rto_loop_next);
1977 ++
1978 ++ if (rd->rto_loop == next)
1979 + break;
1980 ++
1981 ++ rd->rto_loop = next;
1982 + }
1983 +
1984 +- return cpu;
1985 ++ return -1;
1986 ++}
1987 ++
1988 ++static inline bool rto_start_trylock(atomic_t *v)
1989 ++{
1990 ++ return !atomic_cmpxchg_acquire(v, 0, 1);
1991 + }
1992 +
1993 +-#define RT_PUSH_IPI_EXECUTING 1
1994 +-#define RT_PUSH_IPI_RESTART 2
1995 ++static inline void rto_start_unlock(atomic_t *v)
1996 ++{
1997 ++ atomic_set_release(v, 0);
1998 ++}
1999 +
2000 + static void tell_cpu_to_push(struct rq *rq)
2001 + {
2002 +- int cpu;
2003 ++ int cpu = -1;
2004 +
2005 +- if (rq->rt.push_flags & RT_PUSH_IPI_EXECUTING) {
2006 +- raw_spin_lock(&rq->rt.push_lock);
2007 +- /* Make sure it's still executing */
2008 +- if (rq->rt.push_flags & RT_PUSH_IPI_EXECUTING) {
2009 +- /*
2010 +- * Tell the IPI to restart the loop as things have
2011 +- * changed since it started.
2012 +- */
2013 +- rq->rt.push_flags |= RT_PUSH_IPI_RESTART;
2014 +- raw_spin_unlock(&rq->rt.push_lock);
2015 +- return;
2016 +- }
2017 +- raw_spin_unlock(&rq->rt.push_lock);
2018 +- }
2019 ++ /* Keep the loop going if the IPI is currently active */
2020 ++ atomic_inc(&rq->rd->rto_loop_next);
2021 +
2022 +- /* When here, there's no IPI going around */
2023 +-
2024 +- rq->rt.push_cpu = rq->cpu;
2025 +- cpu = find_next_push_cpu(rq);
2026 +- if (cpu >= nr_cpu_ids)
2027 ++ /* Only one CPU can initiate a loop at a time */
2028 ++ if (!rto_start_trylock(&rq->rd->rto_loop_start))
2029 + return;
2030 +
2031 +- rq->rt.push_flags = RT_PUSH_IPI_EXECUTING;
2032 ++ raw_spin_lock(&rq->rd->rto_lock);
2033 ++
2034 ++ /*
2035 ++ * The rto_cpu is updated under the lock, if it has a valid cpu
2036 ++ * then the IPI is still running and will continue due to the
2037 ++ * update to loop_next, and nothing needs to be done here.
2038 ++ * Otherwise it is finishing up and an ipi needs to be sent.
2039 ++ */
2040 ++ if (rq->rd->rto_cpu < 0)
2041 ++ cpu = rto_next_cpu(rq);
2042 ++
2043 ++ raw_spin_unlock(&rq->rd->rto_lock);
2044 +
2045 +- irq_work_queue_on(&rq->rt.push_work, cpu);
2046 ++ rto_start_unlock(&rq->rd->rto_loop_start);
2047 ++
2048 ++ if (cpu >= 0)
2049 ++ irq_work_queue_on(&rq->rd->rto_push_work, cpu);
2050 + }
2051 +
2052 + /* Called from hardirq context */
2053 +-static void try_to_push_tasks(void *arg)
2054 ++void rto_push_irq_work_func(struct irq_work *work)
2055 + {
2056 +- struct rt_rq *rt_rq = arg;
2057 +- struct rq *rq, *src_rq;
2058 +- int this_cpu;
2059 ++ struct rq *rq;
2060 + int cpu;
2061 +
2062 +- this_cpu = rt_rq->push_cpu;
2063 ++ rq = this_rq();
2064 +
2065 +- /* Paranoid check */
2066 +- BUG_ON(this_cpu != smp_processor_id());
2067 +-
2068 +- rq = cpu_rq(this_cpu);
2069 +- src_rq = rq_of_rt_rq(rt_rq);
2070 +-
2071 +-again:
2072 ++ /*
2073 ++ * We do not need to grab the lock to check for has_pushable_tasks.
2074 ++ * When it gets updated, a check is made if a push is possible.
2075 ++ */
2076 + if (has_pushable_tasks(rq)) {
2077 + raw_spin_lock(&rq->lock);
2078 +- push_rt_task(rq);
2079 ++ push_rt_tasks(rq);
2080 + raw_spin_unlock(&rq->lock);
2081 + }
2082 +
2083 +- /* Pass the IPI to the next rt overloaded queue */
2084 +- raw_spin_lock(&rt_rq->push_lock);
2085 +- /*
2086 +- * If the source queue changed since the IPI went out,
2087 +- * we need to restart the search from that CPU again.
2088 +- */
2089 +- if (rt_rq->push_flags & RT_PUSH_IPI_RESTART) {
2090 +- rt_rq->push_flags &= ~RT_PUSH_IPI_RESTART;
2091 +- rt_rq->push_cpu = src_rq->cpu;
2092 +- }
2093 ++ raw_spin_lock(&rq->rd->rto_lock);
2094 +
2095 +- cpu = find_next_push_cpu(src_rq);
2096 ++ /* Pass the IPI to the next rt overloaded queue */
2097 ++ cpu = rto_next_cpu(rq);
2098 +
2099 +- if (cpu >= nr_cpu_ids)
2100 +- rt_rq->push_flags &= ~RT_PUSH_IPI_EXECUTING;
2101 +- raw_spin_unlock(&rt_rq->push_lock);
2102 ++ raw_spin_unlock(&rq->rd->rto_lock);
2103 +
2104 +- if (cpu >= nr_cpu_ids)
2105 ++ if (cpu < 0)
2106 + return;
2107 +
2108 +- /*
2109 +- * It is possible that a restart caused this CPU to be
2110 +- * chosen again. Don't bother with an IPI, just see if we
2111 +- * have more to push.
2112 +- */
2113 +- if (unlikely(cpu == rq->cpu))
2114 +- goto again;
2115 +-
2116 + /* Try the next RT overloaded CPU */
2117 +- irq_work_queue_on(&rt_rq->push_work, cpu);
2118 +-}
2119 +-
2120 +-static void push_irq_work_func(struct irq_work *work)
2121 +-{
2122 +- struct rt_rq *rt_rq = container_of(work, struct rt_rq, push_work);
2123 +-
2124 +- try_to_push_tasks(rt_rq);
2125 ++ irq_work_queue_on(&rq->rd->rto_push_work, cpu);
2126 + }
2127 + #endif /* HAVE_RT_PUSH_IPI */
2128 +
2129 +diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
2130 +index 55d92a1ca070..448a8266ceea 100644
2131 +--- a/kernel/sched/sched.h
2132 ++++ b/kernel/sched/sched.h
2133 +@@ -429,7 +429,7 @@ static inline int rt_bandwidth_enabled(void)
2134 + }
2135 +
2136 + /* RT IPI pull logic requires IRQ_WORK */
2137 +-#ifdef CONFIG_IRQ_WORK
2138 ++#if defined(CONFIG_IRQ_WORK) && defined(CONFIG_SMP)
2139 + # define HAVE_RT_PUSH_IPI
2140 + #endif
2141 +
2142 +@@ -450,12 +450,6 @@ struct rt_rq {
2143 + unsigned long rt_nr_total;
2144 + int overloaded;
2145 + struct plist_head pushable_tasks;
2146 +-#ifdef HAVE_RT_PUSH_IPI
2147 +- int push_flags;
2148 +- int push_cpu;
2149 +- struct irq_work push_work;
2150 +- raw_spinlock_t push_lock;
2151 +-#endif
2152 + #endif /* CONFIG_SMP */
2153 + int rt_queued;
2154 +
2155 +@@ -537,6 +531,19 @@ struct root_domain {
2156 + struct dl_bw dl_bw;
2157 + struct cpudl cpudl;
2158 +
2159 ++#ifdef HAVE_RT_PUSH_IPI
2160 ++ /*
2161 ++ * For IPI pull requests, loop across the rto_mask.
2162 ++ */
2163 ++ struct irq_work rto_push_work;
2164 ++ raw_spinlock_t rto_lock;
2165 ++ /* These are only updated and read within rto_lock */
2166 ++ int rto_loop;
2167 ++ int rto_cpu;
2168 ++ /* These atomics are updated outside of a lock */
2169 ++ atomic_t rto_loop_next;
2170 ++ atomic_t rto_loop_start;
2171 ++#endif
2172 + /*
2173 + * The "RT overload" flag: it gets set if a CPU has more than
2174 + * one runnable RT task.
2175 +@@ -547,6 +554,9 @@ struct root_domain {
2176 +
2177 + extern struct root_domain def_root_domain;
2178 +
2179 ++#ifdef HAVE_RT_PUSH_IPI
2180 ++extern void rto_push_irq_work_func(struct irq_work *work);
2181 ++#endif
2182 + #endif /* CONFIG_SMP */
2183 +
2184 + /*
2185 +diff --git a/lib/mpi/mpi-pow.c b/lib/mpi/mpi-pow.c
2186 +index e24388a863a7..468fb7cd1221 100644
2187 +--- a/lib/mpi/mpi-pow.c
2188 ++++ b/lib/mpi/mpi-pow.c
2189 +@@ -26,6 +26,7 @@
2190 + * however I decided to publish this code under the plain GPL.
2191 + */
2192 +
2193 ++#include <linux/sched.h>
2194 + #include <linux/string.h>
2195 + #include "mpi-internal.h"
2196 + #include "longlong.h"
2197 +@@ -256,6 +257,7 @@ int mpi_powm(MPI res, MPI base, MPI exp, MPI mod)
2198 + }
2199 + e <<= 1;
2200 + c--;
2201 ++ cond_resched();
2202 + }
2203 +
2204 + i--;
2205 +diff --git a/net/9p/client.c b/net/9p/client.c
2206 +index f5feac4ff4ec..3ff26eb1ea20 100644
2207 +--- a/net/9p/client.c
2208 ++++ b/net/9p/client.c
2209 +@@ -749,8 +749,7 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
2210 + }
2211 + again:
2212 + /* Wait for the response */
2213 +- err = wait_event_interruptible(*req->wq,
2214 +- req->status >= REQ_STATUS_RCVD);
2215 ++ err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
2216 +
2217 + /*
2218 + * Make sure our req is coherent with regard to updates in other
2219 +diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
2220 +index 6e70ddb158b4..2ddeecca5b12 100644
2221 +--- a/net/9p/trans_virtio.c
2222 ++++ b/net/9p/trans_virtio.c
2223 +@@ -290,8 +290,8 @@ req_retry:
2224 + if (err == -ENOSPC) {
2225 + chan->ring_bufs_avail = 0;
2226 + spin_unlock_irqrestore(&chan->lock, flags);
2227 +- err = wait_event_interruptible(*chan->vc_wq,
2228 +- chan->ring_bufs_avail);
2229 ++ err = wait_event_killable(*chan->vc_wq,
2230 ++ chan->ring_bufs_avail);
2231 + if (err == -ERESTARTSYS)
2232 + return err;
2233 +
2234 +@@ -331,7 +331,7 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
2235 + * Other zc request to finish here
2236 + */
2237 + if (atomic_read(&vp_pinned) >= chan->p9_max_pages) {
2238 +- err = wait_event_interruptible(vp_wq,
2239 ++ err = wait_event_killable(vp_wq,
2240 + (atomic_read(&vp_pinned) < chan->p9_max_pages));
2241 + if (err == -ERESTARTSYS)
2242 + return err;
2243 +@@ -475,8 +475,8 @@ req_retry_pinned:
2244 + if (err == -ENOSPC) {
2245 + chan->ring_bufs_avail = 0;
2246 + spin_unlock_irqrestore(&chan->lock, flags);
2247 +- err = wait_event_interruptible(*chan->vc_wq,
2248 +- chan->ring_bufs_avail);
2249 ++ err = wait_event_killable(*chan->vc_wq,
2250 ++ chan->ring_bufs_avail);
2251 + if (err == -ERESTARTSYS)
2252 + goto err_out;
2253 +
2254 +@@ -493,8 +493,7 @@ req_retry_pinned:
2255 + virtqueue_kick(chan->vq);
2256 + spin_unlock_irqrestore(&chan->lock, flags);
2257 + p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
2258 +- err = wait_event_interruptible(*req->wq,
2259 +- req->status >= REQ_STATUS_RCVD);
2260 ++ err = wait_event_killable(*req->wq, req->status >= REQ_STATUS_RCVD);
2261 + /*
2262 + * Non kernel buffers are pinned, unpin them
2263 + */
2264 +diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
2265 +index f300d1cbfa91..097a1243c16c 100644
2266 +--- a/net/ipv4/ip_sockglue.c
2267 ++++ b/net/ipv4/ip_sockglue.c
2268 +@@ -808,6 +808,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
2269 + {
2270 + struct ip_mreqn mreq;
2271 + struct net_device *dev = NULL;
2272 ++ int midx;
2273 +
2274 + if (sk->sk_type == SOCK_STREAM)
2275 + goto e_inval;
2276 +@@ -852,11 +853,15 @@ static int do_ip_setsockopt(struct sock *sk, int level,
2277 + err = -EADDRNOTAVAIL;
2278 + if (!dev)
2279 + break;
2280 ++
2281 ++ midx = l3mdev_master_ifindex(dev);
2282 ++
2283 + dev_put(dev);
2284 +
2285 + err = -EINVAL;
2286 + if (sk->sk_bound_dev_if &&
2287 +- mreq.imr_ifindex != sk->sk_bound_dev_if)
2288 ++ mreq.imr_ifindex != sk->sk_bound_dev_if &&
2289 ++ (!midx || midx != sk->sk_bound_dev_if))
2290 + break;
2291 +
2292 + inet->mc_index = mreq.imr_ifindex;
2293 +diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
2294 +index 4449ad1f8114..a4a30d2ca66f 100644
2295 +--- a/net/ipv6/ipv6_sockglue.c
2296 ++++ b/net/ipv6/ipv6_sockglue.c
2297 +@@ -583,16 +583,24 @@ done:
2298 +
2299 + if (val) {
2300 + struct net_device *dev;
2301 ++ int midx;
2302 +
2303 +- if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != val)
2304 +- goto e_inval;
2305 ++ rcu_read_lock();
2306 +
2307 +- dev = dev_get_by_index(net, val);
2308 ++ dev = dev_get_by_index_rcu(net, val);
2309 + if (!dev) {
2310 ++ rcu_read_unlock();
2311 + retv = -ENODEV;
2312 + break;
2313 + }
2314 +- dev_put(dev);
2315 ++ midx = l3mdev_master_ifindex_rcu(dev);
2316 ++
2317 ++ rcu_read_unlock();
2318 ++
2319 ++ if (sk->sk_bound_dev_if &&
2320 ++ sk->sk_bound_dev_if != val &&
2321 ++ (!midx || midx != sk->sk_bound_dev_if))
2322 ++ goto e_inval;
2323 + }
2324 + np->mcast_oif = val;
2325 + retv = 0;
2326 +diff --git a/net/ipv6/route.c b/net/ipv6/route.c
2327 +index 48917437550e..7336a7311038 100644
2328 +--- a/net/ipv6/route.c
2329 ++++ b/net/ipv6/route.c
2330 +@@ -3378,7 +3378,11 @@ static int ip6_route_dev_notify(struct notifier_block *this,
2331 + net->ipv6.ip6_blk_hole_entry->dst.dev = dev;
2332 + net->ipv6.ip6_blk_hole_entry->rt6i_idev = in6_dev_get(dev);
2333 + #endif
2334 +- } else if (event == NETDEV_UNREGISTER) {
2335 ++ } else if (event == NETDEV_UNREGISTER &&
2336 ++ dev->reg_state != NETREG_UNREGISTERED) {
2337 ++ /* NETDEV_UNREGISTER could be fired for multiple times by
2338 ++ * netdev_wait_allrefs(). Make sure we only call this once.
2339 ++ */
2340 + in6_dev_put(net->ipv6.ip6_null_entry->rt6i_idev);
2341 + #ifdef CONFIG_IPV6_MULTIPLE_TABLES
2342 + in6_dev_put(net->ipv6.ip6_prohibit_entry->rt6i_idev);
2343 +diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
2344 +index 6837a46ca4a2..7b271f3ded6b 100644
2345 +--- a/net/mac80211/ieee80211_i.h
2346 ++++ b/net/mac80211/ieee80211_i.h
2347 +@@ -682,7 +682,6 @@ struct ieee80211_if_mesh {
2348 + const struct ieee80211_mesh_sync_ops *sync_ops;
2349 + s64 sync_offset_clockdrift_max;
2350 + spinlock_t sync_offset_lock;
2351 +- bool adjusting_tbtt;
2352 + /* mesh power save */
2353 + enum nl80211_mesh_power_mode nonpeer_pm;
2354 + int ps_peers_light_sleep;
2355 +diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c
2356 +index 9063e8e736ad..9e1ded80a992 100644
2357 +--- a/net/mac80211/mesh.c
2358 ++++ b/net/mac80211/mesh.c
2359 +@@ -295,8 +295,6 @@ int mesh_add_meshconf_ie(struct ieee80211_sub_if_data *sdata,
2360 + /* Mesh PS mode. See IEEE802.11-2012 8.4.2.100.8 */
2361 + *pos |= ifmsh->ps_peers_deep_sleep ?
2362 + IEEE80211_MESHCONF_CAPAB_POWER_SAVE_LEVEL : 0x00;
2363 +- *pos++ |= ifmsh->adjusting_tbtt ?
2364 +- IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING : 0x00;
2365 + *pos++ = 0x00;
2366 +
2367 + return 0;
2368 +@@ -866,7 +864,6 @@ int ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
2369 + ifmsh->mesh_cc_id = 0; /* Disabled */
2370 + /* register sync ops from extensible synchronization framework */
2371 + ifmsh->sync_ops = ieee80211_mesh_sync_ops_get(ifmsh->mesh_sp_id);
2372 +- ifmsh->adjusting_tbtt = false;
2373 + ifmsh->sync_offset_clockdrift_max = 0;
2374 + set_bit(MESH_WORK_HOUSEKEEPING, &ifmsh->wrkq_flags);
2375 + ieee80211_mesh_root_setup(ifmsh);
2376 +diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c
2377 +index bd3d55eb21d4..9f02e54ad2a5 100644
2378 +--- a/net/mac80211/mesh_plink.c
2379 ++++ b/net/mac80211/mesh_plink.c
2380 +@@ -495,12 +495,14 @@ mesh_sta_info_alloc(struct ieee80211_sub_if_data *sdata, u8 *addr,
2381 +
2382 + /* Userspace handles station allocation */
2383 + if (sdata->u.mesh.user_mpm ||
2384 +- sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED)
2385 +- cfg80211_notify_new_peer_candidate(sdata->dev, addr,
2386 +- elems->ie_start,
2387 +- elems->total_len,
2388 +- GFP_KERNEL);
2389 +- else
2390 ++ sdata->u.mesh.security & IEEE80211_MESH_SEC_AUTHED) {
2391 ++ if (mesh_peer_accepts_plinks(elems) &&
2392 ++ mesh_plink_availables(sdata))
2393 ++ cfg80211_notify_new_peer_candidate(sdata->dev, addr,
2394 ++ elems->ie_start,
2395 ++ elems->total_len,
2396 ++ GFP_KERNEL);
2397 ++ } else
2398 + sta = __mesh_sta_info_alloc(sdata, addr);
2399 +
2400 + return sta;
2401 +diff --git a/net/mac80211/mesh_sync.c b/net/mac80211/mesh_sync.c
2402 +index 64bc22ad9496..16ed43fe4841 100644
2403 +--- a/net/mac80211/mesh_sync.c
2404 ++++ b/net/mac80211/mesh_sync.c
2405 +@@ -119,7 +119,6 @@ static void mesh_sync_offset_rx_bcn_presp(struct ieee80211_sub_if_data *sdata,
2406 + */
2407 +
2408 + if (elems->mesh_config && mesh_peer_tbtt_adjusting(elems)) {
2409 +- clear_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN);
2410 + msync_dbg(sdata, "STA %pM : is adjusting TBTT\n",
2411 + sta->sta.addr);
2412 + goto no_sync;
2413 +@@ -168,11 +167,9 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata,
2414 + struct beacon_data *beacon)
2415 + {
2416 + struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
2417 +- u8 cap;
2418 +
2419 + WARN_ON(ifmsh->mesh_sp_id != IEEE80211_SYNC_METHOD_NEIGHBOR_OFFSET);
2420 + WARN_ON(!rcu_read_lock_held());
2421 +- cap = beacon->meshconf->meshconf_cap;
2422 +
2423 + spin_lock_bh(&ifmsh->sync_offset_lock);
2424 +
2425 +@@ -186,21 +183,13 @@ static void mesh_sync_offset_adjust_tbtt(struct ieee80211_sub_if_data *sdata,
2426 + "TBTT : kicking off TBTT adjustment with clockdrift_max=%lld\n",
2427 + ifmsh->sync_offset_clockdrift_max);
2428 + set_bit(MESH_WORK_DRIFT_ADJUST, &ifmsh->wrkq_flags);
2429 +-
2430 +- ifmsh->adjusting_tbtt = true;
2431 + } else {
2432 + msync_dbg(sdata,
2433 + "TBTT : max clockdrift=%lld; too small to adjust\n",
2434 + (long long)ifmsh->sync_offset_clockdrift_max);
2435 + ifmsh->sync_offset_clockdrift_max = 0;
2436 +-
2437 +- ifmsh->adjusting_tbtt = false;
2438 + }
2439 + spin_unlock_bh(&ifmsh->sync_offset_lock);
2440 +-
2441 +- beacon->meshconf->meshconf_cap = ifmsh->adjusting_tbtt ?
2442 +- IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING | cap :
2443 +- ~IEEE80211_MESHCONF_CAPAB_TBTT_ADJUSTING & cap;
2444 + }
2445 +
2446 + static const struct sync_method sync_methods[] = {
2447 +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
2448 +index 2cb429d34c03..120e9ae04db3 100644
2449 +--- a/net/netfilter/nf_tables_api.c
2450 ++++ b/net/netfilter/nf_tables_api.c
2451 +@@ -1996,7 +1996,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
2452 + * is called on error from nf_tables_newrule().
2453 + */
2454 + expr = nft_expr_first(rule);
2455 +- while (expr->ops && expr != nft_expr_last(rule)) {
2456 ++ while (expr != nft_expr_last(rule) && expr->ops) {
2457 + nf_tables_expr_destroy(ctx, expr);
2458 + expr = nft_expr_next(expr);
2459 + }
2460 +diff --git a/net/netfilter/nft_queue.c b/net/netfilter/nft_queue.c
2461 +index 61d216eb7917..5d189c11d208 100644
2462 +--- a/net/netfilter/nft_queue.c
2463 ++++ b/net/netfilter/nft_queue.c
2464 +@@ -37,7 +37,7 @@ static void nft_queue_eval(const struct nft_expr *expr,
2465 +
2466 + if (priv->queues_total > 1) {
2467 + if (priv->flags & NFT_QUEUE_FLAG_CPU_FANOUT) {
2468 +- int cpu = smp_processor_id();
2469 ++ int cpu = raw_smp_processor_id();
2470 +
2471 + queue = priv->queuenum + cpu % priv->queues_total;
2472 + } else {
2473 +diff --git a/net/nfc/core.c b/net/nfc/core.c
2474 +index c5a2c7e733b3..1471e4b0aa2c 100644
2475 +--- a/net/nfc/core.c
2476 ++++ b/net/nfc/core.c
2477 +@@ -1093,7 +1093,7 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
2478 + err_free_dev:
2479 + kfree(dev);
2480 +
2481 +- return ERR_PTR(rc);
2482 ++ return NULL;
2483 + }
2484 + EXPORT_SYMBOL(nfc_allocate_device);
2485 +
2486 +diff --git a/net/rds/send.c b/net/rds/send.c
2487 +index 6815f03324d7..1a3c6acdd3f8 100644
2488 +--- a/net/rds/send.c
2489 ++++ b/net/rds/send.c
2490 +@@ -959,6 +959,11 @@ static int rds_cmsg_send(struct rds_sock *rs, struct rds_message *rm,
2491 + ret = rds_cmsg_rdma_map(rs, rm, cmsg);
2492 + if (!ret)
2493 + *allocated_mr = 1;
2494 ++ else if (ret == -ENODEV)
2495 ++ /* Accommodate the get_mr() case which can fail
2496 ++ * if connection isn't established yet.
2497 ++ */
2498 ++ ret = -EAGAIN;
2499 + break;
2500 + case RDS_CMSG_ATOMIC_CSWP:
2501 + case RDS_CMSG_ATOMIC_FADD:
2502 +@@ -1072,8 +1077,12 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
2503 +
2504 + /* Parse any control messages the user may have included. */
2505 + ret = rds_cmsg_send(rs, rm, msg, &allocated_mr);
2506 +- if (ret)
2507 ++ if (ret) {
2508 ++ /* Trigger connection so that its ready for the next retry */
2509 ++ if (ret == -EAGAIN)
2510 ++ rds_conn_connect_if_down(conn);
2511 + goto out;
2512 ++ }
2513 +
2514 + if (rm->rdma.op_active && !conn->c_trans->xmit_rdma) {
2515 + printk_ratelimited(KERN_NOTICE "rdma_op %p conn xmit_rdma %p\n",
2516 +diff --git a/net/sctp/socket.c b/net/sctp/socket.c
2517 +index 272edd7748a0..7f0f689b8d2b 100644
2518 +--- a/net/sctp/socket.c
2519 ++++ b/net/sctp/socket.c
2520 +@@ -4453,10 +4453,6 @@ int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp)
2521 + struct socket *sock;
2522 + int err = 0;
2523 +
2524 +- /* Do not peel off from one netns to another one. */
2525 +- if (!net_eq(current->nsproxy->net_ns, sock_net(sk)))
2526 +- return -EINVAL;
2527 +-
2528 + /* Do not peel off from one netns to another one. */
2529 + if (!net_eq(current->nsproxy->net_ns, sock_net(sk)))
2530 + return -EINVAL;
2531 +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
2532 +index 9b5bd6d142dc..60324f7c72bd 100644
2533 +--- a/net/vmw_vsock/af_vsock.c
2534 ++++ b/net/vmw_vsock/af_vsock.c
2535 +@@ -1209,10 +1209,14 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
2536 +
2537 + if (signal_pending(current)) {
2538 + err = sock_intr_errno(timeout);
2539 +- goto out_wait_error;
2540 ++ sk->sk_state = SS_UNCONNECTED;
2541 ++ sock->state = SS_UNCONNECTED;
2542 ++ goto out_wait;
2543 + } else if (timeout == 0) {
2544 + err = -ETIMEDOUT;
2545 +- goto out_wait_error;
2546 ++ sk->sk_state = SS_UNCONNECTED;
2547 ++ sock->state = SS_UNCONNECTED;
2548 ++ goto out_wait;
2549 + }
2550 +
2551 + prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
2552 +@@ -1220,20 +1224,17 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
2553 +
2554 + if (sk->sk_err) {
2555 + err = -sk->sk_err;
2556 +- goto out_wait_error;
2557 +- } else
2558 ++ sk->sk_state = SS_UNCONNECTED;
2559 ++ sock->state = SS_UNCONNECTED;
2560 ++ } else {
2561 + err = 0;
2562 ++ }
2563 +
2564 + out_wait:
2565 + finish_wait(sk_sleep(sk), &wait);
2566 + out:
2567 + release_sock(sk);
2568 + return err;
2569 +-
2570 +-out_wait_error:
2571 +- sk->sk_state = SS_UNCONNECTED;
2572 +- sock->state = SS_UNCONNECTED;
2573 +- goto out_wait;
2574 + }
2575 +
2576 + static int vsock_accept(struct socket *sock, struct socket *newsock, int flags)
2577 +@@ -1270,18 +1271,20 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags)
2578 + listener->sk_err == 0) {
2579 + release_sock(listener);
2580 + timeout = schedule_timeout(timeout);
2581 ++ finish_wait(sk_sleep(listener), &wait);
2582 + lock_sock(listener);
2583 +
2584 + if (signal_pending(current)) {
2585 + err = sock_intr_errno(timeout);
2586 +- goto out_wait;
2587 ++ goto out;
2588 + } else if (timeout == 0) {
2589 + err = -EAGAIN;
2590 +- goto out_wait;
2591 ++ goto out;
2592 + }
2593 +
2594 + prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE);
2595 + }
2596 ++ finish_wait(sk_sleep(listener), &wait);
2597 +
2598 + if (listener->sk_err)
2599 + err = -listener->sk_err;
2600 +@@ -1301,19 +1304,15 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags)
2601 + */
2602 + if (err) {
2603 + vconnected->rejected = true;
2604 +- release_sock(connected);
2605 +- sock_put(connected);
2606 +- goto out_wait;
2607 ++ } else {
2608 ++ newsock->state = SS_CONNECTED;
2609 ++ sock_graft(connected, newsock);
2610 + }
2611 +
2612 +- newsock->state = SS_CONNECTED;
2613 +- sock_graft(connected, newsock);
2614 + release_sock(connected);
2615 + sock_put(connected);
2616 + }
2617 +
2618 +-out_wait:
2619 +- finish_wait(sk_sleep(listener), &wait);
2620 + out:
2621 + release_sock(listener);
2622 + return err;
2623 +@@ -1513,8 +1512,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2624 + long timeout;
2625 + int err;
2626 + struct vsock_transport_send_notify_data send_data;
2627 +-
2628 +- DEFINE_WAIT(wait);
2629 ++ DEFINE_WAIT_FUNC(wait, woken_wake_function);
2630 +
2631 + sk = sock->sk;
2632 + vsk = vsock_sk(sk);
2633 +@@ -1557,11 +1555,10 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2634 + if (err < 0)
2635 + goto out;
2636 +
2637 +- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
2638 +-
2639 + while (total_written < len) {
2640 + ssize_t written;
2641 +
2642 ++ add_wait_queue(sk_sleep(sk), &wait);
2643 + while (vsock_stream_has_space(vsk) == 0 &&
2644 + sk->sk_err == 0 &&
2645 + !(sk->sk_shutdown & SEND_SHUTDOWN) &&
2646 +@@ -1570,27 +1567,30 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2647 + /* Don't wait for non-blocking sockets. */
2648 + if (timeout == 0) {
2649 + err = -EAGAIN;
2650 +- goto out_wait;
2651 ++ remove_wait_queue(sk_sleep(sk), &wait);
2652 ++ goto out_err;
2653 + }
2654 +
2655 + err = transport->notify_send_pre_block(vsk, &send_data);
2656 +- if (err < 0)
2657 +- goto out_wait;
2658 ++ if (err < 0) {
2659 ++ remove_wait_queue(sk_sleep(sk), &wait);
2660 ++ goto out_err;
2661 ++ }
2662 +
2663 + release_sock(sk);
2664 +- timeout = schedule_timeout(timeout);
2665 ++ timeout = wait_woken(&wait, TASK_INTERRUPTIBLE, timeout);
2666 + lock_sock(sk);
2667 + if (signal_pending(current)) {
2668 + err = sock_intr_errno(timeout);
2669 +- goto out_wait;
2670 ++ remove_wait_queue(sk_sleep(sk), &wait);
2671 ++ goto out_err;
2672 + } else if (timeout == 0) {
2673 + err = -EAGAIN;
2674 +- goto out_wait;
2675 ++ remove_wait_queue(sk_sleep(sk), &wait);
2676 ++ goto out_err;
2677 + }
2678 +-
2679 +- prepare_to_wait(sk_sleep(sk), &wait,
2680 +- TASK_INTERRUPTIBLE);
2681 + }
2682 ++ remove_wait_queue(sk_sleep(sk), &wait);
2683 +
2684 + /* These checks occur both as part of and after the loop
2685 + * conditional since we need to check before and after
2686 +@@ -1598,16 +1598,16 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2687 + */
2688 + if (sk->sk_err) {
2689 + err = -sk->sk_err;
2690 +- goto out_wait;
2691 ++ goto out_err;
2692 + } else if ((sk->sk_shutdown & SEND_SHUTDOWN) ||
2693 + (vsk->peer_shutdown & RCV_SHUTDOWN)) {
2694 + err = -EPIPE;
2695 +- goto out_wait;
2696 ++ goto out_err;
2697 + }
2698 +
2699 + err = transport->notify_send_pre_enqueue(vsk, &send_data);
2700 + if (err < 0)
2701 +- goto out_wait;
2702 ++ goto out_err;
2703 +
2704 + /* Note that enqueue will only write as many bytes as are free
2705 + * in the produce queue, so we don't need to ensure len is
2706 +@@ -1620,7 +1620,7 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2707 + len - total_written);
2708 + if (written < 0) {
2709 + err = -ENOMEM;
2710 +- goto out_wait;
2711 ++ goto out_err;
2712 + }
2713 +
2714 + total_written += written;
2715 +@@ -1628,14 +1628,13 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg,
2716 + err = transport->notify_send_post_enqueue(
2717 + vsk, written, &send_data);
2718 + if (err < 0)
2719 +- goto out_wait;
2720 ++ goto out_err;
2721 +
2722 + }
2723 +
2724 +-out_wait:
2725 ++out_err:
2726 + if (total_written > 0)
2727 + err = total_written;
2728 +- finish_wait(sk_sleep(sk), &wait);
2729 + out:
2730 + release_sock(sk);
2731 + return err;
2732 +@@ -1716,21 +1715,61 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
2733 + if (err < 0)
2734 + goto out;
2735 +
2736 +- prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
2737 +
2738 + while (1) {
2739 +- s64 ready = vsock_stream_has_data(vsk);
2740 ++ s64 ready;
2741 +
2742 +- if (ready < 0) {
2743 +- /* Invalid queue pair content. XXX This should be
2744 +- * changed to a connection reset in a later change.
2745 +- */
2746 ++ prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
2747 ++ ready = vsock_stream_has_data(vsk);
2748 +
2749 +- err = -ENOMEM;
2750 +- goto out_wait;
2751 +- } else if (ready > 0) {
2752 ++ if (ready == 0) {
2753 ++ if (sk->sk_err != 0 ||
2754 ++ (sk->sk_shutdown & RCV_SHUTDOWN) ||
2755 ++ (vsk->peer_shutdown & SEND_SHUTDOWN)) {
2756 ++ finish_wait(sk_sleep(sk), &wait);
2757 ++ break;
2758 ++ }
2759 ++ /* Don't wait for non-blocking sockets. */
2760 ++ if (timeout == 0) {
2761 ++ err = -EAGAIN;
2762 ++ finish_wait(sk_sleep(sk), &wait);
2763 ++ break;
2764 ++ }
2765 ++
2766 ++ err = transport->notify_recv_pre_block(
2767 ++ vsk, target, &recv_data);
2768 ++ if (err < 0) {
2769 ++ finish_wait(sk_sleep(sk), &wait);
2770 ++ break;
2771 ++ }
2772 ++ release_sock(sk);
2773 ++ timeout = schedule_timeout(timeout);
2774 ++ lock_sock(sk);
2775 ++
2776 ++ if (signal_pending(current)) {
2777 ++ err = sock_intr_errno(timeout);
2778 ++ finish_wait(sk_sleep(sk), &wait);
2779 ++ break;
2780 ++ } else if (timeout == 0) {
2781 ++ err = -EAGAIN;
2782 ++ finish_wait(sk_sleep(sk), &wait);
2783 ++ break;
2784 ++ }
2785 ++ } else {
2786 + ssize_t read;
2787 +
2788 ++ finish_wait(sk_sleep(sk), &wait);
2789 ++
2790 ++ if (ready < 0) {
2791 ++ /* Invalid queue pair content. XXX This should
2792 ++ * be changed to a connection reset in a later
2793 ++ * change.
2794 ++ */
2795 ++
2796 ++ err = -ENOMEM;
2797 ++ goto out;
2798 ++ }
2799 ++
2800 + err = transport->notify_recv_pre_dequeue(
2801 + vsk, target, &recv_data);
2802 + if (err < 0)
2803 +@@ -1750,42 +1789,12 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
2804 + vsk, target, read,
2805 + !(flags & MSG_PEEK), &recv_data);
2806 + if (err < 0)
2807 +- goto out_wait;
2808 ++ goto out;
2809 +
2810 + if (read >= target || flags & MSG_PEEK)
2811 + break;
2812 +
2813 + target -= read;
2814 +- } else {
2815 +- if (sk->sk_err != 0 || (sk->sk_shutdown & RCV_SHUTDOWN)
2816 +- || (vsk->peer_shutdown & SEND_SHUTDOWN)) {
2817 +- break;
2818 +- }
2819 +- /* Don't wait for non-blocking sockets. */
2820 +- if (timeout == 0) {
2821 +- err = -EAGAIN;
2822 +- break;
2823 +- }
2824 +-
2825 +- err = transport->notify_recv_pre_block(
2826 +- vsk, target, &recv_data);
2827 +- if (err < 0)
2828 +- break;
2829 +-
2830 +- release_sock(sk);
2831 +- timeout = schedule_timeout(timeout);
2832 +- lock_sock(sk);
2833 +-
2834 +- if (signal_pending(current)) {
2835 +- err = sock_intr_errno(timeout);
2836 +- break;
2837 +- } else if (timeout == 0) {
2838 +- err = -EAGAIN;
2839 +- break;
2840 +- }
2841 +-
2842 +- prepare_to_wait(sk_sleep(sk), &wait,
2843 +- TASK_INTERRUPTIBLE);
2844 + }
2845 + }
2846 +
2847 +@@ -1797,8 +1806,6 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
2848 + if (copied > 0)
2849 + err = copied;
2850 +
2851 +-out_wait:
2852 +- finish_wait(sk_sleep(sk), &wait);
2853 + out:
2854 + release_sock(sk);
2855 + return err;
2856 +diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
2857 +index 0aca39762ed0..cd20f91326fe 100644
2858 +--- a/sound/core/pcm_lib.c
2859 ++++ b/sound/core/pcm_lib.c
2860 +@@ -264,8 +264,10 @@ static void update_audio_tstamp(struct snd_pcm_substream *substream,
2861 + runtime->rate);
2862 + *audio_tstamp = ns_to_timespec(audio_nsecs);
2863 + }
2864 +- runtime->status->audio_tstamp = *audio_tstamp;
2865 +- runtime->status->tstamp = *curr_tstamp;
2866 ++ if (!timespec_equal(&runtime->status->audio_tstamp, audio_tstamp)) {
2867 ++ runtime->status->audio_tstamp = *audio_tstamp;
2868 ++ runtime->status->tstamp = *curr_tstamp;
2869 ++ }
2870 +
2871 + /*
2872 + * re-take a driver timestamp to let apps detect if the reference tstamp
2873 +diff --git a/sound/core/timer_compat.c b/sound/core/timer_compat.c
2874 +index 0b4b028e8e98..de9155eed727 100644
2875 +--- a/sound/core/timer_compat.c
2876 ++++ b/sound/core/timer_compat.c
2877 +@@ -40,11 +40,11 @@ static int snd_timer_user_info_compat(struct file *file,
2878 + struct snd_timer *t;
2879 +
2880 + tu = file->private_data;
2881 +- if (snd_BUG_ON(!tu->timeri))
2882 +- return -ENXIO;
2883 ++ if (!tu->timeri)
2884 ++ return -EBADFD;
2885 + t = tu->timeri->timer;
2886 +- if (snd_BUG_ON(!t))
2887 +- return -ENXIO;
2888 ++ if (!t)
2889 ++ return -EBADFD;
2890 + memset(&info, 0, sizeof(info));
2891 + info.card = t->card ? t->card->number : -1;
2892 + if (t->hw.flags & SNDRV_TIMER_HW_SLAVE)
2893 +@@ -73,8 +73,8 @@ static int snd_timer_user_status_compat(struct file *file,
2894 + struct snd_timer_status32 status;
2895 +
2896 + tu = file->private_data;
2897 +- if (snd_BUG_ON(!tu->timeri))
2898 +- return -ENXIO;
2899 ++ if (!tu->timeri)
2900 ++ return -EBADFD;
2901 + memset(&status, 0, sizeof(status));
2902 + status.tstamp.tv_sec = tu->tstamp.tv_sec;
2903 + status.tstamp.tv_nsec = tu->tstamp.tv_nsec;
2904 +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
2905 +index e6de496bffbe..e2e08fc73b50 100644
2906 +--- a/sound/pci/hda/hda_intel.c
2907 ++++ b/sound/pci/hda/hda_intel.c
2908 +@@ -2316,6 +2316,9 @@ static const struct pci_device_id azx_ids[] = {
2909 + /* AMD Hudson */
2910 + { PCI_DEVICE(0x1022, 0x780d),
2911 + .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
2912 ++ /* AMD Raven */
2913 ++ { PCI_DEVICE(0x1022, 0x15e3),
2914 ++ .driver_data = AZX_DRIVER_GENERIC | AZX_DCAPS_PRESET_ATI_SB },
2915 + /* ATI HDMI */
2916 + { PCI_DEVICE(0x1002, 0x0002),
2917 + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS },
2918 +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2919 +index af0962307b7f..e5730a7d0480 100644
2920 +--- a/sound/pci/hda/patch_realtek.c
2921 ++++ b/sound/pci/hda/patch_realtek.c
2922 +@@ -4404,7 +4404,7 @@ static void alc_no_shutup(struct hda_codec *codec)
2923 + static void alc_fixup_no_shutup(struct hda_codec *codec,
2924 + const struct hda_fixup *fix, int action)
2925 + {
2926 +- if (action == HDA_FIXUP_ACT_PRE_PROBE) {
2927 ++ if (action == HDA_FIXUP_ACT_PROBE) {
2928 + struct alc_spec *spec = codec->spec;
2929 + spec->shutup = alc_no_shutup;
2930 + }
2931 +@@ -6254,7 +6254,7 @@ static int patch_alc269(struct hda_codec *codec)
2932 + case 0x10ec0703:
2933 + spec->codec_variant = ALC269_TYPE_ALC700;
2934 + spec->gen.mixer_nid = 0; /* ALC700 does not have any loopback mixer path */
2935 +- alc_update_coef_idx(codec, 0x4a, 0, 1 << 15); /* Combo jack auto trigger control */
2936 ++ alc_update_coef_idx(codec, 0x4a, 1 << 15, 0); /* Combo jack auto trigger control */
2937 + break;
2938 +
2939 + }
2940 +diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
2941 +index 0bb415a28723..f1f990b325ad 100644
2942 +--- a/sound/soc/codecs/wm_adsp.c
2943 ++++ b/sound/soc/codecs/wm_adsp.c
2944 +@@ -1060,7 +1060,7 @@ static int wm_adsp_load(struct wm_adsp *dsp)
2945 + const struct wmfw_region *region;
2946 + const struct wm_adsp_region *mem;
2947 + const char *region_name;
2948 +- char *file, *text;
2949 ++ char *file, *text = NULL;
2950 + struct wm_adsp_buf *buf;
2951 + unsigned int reg;
2952 + int regions = 0;
2953 +@@ -1221,10 +1221,21 @@ static int wm_adsp_load(struct wm_adsp *dsp)
2954 + regions, le32_to_cpu(region->len), offset,
2955 + region_name);
2956 +
2957 ++ if ((pos + le32_to_cpu(region->len) + sizeof(*region)) >
2958 ++ firmware->size) {
2959 ++ adsp_err(dsp,
2960 ++ "%s.%d: %s region len %d bytes exceeds file length %zu\n",
2961 ++ file, regions, region_name,
2962 ++ le32_to_cpu(region->len), firmware->size);
2963 ++ ret = -EINVAL;
2964 ++ goto out_fw;
2965 ++ }
2966 ++
2967 + if (text) {
2968 + memcpy(text, region->data, le32_to_cpu(region->len));
2969 + adsp_info(dsp, "%s: %s\n", file, text);
2970 + kfree(text);
2971 ++ text = NULL;
2972 + }
2973 +
2974 + if (reg) {
2975 +@@ -1269,6 +1280,7 @@ out_fw:
2976 + regmap_async_complete(regmap);
2977 + wm_adsp_buf_free(&buf_list);
2978 + release_firmware(firmware);
2979 ++ kfree(text);
2980 + out:
2981 + kfree(file);
2982 +
2983 +@@ -1730,6 +1742,17 @@ static int wm_adsp_load_coeff(struct wm_adsp *dsp)
2984 + }
2985 +
2986 + if (reg) {
2987 ++ if ((pos + le32_to_cpu(blk->len) + sizeof(*blk)) >
2988 ++ firmware->size) {
2989 ++ adsp_err(dsp,
2990 ++ "%s.%d: %s region len %d bytes exceeds file length %zu\n",
2991 ++ file, blocks, region_name,
2992 ++ le32_to_cpu(blk->len),
2993 ++ firmware->size);
2994 ++ ret = -EINVAL;
2995 ++ goto out_fw;
2996 ++ }
2997 ++
2998 + buf = wm_adsp_buf_alloc(blk->data,
2999 + le32_to_cpu(blk->len),
3000 + &buf_list);
3001 +diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c
3002 +index 362446c36c9e..e00dfbec22c5 100644
3003 +--- a/sound/soc/sh/rcar/core.c
3004 ++++ b/sound/soc/sh/rcar/core.c
3005 +@@ -1049,10 +1049,8 @@ static int __rsnd_kctrl_new(struct rsnd_mod *mod,
3006 + return -ENOMEM;
3007 +
3008 + ret = snd_ctl_add(card, kctrl);
3009 +- if (ret < 0) {
3010 +- snd_ctl_free_one(kctrl);
3011 ++ if (ret < 0)
3012 + return ret;
3013 +- }
3014 +
3015 + cfg->update = update;
3016 + cfg->card = card;
3017 +diff --git a/sound/usb/clock.c b/sound/usb/clock.c
3018 +index 7ccbcaf6a147..66294eb64501 100644
3019 +--- a/sound/usb/clock.c
3020 ++++ b/sound/usb/clock.c
3021 +@@ -43,7 +43,7 @@ static struct uac_clock_source_descriptor *
3022 + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
3023 + ctrl_iface->extralen,
3024 + cs, UAC2_CLOCK_SOURCE))) {
3025 +- if (cs->bClockID == clock_id)
3026 ++ if (cs->bLength >= sizeof(*cs) && cs->bClockID == clock_id)
3027 + return cs;
3028 + }
3029 +
3030 +@@ -59,8 +59,11 @@ static struct uac_clock_selector_descriptor *
3031 + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
3032 + ctrl_iface->extralen,
3033 + cs, UAC2_CLOCK_SELECTOR))) {
3034 +- if (cs->bClockID == clock_id)
3035 ++ if (cs->bLength >= sizeof(*cs) && cs->bClockID == clock_id) {
3036 ++ if (cs->bLength < 5 + cs->bNrInPins)
3037 ++ return NULL;
3038 + return cs;
3039 ++ }
3040 + }
3041 +
3042 + return NULL;
3043 +@@ -75,7 +78,7 @@ static struct uac_clock_multiplier_descriptor *
3044 + while ((cs = snd_usb_find_csint_desc(ctrl_iface->extra,
3045 + ctrl_iface->extralen,
3046 + cs, UAC2_CLOCK_MULTIPLIER))) {
3047 +- if (cs->bClockID == clock_id)
3048 ++ if (cs->bLength >= sizeof(*cs) && cs->bClockID == clock_id)
3049 + return cs;
3050 + }
3051 +
3052 +diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
3053 +index a23efc8671d6..1050008d7719 100644
3054 +--- a/sound/usb/mixer.c
3055 ++++ b/sound/usb/mixer.c
3056 +@@ -1397,6 +1397,12 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
3057 + __u8 *bmaControls;
3058 +
3059 + if (state->mixer->protocol == UAC_VERSION_1) {
3060 ++ if (hdr->bLength < 7) {
3061 ++ usb_audio_err(state->chip,
3062 ++ "unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
3063 ++ unitid);
3064 ++ return -EINVAL;
3065 ++ }
3066 + csize = hdr->bControlSize;
3067 + if (!csize) {
3068 + usb_audio_dbg(state->chip,
3069 +@@ -1414,6 +1420,12 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
3070 + }
3071 + } else {
3072 + struct uac2_feature_unit_descriptor *ftr = _ftr;
3073 ++ if (hdr->bLength < 6) {
3074 ++ usb_audio_err(state->chip,
3075 ++ "unit %u: invalid UAC_FEATURE_UNIT descriptor\n",
3076 ++ unitid);
3077 ++ return -EINVAL;
3078 ++ }
3079 + csize = 4;
3080 + channels = (hdr->bLength - 6) / 4 - 1;
3081 + bmaControls = ftr->bmaControls;
3082 +@@ -2014,7 +2026,8 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
3083 + const struct usbmix_name_map *map;
3084 + char **namelist;
3085 +
3086 +- if (!desc->bNrInPins || desc->bLength < 5 + desc->bNrInPins) {
3087 ++ if (desc->bLength < 5 || !desc->bNrInPins ||
3088 ++ desc->bLength < 5 + desc->bNrInPins) {
3089 + usb_audio_err(state->chip,
3090 + "invalid SELECTOR UNIT descriptor %d\n", unitid);
3091 + return -EINVAL;