Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Wed, 21 Nov 2018 15:02:41
Message-Id: 1542812495.4d243029f141bd93cf49f44c3bbf3d6d32298d7f.mpagano@gentoo
1 commit: 4d243029f141bd93cf49f44c3bbf3d6d32298d7f
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Wed Sep 26 10:44:28 2018 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 21 15:01:35 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=4d243029
7
8 Linux patch 4.4.158
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1157_linux-4.4.158.patch | 1693 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1697 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 3388582..7661927 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -671,6 +671,10 @@ Patch: 1156_linux-4.4.157.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.4.157
23
24 +Patch: 1157_linux-4.4.158.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.158
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1157_linux-4.4.158.patch b/1157_linux-4.4.158.patch
33 new file mode 100644
34 index 0000000..67b7dbb
35 --- /dev/null
36 +++ b/1157_linux-4.4.158.patch
37 @@ -0,0 +1,1693 @@
38 +diff --git a/Makefile b/Makefile
39 +index 2d55f88e6a08..d07a6283b67e 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 4
45 +-SUBLEVEL = 157
46 ++SUBLEVEL = 158
47 + EXTRAVERSION =
48 + NAME = Blurry Fish Butt
49 +
50 +diff --git a/arch/arm/mach-exynos/suspend.c b/arch/arm/mach-exynos/suspend.c
51 +index c169cc3049aa..e8adb428dddb 100644
52 +--- a/arch/arm/mach-exynos/suspend.c
53 ++++ b/arch/arm/mach-exynos/suspend.c
54 +@@ -260,6 +260,7 @@ static int __init exynos_pmu_irq_init(struct device_node *node,
55 + NULL);
56 + if (!domain) {
57 + iounmap(pmu_base_addr);
58 ++ pmu_base_addr = NULL;
59 + return -ENOMEM;
60 + }
61 +
62 +diff --git a/arch/arm/mach-hisi/hotplug.c b/arch/arm/mach-hisi/hotplug.c
63 +index a129aae72602..909bb2493781 100644
64 +--- a/arch/arm/mach-hisi/hotplug.c
65 ++++ b/arch/arm/mach-hisi/hotplug.c
66 +@@ -148,13 +148,20 @@ static int hi3xxx_hotplug_init(void)
67 + struct device_node *node;
68 +
69 + node = of_find_compatible_node(NULL, NULL, "hisilicon,sysctrl");
70 +- if (node) {
71 +- ctrl_base = of_iomap(node, 0);
72 +- id = HI3620_CTRL;
73 +- return 0;
74 ++ if (!node) {
75 ++ id = ERROR_CTRL;
76 ++ return -ENOENT;
77 + }
78 +- id = ERROR_CTRL;
79 +- return -ENOENT;
80 ++
81 ++ ctrl_base = of_iomap(node, 0);
82 ++ of_node_put(node);
83 ++ if (!ctrl_base) {
84 ++ id = ERROR_CTRL;
85 ++ return -ENOMEM;
86 ++ }
87 ++
88 ++ id = HI3620_CTRL;
89 ++ return 0;
90 + }
91 +
92 + void hi3xxx_set_cpu(int cpu, bool enable)
93 +@@ -173,11 +180,15 @@ static bool hix5hd2_hotplug_init(void)
94 + struct device_node *np;
95 +
96 + np = of_find_compatible_node(NULL, NULL, "hisilicon,cpuctrl");
97 +- if (np) {
98 +- ctrl_base = of_iomap(np, 0);
99 +- return true;
100 +- }
101 +- return false;
102 ++ if (!np)
103 ++ return false;
104 ++
105 ++ ctrl_base = of_iomap(np, 0);
106 ++ of_node_put(np);
107 ++ if (!ctrl_base)
108 ++ return false;
109 ++
110 ++ return true;
111 + }
112 +
113 + void hix5hd2_set_cpu(int cpu, bool enable)
114 +@@ -219,10 +230,10 @@ void hip01_set_cpu(int cpu, bool enable)
115 +
116 + if (!ctrl_base) {
117 + np = of_find_compatible_node(NULL, NULL, "hisilicon,hip01-sysctrl");
118 +- if (np)
119 +- ctrl_base = of_iomap(np, 0);
120 +- else
121 +- BUG();
122 ++ BUG_ON(!np);
123 ++ ctrl_base = of_iomap(np, 0);
124 ++ of_node_put(np);
125 ++ BUG_ON(!ctrl_base);
126 + }
127 +
128 + if (enable) {
129 +diff --git a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
130 +index 6b8abbe68746..3011c88bd2f3 100644
131 +--- a/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
132 ++++ b/arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
133 +@@ -105,7 +105,7 @@
134 + led@6 {
135 + label = "apq8016-sbc:blue:bt";
136 + gpios = <&pm8916_mpps 3 GPIO_ACTIVE_HIGH>;
137 +- linux,default-trigger = "bt";
138 ++ linux,default-trigger = "bluetooth-power";
139 + default-state = "off";
140 + };
141 + };
142 +diff --git a/arch/mips/ath79/setup.c b/arch/mips/ath79/setup.c
143 +index 8755d618e116..961c393c0f55 100644
144 +--- a/arch/mips/ath79/setup.c
145 ++++ b/arch/mips/ath79/setup.c
146 +@@ -44,6 +44,7 @@ static char ath79_sys_type[ATH79_SYS_TYPE_LEN];
147 +
148 + static void ath79_restart(char *command)
149 + {
150 ++ local_irq_disable();
151 + ath79_device_reset_set(AR71XX_RESET_FULL_CHIP);
152 + for (;;)
153 + if (cpu_wait)
154 +diff --git a/arch/mips/include/asm/mach-ath79/ath79.h b/arch/mips/include/asm/mach-ath79/ath79.h
155 +index 4eee221b0cf0..d2be8e4f7a35 100644
156 +--- a/arch/mips/include/asm/mach-ath79/ath79.h
157 ++++ b/arch/mips/include/asm/mach-ath79/ath79.h
158 +@@ -133,6 +133,7 @@ static inline u32 ath79_pll_rr(unsigned reg)
159 + static inline void ath79_reset_wr(unsigned reg, u32 val)
160 + {
161 + __raw_writel(val, ath79_reset_base + reg);
162 ++ (void) __raw_readl(ath79_reset_base + reg); /* flush */
163 + }
164 +
165 + static inline u32 ath79_reset_rr(unsigned reg)
166 +diff --git a/arch/mips/jz4740/Platform b/arch/mips/jz4740/Platform
167 +index 28448d358c10..a2a5a85ea1f9 100644
168 +--- a/arch/mips/jz4740/Platform
169 ++++ b/arch/mips/jz4740/Platform
170 +@@ -1,4 +1,4 @@
171 + platform-$(CONFIG_MACH_INGENIC) += jz4740/
172 + cflags-$(CONFIG_MACH_INGENIC) += -I$(srctree)/arch/mips/include/asm/mach-jz4740
173 + load-$(CONFIG_MACH_INGENIC) += 0xffffffff80010000
174 +-zload-$(CONFIG_MACH_INGENIC) += 0xffffffff80600000
175 ++zload-$(CONFIG_MACH_INGENIC) += 0xffffffff81000000
176 +diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
177 +index 5649a9e429e0..aca06b18c43e 100644
178 +--- a/arch/mips/kernel/vdso.c
179 ++++ b/arch/mips/kernel/vdso.c
180 +@@ -14,12 +14,14 @@
181 + #include <linux/init.h>
182 + #include <linux/ioport.h>
183 + #include <linux/irqchip/mips-gic.h>
184 ++#include <linux/kernel.h>
185 + #include <linux/mm.h>
186 + #include <linux/sched.h>
187 + #include <linux/slab.h>
188 + #include <linux/timekeeper_internal.h>
189 +
190 + #include <asm/abi.h>
191 ++#include <asm/page.h>
192 + #include <asm/vdso.h>
193 +
194 + /* Kernel-provided data used by the VDSO. */
195 +@@ -118,12 +120,30 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
196 + vvar_size = gic_size + PAGE_SIZE;
197 + size = vvar_size + image->size;
198 +
199 ++ /*
200 ++ * Find a region that's large enough for us to perform the
201 ++ * colour-matching alignment below.
202 ++ */
203 ++ if (cpu_has_dc_aliases)
204 ++ size += shm_align_mask + 1;
205 ++
206 + base = get_unmapped_area(NULL, 0, size, 0, 0);
207 + if (IS_ERR_VALUE(base)) {
208 + ret = base;
209 + goto out;
210 + }
211 +
212 ++ /*
213 ++ * If we suffer from dcache aliasing, ensure that the VDSO data page
214 ++ * mapping is coloured the same as the kernel's mapping of that memory.
215 ++ * This ensures that when the kernel updates the VDSO data userland
216 ++ * will observe it without requiring cache invalidations.
217 ++ */
218 ++ if (cpu_has_dc_aliases) {
219 ++ base = __ALIGN_MASK(base, shm_align_mask);
220 ++ base += ((unsigned long)&vdso_data - gic_size) & shm_align_mask;
221 ++ }
222 ++
223 + data_addr = base + gic_size;
224 + vdso_addr = data_addr + PAGE_SIZE;
225 +
226 +diff --git a/arch/mips/loongson64/common/cs5536/cs5536_ohci.c b/arch/mips/loongson64/common/cs5536/cs5536_ohci.c
227 +index f7c905e50dc4..92dc6bafc127 100644
228 +--- a/arch/mips/loongson64/common/cs5536/cs5536_ohci.c
229 ++++ b/arch/mips/loongson64/common/cs5536/cs5536_ohci.c
230 +@@ -138,7 +138,7 @@ u32 pci_ohci_read_reg(int reg)
231 + break;
232 + case PCI_OHCI_INT_REG:
233 + _rdmsr(DIVIL_MSR_REG(PIC_YSEL_LOW), &hi, &lo);
234 +- if ((lo & 0x00000f00) == CS5536_USB_INTR)
235 ++ if (((lo >> PIC_YSEL_LOW_USB_SHIFT) & 0xf) == CS5536_USB_INTR)
236 + conf_data = 1;
237 + break;
238 + default:
239 +diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
240 +index e48826aa314c..b40606051efe 100644
241 +--- a/arch/powerpc/platforms/powernv/opal.c
242 ++++ b/arch/powerpc/platforms/powernv/opal.c
243 +@@ -371,7 +371,7 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
244 + /* Closed or other error drop */
245 + if (rc != OPAL_SUCCESS && rc != OPAL_BUSY &&
246 + rc != OPAL_BUSY_EVENT) {
247 +- written = total_len;
248 ++ written += total_len;
249 + break;
250 + }
251 + if (rc == OPAL_SUCCESS) {
252 +diff --git a/drivers/clk/imx/clk-imx6ul.c b/drivers/clk/imx/clk-imx6ul.c
253 +index 01718d05e952..9e8f0e255de2 100644
254 +--- a/drivers/clk/imx/clk-imx6ul.c
255 ++++ b/drivers/clk/imx/clk-imx6ul.c
256 +@@ -120,6 +120,7 @@ static void __init imx6ul_clocks_init(struct device_node *ccm_node)
257 +
258 + np = of_find_compatible_node(NULL, NULL, "fsl,imx6ul-anatop");
259 + base = of_iomap(np, 0);
260 ++ of_node_put(np);
261 + WARN_ON(!base);
262 +
263 + clks[IMX6UL_PLL1_BYPASS_SRC] = imx_clk_mux("pll1_bypass_src", base + 0x00, 14, 1, pll_bypass_src_sels, ARRAY_SIZE(pll_bypass_src_sels));
264 +diff --git a/drivers/crypto/sahara.c b/drivers/crypto/sahara.c
265 +index f68c24a98277..dedfc96acc66 100644
266 +--- a/drivers/crypto/sahara.c
267 ++++ b/drivers/crypto/sahara.c
268 +@@ -1363,7 +1363,7 @@ err_sha_v4_algs:
269 +
270 + err_sha_v3_algs:
271 + for (j = 0; j < k; j++)
272 +- crypto_unregister_ahash(&sha_v4_algs[j]);
273 ++ crypto_unregister_ahash(&sha_v3_algs[j]);
274 +
275 + err_aes_algs:
276 + for (j = 0; j < i; j++)
277 +@@ -1379,7 +1379,7 @@ static void sahara_unregister_algs(struct sahara_dev *dev)
278 + for (i = 0; i < ARRAY_SIZE(aes_algs); i++)
279 + crypto_unregister_alg(&aes_algs[i]);
280 +
281 +- for (i = 0; i < ARRAY_SIZE(sha_v4_algs); i++)
282 ++ for (i = 0; i < ARRAY_SIZE(sha_v3_algs); i++)
283 + crypto_unregister_ahash(&sha_v3_algs[i]);
284 +
285 + if (dev->version > SAHARA_VERSION_3)
286 +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
287 +index 8db791ef2027..95619ee33112 100644
288 +--- a/drivers/dma/pl330.c
289 ++++ b/drivers/dma/pl330.c
290 +@@ -2132,13 +2132,14 @@ static int pl330_terminate_all(struct dma_chan *chan)
291 +
292 + pm_runtime_get_sync(pl330->ddma.dev);
293 + spin_lock_irqsave(&pch->lock, flags);
294 ++
295 + spin_lock(&pl330->lock);
296 + _stop(pch->thread);
297 +- spin_unlock(&pl330->lock);
298 +-
299 + pch->thread->req[0].desc = NULL;
300 + pch->thread->req[1].desc = NULL;
301 + pch->thread->req_running = -1;
302 ++ spin_unlock(&pl330->lock);
303 ++
304 + power_down = pch->active;
305 + pch->active = false;
306 +
307 +diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h
308 +index 98ab08c0aa2d..07541c5670e6 100644
309 +--- a/drivers/gpio/gpiolib.h
310 ++++ b/drivers/gpio/gpiolib.h
311 +@@ -30,7 +30,7 @@ struct acpi_gpio_info {
312 + };
313 +
314 + /* gpio suffixes used for ACPI and device tree lookup */
315 +-static const char * const gpio_suffixes[] = { "gpios", "gpio" };
316 ++static __maybe_unused const char * const gpio_suffixes[] = { "gpios", "gpio" };
317 +
318 + #ifdef CONFIG_ACPI
319 + void acpi_gpiochip_add(struct gpio_chip *chip);
320 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
321 +index eb1da83c9902..8cdd505784ed 100644
322 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
323 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
324 +@@ -125,6 +125,8 @@ struct kfd_process *kfd_get_process(const struct task_struct *thread)
325 + return ERR_PTR(-EINVAL);
326 +
327 + process = find_process(thread);
328 ++ if (!process)
329 ++ return ERR_PTR(-EINVAL);
330 +
331 + return process;
332 + }
333 +diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
334 +index e7e581d6a8ff..1bfc4807ce5b 100644
335 +--- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
336 ++++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c
337 +@@ -23,6 +23,10 @@
338 + #ifdef CONFIG_NOUVEAU_PLATFORM_DRIVER
339 + #include "priv.h"
340 +
341 ++#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
342 ++#include <asm/dma-iommu.h>
343 ++#endif
344 ++
345 + static int
346 + nvkm_device_tegra_power_up(struct nvkm_device_tegra *tdev)
347 + {
348 +@@ -85,6 +89,15 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev)
349 + unsigned long pgsize_bitmap;
350 + int ret;
351 +
352 ++#if IS_ENABLED(CONFIG_ARM_DMA_USE_IOMMU)
353 ++ if (dev->archdata.mapping) {
354 ++ struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
355 ++
356 ++ arm_iommu_detach_device(dev);
357 ++ arm_iommu_release_mapping(mapping);
358 ++ }
359 ++#endif
360 ++
361 + if (!tdev->func->iommu_bit)
362 + return;
363 +
364 +diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c b/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c
365 +index a188a3959f1a..6ad827b93ae1 100644
366 +--- a/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c
367 ++++ b/drivers/gpu/drm/panel/panel-samsung-s6e8aa0.c
368 +@@ -823,7 +823,7 @@ static void s6e8aa0_read_mtp_id(struct s6e8aa0 *ctx)
369 + int ret, i;
370 +
371 + ret = s6e8aa0_dcs_read(ctx, 0xd1, id, ARRAY_SIZE(id));
372 +- if (ret < ARRAY_SIZE(id) || id[0] == 0x00) {
373 ++ if (ret < 0 || ret < ARRAY_SIZE(id) || id[0] == 0x00) {
374 + dev_err(ctx->dev, "read id failed\n");
375 + ctx->error = -EIO;
376 + return;
377 +diff --git a/drivers/hwtracing/coresight/coresight-tpiu.c b/drivers/hwtracing/coresight/coresight-tpiu.c
378 +index 22e10b7d505d..fe3a2b19a5db 100644
379 +--- a/drivers/hwtracing/coresight/coresight-tpiu.c
380 ++++ b/drivers/hwtracing/coresight/coresight-tpiu.c
381 +@@ -46,8 +46,9 @@
382 +
383 + /** register definition **/
384 + /* FFSR - 0x300 */
385 +-#define FFSR_FT_STOPPED BIT(1)
386 ++#define FFSR_FT_STOPPED_BIT 1
387 + /* FFCR - 0x304 */
388 ++#define FFCR_FON_MAN_BIT 6
389 + #define FFCR_FON_MAN BIT(6)
390 + #define FFCR_STOP_FI BIT(12)
391 +
392 +@@ -93,9 +94,9 @@ static void tpiu_disable_hw(struct tpiu_drvdata *drvdata)
393 + /* Generate manual flush */
394 + writel_relaxed(FFCR_STOP_FI | FFCR_FON_MAN, drvdata->base + TPIU_FFCR);
395 + /* Wait for flush to complete */
396 +- coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN, 0);
397 ++ coresight_timeout(drvdata->base, TPIU_FFCR, FFCR_FON_MAN_BIT, 0);
398 + /* Wait for formatter to stop */
399 +- coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED, 1);
400 ++ coresight_timeout(drvdata->base, TPIU_FFSR, FFSR_FT_STOPPED_BIT, 1);
401 +
402 + CS_LOCK(drvdata->base);
403 + }
404 +diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
405 +index 93738dfbf631..902ee6efd09c 100644
406 +--- a/drivers/hwtracing/coresight/coresight.c
407 ++++ b/drivers/hwtracing/coresight/coresight.c
408 +@@ -86,7 +86,7 @@ static int coresight_find_link_inport(struct coresight_device *csdev)
409 + dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n",
410 + dev_name(&parent->dev), dev_name(&csdev->dev));
411 +
412 +- return 0;
413 ++ return -ENODEV;
414 + }
415 +
416 + static int coresight_find_link_outport(struct coresight_device *csdev)
417 +@@ -107,7 +107,7 @@ static int coresight_find_link_outport(struct coresight_device *csdev)
418 + dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n",
419 + dev_name(&csdev->dev), dev_name(&child->dev));
420 +
421 +- return 0;
422 ++ return -ENODEV;
423 + }
424 +
425 + static int coresight_enable_sink(struct coresight_device *csdev)
426 +@@ -155,6 +155,9 @@ static int coresight_enable_link(struct coresight_device *csdev)
427 + else
428 + refport = 0;
429 +
430 ++ if (refport < 0)
431 ++ return refport;
432 ++
433 + if (atomic_inc_return(&csdev->refcnt[refport]) == 1) {
434 + if (link_ops(csdev)->enable) {
435 + ret = link_ops(csdev)->enable(csdev, inport, outport);
436 +diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
437 +index 0f42411d6a79..1454290078de 100644
438 +--- a/drivers/infiniband/core/cma.c
439 ++++ b/drivers/infiniband/core/cma.c
440 +@@ -544,6 +544,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
441 + dgid = (union ib_gid *) &addr->sib_addr;
442 + pkey = ntohs(addr->sib_pkey);
443 +
444 ++ mutex_lock(&lock);
445 + list_for_each_entry(cur_dev, &dev_list, list) {
446 + for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) {
447 + if (!rdma_cap_af_ib(cur_dev->device, p))
448 +@@ -567,18 +568,19 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
449 + cma_dev = cur_dev;
450 + sgid = gid;
451 + id_priv->id.port_num = p;
452 ++ goto found;
453 + }
454 + }
455 + }
456 + }
457 +-
458 +- if (!cma_dev)
459 +- return -ENODEV;
460 ++ mutex_unlock(&lock);
461 ++ return -ENODEV;
462 +
463 + found:
464 + cma_attach_to_dev(id_priv, cma_dev);
465 +- addr = (struct sockaddr_ib *) cma_src_addr(id_priv);
466 +- memcpy(&addr->sib_addr, &sgid, sizeof sgid);
467 ++ mutex_unlock(&lock);
468 ++ addr = (struct sockaddr_ib *)cma_src_addr(id_priv);
469 ++ memcpy(&addr->sib_addr, &sgid, sizeof(sgid));
470 + cma_translate_ib(addr, &id_priv->id.route.addr.dev_addr);
471 + return 0;
472 + }
473 +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
474 +index f74b11542603..a338e60836ee 100644
475 +--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
476 ++++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
477 +@@ -992,12 +992,14 @@ static int ipoib_cm_rep_handler(struct ib_cm_id *cm_id, struct ib_cm_event *even
478 +
479 + skb_queue_head_init(&skqueue);
480 +
481 ++ netif_tx_lock_bh(p->dev);
482 + spin_lock_irq(&priv->lock);
483 + set_bit(IPOIB_FLAG_OPER_UP, &p->flags);
484 + if (p->neigh)
485 + while ((skb = __skb_dequeue(&p->neigh->queue)))
486 + __skb_queue_tail(&skqueue, skb);
487 + spin_unlock_irq(&priv->lock);
488 ++ netif_tx_unlock_bh(p->dev);
489 +
490 + while ((skb = __skb_dequeue(&skqueue))) {
491 + skb->dev = p->dev;
492 +diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
493 +index 347aaaa5a7ea..fc6eb752ab35 100644
494 +--- a/drivers/iommu/arm-smmu-v3.c
495 ++++ b/drivers/iommu/arm-smmu-v3.c
496 +@@ -1219,6 +1219,7 @@ static irqreturn_t arm_smmu_priq_thread(int irq, void *dev)
497 +
498 + /* Sync our overflow flag, as we believe we're up to speed */
499 + q->cons = Q_OVF(q, q->prod) | Q_WRP(q, q->cons) | Q_IDX(q, q->cons);
500 ++ writel(q->cons, q->cons_reg);
501 + return IRQ_HANDLED;
502 + }
503 +
504 +diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
505 +index 0c1a42bf27fd..1c37d5a78822 100644
506 +--- a/drivers/media/v4l2-core/videobuf2-core.c
507 ++++ b/drivers/media/v4l2-core/videobuf2-core.c
508 +@@ -1366,6 +1366,11 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
509 + struct vb2_buffer *vb;
510 + int ret;
511 +
512 ++ if (q->error) {
513 ++ dprintk(1, "fatal error occurred on queue\n");
514 ++ return -EIO;
515 ++ }
516 ++
517 + vb = q->bufs[index];
518 +
519 + switch (vb->state) {
520 +diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
521 +index 90520d76633f..9cde4c5bfba4 100644
522 +--- a/drivers/misc/hmc6352.c
523 ++++ b/drivers/misc/hmc6352.c
524 +@@ -27,6 +27,7 @@
525 + #include <linux/err.h>
526 + #include <linux/delay.h>
527 + #include <linux/sysfs.h>
528 ++#include <linux/nospec.h>
529 +
530 + static DEFINE_MUTEX(compass_mutex);
531 +
532 +@@ -50,6 +51,7 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
533 + return ret;
534 + if (val >= strlen(map))
535 + return -EINVAL;
536 ++ val = array_index_nospec(val, strlen(map));
537 + mutex_lock(&compass_mutex);
538 + ret = compass_command(c, map[val]);
539 + mutex_unlock(&compass_mutex);
540 +diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c
541 +index bdc7fcd80eca..9dcdc6f41ceb 100644
542 +--- a/drivers/misc/mei/bus-fixup.c
543 ++++ b/drivers/misc/mei/bus-fixup.c
544 +@@ -151,7 +151,7 @@ static int mei_nfc_if_version(struct mei_cl *cl,
545 +
546 + ret = 0;
547 + bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length);
548 +- if (bytes_recv < if_version_length) {
549 ++ if (bytes_recv < 0 || bytes_recv < if_version_length) {
550 + dev_err(bus->dev, "Could not read IF version\n");
551 + ret = -EIO;
552 + goto err;
553 +diff --git a/drivers/mtd/maps/solutionengine.c b/drivers/mtd/maps/solutionengine.c
554 +index bb580bc16445..c07f21b20463 100644
555 +--- a/drivers/mtd/maps/solutionengine.c
556 ++++ b/drivers/mtd/maps/solutionengine.c
557 +@@ -59,9 +59,9 @@ static int __init init_soleng_maps(void)
558 + return -ENXIO;
559 + }
560 + }
561 +- printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
562 +- soleng_flash_map.phys & 0x1fffffff,
563 +- soleng_eprom_map.phys & 0x1fffffff);
564 ++ printk(KERN_NOTICE "Solution Engine: Flash at 0x%pap, EPROM at 0x%pap\n",
565 ++ &soleng_flash_map.phys,
566 ++ &soleng_eprom_map.phys);
567 + flash_mtd->owner = THIS_MODULE;
568 +
569 + eprom_mtd = do_map_probe("map_rom", &soleng_eprom_map);
570 +diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
571 +index 6d19835b80a9..0d244dac1ccb 100644
572 +--- a/drivers/mtd/mtdchar.c
573 ++++ b/drivers/mtd/mtdchar.c
574 +@@ -160,8 +160,12 @@ static ssize_t mtdchar_read(struct file *file, char __user *buf, size_t count,
575 +
576 + pr_debug("MTD_read\n");
577 +
578 +- if (*ppos + count > mtd->size)
579 +- count = mtd->size - *ppos;
580 ++ if (*ppos + count > mtd->size) {
581 ++ if (*ppos < mtd->size)
582 ++ count = mtd->size - *ppos;
583 ++ else
584 ++ count = 0;
585 ++ }
586 +
587 + if (!count)
588 + return 0;
589 +@@ -246,7 +250,7 @@ static ssize_t mtdchar_write(struct file *file, const char __user *buf, size_t c
590 +
591 + pr_debug("MTD_write\n");
592 +
593 +- if (*ppos == mtd->size)
594 ++ if (*ppos >= mtd->size)
595 + return -ENOSPC;
596 +
597 + if (*ppos + count > mtd->size)
598 +diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
599 +index c2e110b2549b..c1217a87d535 100644
600 +--- a/drivers/net/ethernet/ti/cpsw.c
601 ++++ b/drivers/net/ethernet/ti/cpsw.c
602 +@@ -1164,25 +1164,34 @@ static void cpsw_slave_open(struct cpsw_slave *slave, struct cpsw_priv *priv)
603 + cpsw_ale_add_mcast(priv->ale, priv->ndev->broadcast,
604 + 1 << slave_port, 0, 0, ALE_MCAST_FWD_2);
605 +
606 +- if (slave->data->phy_node)
607 ++ if (slave->data->phy_node) {
608 + slave->phy = of_phy_connect(priv->ndev, slave->data->phy_node,
609 + &cpsw_adjust_link, 0, slave->data->phy_if);
610 +- else
611 ++ if (!slave->phy) {
612 ++ dev_err(priv->dev, "phy \"%s\" not found on slave %d\n",
613 ++ slave->data->phy_node->full_name,
614 ++ slave->slave_num);
615 ++ return;
616 ++ }
617 ++ } else {
618 + slave->phy = phy_connect(priv->ndev, slave->data->phy_id,
619 + &cpsw_adjust_link, slave->data->phy_if);
620 +- if (IS_ERR(slave->phy)) {
621 +- dev_err(priv->dev, "phy %s not found on slave %d\n",
622 +- slave->data->phy_id, slave->slave_num);
623 +- slave->phy = NULL;
624 +- } else {
625 +- dev_info(priv->dev, "phy found : id is : 0x%x\n",
626 +- slave->phy->phy_id);
627 +- phy_start(slave->phy);
628 +-
629 +- /* Configure GMII_SEL register */
630 +- cpsw_phy_sel(&priv->pdev->dev, slave->phy->interface,
631 +- slave->slave_num);
632 ++ if (IS_ERR(slave->phy)) {
633 ++ dev_err(priv->dev,
634 ++ "phy \"%s\" not found on slave %d, err %ld\n",
635 ++ slave->data->phy_id, slave->slave_num,
636 ++ PTR_ERR(slave->phy));
637 ++ slave->phy = NULL;
638 ++ return;
639 ++ }
640 + }
641 ++
642 ++ dev_info(priv->dev, "phy found : id is : 0x%x\n", slave->phy->phy_id);
643 ++
644 ++ phy_start(slave->phy);
645 ++
646 ++ /* Configure GMII_SEL register */
647 ++ cpsw_phy_sel(&priv->pdev->dev, slave->phy->interface, slave->slave_num);
648 + }
649 +
650 + static inline void cpsw_add_default_vlan(struct cpsw_priv *priv)
651 +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
652 +index 68d0a5c9d437..3270b4333668 100644
653 +--- a/drivers/net/xen-netfront.c
654 ++++ b/drivers/net/xen-netfront.c
655 +@@ -86,8 +86,7 @@ struct netfront_cb {
656 + /* IRQ name is queue name with "-tx" or "-rx" appended */
657 + #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3)
658 +
659 +-static DECLARE_WAIT_QUEUE_HEAD(module_load_q);
660 +-static DECLARE_WAIT_QUEUE_HEAD(module_unload_q);
661 ++static DECLARE_WAIT_QUEUE_HEAD(module_wq);
662 +
663 + struct netfront_stats {
664 + u64 packets;
665 +@@ -1336,11 +1335,11 @@ static struct net_device *xennet_create_dev(struct xenbus_device *dev)
666 + netif_carrier_off(netdev);
667 +
668 + xenbus_switch_state(dev, XenbusStateInitialising);
669 +- wait_event(module_load_q,
670 +- xenbus_read_driver_state(dev->otherend) !=
671 +- XenbusStateClosed &&
672 +- xenbus_read_driver_state(dev->otherend) !=
673 +- XenbusStateUnknown);
674 ++ wait_event(module_wq,
675 ++ xenbus_read_driver_state(dev->otherend) !=
676 ++ XenbusStateClosed &&
677 ++ xenbus_read_driver_state(dev->otherend) !=
678 ++ XenbusStateUnknown);
679 + return netdev;
680 +
681 + exit:
682 +@@ -1608,6 +1607,7 @@ static int xennet_init_queue(struct netfront_queue *queue)
683 + {
684 + unsigned short i;
685 + int err = 0;
686 ++ char *devid;
687 +
688 + spin_lock_init(&queue->tx_lock);
689 + spin_lock_init(&queue->rx_lock);
690 +@@ -1615,8 +1615,9 @@ static int xennet_init_queue(struct netfront_queue *queue)
691 + setup_timer(&queue->rx_refill_timer, rx_refill_timeout,
692 + (unsigned long)queue);
693 +
694 +- snprintf(queue->name, sizeof(queue->name), "%s-q%u",
695 +- queue->info->netdev->name, queue->id);
696 ++ devid = strrchr(queue->info->xbdev->nodename, '/') + 1;
697 ++ snprintf(queue->name, sizeof(queue->name), "vif%s-q%u",
698 ++ devid, queue->id);
699 +
700 + /* Initialise tx_skbs as a free chain containing every entry. */
701 + queue->tx_skb_freelist = 0;
702 +@@ -2023,15 +2024,14 @@ static void netback_changed(struct xenbus_device *dev,
703 +
704 + dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state));
705 +
706 ++ wake_up_all(&module_wq);
707 ++
708 + switch (backend_state) {
709 + case XenbusStateInitialising:
710 + case XenbusStateInitialised:
711 + case XenbusStateReconfiguring:
712 + case XenbusStateReconfigured:
713 +- break;
714 +-
715 + case XenbusStateUnknown:
716 +- wake_up_all(&module_unload_q);
717 + break;
718 +
719 + case XenbusStateInitWait:
720 +@@ -2047,12 +2047,10 @@ static void netback_changed(struct xenbus_device *dev,
721 + break;
722 +
723 + case XenbusStateClosed:
724 +- wake_up_all(&module_unload_q);
725 + if (dev->state == XenbusStateClosed)
726 + break;
727 + /* Missed the backend's CLOSING state -- fallthrough */
728 + case XenbusStateClosing:
729 +- wake_up_all(&module_unload_q);
730 + xenbus_frontend_closed(dev);
731 + break;
732 + }
733 +@@ -2160,14 +2158,14 @@ static int xennet_remove(struct xenbus_device *dev)
734 +
735 + if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) {
736 + xenbus_switch_state(dev, XenbusStateClosing);
737 +- wait_event(module_unload_q,
738 ++ wait_event(module_wq,
739 + xenbus_read_driver_state(dev->otherend) ==
740 + XenbusStateClosing ||
741 + xenbus_read_driver_state(dev->otherend) ==
742 + XenbusStateUnknown);
743 +
744 + xenbus_switch_state(dev, XenbusStateClosed);
745 +- wait_event(module_unload_q,
746 ++ wait_event(module_wq,
747 + xenbus_read_driver_state(dev->otherend) ==
748 + XenbusStateClosed ||
749 + xenbus_read_driver_state(dev->otherend) ==
750 +diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c
751 +index 01cf1c1a841a..8de329546b82 100644
752 +--- a/drivers/parport/parport_sunbpp.c
753 ++++ b/drivers/parport/parport_sunbpp.c
754 +@@ -286,12 +286,16 @@ static int bpp_probe(struct platform_device *op)
755 +
756 + ops = kmemdup(&parport_sunbpp_ops, sizeof(struct parport_operations),
757 + GFP_KERNEL);
758 +- if (!ops)
759 ++ if (!ops) {
760 ++ err = -ENOMEM;
761 + goto out_unmap;
762 ++ }
763 +
764 + dprintk(("register_port\n"));
765 +- if (!(p = parport_register_port((unsigned long)base, irq, dma, ops)))
766 ++ if (!(p = parport_register_port((unsigned long)base, irq, dma, ops))) {
767 ++ err = -ENOMEM;
768 + goto out_free_ops;
769 ++ }
770 +
771 + p->size = size;
772 + p->dev = &op->dev;
773 +diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
774 +index 6c42ca14d2fd..4ea810cafaac 100644
775 +--- a/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
776 ++++ b/drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
777 +@@ -291,31 +291,47 @@ static int pmic_gpio_config_get(struct pinctrl_dev *pctldev,
778 +
779 + switch (param) {
780 + case PIN_CONFIG_DRIVE_PUSH_PULL:
781 +- arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_CMOS;
782 ++ if (pad->buffer_type != PMIC_GPIO_OUT_BUF_CMOS)
783 ++ return -EINVAL;
784 ++ arg = 1;
785 + break;
786 + case PIN_CONFIG_DRIVE_OPEN_DRAIN:
787 +- arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS;
788 ++ if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_NMOS)
789 ++ return -EINVAL;
790 ++ arg = 1;
791 + break;
792 + case PIN_CONFIG_DRIVE_OPEN_SOURCE:
793 +- arg = pad->buffer_type == PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS;
794 ++ if (pad->buffer_type != PMIC_GPIO_OUT_BUF_OPEN_DRAIN_PMOS)
795 ++ return -EINVAL;
796 ++ arg = 1;
797 + break;
798 + case PIN_CONFIG_BIAS_PULL_DOWN:
799 +- arg = pad->pullup == PMIC_GPIO_PULL_DOWN;
800 ++ if (pad->pullup != PMIC_GPIO_PULL_DOWN)
801 ++ return -EINVAL;
802 ++ arg = 1;
803 + break;
804 + case PIN_CONFIG_BIAS_DISABLE:
805 +- arg = pad->pullup = PMIC_GPIO_PULL_DISABLE;
806 ++ if (pad->pullup != PMIC_GPIO_PULL_DISABLE)
807 ++ return -EINVAL;
808 ++ arg = 1;
809 + break;
810 + case PIN_CONFIG_BIAS_PULL_UP:
811 +- arg = pad->pullup == PMIC_GPIO_PULL_UP_30;
812 ++ if (pad->pullup != PMIC_GPIO_PULL_UP_30)
813 ++ return -EINVAL;
814 ++ arg = 1;
815 + break;
816 + case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
817 +- arg = !pad->is_enabled;
818 ++ if (pad->is_enabled)
819 ++ return -EINVAL;
820 ++ arg = 1;
821 + break;
822 + case PIN_CONFIG_POWER_SOURCE:
823 + arg = pad->power_source;
824 + break;
825 + case PIN_CONFIG_INPUT_ENABLE:
826 +- arg = pad->input_enabled;
827 ++ if (!pad->input_enabled)
828 ++ return -EINVAL;
829 ++ arg = 1;
830 + break;
831 + case PIN_CONFIG_OUTPUT:
832 + arg = pad->out_value;
833 +diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
834 +index f774cb576ffa..1ff95b5a429d 100644
835 +--- a/drivers/platform/x86/toshiba_acpi.c
836 ++++ b/drivers/platform/x86/toshiba_acpi.c
837 +@@ -34,6 +34,7 @@
838 + #define TOSHIBA_ACPI_VERSION "0.23"
839 + #define PROC_INTERFACE_VERSION 1
840 +
841 ++#include <linux/compiler.h>
842 + #include <linux/kernel.h>
843 + #include <linux/module.h>
844 + #include <linux/init.h>
845 +@@ -1472,7 +1473,7 @@ static const struct file_operations keys_proc_fops = {
846 + .write = keys_proc_write,
847 + };
848 +
849 +-static int version_proc_show(struct seq_file *m, void *v)
850 ++static int __maybe_unused version_proc_show(struct seq_file *m, void *v)
851 + {
852 + seq_printf(m, "driver: %s\n", TOSHIBA_ACPI_VERSION);
853 + seq_printf(m, "proc_interface: %d\n", PROC_INTERFACE_VERSION);
854 +diff --git a/drivers/rtc/rtc-bq4802.c b/drivers/rtc/rtc-bq4802.c
855 +index bd170cb3361c..5747a54cbd42 100644
856 +--- a/drivers/rtc/rtc-bq4802.c
857 ++++ b/drivers/rtc/rtc-bq4802.c
858 +@@ -164,6 +164,10 @@ static int bq4802_probe(struct platform_device *pdev)
859 + } else if (p->r->flags & IORESOURCE_MEM) {
860 + p->regs = devm_ioremap(&pdev->dev, p->r->start,
861 + resource_size(p->r));
862 ++ if (!p->regs){
863 ++ err = -ENOMEM;
864 ++ goto out;
865 ++ }
866 + p->read = bq4802_read_mem;
867 + p->write = bq4802_write_mem;
868 + } else {
869 +diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
870 +index 95c631125a20..09ac56317f1b 100644
871 +--- a/drivers/s390/net/qeth_core_main.c
872 ++++ b/drivers/s390/net/qeth_core_main.c
873 +@@ -3505,13 +3505,14 @@ static void qeth_flush_buffers(struct qeth_qdio_out_q *queue, int index,
874 + qdio_flags = QDIO_FLAG_SYNC_OUTPUT;
875 + if (atomic_read(&queue->set_pci_flags_count))
876 + qdio_flags |= QDIO_FLAG_PCI_OUT;
877 ++ atomic_add(count, &queue->used_buffers);
878 ++
879 + rc = do_QDIO(CARD_DDEV(queue->card), qdio_flags,
880 + queue->queue_no, index, count);
881 + if (queue->card->options.performance_stats)
882 + queue->card->perf_stats.outbound_do_qdio_time +=
883 + qeth_get_micros() -
884 + queue->card->perf_stats.outbound_do_qdio_start_time;
885 +- atomic_add(count, &queue->used_buffers);
886 + if (rc) {
887 + queue->card->stats.tx_errors += count;
888 + /* ignore temporary SIGA errors without busy condition */
889 +diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
890 +index fa844b0ff847..7bcf0dae3a65 100644
891 +--- a/drivers/s390/net/qeth_core_sys.c
892 ++++ b/drivers/s390/net/qeth_core_sys.c
893 +@@ -419,6 +419,7 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,
894 + if (card->discipline) {
895 + card->discipline->remove(card->gdev);
896 + qeth_core_free_discipline(card);
897 ++ card->options.layer2 = -1;
898 + }
899 +
900 + rc = qeth_core_load_discipline(card, newdis);
901 +diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
902 +index 61ea87917433..4380e4f600ab 100644
903 +--- a/drivers/usb/class/cdc-wdm.c
904 ++++ b/drivers/usb/class/cdc-wdm.c
905 +@@ -453,7 +453,7 @@ static int clear_wdm_read_flag(struct wdm_device *desc)
906 +
907 + set_bit(WDM_RESPONDING, &desc->flags);
908 + spin_unlock_irq(&desc->iuspin);
909 +- rv = usb_submit_urb(desc->response, GFP_KERNEL);
910 ++ rv = usb_submit_urb(desc->response, GFP_ATOMIC);
911 + spin_lock_irq(&desc->iuspin);
912 + if (rv) {
913 + dev_err(&desc->intf->dev,
914 +diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
915 +index 40378487e023..a5e3e410db4e 100644
916 +--- a/drivers/usb/core/hcd-pci.c
917 ++++ b/drivers/usb/core/hcd-pci.c
918 +@@ -529,8 +529,6 @@ static int resume_common(struct device *dev, int event)
919 + event == PM_EVENT_RESTORE);
920 + if (retval) {
921 + dev_err(dev, "PCI post-resume error %d!\n", retval);
922 +- if (hcd->shared_hcd)
923 +- usb_hc_died(hcd->shared_hcd);
924 + usb_hc_died(hcd);
925 + }
926 + }
927 +diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
928 +index 29adabdb305f..08cba309eb78 100644
929 +--- a/drivers/usb/core/message.c
930 ++++ b/drivers/usb/core/message.c
931 +@@ -1282,6 +1282,11 @@ void usb_enable_interface(struct usb_device *dev,
932 + * is submitted that needs that bandwidth. Some other operating systems
933 + * allocate bandwidth early, when a configuration is chosen.
934 + *
935 ++ * xHCI reserves bandwidth and configures the alternate setting in
936 ++ * usb_hcd_alloc_bandwidth(). If it fails the original interface altsetting
937 ++ * may be disabled. Drivers cannot rely on any particular alternate
938 ++ * setting being in effect after a failure.
939 ++ *
940 + * This call is synchronous, and may not be used in an interrupt context.
941 + * Also, drivers must not change altsettings while urbs are scheduled for
942 + * endpoints in that interface; all such urbs must first be completed
943 +@@ -1317,6 +1322,12 @@ int usb_set_interface(struct usb_device *dev, int interface, int alternate)
944 + alternate);
945 + return -EINVAL;
946 + }
947 ++ /*
948 ++ * usb3 hosts configure the interface in usb_hcd_alloc_bandwidth,
949 ++ * including freeing dropped endpoint ring buffers.
950 ++ * Make sure the interface endpoints are flushed before that
951 ++ */
952 ++ usb_disable_interface(dev, iface, false);
953 +
954 + /* Make sure we have enough bandwidth for this alternate interface.
955 + * Remove the current alt setting and add the new alt setting.
956 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
957 +index 99f67764765f..37a5e07b3488 100644
958 +--- a/drivers/usb/core/quirks.c
959 ++++ b/drivers/usb/core/quirks.c
960 +@@ -37,6 +37,10 @@ static const struct usb_device_id usb_quirk_list[] = {
961 + /* CBM - Flash disk */
962 + { USB_DEVICE(0x0204, 0x6025), .driver_info = USB_QUIRK_RESET_RESUME },
963 +
964 ++ /* WORLDE Controller KS49 or Prodipe MIDI 49C USB controller */
965 ++ { USB_DEVICE(0x0218, 0x0201), .driver_info =
966 ++ USB_QUIRK_CONFIG_INTF_STRINGS },
967 ++
968 + /* WORLDE easy key (easykey.25) MIDI controller */
969 + { USB_DEVICE(0x0218, 0x0401), .driver_info =
970 + USB_QUIRK_CONFIG_INTF_STRINGS },
971 +@@ -259,6 +263,9 @@ static const struct usb_device_id usb_quirk_list[] = {
972 + { USB_DEVICE(0x2040, 0x7200), .driver_info =
973 + USB_QUIRK_CONFIG_INTF_STRINGS },
974 +
975 ++ /* DJI CineSSD */
976 ++ { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
977 ++
978 + /* INTEL VALUE SSD */
979 + { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME },
980 +
981 +diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c
982 +index a47de8c31ce9..8efeadf30b4d 100644
983 +--- a/drivers/usb/gadget/udc/net2280.c
984 ++++ b/drivers/usb/gadget/udc/net2280.c
985 +@@ -1542,11 +1542,14 @@ static int net2280_pullup(struct usb_gadget *_gadget, int is_on)
986 + writel(tmp | BIT(USB_DETECT_ENABLE), &dev->usb->usbctl);
987 + } else {
988 + writel(tmp & ~BIT(USB_DETECT_ENABLE), &dev->usb->usbctl);
989 +- stop_activity(dev, dev->driver);
990 ++ stop_activity(dev, NULL);
991 + }
992 +
993 + spin_unlock_irqrestore(&dev->lock, flags);
994 +
995 ++ if (!is_on && dev->driver)
996 ++ dev->driver->disconnect(&dev->gadget);
997 ++
998 + return 0;
999 + }
1000 +
1001 +@@ -2425,8 +2428,11 @@ static void stop_activity(struct net2280 *dev, struct usb_gadget_driver *driver)
1002 + nuke(&dev->ep[i]);
1003 +
1004 + /* report disconnect; the driver is already quiesced */
1005 +- if (driver)
1006 ++ if (driver) {
1007 ++ spin_unlock(&dev->lock);
1008 + driver->disconnect(&dev->gadget);
1009 ++ spin_lock(&dev->lock);
1010 ++ }
1011 +
1012 + usb_reinit(dev);
1013 + }
1014 +@@ -3272,6 +3278,8 @@ next_endpoints:
1015 + BIT(PCI_RETRY_ABORT_INTERRUPT))
1016 +
1017 + static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
1018 ++__releases(dev->lock)
1019 ++__acquires(dev->lock)
1020 + {
1021 + struct net2280_ep *ep;
1022 + u32 tmp, num, mask, scratch;
1023 +@@ -3312,12 +3320,14 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
1024 + if (disconnect || reset) {
1025 + stop_activity(dev, dev->driver);
1026 + ep0_start(dev);
1027 ++ spin_unlock(&dev->lock);
1028 + if (reset)
1029 + usb_gadget_udc_reset
1030 + (&dev->gadget, dev->driver);
1031 + else
1032 + (dev->driver->disconnect)
1033 + (&dev->gadget);
1034 ++ spin_lock(&dev->lock);
1035 + return;
1036 + }
1037 + }
1038 +@@ -3336,6 +3346,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
1039 + tmp = BIT(SUSPEND_REQUEST_CHANGE_INTERRUPT);
1040 + if (stat & tmp) {
1041 + writel(tmp, &dev->regs->irqstat1);
1042 ++ spin_unlock(&dev->lock);
1043 + if (stat & BIT(SUSPEND_REQUEST_INTERRUPT)) {
1044 + if (dev->driver->suspend)
1045 + dev->driver->suspend(&dev->gadget);
1046 +@@ -3346,6 +3357,7 @@ static void handle_stat1_irqs(struct net2280 *dev, u32 stat)
1047 + dev->driver->resume(&dev->gadget);
1048 + /* at high speed, note erratum 0133 */
1049 + }
1050 ++ spin_lock(&dev->lock);
1051 + stat &= ~tmp;
1052 + }
1053 +
1054 +diff --git a/drivers/usb/host/u132-hcd.c b/drivers/usb/host/u132-hcd.c
1055 +index 692ccc69345e..d5434e7a3b2e 100644
1056 +--- a/drivers/usb/host/u132-hcd.c
1057 ++++ b/drivers/usb/host/u132-hcd.c
1058 +@@ -2565,7 +2565,7 @@ static int u132_get_frame(struct usb_hcd *hcd)
1059 + } else {
1060 + int frame = 0;
1061 + dev_err(&u132->platform_dev->dev, "TODO: u132_get_frame\n");
1062 +- msleep(100);
1063 ++ mdelay(100);
1064 + return frame;
1065 + }
1066 + }
1067 +diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
1068 +index 442b6631162e..3d750671b85a 100644
1069 +--- a/drivers/usb/misc/uss720.c
1070 ++++ b/drivers/usb/misc/uss720.c
1071 +@@ -388,7 +388,7 @@ static unsigned char parport_uss720_frob_control(struct parport *pp, unsigned ch
1072 + mask &= 0x0f;
1073 + val &= 0x0f;
1074 + d = (priv->reg[1] & (~mask)) ^ val;
1075 +- if (set_1284_register(pp, 2, d, GFP_KERNEL))
1076 ++ if (set_1284_register(pp, 2, d, GFP_ATOMIC))
1077 + return 0;
1078 + priv->reg[1] = d;
1079 + return d & 0xf;
1080 +@@ -398,7 +398,7 @@ static unsigned char parport_uss720_read_status(struct parport *pp)
1081 + {
1082 + unsigned char ret;
1083 +
1084 +- if (get_1284_register(pp, 1, &ret, GFP_KERNEL))
1085 ++ if (get_1284_register(pp, 1, &ret, GFP_ATOMIC))
1086 + return 0;
1087 + return ret & 0xf8;
1088 + }
1089 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
1090 +index 512c84adcace..e8e8702d5adf 100644
1091 +--- a/drivers/usb/misc/yurex.c
1092 ++++ b/drivers/usb/misc/yurex.c
1093 +@@ -439,13 +439,13 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
1094 + {
1095 + struct usb_yurex *dev;
1096 + int i, set = 0, retval = 0;
1097 +- char buffer[16];
1098 ++ char buffer[16 + 1];
1099 + char *data = buffer;
1100 + unsigned long long c, c2 = 0;
1101 + signed long timeout = 0;
1102 + DEFINE_WAIT(wait);
1103 +
1104 +- count = min(sizeof(buffer), count);
1105 ++ count = min(sizeof(buffer) - 1, count);
1106 + dev = file->private_data;
1107 +
1108 + /* verify that we actually have some data to write */
1109 +@@ -464,6 +464,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
1110 + retval = -EFAULT;
1111 + goto error;
1112 + }
1113 ++ buffer[count] = 0;
1114 + memset(dev->cntl_buffer, CMD_PADDING, YUREX_BUF_SIZE);
1115 +
1116 + switch (buffer[0]) {
1117 +diff --git a/drivers/usb/serial/io_ti.h b/drivers/usb/serial/io_ti.h
1118 +index 1bd67b24f916..bc9ff5ebd67c 100644
1119 +--- a/drivers/usb/serial/io_ti.h
1120 ++++ b/drivers/usb/serial/io_ti.h
1121 +@@ -178,7 +178,7 @@ struct ump_interrupt {
1122 + } __attribute__((packed));
1123 +
1124 +
1125 +-#define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 4) - 3)
1126 ++#define TIUMP_GET_PORT_FROM_CODE(c) (((c) >> 6) & 0x01)
1127 + #define TIUMP_GET_FUNC_FROM_CODE(c) ((c) & 0x0f)
1128 + #define TIUMP_INTERRUPT_CODE_LSR 0x03
1129 + #define TIUMP_INTERRUPT_CODE_MSR 0x04
1130 +diff --git a/drivers/usb/serial/ti_usb_3410_5052.h b/drivers/usb/serial/ti_usb_3410_5052.h
1131 +index 98f35c656c02..0cd247f75b8b 100644
1132 +--- a/drivers/usb/serial/ti_usb_3410_5052.h
1133 ++++ b/drivers/usb/serial/ti_usb_3410_5052.h
1134 +@@ -227,7 +227,7 @@ struct ti_interrupt {
1135 + } __attribute__((packed));
1136 +
1137 + /* Interrupt codes */
1138 +-#define TI_GET_PORT_FROM_CODE(c) (((c) >> 4) - 3)
1139 ++#define TI_GET_PORT_FROM_CODE(c) (((c) >> 6) & 0x01)
1140 + #define TI_GET_FUNC_FROM_CODE(c) ((c) & 0x0f)
1141 + #define TI_CODE_HARDWARE_ERROR 0xFF
1142 + #define TI_CODE_DATA_ERROR 0x03
1143 +diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
1144 +index dba51362d2e2..6c186b4df94a 100644
1145 +--- a/drivers/usb/storage/scsiglue.c
1146 ++++ b/drivers/usb/storage/scsiglue.c
1147 +@@ -341,6 +341,15 @@ static int queuecommand_lck(struct scsi_cmnd *srb,
1148 + return 0;
1149 + }
1150 +
1151 ++ if ((us->fflags & US_FL_NO_ATA_1X) &&
1152 ++ (srb->cmnd[0] == ATA_12 || srb->cmnd[0] == ATA_16)) {
1153 ++ memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
1154 ++ sizeof(usb_stor_sense_invalidCDB));
1155 ++ srb->result = SAM_STAT_CHECK_CONDITION;
1156 ++ done(srb);
1157 ++ return 0;
1158 ++ }
1159 ++
1160 + /* enqueue the command and wake up the control thread */
1161 + srb->scsi_done = done;
1162 + us->srb = srb;
1163 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1164 +index 1a34d2a89de6..898215cad351 100644
1165 +--- a/drivers/usb/storage/unusual_devs.h
1166 ++++ b/drivers/usb/storage/unusual_devs.h
1167 +@@ -2213,6 +2213,13 @@ UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100,
1168 + "Micro Mini 1GB",
1169 + USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
1170 +
1171 ++/* Reported-by: Tim Anderson <tsa@×××××××××××××××.com> */
1172 ++UNUSUAL_DEV( 0x2ca3, 0x0031, 0x0000, 0x9999,
1173 ++ "DJI",
1174 ++ "CineSSD",
1175 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1176 ++ US_FL_NO_ATA_1X),
1177 ++
1178 + /*
1179 + * Nick Bowler <nbowler@××××××××××××.com>
1180 + * SCSI stack spams (otherwise harmless) error messages.
1181 +diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c
1182 +index 2510fa728d77..de119f11b78f 100644
1183 +--- a/drivers/video/fbdev/core/modedb.c
1184 ++++ b/drivers/video/fbdev/core/modedb.c
1185 +@@ -644,7 +644,7 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info,
1186 + *
1187 + * Valid mode specifiers for @mode_option:
1188 + *
1189 +- * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] or
1190 ++ * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][p][m] or
1191 + * <name>[-<bpp>][@<refresh>]
1192 + *
1193 + * with <xres>, <yres>, <bpp> and <refresh> decimal numbers and
1194 +@@ -653,10 +653,10 @@ static int fb_try_mode(struct fb_var_screeninfo *var, struct fb_info *info,
1195 + * If 'M' is present after yres (and before refresh/bpp if present),
1196 + * the function will compute the timings using VESA(tm) Coordinated
1197 + * Video Timings (CVT). If 'R' is present after 'M', will compute with
1198 +- * reduced blanking (for flatpanels). If 'i' is present, compute
1199 +- * interlaced mode. If 'm' is present, add margins equal to 1.8%
1200 +- * of xres rounded down to 8 pixels, and 1.8% of yres. The char
1201 +- * 'i' and 'm' must be after 'M' and 'R'. Example:
1202 ++ * reduced blanking (for flatpanels). If 'i' or 'p' are present, compute
1203 ++ * interlaced or progressive mode. If 'm' is present, add margins equal
1204 ++ * to 1.8% of xres rounded down to 8 pixels, and 1.8% of yres. The chars
1205 ++ * 'i', 'p' and 'm' must be after 'M' and 'R'. Example:
1206 + *
1207 + * 1024x768MR-8@60m - Reduced blank with margins at 60Hz.
1208 + *
1209 +@@ -697,7 +697,8 @@ int fb_find_mode(struct fb_var_screeninfo *var,
1210 + unsigned int namelen = strlen(name);
1211 + int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
1212 + unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
1213 +- int yres_specified = 0, cvt = 0, rb = 0, interlace = 0;
1214 ++ int yres_specified = 0, cvt = 0, rb = 0;
1215 ++ int interlace_specified = 0, interlace = 0;
1216 + int margins = 0;
1217 + u32 best, diff, tdiff;
1218 +
1219 +@@ -748,9 +749,17 @@ int fb_find_mode(struct fb_var_screeninfo *var,
1220 + if (!cvt)
1221 + margins = 1;
1222 + break;
1223 ++ case 'p':
1224 ++ if (!cvt) {
1225 ++ interlace = 0;
1226 ++ interlace_specified = 1;
1227 ++ }
1228 ++ break;
1229 + case 'i':
1230 +- if (!cvt)
1231 ++ if (!cvt) {
1232 + interlace = 1;
1233 ++ interlace_specified = 1;
1234 ++ }
1235 + break;
1236 + default:
1237 + goto done;
1238 +@@ -819,11 +828,21 @@ done:
1239 + if ((name_matches(db[i], name, namelen) ||
1240 + (res_specified && res_matches(db[i], xres, yres))) &&
1241 + !fb_try_mode(var, info, &db[i], bpp)) {
1242 +- if (refresh_specified && db[i].refresh == refresh)
1243 +- return 1;
1244 ++ const int db_interlace = (db[i].vmode &
1245 ++ FB_VMODE_INTERLACED ? 1 : 0);
1246 ++ int score = abs(db[i].refresh - refresh);
1247 ++
1248 ++ if (interlace_specified)
1249 ++ score += abs(db_interlace - interlace);
1250 ++
1251 ++ if (!interlace_specified ||
1252 ++ db_interlace == interlace)
1253 ++ if (refresh_specified &&
1254 ++ db[i].refresh == refresh)
1255 ++ return 1;
1256 +
1257 +- if (abs(db[i].refresh - refresh) < diff) {
1258 +- diff = abs(db[i].refresh - refresh);
1259 ++ if (score < diff) {
1260 ++ diff = score;
1261 + best = i;
1262 + }
1263 + }
1264 +diff --git a/drivers/video/fbdev/goldfishfb.c b/drivers/video/fbdev/goldfishfb.c
1265 +index 7f6c9e6cfc6c..14a93cb21310 100644
1266 +--- a/drivers/video/fbdev/goldfishfb.c
1267 ++++ b/drivers/video/fbdev/goldfishfb.c
1268 +@@ -301,6 +301,7 @@ static int goldfish_fb_remove(struct platform_device *pdev)
1269 + dma_free_coherent(&pdev->dev, framesize, (void *)fb->fb.screen_base,
1270 + fb->fb.fix.smem_start);
1271 + iounmap(fb->reg_base);
1272 ++ kfree(fb);
1273 + return 0;
1274 + }
1275 +
1276 +diff --git a/drivers/video/fbdev/omap/omapfb_main.c b/drivers/video/fbdev/omap/omapfb_main.c
1277 +index 393ae1bc07e8..a8a6f072fb78 100644
1278 +--- a/drivers/video/fbdev/omap/omapfb_main.c
1279 ++++ b/drivers/video/fbdev/omap/omapfb_main.c
1280 +@@ -977,7 +977,7 @@ int omapfb_register_client(struct omapfb_notifier_block *omapfb_nb,
1281 + {
1282 + int r;
1283 +
1284 +- if ((unsigned)omapfb_nb->plane_idx > OMAPFB_PLANE_NUM)
1285 ++ if ((unsigned)omapfb_nb->plane_idx >= OMAPFB_PLANE_NUM)
1286 + return -EINVAL;
1287 +
1288 + if (!notifier_inited) {
1289 +diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c
1290 +index badee04ef496..71b5dca95bdb 100644
1291 +--- a/drivers/video/fbdev/via/viafbdev.c
1292 ++++ b/drivers/video/fbdev/via/viafbdev.c
1293 +@@ -19,6 +19,7 @@
1294 + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1295 + */
1296 +
1297 ++#include <linux/compiler.h>
1298 + #include <linux/module.h>
1299 + #include <linux/seq_file.h>
1300 + #include <linux/slab.h>
1301 +@@ -1468,7 +1469,7 @@ static const struct file_operations viafb_vt1636_proc_fops = {
1302 +
1303 + #endif /* CONFIG_FB_VIA_DIRECT_PROCFS */
1304 +
1305 +-static int viafb_sup_odev_proc_show(struct seq_file *m, void *v)
1306 ++static int __maybe_unused viafb_sup_odev_proc_show(struct seq_file *m, void *v)
1307 + {
1308 + via_odev_to_seq(m, supported_odev_map[
1309 + viaparinfo->shared->chip_info.gfx_chip_name]);
1310 +diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
1311 +index f44e93d2650d..62bc72001fce 100644
1312 +--- a/fs/binfmt_elf.c
1313 ++++ b/fs/binfmt_elf.c
1314 +@@ -1707,7 +1707,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
1315 + const struct user_regset *regset = &view->regsets[i];
1316 + do_thread_regset_writeback(t->task, regset);
1317 + if (regset->core_note_type && regset->get &&
1318 +- (!regset->active || regset->active(t->task, regset))) {
1319 ++ (!regset->active || regset->active(t->task, regset) > 0)) {
1320 + int ret;
1321 + size_t size = regset->n * regset->size;
1322 + void *data = kmalloc(size, GFP_KERNEL);
1323 +diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
1324 +index 97d1a15873c5..57b039ebfb1f 100644
1325 +--- a/fs/cifs/readdir.c
1326 ++++ b/fs/cifs/readdir.c
1327 +@@ -373,8 +373,15 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
1328 +
1329 + new_entry = old_entry + sizeof(FIND_FILE_STANDARD_INFO) +
1330 + pfData->FileNameLength;
1331 +- } else
1332 +- new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
1333 ++ } else {
1334 ++ u32 next_offset = le32_to_cpu(pDirInfo->NextEntryOffset);
1335 ++
1336 ++ if (old_entry + next_offset < old_entry) {
1337 ++ cifs_dbg(VFS, "invalid offset %u\n", next_offset);
1338 ++ return NULL;
1339 ++ }
1340 ++ new_entry = old_entry + next_offset;
1341 ++ }
1342 + cifs_dbg(FYI, "new entry %p old entry %p\n", new_entry, old_entry);
1343 + /* validate that new_entry is not past end of SMB */
1344 + if (new_entry >= end_of_smb) {
1345 +diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
1346 +index 52d79fb04115..f7111bb88ec1 100644
1347 +--- a/fs/cifs/smb2pdu.c
1348 ++++ b/fs/cifs/smb2pdu.c
1349 +@@ -2402,33 +2402,38 @@ num_entries(char *bufstart, char *end_of_buf, char **lastentry, size_t size)
1350 + int len;
1351 + unsigned int entrycount = 0;
1352 + unsigned int next_offset = 0;
1353 +- FILE_DIRECTORY_INFO *entryptr;
1354 ++ char *entryptr;
1355 ++ FILE_DIRECTORY_INFO *dir_info;
1356 +
1357 + if (bufstart == NULL)
1358 + return 0;
1359 +
1360 +- entryptr = (FILE_DIRECTORY_INFO *)bufstart;
1361 ++ entryptr = bufstart;
1362 +
1363 + while (1) {
1364 +- entryptr = (FILE_DIRECTORY_INFO *)
1365 +- ((char *)entryptr + next_offset);
1366 +-
1367 +- if ((char *)entryptr + size > end_of_buf) {
1368 ++ if (entryptr + next_offset < entryptr ||
1369 ++ entryptr + next_offset > end_of_buf ||
1370 ++ entryptr + next_offset + size > end_of_buf) {
1371 + cifs_dbg(VFS, "malformed search entry would overflow\n");
1372 + break;
1373 + }
1374 +
1375 +- len = le32_to_cpu(entryptr->FileNameLength);
1376 +- if ((char *)entryptr + len + size > end_of_buf) {
1377 ++ entryptr = entryptr + next_offset;
1378 ++ dir_info = (FILE_DIRECTORY_INFO *)entryptr;
1379 ++
1380 ++ len = le32_to_cpu(dir_info->FileNameLength);
1381 ++ if (entryptr + len < entryptr ||
1382 ++ entryptr + len > end_of_buf ||
1383 ++ entryptr + len + size > end_of_buf) {
1384 + cifs_dbg(VFS, "directory entry name would overflow frame end of buf %p\n",
1385 + end_of_buf);
1386 + break;
1387 + }
1388 +
1389 +- *lastentry = (char *)entryptr;
1390 ++ *lastentry = entryptr;
1391 + entrycount++;
1392 +
1393 +- next_offset = le32_to_cpu(entryptr->NextEntryOffset);
1394 ++ next_offset = le32_to_cpu(dir_info->NextEntryOffset);
1395 + if (!next_offset)
1396 + break;
1397 + }
1398 +diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
1399 +index 61296ecbd0e2..09476bb8f6cd 100644
1400 +--- a/fs/gfs2/bmap.c
1401 ++++ b/fs/gfs2/bmap.c
1402 +@@ -1476,7 +1476,7 @@ int gfs2_write_alloc_required(struct gfs2_inode *ip, u64 offset,
1403 + end_of_file = (i_size_read(&ip->i_inode) + sdp->sd_sb.sb_bsize - 1) >> shift;
1404 + lblock = offset >> shift;
1405 + lblock_stop = (offset + len + sdp->sd_sb.sb_bsize - 1) >> shift;
1406 +- if (lblock_stop > end_of_file)
1407 ++ if (lblock_stop > end_of_file && ip != GFS2_I(sdp->sd_rindex))
1408 + return 1;
1409 +
1410 + size = (lblock_stop - lblock) << shift;
1411 +diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
1412 +index 27300533c2dd..bd21795ce657 100644
1413 +--- a/fs/pstore/ram_core.c
1414 ++++ b/fs/pstore/ram_core.c
1415 +@@ -378,7 +378,12 @@ static void *persistent_ram_vmap(phys_addr_t start, size_t size,
1416 + vaddr = vmap(pages, page_count, VM_MAP, prot);
1417 + kfree(pages);
1418 +
1419 +- return vaddr;
1420 ++ /*
1421 ++ * Since vmap() uses page granularity, we must add the offset
1422 ++ * into the page here, to get the byte granularity address
1423 ++ * into the mapping to represent the actual "start" location.
1424 ++ */
1425 ++ return vaddr + offset_in_page(start);
1426 + }
1427 +
1428 + static void *persistent_ram_iomap(phys_addr_t start, size_t size,
1429 +@@ -397,6 +402,11 @@ static void *persistent_ram_iomap(phys_addr_t start, size_t size,
1430 + else
1431 + va = ioremap_wc(start, size);
1432 +
1433 ++ /*
1434 ++ * Since request_mem_region() and ioremap() are byte-granularity
1435 ++ * there is no need handle anything special like we do when the
1436 ++ * vmap() case in persistent_ram_vmap() above.
1437 ++ */
1438 + return va;
1439 + }
1440 +
1441 +@@ -417,7 +427,7 @@ static int persistent_ram_buffer_map(phys_addr_t start, phys_addr_t size,
1442 + return -ENOMEM;
1443 + }
1444 +
1445 +- prz->buffer = prz->vaddr + offset_in_page(start);
1446 ++ prz->buffer = prz->vaddr;
1447 + prz->buffer_size = size - sizeof(struct persistent_ram_buffer);
1448 +
1449 + return 0;
1450 +@@ -464,7 +474,8 @@ void persistent_ram_free(struct persistent_ram_zone *prz)
1451 +
1452 + if (prz->vaddr) {
1453 + if (pfn_valid(prz->paddr >> PAGE_SHIFT)) {
1454 +- vunmap(prz->vaddr);
1455 ++ /* We must vunmap() at page-granularity. */
1456 ++ vunmap(prz->vaddr - offset_in_page(prz->paddr));
1457 + } else {
1458 + iounmap(prz->vaddr);
1459 + release_mem_region(prz->paddr, prz->size);
1460 +diff --git a/kernel/audit_watch.c b/kernel/audit_watch.c
1461 +index a162661c9d60..f45a9a5d3e47 100644
1462 +--- a/kernel/audit_watch.c
1463 ++++ b/kernel/audit_watch.c
1464 +@@ -419,6 +419,13 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
1465 + struct path parent_path;
1466 + int h, ret = 0;
1467 +
1468 ++ /*
1469 ++ * When we will be calling audit_add_to_parent, krule->watch might have
1470 ++ * been updated and watch might have been freed.
1471 ++ * So we need to keep a reference of watch.
1472 ++ */
1473 ++ audit_get_watch(watch);
1474 ++
1475 + mutex_unlock(&audit_filter_mutex);
1476 +
1477 + /* Avoid calling path_lookup under audit_filter_mutex. */
1478 +@@ -427,8 +434,10 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
1479 + /* caller expects mutex locked */
1480 + mutex_lock(&audit_filter_mutex);
1481 +
1482 +- if (ret)
1483 ++ if (ret) {
1484 ++ audit_put_watch(watch);
1485 + return ret;
1486 ++ }
1487 +
1488 + /* either find an old parent or attach a new one */
1489 + parent = audit_find_parent(d_backing_inode(parent_path.dentry));
1490 +@@ -446,6 +455,7 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
1491 + *list = &audit_inode_hash[h];
1492 + error:
1493 + path_put(&parent_path);
1494 ++ audit_put_watch(watch);
1495 + return ret;
1496 + }
1497 +
1498 +diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
1499 +index 00a8cc572a22..1f930032253a 100644
1500 +--- a/net/mac80211/cfg.c
1501 ++++ b/net/mac80211/cfg.c
1502 +@@ -286,7 +286,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
1503 + goto out_unlock;
1504 + }
1505 +
1506 +- ieee80211_key_free(key, true);
1507 ++ ieee80211_key_free(key, sdata->vif.type == NL80211_IFTYPE_STATION);
1508 +
1509 + ret = 0;
1510 + out_unlock:
1511 +diff --git a/net/mac80211/key.c b/net/mac80211/key.c
1512 +index 4a72c0d1e56f..91a4e606edcd 100644
1513 +--- a/net/mac80211/key.c
1514 ++++ b/net/mac80211/key.c
1515 +@@ -647,11 +647,15 @@ int ieee80211_key_link(struct ieee80211_key *key,
1516 + {
1517 + struct ieee80211_local *local = sdata->local;
1518 + struct ieee80211_key *old_key;
1519 +- int idx, ret;
1520 +- bool pairwise;
1521 +-
1522 +- pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
1523 +- idx = key->conf.keyidx;
1524 ++ int idx = key->conf.keyidx;
1525 ++ bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
1526 ++ /*
1527 ++ * We want to delay tailroom updates only for station - in that
1528 ++ * case it helps roaming speed, but in other cases it hurts and
1529 ++ * can cause warnings to appear.
1530 ++ */
1531 ++ bool delay_tailroom = sdata->vif.type == NL80211_IFTYPE_STATION;
1532 ++ int ret;
1533 +
1534 + mutex_lock(&sdata->local->key_mtx);
1535 +
1536 +@@ -679,14 +683,14 @@ int ieee80211_key_link(struct ieee80211_key *key,
1537 + increment_tailroom_need_count(sdata);
1538 +
1539 + ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
1540 +- ieee80211_key_destroy(old_key, true);
1541 ++ ieee80211_key_destroy(old_key, delay_tailroom);
1542 +
1543 + ieee80211_debugfs_key_add(key);
1544 +
1545 + if (!local->wowlan) {
1546 + ret = ieee80211_key_enable_hw_accel(key);
1547 + if (ret)
1548 +- ieee80211_key_free(key, true);
1549 ++ ieee80211_key_free(key, delay_tailroom);
1550 + } else {
1551 + ret = 0;
1552 + }
1553 +@@ -874,7 +878,8 @@ void ieee80211_free_sta_keys(struct ieee80211_local *local,
1554 + ieee80211_key_replace(key->sdata, key->sta,
1555 + key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE,
1556 + key, NULL);
1557 +- __ieee80211_key_destroy(key, true);
1558 ++ __ieee80211_key_destroy(key, key->sdata->vif.type ==
1559 ++ NL80211_IFTYPE_STATION);
1560 + }
1561 +
1562 + for (i = 0; i < NUM_DEFAULT_KEYS; i++) {
1563 +@@ -884,7 +889,8 @@ void ieee80211_free_sta_keys(struct ieee80211_local *local,
1564 + ieee80211_key_replace(key->sdata, key->sta,
1565 + key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE,
1566 + key, NULL);
1567 +- __ieee80211_key_destroy(key, true);
1568 ++ __ieee80211_key_destroy(key, key->sdata->vif.type ==
1569 ++ NL80211_IFTYPE_STATION);
1570 + }
1571 +
1572 + mutex_unlock(&local->key_mtx);
1573 +diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
1574 +index e9eecf6f0bff..48080f89ed25 100644
1575 +--- a/net/xfrm/xfrm_policy.c
1576 ++++ b/net/xfrm/xfrm_policy.c
1577 +@@ -1845,7 +1845,10 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
1578 + /* Try to instantiate a bundle */
1579 + err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);
1580 + if (err <= 0) {
1581 +- if (err != 0 && err != -EAGAIN)
1582 ++ if (err == 0)
1583 ++ return NULL;
1584 ++
1585 ++ if (err != -EAGAIN)
1586 + XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
1587 + return ERR_PTR(err);
1588 + }
1589 +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
1590 +index 31a981d6229d..5897fc3857a0 100644
1591 +--- a/scripts/Kbuild.include
1592 ++++ b/scripts/Kbuild.include
1593 +@@ -359,3 +359,6 @@ endif
1594 + endef
1595 + #
1596 + ###############################################################################
1597 ++
1598 ++# delete partially updated (i.e. corrupted) files on error
1599 ++.DELETE_ON_ERROR:
1600 +diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
1601 +index 4c145d6bccd4..5bc7ddf8fc70 100644
1602 +--- a/sound/core/pcm_lib.c
1603 ++++ b/sound/core/pcm_lib.c
1604 +@@ -648,27 +648,33 @@ EXPORT_SYMBOL(snd_interval_refine);
1605 +
1606 + static int snd_interval_refine_first(struct snd_interval *i)
1607 + {
1608 ++ const unsigned int last_max = i->max;
1609 ++
1610 + if (snd_BUG_ON(snd_interval_empty(i)))
1611 + return -EINVAL;
1612 + if (snd_interval_single(i))
1613 + return 0;
1614 + i->max = i->min;
1615 +- i->openmax = i->openmin;
1616 +- if (i->openmax)
1617 ++ if (i->openmin)
1618 + i->max++;
1619 ++ /* only exclude max value if also excluded before refine */
1620 ++ i->openmax = (i->openmax && i->max >= last_max);
1621 + return 1;
1622 + }
1623 +
1624 + static int snd_interval_refine_last(struct snd_interval *i)
1625 + {
1626 ++ const unsigned int last_min = i->min;
1627 ++
1628 + if (snd_BUG_ON(snd_interval_empty(i)))
1629 + return -EINVAL;
1630 + if (snd_interval_single(i))
1631 + return 0;
1632 + i->min = i->max;
1633 +- i->openmin = i->openmax;
1634 +- if (i->openmin)
1635 ++ if (i->openmax)
1636 + i->min--;
1637 ++ /* only exclude min value if also excluded before refine */
1638 ++ i->openmin = (i->openmin && i->min <= last_min);
1639 + return 1;
1640 + }
1641 +
1642 +diff --git a/sound/isa/msnd/msnd_pinnacle.c b/sound/isa/msnd/msnd_pinnacle.c
1643 +index a31ea6c22d19..2d7379dec1f0 100644
1644 +--- a/sound/isa/msnd/msnd_pinnacle.c
1645 ++++ b/sound/isa/msnd/msnd_pinnacle.c
1646 +@@ -82,10 +82,10 @@
1647 +
1648 + static void set_default_audio_parameters(struct snd_msnd *chip)
1649 + {
1650 +- chip->play_sample_size = DEFSAMPLESIZE;
1651 ++ chip->play_sample_size = snd_pcm_format_width(DEFSAMPLESIZE);
1652 + chip->play_sample_rate = DEFSAMPLERATE;
1653 + chip->play_channels = DEFCHANNELS;
1654 +- chip->capture_sample_size = DEFSAMPLESIZE;
1655 ++ chip->capture_sample_size = snd_pcm_format_width(DEFSAMPLESIZE);
1656 + chip->capture_sample_rate = DEFSAMPLERATE;
1657 + chip->capture_channels = DEFCHANNELS;
1658 + }
1659 +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
1660 +index 69bf5cf1e91e..15cbe2565703 100644
1661 +--- a/sound/usb/quirks-table.h
1662 ++++ b/sound/usb/quirks-table.h
1663 +@@ -2875,7 +2875,8 @@ YAMAHA_DEVICE(0x7010, "UB99"),
1664 + */
1665 +
1666 + #define AU0828_DEVICE(vid, pid, vname, pname) { \
1667 +- USB_DEVICE_VENDOR_SPEC(vid, pid), \
1668 ++ .idVendor = vid, \
1669 ++ .idProduct = pid, \
1670 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
1671 + USB_DEVICE_ID_MATCH_INT_CLASS | \
1672 + USB_DEVICE_ID_MATCH_INT_SUBCLASS, \
1673 +diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
1674 +index 60a94b3e532e..177480066816 100644
1675 +--- a/tools/hv/hv_kvp_daemon.c
1676 ++++ b/tools/hv/hv_kvp_daemon.c
1677 +@@ -286,7 +286,7 @@ static int kvp_key_delete(int pool, const __u8 *key, int key_size)
1678 + * Found a match; just move the remaining
1679 + * entries up.
1680 + */
1681 +- if (i == num_records) {
1682 ++ if (i == (num_records - 1)) {
1683 + kvp_file_info[pool].num_records--;
1684 + kvp_update_file(pool);
1685 + return 0;
1686 +diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
1687 +index bd630c222e65..9a53f6e9ef43 100644
1688 +--- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c
1689 ++++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c
1690 +@@ -58,9 +58,13 @@ static int check_return_reg(int ra_regno, Dwarf_Frame *frame)
1691 + }
1692 +
1693 + /*
1694 +- * Check if return address is on the stack.
1695 ++ * Check if return address is on the stack. If return address
1696 ++ * is in a register (typically R0), it is yet to be saved on
1697 ++ * the stack.
1698 + */
1699 +- if (nops != 0 || ops != NULL)
1700 ++ if ((nops != 0 || ops != NULL) &&
1701 ++ !(nops == 1 && ops[0].atom == DW_OP_regx &&
1702 ++ ops[0].number2 == 0 && ops[0].offset == 0))
1703 + return 0;
1704 +
1705 + /*
1706 +@@ -246,7 +250,7 @@ int arch_skip_callchain_idx(struct thread *thread, struct ip_callchain *chain)
1707 + if (!chain || chain->nr < 3)
1708 + return skip_slot;
1709 +
1710 +- ip = chain->ips[2];
1711 ++ ip = chain->ips[1];
1712 +
1713 + thread__find_addr_location(thread, PERF_RECORD_MISC_USER,
1714 + MAP__FUNCTION, ip, &al);
1715 +diff --git a/tools/testing/selftests/timers/raw_skew.c b/tools/testing/selftests/timers/raw_skew.c
1716 +index 30906bfd9c1b..0ab937a17ebb 100644
1717 +--- a/tools/testing/selftests/timers/raw_skew.c
1718 ++++ b/tools/testing/selftests/timers/raw_skew.c
1719 +@@ -146,6 +146,11 @@ int main(int argv, char **argc)
1720 + printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000)));
1721 +
1722 + if (llabs(eppm - ppm) > 1000) {
1723 ++ if (tx1.offset || tx2.offset ||
1724 ++ tx1.freq != tx2.freq || tx1.tick != tx2.tick) {
1725 ++ printf(" [SKIP]\n");
1726 ++ return ksft_exit_skip("The clock was adjusted externally. Shutdown NTPd or other time sync daemons\n");
1727 ++ }
1728 + printf(" [FAILED]\n");
1729 + return ksft_exit_fail();
1730 + }