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