Magellan Linux

Annotation of /trunk/kernel-alx-legacy/patches-4.9/0410-4.9.311-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3712 - (hide annotations) (download)
Mon Oct 24 14:08:24 2022 UTC (18 months, 3 weeks ago) by niro
File size: 203363 byte(s)
-linux-4.9.311
1 niro 3712 diff --git a/Makefile b/Makefile
2     index 72a8c786cb777..c1a20e4a2d136 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 9
8     -SUBLEVEL = 310
9     +SUBLEVEL = 311
10     EXTRAVERSION =
11     NAME = Roaring Lionus
12    
13     diff --git a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
14     index 2f6ab32b59548..7bb09532840fc 100644
15     --- a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
16     +++ b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
17     @@ -257,7 +257,7 @@
18     };
19    
20     uart3_data: uart3-data {
21     - samsung,pins = "gpa1-4", "gpa1-4";
22     + samsung,pins = "gpa1-4", "gpa1-5";
23     samsung,pin-function = <EXYNOS_PIN_FUNC_2>;
24     samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>;
25     samsung,pin-drv = <EXYNOS4_PIN_DRV_LV1>;
26     diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts b/arch/arm/boot/dts/exynos5250-smdk5250.dts
27     index f0906d67a1070..54e79f6887ffa 100644
28     --- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
29     +++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
30     @@ -118,6 +118,9 @@
31    
32     &hdmi {
33     hpd-gpios = <&gpx3 7 GPIO_ACTIVE_HIGH>;
34     + vdd-supply = <&ldo8_reg>;
35     + vdd_osc-supply = <&ldo10_reg>;
36     + vdd_pll-supply = <&ldo8_reg>;
37     };
38    
39     &i2c_0 {
40     diff --git a/arch/arm/boot/dts/exynos5420-smdk5420.dts b/arch/arm/boot/dts/exynos5420-smdk5420.dts
41     index aaccd0da41e54..5ab719cf69ddd 100644
42     --- a/arch/arm/boot/dts/exynos5420-smdk5420.dts
43     +++ b/arch/arm/boot/dts/exynos5420-smdk5420.dts
44     @@ -134,6 +134,9 @@
45     hpd-gpios = <&gpx3 7 GPIO_ACTIVE_HIGH>;
46     pinctrl-names = "default";
47     pinctrl-0 = <&hdmi_hpd_irq>;
48     + vdd-supply = <&ldo6_reg>;
49     + vdd_osc-supply = <&ldo7_reg>;
50     + vdd_pll-supply = <&ldo6_reg>;
51     };
52    
53     &hsi2c_4 {
54     diff --git a/arch/arm/boot/dts/qcom-ipq4019.dtsi b/arch/arm/boot/dts/qcom-ipq4019.dtsi
55     index 5ee84e3cb3e97..1fd63f485d3b6 100644
56     --- a/arch/arm/boot/dts/qcom-ipq4019.dtsi
57     +++ b/arch/arm/boot/dts/qcom-ipq4019.dtsi
58     @@ -93,7 +93,8 @@
59     clocks {
60     sleep_clk: sleep_clk {
61     compatible = "fixed-clock";
62     - clock-frequency = <32768>;
63     + clock-frequency = <32000>;
64     + clock-output-names = "gcc_sleep_clk_src";
65     #clock-cells = <0>;
66     };
67     };
68     diff --git a/arch/arm/boot/dts/qcom-msm8960.dtsi b/arch/arm/boot/dts/qcom-msm8960.dtsi
69     index 288f56e0ccf55..819d0f085f8ca 100644
70     --- a/arch/arm/boot/dts/qcom-msm8960.dtsi
71     +++ b/arch/arm/boot/dts/qcom-msm8960.dtsi
72     @@ -139,7 +139,9 @@
73     reg = <0x108000 0x1000>;
74     qcom,ipc = <&l2cc 0x8 2>;
75    
76     - interrupts = <0 19 0>, <0 21 0>, <0 22 0>;
77     + interrupts = <GIC_SPI 19 IRQ_TYPE_EDGE_RISING>,
78     + <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>,
79     + <GIC_SPI 22 IRQ_TYPE_EDGE_RISING>;
80     interrupt-names = "ack", "err", "wakeup";
81    
82     regulators {
83     @@ -185,7 +187,7 @@
84     compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
85     reg = <0x16440000 0x1000>,
86     <0x16400000 0x1000>;
87     - interrupts = <0 154 0x0>;
88     + interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
89     clocks = <&gcc GSBI5_UART_CLK>, <&gcc GSBI5_H_CLK>;
90     clock-names = "core", "iface";
91     status = "disabled";
92     @@ -311,7 +313,7 @@
93     #address-cells = <1>;
94     #size-cells = <0>;
95     reg = <0x16080000 0x1000>;
96     - interrupts = <0 147 0>;
97     + interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>;
98     spi-max-frequency = <24000000>;
99     cs-gpios = <&msmgpio 8 0>;
100    
101     diff --git a/arch/arm/boot/dts/spear1340.dtsi b/arch/arm/boot/dts/spear1340.dtsi
102     index 6361cbfcbe5e6..ece38b8c450dd 100644
103     --- a/arch/arm/boot/dts/spear1340.dtsi
104     +++ b/arch/arm/boot/dts/spear1340.dtsi
105     @@ -141,9 +141,9 @@
106     reg = <0xb4100000 0x1000>;
107     interrupts = <0 105 0x4>;
108     status = "disabled";
109     - dmas = <&dwdma0 12 0 1>,
110     - <&dwdma0 13 1 0>;
111     - dma-names = "tx", "rx";
112     + dmas = <&dwdma0 13 0 1>,
113     + <&dwdma0 12 1 0>;
114     + dma-names = "rx", "tx";
115     };
116    
117     thermal@e07008c4 {
118     diff --git a/arch/arm/boot/dts/spear13xx.dtsi b/arch/arm/boot/dts/spear13xx.dtsi
119     index 9564337c1815d..45f5bd8d30f09 100644
120     --- a/arch/arm/boot/dts/spear13xx.dtsi
121     +++ b/arch/arm/boot/dts/spear13xx.dtsi
122     @@ -288,9 +288,9 @@
123     #size-cells = <0>;
124     interrupts = <0 31 0x4>;
125     status = "disabled";
126     - dmas = <&dwdma0 4 0 0>,
127     - <&dwdma0 5 0 0>;
128     - dma-names = "tx", "rx";
129     + dmas = <&dwdma0 5 0 0>,
130     + <&dwdma0 4 0 0>;
131     + dma-names = "rx", "tx";
132     };
133    
134     rtc@e0580000 {
135     diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi b/arch/arm/boot/dts/tegra20-tamonten.dtsi
136     index a613e3b85b456..29769bf7a11ab 100644
137     --- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
138     +++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
139     @@ -182,8 +182,8 @@
140     };
141     conf_ata {
142     nvidia,pins = "ata", "atb", "atc", "atd", "ate",
143     - "cdev1", "cdev2", "dap1", "dtb", "gma",
144     - "gmb", "gmc", "gmd", "gme", "gpu7",
145     + "cdev1", "cdev2", "dap1", "dtb", "dtf",
146     + "gma", "gmb", "gmc", "gmd", "gme", "gpu7",
147     "gpv", "i2cp", "irrx", "irtx", "pta",
148     "rm", "slxa", "slxk", "spia", "spib",
149     "uac";
150     @@ -202,7 +202,7 @@
151     };
152     conf_crtp {
153     nvidia,pins = "crtp", "dap2", "dap3", "dap4",
154     - "dtc", "dte", "dtf", "gpu", "sdio1",
155     + "dtc", "dte", "gpu", "sdio1",
156     "slxc", "slxd", "spdi", "spdo", "spig",
157     "uda";
158     nvidia,pull = <TEGRA_PIN_PULL_NONE>;
159     diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
160     index 3bdf0d5882383..5deafd26c7099 100644
161     --- a/arch/arm/mach-davinci/board-da850-evm.c
162     +++ b/arch/arm/mach-davinci/board-da850-evm.c
163     @@ -1043,11 +1043,13 @@ static int __init da850_evm_config_emac(void)
164     int ret;
165     u32 val;
166     struct davinci_soc_info *soc_info = &davinci_soc_info;
167     - u8 rmii_en = soc_info->emac_pdata->rmii_en;
168     + u8 rmii_en;
169    
170     if (!machine_is_davinci_da850_evm())
171     return 0;
172    
173     + rmii_en = soc_info->emac_pdata->rmii_en;
174     +
175     cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
176    
177     val = __raw_readl(cfg_chip3_base);
178     diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
179     index bf5e64906e656..a41162dc4af40 100644
180     --- a/arch/arm/mach-mmp/sram.c
181     +++ b/arch/arm/mach-mmp/sram.c
182     @@ -75,6 +75,8 @@ static int sram_probe(struct platform_device *pdev)
183     if (!info)
184     return -ENOMEM;
185    
186     + platform_set_drvdata(pdev, info);
187     +
188     res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
189     if (res == NULL) {
190     dev_err(&pdev->dev, "no memory resource defined\n");
191     @@ -110,8 +112,6 @@ static int sram_probe(struct platform_device *pdev)
192     list_add(&info->node, &sram_bank_list);
193     mutex_unlock(&sram_lock);
194    
195     - platform_set_drvdata(pdev, info);
196     -
197     dev_info(&pdev->dev, "initialized\n");
198     return 0;
199    
200     @@ -130,17 +130,19 @@ static int sram_remove(struct platform_device *pdev)
201     struct sram_bank_info *info;
202    
203     info = platform_get_drvdata(pdev);
204     - if (info == NULL)
205     - return -ENODEV;
206    
207     - mutex_lock(&sram_lock);
208     - list_del(&info->node);
209     - mutex_unlock(&sram_lock);
210     + if (info->sram_size) {
211     + mutex_lock(&sram_lock);
212     + list_del(&info->node);
213     + mutex_unlock(&sram_lock);
214     +
215     + gen_pool_destroy(info->gpool);
216     + iounmap(info->sram_virt);
217     + kfree(info->pool_name);
218     + }
219    
220     - gen_pool_destroy(info->gpool);
221     - iounmap(info->sram_virt);
222     - kfree(info->pool_name);
223     kfree(info);
224     +
225     return 0;
226     }
227    
228     diff --git a/arch/arm/mach-s3c24xx/mach-jive.c b/arch/arm/mach-s3c24xx/mach-jive.c
229     index 7d99fe8f61576..5d43733ee7d69 100644
230     --- a/arch/arm/mach-s3c24xx/mach-jive.c
231     +++ b/arch/arm/mach-s3c24xx/mach-jive.c
232     @@ -240,11 +240,11 @@ static int __init jive_mtdset(char *options)
233     unsigned long set;
234    
235     if (options == NULL || options[0] == '\0')
236     - return 0;
237     + return 1;
238    
239     if (kstrtoul(options, 10, &set)) {
240     printk(KERN_ERR "failed to parse mtdset=%s\n", options);
241     - return 0;
242     + return 1;
243     }
244    
245     switch (set) {
246     @@ -259,7 +259,7 @@ static int __init jive_mtdset(char *options)
247     "using default.", set);
248     }
249    
250     - return 0;
251     + return 1;
252     }
253    
254     /* parse the mtdset= option given to the kernel command line */
255     diff --git a/arch/arm64/boot/dts/broadcom/bcm2837.dtsi b/arch/arm64/boot/dts/broadcom/bcm2837.dtsi
256     index c1f719b7097a6..95e3cb38474fb 100644
257     --- a/arch/arm64/boot/dts/broadcom/bcm2837.dtsi
258     +++ b/arch/arm64/boot/dts/broadcom/bcm2837.dtsi
259     @@ -31,12 +31,26 @@
260     #address-cells = <1>;
261     #size-cells = <0>;
262    
263     + /* Source for d/i-cache-line-size and d/i-cache-sets
264     + * https://developer.arm.com/documentation/ddi0500/e/level-1-memory-system
265     + * /about-the-l1-memory-system?lang=en
266     + *
267     + * Source for d/i-cache-size
268     + * https://magpi.raspberrypi.com/articles/raspberry-pi-3-specs-benchmarks
269     + */
270     cpu0: cpu@0 {
271     device_type = "cpu";
272     compatible = "arm,cortex-a53";
273     reg = <0>;
274     enable-method = "spin-table";
275     cpu-release-addr = <0x0 0x000000d8>;
276     + d-cache-size = <0x8000>;
277     + d-cache-line-size = <64>;
278     + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set
279     + i-cache-size = <0x8000>;
280     + i-cache-line-size = <64>;
281     + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set
282     + next-level-cache = <&l2>;
283     };
284    
285     cpu1: cpu@1 {
286     @@ -45,6 +59,13 @@
287     reg = <1>;
288     enable-method = "spin-table";
289     cpu-release-addr = <0x0 0x000000e0>;
290     + d-cache-size = <0x8000>;
291     + d-cache-line-size = <64>;
292     + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set
293     + i-cache-size = <0x8000>;
294     + i-cache-line-size = <64>;
295     + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set
296     + next-level-cache = <&l2>;
297     };
298    
299     cpu2: cpu@2 {
300     @@ -53,6 +74,13 @@
301     reg = <2>;
302     enable-method = "spin-table";
303     cpu-release-addr = <0x0 0x000000e8>;
304     + d-cache-size = <0x8000>;
305     + d-cache-line-size = <64>;
306     + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set
307     + i-cache-size = <0x8000>;
308     + i-cache-line-size = <64>;
309     + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set
310     + next-level-cache = <&l2>;
311     };
312    
313     cpu3: cpu@3 {
314     @@ -61,6 +89,27 @@
315     reg = <3>;
316     enable-method = "spin-table";
317     cpu-release-addr = <0x0 0x000000f0>;
318     + d-cache-size = <0x8000>;
319     + d-cache-line-size = <64>;
320     + d-cache-sets = <128>; // 32KiB(size)/64(line-size)=512ways/4-way set
321     + i-cache-size = <0x8000>;
322     + i-cache-line-size = <64>;
323     + i-cache-sets = <256>; // 32KiB(size)/64(line-size)=512ways/2-way set
324     + next-level-cache = <&l2>;
325     + };
326     +
327     + /* Source for cache-line-size + cache-sets
328     + * https://developer.arm.com/documentation/ddi0500
329     + * /e/level-2-memory-system/about-the-l2-memory-system?lang=en
330     + * Source for cache-size
331     + * https://datasheets.raspberrypi.com/cm/cm1-and-cm3-datasheet.pdf
332     + */
333     + l2: l2-cache0 {
334     + compatible = "cache";
335     + cache-size = <0x80000>;
336     + cache-line-size = <64>;
337     + cache-sets = <512>; // 512KiB(size)/64(line-size)=8192ways/16-way set
338     + cache-level = <2>;
339     };
340     };
341     };
342     diff --git a/arch/arm64/boot/dts/broadcom/ns2-svk.dts b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
343     index b09f3bc5c6c16..58114b842a592 100644
344     --- a/arch/arm64/boot/dts/broadcom/ns2-svk.dts
345     +++ b/arch/arm64/boot/dts/broadcom/ns2-svk.dts
346     @@ -103,8 +103,8 @@
347     compatible = "silabs,si3226x";
348     reg = <0>;
349     spi-max-frequency = <5000000>;
350     - spi-cpha = <1>;
351     - spi-cpol = <1>;
352     + spi-cpha;
353     + spi-cpol;
354     pl022,hierarchy = <0>;
355     pl022,interface = <0>;
356     pl022,slave-tx-disable = <0>;
357     @@ -127,8 +127,8 @@
358     at25,byte-len = <0x8000>;
359     at25,addr-mode = <2>;
360     at25,page-size = <64>;
361     - spi-cpha = <1>;
362     - spi-cpol = <1>;
363     + spi-cpha;
364     + spi-cpol;
365     pl022,hierarchy = <0>;
366     pl022,interface = <0>;
367     pl022,slave-tx-disable = <0>;
368     diff --git a/arch/arm64/boot/dts/broadcom/ns2.dtsi b/arch/arm64/boot/dts/broadcom/ns2.dtsi
369     index 8a94ec8035d38..83c1718dac292 100644
370     --- a/arch/arm64/boot/dts/broadcom/ns2.dtsi
371     +++ b/arch/arm64/boot/dts/broadcom/ns2.dtsi
372     @@ -514,7 +514,7 @@
373     };
374     };
375    
376     - sata: ahci@663f2000 {
377     + sata: sata@663f2000 {
378     compatible = "brcm,iproc-ahci", "generic-ahci";
379     reg = <0x663f2000 0x1000>;
380     reg-names = "ahci";
381     diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c
382     index 755b3dd3073e5..fbfad5a83526b 100644
383     --- a/arch/arm64/kernel/insn.c
384     +++ b/arch/arm64/kernel/insn.c
385     @@ -234,8 +234,8 @@ static int __kprobes aarch64_insn_patch_text_cb(void *arg)
386     int i, ret = 0;
387     struct aarch64_insn_patch *pp = arg;
388    
389     - /* The first CPU becomes master */
390     - if (atomic_inc_return(&pp->cpu_count) == 1) {
391     + /* The last CPU becomes master */
392     + if (atomic_inc_return(&pp->cpu_count) == num_online_cpus()) {
393     for (i = 0; ret == 0 && i < pp->insn_cnt; i++)
394     ret = aarch64_insn_patch_text_nosync(pp->text_addrs[i],
395     pp->new_insns[i]);
396     diff --git a/arch/arm64/kernel/module.lds b/arch/arm64/kernel/module.lds
397     index 8949f6c6f729d..05881e2b414c5 100644
398     --- a/arch/arm64/kernel/module.lds
399     +++ b/arch/arm64/kernel/module.lds
400     @@ -1,3 +1,3 @@
401     SECTIONS {
402     - .plt (NOLOAD) : { BYTE(0) }
403     + .plt : { BYTE(0) }
404     }
405     diff --git a/arch/mips/dec/prom/Makefile b/arch/mips/dec/prom/Makefile
406     index ae73e42ac20b1..4c369359cdab5 100644
407     --- a/arch/mips/dec/prom/Makefile
408     +++ b/arch/mips/dec/prom/Makefile
409     @@ -5,4 +5,4 @@
410    
411     lib-y += init.o memory.o cmdline.o identify.o console.o
412    
413     -lib-$(CONFIG_32BIT) += locore.o
414     +lib-$(CONFIG_CPU_R3000) += locore.o
415     diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h
416     index b59a2103b61a3..09538ff5e9245 100644
417     --- a/arch/mips/include/asm/dec/prom.h
418     +++ b/arch/mips/include/asm/dec/prom.h
419     @@ -47,16 +47,11 @@
420     */
421     #define REX_PROM_MAGIC 0x30464354
422    
423     -#ifdef CONFIG_64BIT
424     -
425     -#define prom_is_rex(magic) 1 /* KN04 and KN05 are REX PROMs. */
426     -
427     -#else /* !CONFIG_64BIT */
428     -
429     -#define prom_is_rex(magic) ((magic) == REX_PROM_MAGIC)
430     -
431     -#endif /* !CONFIG_64BIT */
432     -
433     +/* KN04 and KN05 are REX PROMs, so only do the check for R3k systems. */
434     +static inline bool prom_is_rex(u32 magic)
435     +{
436     + return !IS_ENABLED(CONFIG_CPU_R3000) || magic == REX_PROM_MAGIC;
437     +}
438    
439     /*
440     * 3MIN/MAXINE PROM entry points for DS5000/1xx's, DS5000/xx's and
441     diff --git a/arch/mips/include/asm/setup.h b/arch/mips/include/asm/setup.h
442     index 4f5279a8308d7..e301967fcffdd 100644
443     --- a/arch/mips/include/asm/setup.h
444     +++ b/arch/mips/include/asm/setup.h
445     @@ -13,7 +13,7 @@ static inline void setup_8250_early_printk_port(unsigned long base,
446     unsigned int reg_shift, unsigned int timeout) {}
447     #endif
448    
449     -extern void set_handler(unsigned long offset, void *addr, unsigned long len);
450     +void set_handler(unsigned long offset, const void *addr, unsigned long len);
451     extern void set_uncached_handler(unsigned long offset, void *addr, unsigned long len);
452    
453     typedef void (*vi_handler_t)(void);
454     diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
455     index 5f717473d08e7..278e81c9e6143 100644
456     --- a/arch/mips/kernel/traps.c
457     +++ b/arch/mips/kernel/traps.c
458     @@ -2019,19 +2019,19 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs)
459     * If no shadow set is selected then use the default handler
460     * that does normal register saving and standard interrupt exit
461     */
462     - extern char except_vec_vi, except_vec_vi_lui;
463     - extern char except_vec_vi_ori, except_vec_vi_end;
464     - extern char rollback_except_vec_vi;
465     - char *vec_start = using_rollback_handler() ?
466     - &rollback_except_vec_vi : &except_vec_vi;
467     + extern const u8 except_vec_vi[], except_vec_vi_lui[];
468     + extern const u8 except_vec_vi_ori[], except_vec_vi_end[];
469     + extern const u8 rollback_except_vec_vi[];
470     + const u8 *vec_start = using_rollback_handler() ?
471     + rollback_except_vec_vi : except_vec_vi;
472     #if defined(CONFIG_CPU_MICROMIPS) || defined(CONFIG_CPU_BIG_ENDIAN)
473     - const int lui_offset = &except_vec_vi_lui - vec_start + 2;
474     - const int ori_offset = &except_vec_vi_ori - vec_start + 2;
475     + const int lui_offset = except_vec_vi_lui - vec_start + 2;
476     + const int ori_offset = except_vec_vi_ori - vec_start + 2;
477     #else
478     - const int lui_offset = &except_vec_vi_lui - vec_start;
479     - const int ori_offset = &except_vec_vi_ori - vec_start;
480     + const int lui_offset = except_vec_vi_lui - vec_start;
481     + const int ori_offset = except_vec_vi_ori - vec_start;
482     #endif
483     - const int handler_len = &except_vec_vi_end - vec_start;
484     + const int handler_len = except_vec_vi_end - vec_start;
485    
486     if (handler_len > VECTORSPACING) {
487     /*
488     @@ -2251,7 +2251,7 @@ void per_cpu_trap_init(bool is_boot_cpu)
489     }
490    
491     /* Install CPU exception handler */
492     -void set_handler(unsigned long offset, void *addr, unsigned long size)
493     +void set_handler(unsigned long offset, const void *addr, unsigned long size)
494     {
495     #ifdef CONFIG_CPU_MICROMIPS
496     memcpy((void *)(ebase + offset), ((unsigned char *)addr - 1), size);
497     diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
498     index 0966adccf5200..ed921f7b43648 100644
499     --- a/arch/mips/rb532/devices.c
500     +++ b/arch/mips/rb532/devices.c
501     @@ -313,11 +313,9 @@ static int __init plat_setup_devices(void)
502     static int __init setup_kmac(char *s)
503     {
504     printk(KERN_INFO "korina mac = %s\n", s);
505     - if (!mac_pton(s, korina_dev0_data.mac)) {
506     + if (!mac_pton(s, korina_dev0_data.mac))
507     printk(KERN_ERR "Invalid mac\n");
508     - return -EINVAL;
509     - }
510     - return 0;
511     + return 1;
512     }
513    
514     __setup("kmac=", setup_kmac);
515     diff --git a/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi b/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi
516     index 5fdddbd2a62b2..b0a9beab1c26d 100644
517     --- a/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi
518     +++ b/arch/powerpc/boot/dts/fsl/t104xrdb.dtsi
519     @@ -139,12 +139,12 @@
520     fman@400000 {
521     ethernet@e6000 {
522     phy-handle = <&phy_rgmii_0>;
523     - phy-connection-type = "rgmii";
524     + phy-connection-type = "rgmii-id";
525     };
526    
527     ethernet@e8000 {
528     phy-handle = <&phy_rgmii_1>;
529     - phy-connection-type = "rgmii";
530     + phy-connection-type = "rgmii-id";
531     };
532    
533     mdio0: mdio@fc000 {
534     diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c
535     index a6f0b96ce2c94..97dee7c99aa02 100644
536     --- a/arch/powerpc/sysdev/fsl_gtm.c
537     +++ b/arch/powerpc/sysdev/fsl_gtm.c
538     @@ -90,7 +90,7 @@ static LIST_HEAD(gtms);
539     */
540     struct gtm_timer *gtm_get_timer16(void)
541     {
542     - struct gtm *gtm = NULL;
543     + struct gtm *gtm;
544     int i;
545    
546     list_for_each_entry(gtm, &gtms, list_node) {
547     @@ -107,7 +107,7 @@ struct gtm_timer *gtm_get_timer16(void)
548     spin_unlock_irq(&gtm->lock);
549     }
550    
551     - if (gtm)
552     + if (!list_empty(&gtms))
553     return ERR_PTR(-EBUSY);
554     return ERR_PTR(-ENODEV);
555     }
556     diff --git a/arch/x86/events/intel/pt.c b/arch/x86/events/intel/pt.c
557     index 1808c57ce1614..2539aaddd1373 100644
558     --- a/arch/x86/events/intel/pt.c
559     +++ b/arch/x86/events/intel/pt.c
560     @@ -410,7 +410,7 @@ static u64 pt_config_filters(struct perf_event *event)
561     pt->filters.filter[range].msr_b = filter->msr_b;
562     }
563    
564     - rtit_ctl |= filter->config << pt_address_ranges[range].reg_off;
565     + rtit_ctl |= (u64)filter->config << pt_address_ranges[range].reg_off;
566     }
567    
568     return rtit_ctl;
569     diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
570     index 2e5553091f902..3edafdffa687c 100644
571     --- a/arch/x86/kvm/emulate.c
572     +++ b/arch/x86/kvm/emulate.c
573     @@ -1674,11 +1674,6 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
574     goto exception;
575     }
576    
577     - if (!seg_desc.p) {
578     - err_vec = (seg == VCPU_SREG_SS) ? SS_VECTOR : NP_VECTOR;
579     - goto exception;
580     - }
581     -
582     dpl = seg_desc.dpl;
583    
584     switch (seg) {
585     @@ -1718,6 +1713,10 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
586     case VCPU_SREG_TR:
587     if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9))
588     goto exception;
589     + if (!seg_desc.p) {
590     + err_vec = NP_VECTOR;
591     + goto exception;
592     + }
593     old_desc = seg_desc;
594     seg_desc.type |= 2; /* busy */
595     ret = ctxt->ops->cmpxchg_emulated(ctxt, desc_addr, &old_desc, &seg_desc,
596     @@ -1742,6 +1741,11 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
597     break;
598     }
599    
600     + if (!seg_desc.p) {
601     + err_vec = (seg == VCPU_SREG_SS) ? SS_VECTOR : NP_VECTOR;
602     + goto exception;
603     + }
604     +
605     if (seg_desc.s) {
606     /* mark segment as accessed */
607     if (!(seg_desc.type & 1)) {
608     diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
609     index 5e837c96e93f2..56feb7d8f96d5 100644
610     --- a/arch/x86/kvm/hyperv.c
611     +++ b/arch/x86/kvm/hyperv.c
612     @@ -244,6 +244,9 @@ static int synic_set_msr(struct kvm_vcpu_hv_synic *synic,
613     case HV_X64_MSR_EOM: {
614     int i;
615    
616     + if (!synic->active)
617     + break;
618     +
619     for (i = 0; i < ARRAY_SIZE(synic->sint); i++)
620     kvm_hv_notify_acked_sint(vcpu, i);
621     break;
622     @@ -504,6 +507,12 @@ static int stimer_start(struct kvm_vcpu_hv_stimer *stimer)
623     static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,
624     bool host)
625     {
626     + struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer);
627     + struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu);
628     +
629     + if (!synic->active && (!host || config))
630     + return 1;
631     +
632     trace_kvm_hv_stimer_set_config(stimer_to_vcpu(stimer)->vcpu_id,
633     stimer->index, config, host);
634    
635     @@ -518,6 +527,12 @@ static int stimer_set_config(struct kvm_vcpu_hv_stimer *stimer, u64 config,
636     static int stimer_set_count(struct kvm_vcpu_hv_stimer *stimer, u64 count,
637     bool host)
638     {
639     + struct kvm_vcpu *vcpu = stimer_to_vcpu(stimer);
640     + struct kvm_vcpu_hv_synic *synic = vcpu_to_synic(vcpu);
641     +
642     + if (!synic->active && (!host || count))
643     + return 1;
644     +
645     trace_kvm_hv_stimer_set_count(stimer_to_vcpu(stimer)->vcpu_id,
646     stimer->index, count, host);
647    
648     diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
649     index bfed29a4c2cec..e5f92488c3cde 100644
650     --- a/arch/x86/kvm/lapic.c
651     +++ b/arch/x86/kvm/lapic.c
652     @@ -1767,10 +1767,7 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
653    
654     void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu, unsigned long cr8)
655     {
656     - struct kvm_lapic *apic = vcpu->arch.apic;
657     -
658     - apic_set_tpr(apic, ((cr8 & 0x0f) << 4)
659     - | (kvm_lapic_get_reg(apic, APIC_TASKPRI) & 4));
660     + apic_set_tpr(vcpu->arch.apic, (cr8 & 0x0f) << 4);
661     }
662    
663     u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu)
664     diff --git a/arch/x86/kvm/pmu_amd.c b/arch/x86/kvm/pmu_amd.c
665     index cd944435dfbd7..e0473c72062e2 100644
666     --- a/arch/x86/kvm/pmu_amd.c
667     +++ b/arch/x86/kvm/pmu_amd.c
668     @@ -139,12 +139,10 @@ static int amd_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
669     /* MSR_K7_EVNTSELn */
670     pmc = get_gp_pmc(pmu, msr, MSR_K7_EVNTSEL0);
671     if (pmc) {
672     - if (data == pmc->eventsel)
673     - return 0;
674     - if (!(data & pmu->reserved_bits)) {
675     + data &= ~pmu->reserved_bits;
676     + if (data != pmc->eventsel)
677     reprogram_gp_counter(pmc, data);
678     - return 0;
679     - }
680     + return 0;
681     }
682    
683     return 1;
684     diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
685     index c8f947a4aaf20..357b3e6a2f7b1 100644
686     --- a/arch/x86/power/cpu.c
687     +++ b/arch/x86/power/cpu.c
688     @@ -41,7 +41,8 @@ static void msr_save_context(struct saved_context *ctxt)
689     struct saved_msr *end = msr + ctxt->saved_msrs.num;
690    
691     while (msr < end) {
692     - msr->valid = !rdmsrl_safe(msr->info.msr_no, &msr->info.reg.q);
693     + if (msr->valid)
694     + rdmsrl(msr->info.msr_no, msr->info.reg.q);
695     msr++;
696     }
697     }
698     @@ -419,8 +420,10 @@ static int msr_build_context(const u32 *msr_id, const int num)
699     }
700    
701     for (i = saved_msrs->num, j = 0; i < total_num; i++, j++) {
702     + u64 dummy;
703     +
704     msr_array[i].info.msr_no = msr_id[j];
705     - msr_array[i].valid = false;
706     + msr_array[i].valid = !rdmsrl_safe(msr_id[j], &dummy);
707     msr_array[i].info.reg.q = 0;
708     }
709     saved_msrs->num = total_num;
710     @@ -507,10 +510,24 @@ static int pm_cpu_check(const struct x86_cpu_id *c)
711     return ret;
712     }
713    
714     +static void pm_save_spec_msr(void)
715     +{
716     + u32 spec_msr_id[] = {
717     + MSR_IA32_SPEC_CTRL,
718     + MSR_IA32_TSX_CTRL,
719     + MSR_TSX_FORCE_ABORT,
720     + MSR_IA32_MCU_OPT_CTRL,
721     + MSR_AMD64_LS_CFG,
722     + };
723     +
724     + msr_build_context(spec_msr_id, ARRAY_SIZE(spec_msr_id));
725     +}
726     +
727     static int pm_check_save_msr(void)
728     {
729     dmi_check_system(msr_save_dmi_table);
730     pm_cpu_check(msr_save_cpu_table);
731     + pm_save_spec_msr();
732    
733     return 0;
734     }
735     diff --git a/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
736     index d3a88e029873d..d9b399b57bcdc 100644
737     --- a/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
738     +++ b/arch/xtensa/boot/dts/xtfpga-flash-128m.dtsi
739     @@ -7,19 +7,19 @@
740     reg = <0x00000000 0x08000000>;
741     bank-width = <2>;
742     device-width = <2>;
743     - partition@0x0 {
744     + partition@0 {
745     label = "data";
746     reg = <0x00000000 0x06000000>;
747     };
748     - partition@0x6000000 {
749     + partition@6000000 {
750     label = "boot loader area";
751     reg = <0x06000000 0x00800000>;
752     };
753     - partition@0x6800000 {
754     + partition@6800000 {
755     label = "kernel image";
756     reg = <0x06800000 0x017e0000>;
757     };
758     - partition@0x7fe0000 {
759     + partition@7fe0000 {
760     label = "boot environment";
761     reg = <0x07fe0000 0x00020000>;
762     };
763     diff --git a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
764     index 1d97203c18e7f..c9d0fc0b62657 100644
765     --- a/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
766     +++ b/arch/xtensa/boot/dts/xtfpga-flash-16m.dtsi
767     @@ -7,19 +7,19 @@
768     reg = <0x08000000 0x01000000>;
769     bank-width = <2>;
770     device-width = <2>;
771     - partition@0x0 {
772     + partition@0 {
773     label = "boot loader area";
774     reg = <0x00000000 0x00400000>;
775     };
776     - partition@0x400000 {
777     + partition@400000 {
778     label = "kernel image";
779     reg = <0x00400000 0x00600000>;
780     };
781     - partition@0xa00000 {
782     + partition@a00000 {
783     label = "data";
784     reg = <0x00a00000 0x005e0000>;
785     };
786     - partition@0xfe0000 {
787     + partition@fe0000 {
788     label = "boot environment";
789     reg = <0x00fe0000 0x00020000>;
790     };
791     diff --git a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi b/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
792     index d1c621ca8be10..332892315f92b 100644
793     --- a/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
794     +++ b/arch/xtensa/boot/dts/xtfpga-flash-4m.dtsi
795     @@ -7,11 +7,11 @@
796     reg = <0x08000000 0x00400000>;
797     bank-width = <2>;
798     device-width = <2>;
799     - partition@0x0 {
800     + partition@0 {
801     label = "boot loader area";
802     reg = <0x00000000 0x003f0000>;
803     };
804     - partition@0x3f0000 {
805     + partition@3f0000 {
806     label = "boot environment";
807     reg = <0x003f0000 0x00010000>;
808     };
809     diff --git a/crypto/authenc.c b/crypto/authenc.c
810     index 6bfec690ca5be..f9ab04aa6dd59 100644
811     --- a/crypto/authenc.c
812     +++ b/crypto/authenc.c
813     @@ -268,7 +268,7 @@ static int crypto_authenc_decrypt_tail(struct aead_request *req,
814     dst = scatterwalk_ffwd(areq_ctx->dst, req->dst, req->assoclen);
815    
816     skcipher_request_set_tfm(skreq, ctx->enc);
817     - skcipher_request_set_callback(skreq, aead_request_flags(req),
818     + skcipher_request_set_callback(skreq, flags,
819     req->base.complete, req->base.data);
820     skcipher_request_set_crypt(skreq, src, dst,
821     req->cryptlen - authsize, req->iv);
822     diff --git a/drivers/acpi/acpica/nswalk.c b/drivers/acpi/acpica/nswalk.c
823     index ebd731fe8e457..6902c2a01f6f7 100644
824     --- a/drivers/acpi/acpica/nswalk.c
825     +++ b/drivers/acpi/acpica/nswalk.c
826     @@ -203,6 +203,9 @@ acpi_ns_walk_namespace(acpi_object_type type,
827    
828     if (start_node == ACPI_ROOT_OBJECT) {
829     start_node = acpi_gbl_root_node;
830     + if (!start_node) {
831     + return_ACPI_STATUS(AE_NO_NAMESPACE);
832     + }
833     }
834    
835     /* Null child means "get first node" */
836     diff --git a/drivers/acpi/apei/bert.c b/drivers/acpi/apei/bert.c
837     index a05b5c0cf181a..e22f3d89b84b0 100644
838     --- a/drivers/acpi/apei/bert.c
839     +++ b/drivers/acpi/apei/bert.c
840     @@ -31,6 +31,7 @@
841    
842     #undef pr_fmt
843     #define pr_fmt(fmt) "BERT: " fmt
844     +#define ACPI_BERT_PRINT_MAX_LEN 1024
845    
846     static int bert_disable;
847    
848     @@ -59,8 +60,11 @@ static void __init bert_print_all(struct acpi_bert_region *region,
849     }
850    
851     pr_info_once("Error records from previous boot:\n");
852     -
853     - cper_estatus_print(KERN_INFO HW_ERR, estatus);
854     + if (region_len < ACPI_BERT_PRINT_MAX_LEN)
855     + cper_estatus_print(KERN_INFO HW_ERR, estatus);
856     + else
857     + pr_info_once("Max print length exceeded, table data is available at:\n"
858     + "/sys/firmware/acpi/tables/data/BERT");
859    
860     /*
861     * Because the boot error source is "one-time polled" type,
862     diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
863     index 318bdfb8703cc..b27a405a0f87d 100644
864     --- a/drivers/acpi/cppc_acpi.c
865     +++ b/drivers/acpi/cppc_acpi.c
866     @@ -681,6 +681,11 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
867     cpc_obj = &out_obj->package.elements[0];
868     if (cpc_obj->type == ACPI_TYPE_INTEGER) {
869     num_ent = cpc_obj->integer.value;
870     + if (num_ent <= 1) {
871     + pr_debug("Unexpected _CPC NumEntries value (%d) for CPU:%d\n",
872     + num_ent, pr->id);
873     + goto out_free;
874     + }
875     } else {
876     pr_debug("Unexpected entry type(%d) for NumEntries\n",
877     cpc_obj->type);
878     diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
879     index d707cd16ed014..b4d50c5dcbf86 100644
880     --- a/drivers/base/power/main.c
881     +++ b/drivers/base/power/main.c
882     @@ -1766,7 +1766,9 @@ static bool pm_ops_is_empty(const struct dev_pm_ops *ops)
883    
884     void device_pm_check_callbacks(struct device *dev)
885     {
886     - spin_lock_irq(&dev->power.lock);
887     + unsigned long flags;
888     +
889     + spin_lock_irqsave(&dev->power.lock, flags);
890     dev->power.no_pm_callbacks =
891     (!dev->bus || (pm_ops_is_empty(dev->bus->pm) &&
892     !dev->bus->suspend && !dev->bus->resume)) &&
893     @@ -1776,5 +1778,5 @@ void device_pm_check_callbacks(struct device *dev)
894     (!dev->pm_domain || pm_ops_is_empty(&dev->pm_domain->ops)) &&
895     (!dev->driver || (pm_ops_is_empty(dev->driver->pm) &&
896     !dev->driver->suspend && !dev->driver->resume));
897     - spin_unlock_irq(&dev->power.lock);
898     + spin_unlock_irqrestore(&dev->power.lock, flags);
899     }
900     diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
901     index 4cb8f21ff4eff..4a7be81e7de9a 100644
902     --- a/drivers/block/drbd/drbd_int.h
903     +++ b/drivers/block/drbd/drbd_int.h
904     @@ -1696,22 +1696,22 @@ struct sib_info {
905     };
906     void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib);
907    
908     -extern void notify_resource_state(struct sk_buff *,
909     +extern int notify_resource_state(struct sk_buff *,
910     unsigned int,
911     struct drbd_resource *,
912     struct resource_info *,
913     enum drbd_notification_type);
914     -extern void notify_device_state(struct sk_buff *,
915     +extern int notify_device_state(struct sk_buff *,
916     unsigned int,
917     struct drbd_device *,
918     struct device_info *,
919     enum drbd_notification_type);
920     -extern void notify_connection_state(struct sk_buff *,
921     +extern int notify_connection_state(struct sk_buff *,
922     unsigned int,
923     struct drbd_connection *,
924     struct connection_info *,
925     enum drbd_notification_type);
926     -extern void notify_peer_device_state(struct sk_buff *,
927     +extern int notify_peer_device_state(struct sk_buff *,
928     unsigned int,
929     struct drbd_peer_device *,
930     struct peer_device_info *,
931     diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
932     index b809f325c2bea..3c9cee9520ed5 100644
933     --- a/drivers/block/drbd/drbd_nl.c
934     +++ b/drivers/block/drbd/drbd_nl.c
935     @@ -4611,7 +4611,7 @@ static int nla_put_notification_header(struct sk_buff *msg,
936     return drbd_notification_header_to_skb(msg, &nh, true);
937     }
938    
939     -void notify_resource_state(struct sk_buff *skb,
940     +int notify_resource_state(struct sk_buff *skb,
941     unsigned int seq,
942     struct drbd_resource *resource,
943     struct resource_info *resource_info,
944     @@ -4653,16 +4653,17 @@ void notify_resource_state(struct sk_buff *skb,
945     if (err && err != -ESRCH)
946     goto failed;
947     }
948     - return;
949     + return 0;
950    
951     nla_put_failure:
952     nlmsg_free(skb);
953     failed:
954     drbd_err(resource, "Error %d while broadcasting event. Event seq:%u\n",
955     err, seq);
956     + return err;
957     }
958    
959     -void notify_device_state(struct sk_buff *skb,
960     +int notify_device_state(struct sk_buff *skb,
961     unsigned int seq,
962     struct drbd_device *device,
963     struct device_info *device_info,
964     @@ -4702,16 +4703,17 @@ void notify_device_state(struct sk_buff *skb,
965     if (err && err != -ESRCH)
966     goto failed;
967     }
968     - return;
969     + return 0;
970    
971     nla_put_failure:
972     nlmsg_free(skb);
973     failed:
974     drbd_err(device, "Error %d while broadcasting event. Event seq:%u\n",
975     err, seq);
976     + return err;
977     }
978    
979     -void notify_connection_state(struct sk_buff *skb,
980     +int notify_connection_state(struct sk_buff *skb,
981     unsigned int seq,
982     struct drbd_connection *connection,
983     struct connection_info *connection_info,
984     @@ -4751,16 +4753,17 @@ void notify_connection_state(struct sk_buff *skb,
985     if (err && err != -ESRCH)
986     goto failed;
987     }
988     - return;
989     + return 0;
990    
991     nla_put_failure:
992     nlmsg_free(skb);
993     failed:
994     drbd_err(connection, "Error %d while broadcasting event. Event seq:%u\n",
995     err, seq);
996     + return err;
997     }
998    
999     -void notify_peer_device_state(struct sk_buff *skb,
1000     +int notify_peer_device_state(struct sk_buff *skb,
1001     unsigned int seq,
1002     struct drbd_peer_device *peer_device,
1003     struct peer_device_info *peer_device_info,
1004     @@ -4801,13 +4804,14 @@ void notify_peer_device_state(struct sk_buff *skb,
1005     if (err && err != -ESRCH)
1006     goto failed;
1007     }
1008     - return;
1009     + return 0;
1010    
1011     nla_put_failure:
1012     nlmsg_free(skb);
1013     failed:
1014     drbd_err(peer_device, "Error %d while broadcasting event. Event seq:%u\n",
1015     err, seq);
1016     + return err;
1017     }
1018    
1019     void notify_helper(enum drbd_notification_type type,
1020     @@ -4858,7 +4862,7 @@ fail:
1021     err, seq);
1022     }
1023    
1024     -static void notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
1025     +static int notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
1026     {
1027     struct drbd_genlmsghdr *dh;
1028     int err;
1029     @@ -4872,11 +4876,12 @@ static void notify_initial_state_done(struct sk_buff *skb, unsigned int seq)
1030     if (nla_put_notification_header(skb, NOTIFY_EXISTS))
1031     goto nla_put_failure;
1032     genlmsg_end(skb, dh);
1033     - return;
1034     + return 0;
1035    
1036     nla_put_failure:
1037     nlmsg_free(skb);
1038     pr_err("Error %d sending event. Event seq:%u\n", err, seq);
1039     + return err;
1040     }
1041    
1042     static void free_state_changes(struct list_head *list)
1043     @@ -4903,6 +4908,7 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
1044     unsigned int seq = cb->args[2];
1045     unsigned int n;
1046     enum drbd_notification_type flags = 0;
1047     + int err = 0;
1048    
1049     /* There is no need for taking notification_mutex here: it doesn't
1050     matter if the initial state events mix with later state chage
1051     @@ -4911,32 +4917,32 @@ static int get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
1052    
1053     cb->args[5]--;
1054     if (cb->args[5] == 1) {
1055     - notify_initial_state_done(skb, seq);
1056     + err = notify_initial_state_done(skb, seq);
1057     goto out;
1058     }
1059     n = cb->args[4]++;
1060     if (cb->args[4] < cb->args[3])
1061     flags |= NOTIFY_CONTINUES;
1062     if (n < 1) {
1063     - notify_resource_state_change(skb, seq, state_change->resource,
1064     + err = notify_resource_state_change(skb, seq, state_change->resource,
1065     NOTIFY_EXISTS | flags);
1066     goto next;
1067     }
1068     n--;
1069     if (n < state_change->n_connections) {
1070     - notify_connection_state_change(skb, seq, &state_change->connections[n],
1071     + err = notify_connection_state_change(skb, seq, &state_change->connections[n],
1072     NOTIFY_EXISTS | flags);
1073     goto next;
1074     }
1075     n -= state_change->n_connections;
1076     if (n < state_change->n_devices) {
1077     - notify_device_state_change(skb, seq, &state_change->devices[n],
1078     + err = notify_device_state_change(skb, seq, &state_change->devices[n],
1079     NOTIFY_EXISTS | flags);
1080     goto next;
1081     }
1082     n -= state_change->n_devices;
1083     if (n < state_change->n_devices * state_change->n_connections) {
1084     - notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
1085     + err = notify_peer_device_state_change(skb, seq, &state_change->peer_devices[n],
1086     NOTIFY_EXISTS | flags);
1087     goto next;
1088     }
1089     @@ -4951,7 +4957,10 @@ next:
1090     cb->args[4] = 0;
1091     }
1092     out:
1093     - return skb->len;
1094     + if (err)
1095     + return err;
1096     + else
1097     + return skb->len;
1098     }
1099    
1100     int drbd_adm_get_initial_state(struct sk_buff *skb, struct netlink_callback *cb)
1101     diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
1102     index eea0c4aec9789..b636d9c08c0e0 100644
1103     --- a/drivers/block/drbd/drbd_state.c
1104     +++ b/drivers/block/drbd/drbd_state.c
1105     @@ -1505,7 +1505,7 @@ int drbd_bitmap_io_from_worker(struct drbd_device *device,
1106     return rv;
1107     }
1108    
1109     -void notify_resource_state_change(struct sk_buff *skb,
1110     +int notify_resource_state_change(struct sk_buff *skb,
1111     unsigned int seq,
1112     struct drbd_resource_state_change *resource_state_change,
1113     enum drbd_notification_type type)
1114     @@ -1518,10 +1518,10 @@ void notify_resource_state_change(struct sk_buff *skb,
1115     .res_susp_fen = resource_state_change->susp_fen[NEW],
1116     };
1117    
1118     - notify_resource_state(skb, seq, resource, &resource_info, type);
1119     + return notify_resource_state(skb, seq, resource, &resource_info, type);
1120     }
1121    
1122     -void notify_connection_state_change(struct sk_buff *skb,
1123     +int notify_connection_state_change(struct sk_buff *skb,
1124     unsigned int seq,
1125     struct drbd_connection_state_change *connection_state_change,
1126     enum drbd_notification_type type)
1127     @@ -1532,10 +1532,10 @@ void notify_connection_state_change(struct sk_buff *skb,
1128     .conn_role = connection_state_change->peer_role[NEW],
1129     };
1130    
1131     - notify_connection_state(skb, seq, connection, &connection_info, type);
1132     + return notify_connection_state(skb, seq, connection, &connection_info, type);
1133     }
1134    
1135     -void notify_device_state_change(struct sk_buff *skb,
1136     +int notify_device_state_change(struct sk_buff *skb,
1137     unsigned int seq,
1138     struct drbd_device_state_change *device_state_change,
1139     enum drbd_notification_type type)
1140     @@ -1545,10 +1545,10 @@ void notify_device_state_change(struct sk_buff *skb,
1141     .dev_disk_state = device_state_change->disk_state[NEW],
1142     };
1143    
1144     - notify_device_state(skb, seq, device, &device_info, type);
1145     + return notify_device_state(skb, seq, device, &device_info, type);
1146     }
1147    
1148     -void notify_peer_device_state_change(struct sk_buff *skb,
1149     +int notify_peer_device_state_change(struct sk_buff *skb,
1150     unsigned int seq,
1151     struct drbd_peer_device_state_change *p,
1152     enum drbd_notification_type type)
1153     @@ -1562,7 +1562,7 @@ void notify_peer_device_state_change(struct sk_buff *skb,
1154     .peer_resync_susp_dependency = p->resync_susp_dependency[NEW],
1155     };
1156    
1157     - notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type);
1158     + return notify_peer_device_state(skb, seq, peer_device, &peer_device_info, type);
1159     }
1160    
1161     static void broadcast_state_change(struct drbd_state_change *state_change)
1162     @@ -1570,7 +1570,7 @@ static void broadcast_state_change(struct drbd_state_change *state_change)
1163     struct drbd_resource_state_change *resource_state_change = &state_change->resource[0];
1164     bool resource_state_has_changed;
1165     unsigned int n_device, n_connection, n_peer_device, n_peer_devices;
1166     - void (*last_func)(struct sk_buff *, unsigned int, void *,
1167     + int (*last_func)(struct sk_buff *, unsigned int, void *,
1168     enum drbd_notification_type) = NULL;
1169     void *uninitialized_var(last_arg);
1170    
1171     diff --git a/drivers/block/drbd/drbd_state_change.h b/drivers/block/drbd/drbd_state_change.h
1172     index 9e503a1a0bfbc..e5a956d268664 100644
1173     --- a/drivers/block/drbd/drbd_state_change.h
1174     +++ b/drivers/block/drbd/drbd_state_change.h
1175     @@ -43,19 +43,19 @@ extern struct drbd_state_change *remember_old_state(struct drbd_resource *, gfp_
1176     extern void copy_old_to_new_state_change(struct drbd_state_change *);
1177     extern void forget_state_change(struct drbd_state_change *);
1178    
1179     -extern void notify_resource_state_change(struct sk_buff *,
1180     +extern int notify_resource_state_change(struct sk_buff *,
1181     unsigned int,
1182     struct drbd_resource_state_change *,
1183     enum drbd_notification_type type);
1184     -extern void notify_connection_state_change(struct sk_buff *,
1185     +extern int notify_connection_state_change(struct sk_buff *,
1186     unsigned int,
1187     struct drbd_connection_state_change *,
1188     enum drbd_notification_type type);
1189     -extern void notify_device_state_change(struct sk_buff *,
1190     +extern int notify_device_state_change(struct sk_buff *,
1191     unsigned int,
1192     struct drbd_device_state_change *,
1193     enum drbd_notification_type type);
1194     -extern void notify_peer_device_state_change(struct sk_buff *,
1195     +extern int notify_peer_device_state_change(struct sk_buff *,
1196     unsigned int,
1197     struct drbd_peer_device_state_change *,
1198     enum drbd_notification_type type);
1199     diff --git a/drivers/block/loop.c b/drivers/block/loop.c
1200     index f236b7984b946..2ff17b397cd2f 100644
1201     --- a/drivers/block/loop.c
1202     +++ b/drivers/block/loop.c
1203     @@ -773,33 +773,33 @@ static ssize_t loop_attr_backing_file_show(struct loop_device *lo, char *buf)
1204    
1205     static ssize_t loop_attr_offset_show(struct loop_device *lo, char *buf)
1206     {
1207     - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_offset);
1208     + return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_offset);
1209     }
1210    
1211     static ssize_t loop_attr_sizelimit_show(struct loop_device *lo, char *buf)
1212     {
1213     - return sprintf(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
1214     + return sysfs_emit(buf, "%llu\n", (unsigned long long)lo->lo_sizelimit);
1215     }
1216    
1217     static ssize_t loop_attr_autoclear_show(struct loop_device *lo, char *buf)
1218     {
1219     int autoclear = (lo->lo_flags & LO_FLAGS_AUTOCLEAR);
1220    
1221     - return sprintf(buf, "%s\n", autoclear ? "1" : "0");
1222     + return sysfs_emit(buf, "%s\n", autoclear ? "1" : "0");
1223     }
1224    
1225     static ssize_t loop_attr_partscan_show(struct loop_device *lo, char *buf)
1226     {
1227     int partscan = (lo->lo_flags & LO_FLAGS_PARTSCAN);
1228    
1229     - return sprintf(buf, "%s\n", partscan ? "1" : "0");
1230     + return sysfs_emit(buf, "%s\n", partscan ? "1" : "0");
1231     }
1232    
1233     static ssize_t loop_attr_dio_show(struct loop_device *lo, char *buf)
1234     {
1235     int dio = (lo->lo_flags & LO_FLAGS_DIRECT_IO);
1236    
1237     - return sprintf(buf, "%s\n", dio ? "1" : "0");
1238     + return sysfs_emit(buf, "%s\n", dio ? "1" : "0");
1239     }
1240    
1241     LOOP_ATTR_RO(backing_file);
1242     diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
1243     index 302260e9002c7..45bd0d7d6a942 100644
1244     --- a/drivers/block/virtio_blk.c
1245     +++ b/drivers/block/virtio_blk.c
1246     @@ -692,9 +692,17 @@ static int virtblk_probe(struct virtio_device *vdev)
1247     err = virtio_cread_feature(vdev, VIRTIO_BLK_F_BLK_SIZE,
1248     struct virtio_blk_config, blk_size,
1249     &blk_size);
1250     - if (!err)
1251     + if (!err) {
1252     + err = blk_validate_block_size(blk_size);
1253     + if (err) {
1254     + dev_err(&vdev->dev,
1255     + "virtio_blk: invalid block size: 0x%x\n",
1256     + blk_size);
1257     + goto out_free_tags;
1258     + }
1259     +
1260     blk_queue_logical_block_size(q, blk_size);
1261     - else
1262     + } else
1263     blk_size = queue_logical_block_size(q);
1264    
1265     /* Use topology information if available */
1266     diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
1267     index 2632b0fdb1b53..ba4c546db756f 100644
1268     --- a/drivers/char/virtio_console.c
1269     +++ b/drivers/char/virtio_console.c
1270     @@ -2004,6 +2004,13 @@ static void virtcons_remove(struct virtio_device *vdev)
1271     list_del(&portdev->list);
1272     spin_unlock_irq(&pdrvdata_lock);
1273    
1274     + /* Device is going away, exit any polling for buffers */
1275     + virtio_break_device(vdev);
1276     + if (use_multiport(portdev))
1277     + flush_work(&portdev->control_work);
1278     + else
1279     + flush_work(&portdev->config_work);
1280     +
1281     /* Disable interrupts for vqs */
1282     vdev->config->reset(vdev);
1283     /* Finish up work that's lined up */
1284     @@ -2277,7 +2284,7 @@ static struct virtio_driver virtio_rproc_serial = {
1285     .remove = virtcons_remove,
1286     };
1287    
1288     -static int __init init(void)
1289     +static int __init virtio_console_init(void)
1290     {
1291     int err;
1292    
1293     @@ -2314,7 +2321,7 @@ free:
1294     return err;
1295     }
1296    
1297     -static void __exit fini(void)
1298     +static void __exit virtio_console_fini(void)
1299     {
1300     reclaim_dma_bufs();
1301    
1302     @@ -2324,8 +2331,8 @@ static void __exit fini(void)
1303     class_destroy(pdrvdata.class);
1304     debugfs_remove_recursive(pdrvdata.debugfs_dir);
1305     }
1306     -module_init(init);
1307     -module_exit(fini);
1308     +module_init(virtio_console_init);
1309     +module_exit(virtio_console_fini);
1310    
1311     MODULE_DESCRIPTION("Virtio console driver");
1312     MODULE_LICENSE("GPL");
1313     diff --git a/drivers/clk/clk-clps711x.c b/drivers/clk/clk-clps711x.c
1314     index 9193f64561f6f..4dcf15a882699 100644
1315     --- a/drivers/clk/clk-clps711x.c
1316     +++ b/drivers/clk/clk-clps711x.c
1317     @@ -32,11 +32,13 @@ static const struct clk_div_table spi_div_table[] = {
1318     { .val = 1, .div = 8, },
1319     { .val = 2, .div = 2, },
1320     { .val = 3, .div = 1, },
1321     + { /* sentinel */ }
1322     };
1323    
1324     static const struct clk_div_table timer_div_table[] = {
1325     { .val = 0, .div = 256, },
1326     { .val = 1, .div = 1, },
1327     + { /* sentinel */ }
1328     };
1329    
1330     struct clps711x_clk {
1331     diff --git a/drivers/clk/loongson1/clk-loongson1c.c b/drivers/clk/loongson1/clk-loongson1c.c
1332     index 3466f7320b40b..e3aa502761a31 100644
1333     --- a/drivers/clk/loongson1/clk-loongson1c.c
1334     +++ b/drivers/clk/loongson1/clk-loongson1c.c
1335     @@ -40,6 +40,7 @@ static const struct clk_div_table ahb_div_table[] = {
1336     [1] = { .val = 1, .div = 4 },
1337     [2] = { .val = 2, .div = 3 },
1338     [3] = { .val = 3, .div = 3 },
1339     + [4] = { /* sentinel */ }
1340     };
1341    
1342     void __init ls1x_clk_init(void)
1343     diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
1344     index 29abb600d7e15..e4d605dcc03db 100644
1345     --- a/drivers/clk/qcom/clk-rcg2.c
1346     +++ b/drivers/clk/qcom/clk-rcg2.c
1347     @@ -644,6 +644,7 @@ static const struct frac_entry frac_table_pixel[] = {
1348     { 2, 9 },
1349     { 4, 9 },
1350     { 1, 1 },
1351     + { 2, 3 },
1352     { }
1353     };
1354    
1355     diff --git a/drivers/clk/tegra/clk-emc.c b/drivers/clk/tegra/clk-emc.c
1356     index 74e7544f861ba..348e7196b7b93 100644
1357     --- a/drivers/clk/tegra/clk-emc.c
1358     +++ b/drivers/clk/tegra/clk-emc.c
1359     @@ -190,6 +190,7 @@ static struct tegra_emc *emc_ensure_emc_driver(struct tegra_clk_emc *tegra)
1360    
1361     tegra->emc = platform_get_drvdata(pdev);
1362     if (!tegra->emc) {
1363     + put_device(&pdev->dev);
1364     pr_err("%s: cannot find EMC driver\n", __func__);
1365     return NULL;
1366     }
1367     diff --git a/drivers/clk/uniphier/clk-uniphier-fixed-rate.c b/drivers/clk/uniphier/clk-uniphier-fixed-rate.c
1368     index 0ad0d46173c0e..225de2302cb76 100644
1369     --- a/drivers/clk/uniphier/clk-uniphier-fixed-rate.c
1370     +++ b/drivers/clk/uniphier/clk-uniphier-fixed-rate.c
1371     @@ -33,6 +33,7 @@ struct clk_hw *uniphier_clk_register_fixed_rate(struct device *dev,
1372    
1373     init.name = name;
1374     init.ops = &clk_fixed_rate_ops;
1375     + init.flags = 0;
1376     init.parent_names = NULL;
1377     init.num_parents = 0;
1378    
1379     diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
1380     index 28037d0b8dcd1..55348e7c1e6f7 100644
1381     --- a/drivers/clocksource/acpi_pm.c
1382     +++ b/drivers/clocksource/acpi_pm.c
1383     @@ -230,8 +230,10 @@ static int __init parse_pmtmr(char *arg)
1384     int ret;
1385    
1386     ret = kstrtouint(arg, 16, &base);
1387     - if (ret)
1388     - return ret;
1389     + if (ret) {
1390     + pr_warn("PMTMR: invalid 'pmtmr=' value: '%s'\n", arg);
1391     + return 1;
1392     + }
1393    
1394     pr_info("PMTMR IOPort override: 0x%04x -> 0x%04x\n", pmtmr_ioport,
1395     base);
1396     diff --git a/drivers/crypto/ccp/ccp-dmaengine.c b/drivers/crypto/ccp/ccp-dmaengine.c
1397     index c4581510c3a14..6f9e228fc8adb 100644
1398     --- a/drivers/crypto/ccp/ccp-dmaengine.c
1399     +++ b/drivers/crypto/ccp/ccp-dmaengine.c
1400     @@ -621,6 +621,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)
1401     return 0;
1402     }
1403    
1404     +static void ccp_dma_release(struct ccp_device *ccp)
1405     +{
1406     + struct ccp_dma_chan *chan;
1407     + struct dma_chan *dma_chan;
1408     + unsigned int i;
1409     +
1410     + for (i = 0; i < ccp->cmd_q_count; i++) {
1411     + chan = ccp->ccp_dma_chan + i;
1412     + dma_chan = &chan->dma_chan;
1413     + tasklet_kill(&chan->cleanup_tasklet);
1414     + list_del_rcu(&dma_chan->device_node);
1415     + }
1416     +}
1417     +
1418     int ccp_dmaengine_register(struct ccp_device *ccp)
1419     {
1420     struct ccp_dma_chan *chan;
1421     @@ -715,6 +729,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)
1422     return 0;
1423    
1424     err_reg:
1425     + ccp_dma_release(ccp);
1426     kmem_cache_destroy(ccp->dma_desc_cache);
1427    
1428     err_cache:
1429     @@ -728,6 +743,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)
1430     struct dma_device *dma_dev = &ccp->dma_dev;
1431    
1432     dma_async_device_unregister(dma_dev);
1433     + ccp_dma_release(ccp);
1434    
1435     kmem_cache_destroy(ccp->dma_desc_cache);
1436     kmem_cache_destroy(ccp->dma_cmd_cache);
1437     diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c
1438     index 0e14a6642de42..ad714798f5d86 100644
1439     --- a/drivers/crypto/mxs-dcp.c
1440     +++ b/drivers/crypto/mxs-dcp.c
1441     @@ -328,7 +328,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
1442     memset(key + AES_KEYSIZE_128, 0, AES_KEYSIZE_128);
1443     }
1444    
1445     - for_each_sg(req->src, src, sg_nents(src), i) {
1446     + for_each_sg(req->src, src, sg_nents(req->src), i) {
1447     src_buf = sg_virt(src);
1448     len = sg_dma_len(src);
1449     tlen += len;
1450     diff --git a/drivers/crypto/vmx/Kconfig b/drivers/crypto/vmx/Kconfig
1451     index c3d524ea69987..f39eeca87932e 100644
1452     --- a/drivers/crypto/vmx/Kconfig
1453     +++ b/drivers/crypto/vmx/Kconfig
1454     @@ -1,7 +1,11 @@
1455     config CRYPTO_DEV_VMX_ENCRYPT
1456     tristate "Encryption acceleration support on P8 CPU"
1457     depends on CRYPTO_DEV_VMX
1458     + select CRYPTO_AES
1459     + select CRYPTO_CBC
1460     + select CRYPTO_CTR
1461     select CRYPTO_GHASH
1462     + select CRYPTO_XTS
1463     default m
1464     help
1465     Support for VMX cryptographic acceleration instructions on Power8 CPU.
1466     diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
1467     index 4f8dfe77da3c5..12fa48e380cf5 100644
1468     --- a/drivers/dma/sh/shdma-base.c
1469     +++ b/drivers/dma/sh/shdma-base.c
1470     @@ -118,10 +118,8 @@ static dma_cookie_t shdma_tx_submit(struct dma_async_tx_descriptor *tx)
1471     ret = pm_runtime_get(schan->dev);
1472    
1473     spin_unlock_irq(&schan->chan_lock);
1474     - if (ret < 0) {
1475     + if (ret < 0)
1476     dev_err(schan->dev, "%s(): GET = %d\n", __func__, ret);
1477     - pm_runtime_put(schan->dev);
1478     - }
1479    
1480     pm_runtime_barrier(schan->dev);
1481    
1482     diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
1483     index 6a3470f849989..732713ff3190d 100644
1484     --- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c
1485     +++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c
1486     @@ -607,6 +607,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events)
1487     event_waiters = kmalloc_array(num_events,
1488     sizeof(struct kfd_event_waiter),
1489     GFP_KERNEL);
1490     + if (!event_waiters)
1491     + return NULL;
1492    
1493     for (i = 0; (event_waiters) && (i < num_events) ; i++) {
1494     INIT_LIST_HEAD(&event_waiters[i].waiters);
1495     diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
1496     index b07b32eb0c4bb..6f93250518e3e 100644
1497     --- a/drivers/gpu/drm/drm_edid.c
1498     +++ b/drivers/gpu/drm/drm_edid.c
1499     @@ -3791,16 +3791,8 @@ static void drm_parse_hdmi_deep_color_info(struct drm_connector *connector,
1500     connector->name, dc_bpc);
1501     info->bpc = dc_bpc;
1502    
1503     - /*
1504     - * Deep color support mandates RGB444 support for all video
1505     - * modes and forbids YCRCB422 support for all video modes per
1506     - * HDMI 1.3 spec.
1507     - */
1508     - info->color_formats = DRM_COLOR_FORMAT_RGB444;
1509     -
1510     /* YCRCB444 is optional according to spec. */
1511     if (hdmi[6] & DRM_EDID_HDMI_DC_Y444) {
1512     - info->color_formats |= DRM_COLOR_FORMAT_YCRCB444;
1513     DRM_DEBUG("%s: HDMI sink does YCRCB444 in deep color.\n",
1514     connector->name);
1515     }
1516     diff --git a/drivers/gpu/drm/imx/parallel-display.c b/drivers/gpu/drm/imx/parallel-display.c
1517     index d796ada2a47ab..924a11232b843 100644
1518     --- a/drivers/gpu/drm/imx/parallel-display.c
1519     +++ b/drivers/gpu/drm/imx/parallel-display.c
1520     @@ -83,8 +83,10 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)
1521     ret = of_get_drm_display_mode(np, &imxpd->mode,
1522     &imxpd->bus_flags,
1523     OF_USE_NATIVE_MODE);
1524     - if (ret)
1525     + if (ret) {
1526     + drm_mode_destroy(connector->dev, mode);
1527     return ret;
1528     + }
1529    
1530     drm_mode_copy(mode, &imxpd->mode);
1531     mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
1532     diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c
1533     index 3dea1216bafdc..dfd9e0b9582d8 100644
1534     --- a/drivers/gpu/drm/tegra/dsi.c
1535     +++ b/drivers/gpu/drm/tegra/dsi.c
1536     @@ -1475,8 +1475,10 @@ static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi)
1537     dsi->slave = platform_get_drvdata(gangster);
1538     of_node_put(np);
1539    
1540     - if (!dsi->slave)
1541     + if (!dsi->slave) {
1542     + put_device(&gangster->dev);
1543     return -EPROBE_DEFER;
1544     + }
1545    
1546     dsi->slave->master = dsi;
1547     }
1548     diff --git a/drivers/gpu/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c
1549     index a8d87ddd8a176..dc0511b22600c 100644
1550     --- a/drivers/gpu/ipu-v3/ipu-di.c
1551     +++ b/drivers/gpu/ipu-v3/ipu-di.c
1552     @@ -460,8 +460,9 @@ static void ipu_di_config_clock(struct ipu_di *di,
1553    
1554     error = rate / (sig->mode.pixelclock / 1000);
1555    
1556     - dev_dbg(di->ipu->dev, " IPU clock can give %lu with divider %u, error %d.%u%%\n",
1557     - rate, div, (signed)(error - 1000) / 10, error % 10);
1558     + dev_dbg(di->ipu->dev, " IPU clock can give %lu with divider %u, error %c%d.%d%%\n",
1559     + rate, div, error < 1000 ? '-' : '+',
1560     + abs(error - 1000) / 10, abs(error - 1000) % 10);
1561    
1562     /* Allow a 1% error */
1563     if (error < 1010 && error >= 990) {
1564     diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
1565     index 518ccf15188ef..26c7701fb188d 100644
1566     --- a/drivers/hid/i2c-hid/i2c-hid-core.c
1567     +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
1568     @@ -643,6 +643,17 @@ static int i2c_hid_get_raw_report(struct hid_device *hid,
1569     if (report_type == HID_OUTPUT_REPORT)
1570     return -EINVAL;
1571    
1572     + /*
1573     + * In case of unnumbered reports the response from the device will
1574     + * not have the report ID that the upper layers expect, so we need
1575     + * to stash it the buffer ourselves and adjust the data size.
1576     + */
1577     + if (!report_number) {
1578     + buf[0] = 0;
1579     + buf++;
1580     + count--;
1581     + }
1582     +
1583     /* +2 bytes to include the size of the reply in the query buffer */
1584     ask_count = min(count + 2, (size_t)ihid->bufsize);
1585    
1586     @@ -664,6 +675,9 @@ static int i2c_hid_get_raw_report(struct hid_device *hid,
1587     count = min(count, ret_count - 2);
1588     memcpy(buf, ihid->rawbuf + 2, count);
1589    
1590     + if (!report_number)
1591     + count++;
1592     +
1593     return count;
1594     }
1595    
1596     @@ -680,17 +694,19 @@ static int i2c_hid_output_raw_report(struct hid_device *hid, __u8 *buf,
1597    
1598     mutex_lock(&ihid->reset_lock);
1599    
1600     - if (report_id) {
1601     - buf++;
1602     - count--;
1603     - }
1604     -
1605     + /*
1606     + * Note that both numbered and unnumbered reports passed here
1607     + * are supposed to have report ID stored in the 1st byte of the
1608     + * buffer, so we strip it off unconditionally before passing payload
1609     + * to i2c_hid_set_or_send_report which takes care of encoding
1610     + * everything properly.
1611     + */
1612     ret = i2c_hid_set_or_send_report(client,
1613     report_type == HID_FEATURE_REPORT ? 0x03 : 0x02,
1614     - report_id, buf, count, use_data);
1615     + report_id, buf + 1, count - 1, use_data);
1616    
1617     - if (report_id && ret >= 0)
1618     - ret++; /* add report_id to the number of transfered bytes */
1619     + if (ret >= 0)
1620     + ret++; /* add report_id to the number of transferred bytes */
1621    
1622     mutex_unlock(&ihid->reset_lock);
1623    
1624     diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h
1625     index bfcb13bae34bd..8b6acb7497e2e 100644
1626     --- a/drivers/hwmon/pmbus/pmbus.h
1627     +++ b/drivers/hwmon/pmbus/pmbus.h
1628     @@ -262,6 +262,7 @@ enum pmbus_regs {
1629     /*
1630     * STATUS_VOUT, STATUS_INPUT
1631     */
1632     +#define PB_VOLTAGE_VIN_OFF BIT(3)
1633     #define PB_VOLTAGE_UV_FAULT BIT(4)
1634     #define PB_VOLTAGE_UV_WARNING BIT(5)
1635     #define PB_VOLTAGE_OV_WARNING BIT(6)
1636     diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
1637     index 0d75bc7b50657..a662702632a8c 100644
1638     --- a/drivers/hwmon/pmbus/pmbus_core.c
1639     +++ b/drivers/hwmon/pmbus/pmbus_core.c
1640     @@ -1133,7 +1133,7 @@ static const struct pmbus_limit_attr vin_limit_attrs[] = {
1641     .reg = PMBUS_VIN_UV_FAULT_LIMIT,
1642     .attr = "lcrit",
1643     .alarm = "lcrit_alarm",
1644     - .sbit = PB_VOLTAGE_UV_FAULT,
1645     + .sbit = PB_VOLTAGE_UV_FAULT | PB_VOLTAGE_VIN_OFF,
1646     }, {
1647     .reg = PMBUS_VIN_OV_WARN_LIMIT,
1648     .attr = "max",
1649     @@ -1818,10 +1818,14 @@ static int pmbus_regulator_is_enabled(struct regulator_dev *rdev)
1650     {
1651     struct device *dev = rdev_get_dev(rdev);
1652     struct i2c_client *client = to_i2c_client(dev->parent);
1653     + struct pmbus_data *data = i2c_get_clientdata(client);
1654     u8 page = rdev_get_id(rdev);
1655     int ret;
1656    
1657     + mutex_lock(&data->update_lock);
1658     ret = pmbus_read_byte_data(client, page, PMBUS_OPERATION);
1659     + mutex_unlock(&data->update_lock);
1660     +
1661     if (ret < 0)
1662     return ret;
1663    
1664     @@ -1832,11 +1836,17 @@ static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable)
1665     {
1666     struct device *dev = rdev_get_dev(rdev);
1667     struct i2c_client *client = to_i2c_client(dev->parent);
1668     + struct pmbus_data *data = i2c_get_clientdata(client);
1669     u8 page = rdev_get_id(rdev);
1670     + int ret;
1671    
1672     - return pmbus_update_byte_data(client, page, PMBUS_OPERATION,
1673     - PB_OPERATION_CONTROL_ON,
1674     - enable ? PB_OPERATION_CONTROL_ON : 0);
1675     + mutex_lock(&data->update_lock);
1676     + ret = pmbus_update_byte_data(client, page, PMBUS_OPERATION,
1677     + PB_OPERATION_CONTROL_ON,
1678     + enable ? PB_OPERATION_CONTROL_ON : 0);
1679     + mutex_unlock(&data->update_lock);
1680     +
1681     + return ret;
1682     }
1683    
1684     static int pmbus_regulator_enable(struct regulator_dev *rdev)
1685     diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c
1686     index 68c350c704fba..5fd9b6769d420 100644
1687     --- a/drivers/hwmon/sch56xx-common.c
1688     +++ b/drivers/hwmon/sch56xx-common.c
1689     @@ -438,7 +438,7 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent,
1690     if (nowayout)
1691     set_bit(WDOG_NO_WAY_OUT, &data->wddev.status);
1692     if (output_enable & SCH56XX_WDOG_OUTPUT_ENABLE)
1693     - set_bit(WDOG_ACTIVE, &data->wddev.status);
1694     + set_bit(WDOG_HW_RUNNING, &data->wddev.status);
1695    
1696     /* Since the watchdog uses a downcounter there is no register to read
1697     the BIOS set timeout from (if any was set at all) ->
1698     diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
1699     index 00904c6b5b5e5..1bf107af8ce00 100644
1700     --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
1701     +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
1702     @@ -379,8 +379,12 @@ static ssize_t mode_store(struct device *dev,
1703     mode = ETM_MODE_QELEM(config->mode);
1704     /* start by clearing QE bits */
1705     config->cfg &= ~(BIT(13) | BIT(14));
1706     - /* if supported, Q elements with instruction counts are enabled */
1707     - if ((mode & BIT(0)) && (drvdata->q_support & BIT(0)))
1708     + /*
1709     + * if supported, Q elements with instruction counts are enabled.
1710     + * Always set the low bit for any requested mode. Valid combos are
1711     + * 0b00, 0b01 and 0b11.
1712     + */
1713     + if (mode && drvdata->q_support)
1714     config->cfg |= BIT(13);
1715     /*
1716     * if supported, Q elements with and without instruction
1717     diff --git a/drivers/i2c/busses/i2c-pasemi.c b/drivers/i2c/busses/i2c-pasemi.c
1718     index df1dbc92a0244..25c877654c32a 100644
1719     --- a/drivers/i2c/busses/i2c-pasemi.c
1720     +++ b/drivers/i2c/busses/i2c-pasemi.c
1721     @@ -145,6 +145,12 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,
1722    
1723     TXFIFO_WR(smbus, msg->buf[msg->len-1] |
1724     (stop ? MTXFIFO_STOP : 0));
1725     +
1726     + if (stop) {
1727     + err = pasemi_smb_waitready(smbus);
1728     + if (err)
1729     + goto reset_out;
1730     + }
1731     }
1732    
1733     return 0;
1734     diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
1735     index b72cf2f8da5cb..c65a5d0af555b 100644
1736     --- a/drivers/i2c/busses/i2c-xiic.c
1737     +++ b/drivers/i2c/busses/i2c-xiic.c
1738     @@ -727,7 +727,6 @@ static const struct i2c_algorithm xiic_algorithm = {
1739    
1740     static struct i2c_adapter xiic_adapter = {
1741     .owner = THIS_MODULE,
1742     - .name = DRIVER_NAME,
1743     .class = I2C_CLASS_DEPRECATED,
1744     .algo = &xiic_algorithm,
1745     };
1746     @@ -763,6 +762,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1747     i2c_set_adapdata(&i2c->adap, i2c);
1748     i2c->adap.dev.parent = &pdev->dev;
1749     i2c->adap.dev.of_node = pdev->dev.of_node;
1750     + snprintf(i2c->adap.name, sizeof(i2c->adap.name),
1751     + DRIVER_NAME " %s", pdev->name);
1752    
1753     mutex_init(&i2c->lock);
1754     init_waitqueue_head(&i2c->wait);
1755     diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
1756     index a86c511c29e0e..c347860b3690f 100644
1757     --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
1758     +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
1759     @@ -259,7 +259,7 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
1760    
1761     err = device_create_file(&pdev->dev, &dev_attr_available_masters);
1762     if (err)
1763     - goto err_rollback;
1764     + goto err_rollback_activation;
1765    
1766     err = device_create_file(&pdev->dev, &dev_attr_current_master);
1767     if (err)
1768     @@ -269,8 +269,9 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
1769    
1770     err_rollback_available:
1771     device_remove_file(&pdev->dev, &dev_attr_available_masters);
1772     -err_rollback:
1773     +err_rollback_activation:
1774     i2c_demux_deactivate_master(priv);
1775     +err_rollback:
1776     for (j = 0; j < i; j++) {
1777     of_node_put(priv->chan[j].parent_np);
1778     of_changeset_destroy(&priv->chan[j].chgset);
1779     diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c
1780     index becbb0aef232b..5075f594d97f7 100644
1781     --- a/drivers/iio/adc/twl6030-gpadc.c
1782     +++ b/drivers/iio/adc/twl6030-gpadc.c
1783     @@ -927,6 +927,8 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
1784     ret = devm_request_threaded_irq(dev, irq, NULL,
1785     twl6030_gpadc_irq_handler,
1786     IRQF_ONESHOT, "twl6030_gpadc", indio_dev);
1787     + if (ret)
1788     + return ret;
1789    
1790     ret = twl6030_gpadc_enable_irq(TWL6030_GPADC_RT_SW1_EOC_MASK);
1791     if (ret < 0) {
1792     diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
1793     index c4757e6367e7a..218cf4567ab58 100644
1794     --- a/drivers/iio/inkern.c
1795     +++ b/drivers/iio/inkern.c
1796     @@ -591,13 +591,35 @@ EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
1797     static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
1798     int raw, int *processed, unsigned int scale)
1799     {
1800     - int scale_type, scale_val, scale_val2, offset;
1801     + int scale_type, scale_val, scale_val2;
1802     + int offset_type, offset_val, offset_val2;
1803     s64 raw64 = raw;
1804     - int ret;
1805    
1806     - ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
1807     - if (ret >= 0)
1808     - raw64 += offset;
1809     + offset_type = iio_channel_read(chan, &offset_val, &offset_val2,
1810     + IIO_CHAN_INFO_OFFSET);
1811     + if (offset_type >= 0) {
1812     + switch (offset_type) {
1813     + case IIO_VAL_INT:
1814     + break;
1815     + case IIO_VAL_INT_PLUS_MICRO:
1816     + case IIO_VAL_INT_PLUS_NANO:
1817     + /*
1818     + * Both IIO_VAL_INT_PLUS_MICRO and IIO_VAL_INT_PLUS_NANO
1819     + * implicitely truncate the offset to it's integer form.
1820     + */
1821     + break;
1822     + case IIO_VAL_FRACTIONAL:
1823     + offset_val /= offset_val2;
1824     + break;
1825     + case IIO_VAL_FRACTIONAL_LOG2:
1826     + offset_val >>= offset_val2;
1827     + break;
1828     + default:
1829     + return -EINVAL;
1830     + }
1831     +
1832     + raw64 += offset_val;
1833     + }
1834    
1835     scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
1836     IIO_CHAN_INFO_SCALE);
1837     @@ -606,7 +628,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
1838    
1839     switch (scale_type) {
1840     case IIO_VAL_INT:
1841     - *processed = raw64 * scale_val;
1842     + *processed = raw64 * scale_val * scale;
1843     break;
1844     case IIO_VAL_INT_PLUS_MICRO:
1845     if (scale_val2 < 0)
1846     diff --git a/drivers/input/input.c b/drivers/input/input.c
1847     index cb31236425a11..5d94fc3fce0bb 100644
1848     --- a/drivers/input/input.c
1849     +++ b/drivers/input/input.c
1850     @@ -2112,12 +2112,6 @@ int input_register_device(struct input_dev *dev)
1851     /* KEY_RESERVED is not supposed to be transmitted to userspace. */
1852     __clear_bit(KEY_RESERVED, dev->keybit);
1853    
1854     - /* Buttonpads should not map BTN_RIGHT and/or BTN_MIDDLE. */
1855     - if (test_bit(INPUT_PROP_BUTTONPAD, dev->propbit)) {
1856     - __clear_bit(BTN_RIGHT, dev->keybit);
1857     - __clear_bit(BTN_MIDDLE, dev->keybit);
1858     - }
1859     -
1860     /* Make sure that bitmasks not mentioned in dev->evbit are clean. */
1861     input_cleanse_bitmasks(dev);
1862    
1863     diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
1864     index 48d3820087881..db40ce599e974 100644
1865     --- a/drivers/iommu/arm-smmu-v3.c
1866     +++ b/drivers/iommu/arm-smmu-v3.c
1867     @@ -1171,6 +1171,7 @@ static irqreturn_t arm_smmu_evtq_thread(int irq, void *dev)
1868     dev_info(smmu->dev, "\t0x%016llx\n",
1869     (unsigned long long)evt[i]);
1870    
1871     + cond_resched();
1872     }
1873    
1874     /*
1875     diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c
1876     index 9694529b709de..330beb62d015c 100644
1877     --- a/drivers/irqchip/irq-nvic.c
1878     +++ b/drivers/irqchip/irq-nvic.c
1879     @@ -108,6 +108,7 @@ static int __init nvic_of_init(struct device_node *node,
1880    
1881     if (!nvic_irq_domain) {
1882     pr_warn("Failed to allocate irq domain\n");
1883     + iounmap(nvic_base);
1884     return -ENOMEM;
1885     }
1886    
1887     @@ -117,6 +118,7 @@ static int __init nvic_of_init(struct device_node *node,
1888     if (ret) {
1889     pr_warn("Failed to allocate irq chips\n");
1890     irq_domain_remove(nvic_irq_domain);
1891     + iounmap(nvic_base);
1892     return ret;
1893     }
1894    
1895     diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
1896     index eb2659a123108..70245782e7f60 100644
1897     --- a/drivers/md/dm-ioctl.c
1898     +++ b/drivers/md/dm-ioctl.c
1899     @@ -16,6 +16,7 @@
1900     #include <linux/dm-ioctl.h>
1901     #include <linux/hdreg.h>
1902     #include <linux/compat.h>
1903     +#include <linux/nospec.h>
1904    
1905     #include <asm/uaccess.h>
1906    
1907     @@ -1642,6 +1643,7 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)
1908     if (unlikely(cmd >= ARRAY_SIZE(_ioctls)))
1909     return NULL;
1910    
1911     + cmd = array_index_nospec(cmd, ARRAY_SIZE(_ioctls));
1912     *ioctl_flags = _ioctls[cmd].flags;
1913     return _ioctls[cmd].fn;
1914     }
1915     diff --git a/drivers/media/pci/cx88/cx88-mpeg.c b/drivers/media/pci/cx88/cx88-mpeg.c
1916     index 245357adbc250..37d4512f3eb80 100644
1917     --- a/drivers/media/pci/cx88/cx88-mpeg.c
1918     +++ b/drivers/media/pci/cx88/cx88-mpeg.c
1919     @@ -175,6 +175,9 @@ int cx8802_start_dma(struct cx8802_dev *dev,
1920     cx_write(MO_TS_GPCNTRL, GP_COUNT_CONTROL_RESET);
1921     q->count = 0;
1922    
1923     + /* clear interrupt status register */
1924     + cx_write(MO_TS_INTSTAT, 0x1f1111);
1925     +
1926     /* enable irqs */
1927     dprintk( 1, "setting the interrupt mask\n" );
1928     cx_set(MO_PCI_INTMSK, core->pci_irqmask | PCI_INT_TSINT);
1929     diff --git a/drivers/media/platform/davinci/vpif.c b/drivers/media/platform/davinci/vpif.c
1930     index 0380cf2e5775d..736719d6d648d 100644
1931     --- a/drivers/media/platform/davinci/vpif.c
1932     +++ b/drivers/media/platform/davinci/vpif.c
1933     @@ -437,6 +437,7 @@ static int vpif_probe(struct platform_device *pdev)
1934    
1935     static int vpif_remove(struct platform_device *pdev)
1936     {
1937     + pm_runtime_put(&pdev->dev);
1938     pm_runtime_disable(&pdev->dev);
1939     return 0;
1940     }
1941     diff --git a/drivers/media/usb/go7007/s2250-board.c b/drivers/media/usb/go7007/s2250-board.c
1942     index 1466db150d82c..625e77f4dbd2e 100644
1943     --- a/drivers/media/usb/go7007/s2250-board.c
1944     +++ b/drivers/media/usb/go7007/s2250-board.c
1945     @@ -512,6 +512,7 @@ static int s2250_probe(struct i2c_client *client,
1946     u8 *data;
1947     struct go7007 *go = i2c_get_adapdata(adapter);
1948     struct go7007_usb *usb = go->hpi_context;
1949     + int err = -EIO;
1950    
1951     audio = i2c_new_dummy(adapter, TLV320_ADDRESS >> 1);
1952     if (audio == NULL)
1953     @@ -540,11 +541,8 @@ static int s2250_probe(struct i2c_client *client,
1954     V4L2_CID_HUE, -512, 511, 1, 0);
1955     sd->ctrl_handler = &state->hdl;
1956     if (state->hdl.error) {
1957     - int err = state->hdl.error;
1958     -
1959     - v4l2_ctrl_handler_free(&state->hdl);
1960     - kfree(state);
1961     - return err;
1962     + err = state->hdl.error;
1963     + goto fail;
1964     }
1965    
1966     state->std = V4L2_STD_NTSC;
1967     @@ -608,7 +606,7 @@ fail:
1968     i2c_unregister_device(audio);
1969     v4l2_ctrl_handler_free(&state->hdl);
1970     kfree(state);
1971     - return -EIO;
1972     + return err;
1973     }
1974    
1975     static int s2250_remove(struct i2c_client *client)
1976     diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
1977     index 474c11e1d4951..cfd8c09f9ded7 100644
1978     --- a/drivers/media/usb/hdpvr/hdpvr-video.c
1979     +++ b/drivers/media/usb/hdpvr/hdpvr-video.c
1980     @@ -312,7 +312,6 @@ static int hdpvr_start_streaming(struct hdpvr_device *dev)
1981    
1982     dev->status = STATUS_STREAMING;
1983    
1984     - INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
1985     schedule_work(&dev->worker);
1986    
1987     v4l2_dbg(MSG_BUFFER, hdpvr_debug, &dev->v4l2_dev,
1988     @@ -1156,6 +1155,9 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
1989     bool ac3 = dev->flags & HDPVR_FLAG_AC3_CAP;
1990     int res;
1991    
1992     + // initialize dev->worker
1993     + INIT_WORK(&dev->worker, hdpvr_transmit_buffers);
1994     +
1995     dev->cur_std = V4L2_STD_525_60;
1996     dev->width = 720;
1997     dev->height = 480;
1998     diff --git a/drivers/memory/emif.c b/drivers/memory/emif.c
1999     index 88c32b8dc88a1..9f293b931144e 100644
2000     --- a/drivers/memory/emif.c
2001     +++ b/drivers/memory/emif.c
2002     @@ -1425,7 +1425,7 @@ static struct emif_data *__init_or_module get_device_details(
2003     temp = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
2004     dev_info = devm_kzalloc(dev, sizeof(*dev_info), GFP_KERNEL);
2005    
2006     - if (!emif || !pd || !dev_info) {
2007     + if (!emif || !temp || !dev_info) {
2008     dev_err(dev, "%s:%d: allocation error\n", __func__, __LINE__);
2009     goto error;
2010     }
2011     @@ -1517,7 +1517,7 @@ static int __init_or_module emif_probe(struct platform_device *pdev)
2012     {
2013     struct emif_data *emif;
2014     struct resource *res;
2015     - int irq;
2016     + int irq, ret;
2017    
2018     if (pdev->dev.of_node)
2019     emif = of_get_memory_device_details(pdev->dev.of_node, &pdev->dev);
2020     @@ -1551,7 +1551,9 @@ static int __init_or_module emif_probe(struct platform_device *pdev)
2021     emif_onetime_settings(emif);
2022     emif_debugfs_init(emif);
2023     disable_and_clear_all_interrupts(emif);
2024     - setup_interrupts(emif, irq);
2025     + ret = setup_interrupts(emif, irq);
2026     + if (ret)
2027     + goto error;
2028    
2029     /* One-time actions taken on probing the first device */
2030     if (!emif1) {
2031     diff --git a/drivers/mfd/asic3.c b/drivers/mfd/asic3.c
2032     index 0413c8159551e..34270e237726f 100644
2033     --- a/drivers/mfd/asic3.c
2034     +++ b/drivers/mfd/asic3.c
2035     @@ -915,14 +915,14 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
2036     ret = mfd_add_devices(&pdev->dev, pdev->id,
2037     &asic3_cell_ds1wm, 1, mem, asic->irq_base, NULL);
2038     if (ret < 0)
2039     - goto out;
2040     + goto out_unmap;
2041     }
2042    
2043     if (mem_sdio && (irq >= 0)) {
2044     ret = mfd_add_devices(&pdev->dev, pdev->id,
2045     &asic3_cell_mmc, 1, mem_sdio, irq, NULL);
2046     if (ret < 0)
2047     - goto out;
2048     + goto out_unmap;
2049     }
2050    
2051     ret = 0;
2052     @@ -936,8 +936,12 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
2053     ret = mfd_add_devices(&pdev->dev, 0,
2054     asic3_cell_leds, ASIC3_NUM_LEDS, NULL, 0, NULL);
2055     }
2056     + return ret;
2057    
2058     - out:
2059     +out_unmap:
2060     + if (asic->tmio_cnf)
2061     + iounmap(asic->tmio_cnf);
2062     +out:
2063     return ret;
2064     }
2065    
2066     diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
2067     index 75d52034f89da..5b4faebdcae23 100644
2068     --- a/drivers/mfd/mc13xxx-core.c
2069     +++ b/drivers/mfd/mc13xxx-core.c
2070     @@ -313,8 +313,10 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
2071     adc1 |= MC13783_ADC1_ATOX;
2072    
2073     dev_dbg(mc13xxx->dev, "%s: request irq\n", __func__);
2074     - mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
2075     + ret = mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
2076     mc13xxx_handler_adcdone, __func__, &adcdone_data);
2077     + if (ret)
2078     + goto out;
2079    
2080     mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, adc0);
2081     mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
2082     diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
2083     index ab2184003c29d..d75686c1c6e85 100644
2084     --- a/drivers/misc/kgdbts.c
2085     +++ b/drivers/misc/kgdbts.c
2086     @@ -1066,10 +1066,10 @@ static int kgdbts_option_setup(char *opt)
2087     {
2088     if (strlen(opt) >= MAX_CONFIG_LEN) {
2089     printk(KERN_ERR "kgdbts: config string too long\n");
2090     - return -ENOSPC;
2091     + return 1;
2092     }
2093     strcpy(config, opt);
2094     - return 0;
2095     + return 1;
2096     }
2097    
2098     __setup("kgdbts=", kgdbts_option_setup);
2099     diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
2100     index 848b3453517ea..60c2ca58dec34 100644
2101     --- a/drivers/mmc/core/host.c
2102     +++ b/drivers/mmc/core/host.c
2103     @@ -403,6 +403,16 @@ again:
2104    
2105     EXPORT_SYMBOL(mmc_alloc_host);
2106    
2107     +static int mmc_validate_host_caps(struct mmc_host *host)
2108     +{
2109     + if (host->caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) {
2110     + dev_warn(host->parent, "missing ->enable_sdio_irq() ops\n");
2111     + return -EINVAL;
2112     + }
2113     +
2114     + return 0;
2115     +}
2116     +
2117     /**
2118     * mmc_add_host - initialise host hardware
2119     * @host: mmc host
2120     @@ -415,8 +425,9 @@ int mmc_add_host(struct mmc_host *host)
2121     {
2122     int err;
2123    
2124     - WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
2125     - !host->ops->enable_sdio_irq);
2126     + err = mmc_validate_host_caps(host);
2127     + if (err)
2128     + return err;
2129    
2130     err = device_add(&host->class_dev);
2131     if (err)
2132     diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
2133     index 125da34d8ff95..23a878e7974e0 100644
2134     --- a/drivers/mtd/onenand/generic.c
2135     +++ b/drivers/mtd/onenand/generic.c
2136     @@ -58,7 +58,12 @@ static int generic_onenand_probe(struct platform_device *pdev)
2137     }
2138    
2139     info->onenand.mmcontrol = pdata ? pdata->mmcontrol : NULL;
2140     - info->onenand.irq = platform_get_irq(pdev, 0);
2141     +
2142     + err = platform_get_irq(pdev, 0);
2143     + if (err < 0)
2144     + goto out_iounmap;
2145     +
2146     + info->onenand.irq = err;
2147    
2148     info->mtd.dev.parent = &pdev->dev;
2149     info->mtd.priv = &info->onenand;
2150     diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
2151     index e7b177c61642f..1486f9af8f1e8 100644
2152     --- a/drivers/mtd/ubi/fastmap.c
2153     +++ b/drivers/mtd/ubi/fastmap.c
2154     @@ -478,7 +478,9 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
2155     if (err == UBI_IO_FF_BITFLIPS)
2156     scrub = 1;
2157    
2158     - add_aeb(ai, free, pnum, ec, scrub);
2159     + ret = add_aeb(ai, free, pnum, ec, scrub);
2160     + if (ret)
2161     + goto out;
2162     continue;
2163     } else if (err == 0 || err == UBI_IO_BITFLIPS) {
2164     dbg_bld("Found non empty PEB:%i in pool", pnum);
2165     @@ -648,8 +650,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
2166     if (fm_pos >= fm_size)
2167     goto fail_bad;
2168    
2169     - add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum),
2170     - be32_to_cpu(fmec->ec), 0);
2171     + ret = add_aeb(ai, &ai->free, be32_to_cpu(fmec->pnum),
2172     + be32_to_cpu(fmec->ec), 0);
2173     + if (ret)
2174     + goto fail;
2175     }
2176    
2177     /* read EC values from used list */
2178     @@ -659,8 +663,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
2179     if (fm_pos >= fm_size)
2180     goto fail_bad;
2181    
2182     - add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
2183     - be32_to_cpu(fmec->ec), 0);
2184     + ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
2185     + be32_to_cpu(fmec->ec), 0);
2186     + if (ret)
2187     + goto fail;
2188     }
2189    
2190     /* read EC values from scrub list */
2191     @@ -670,8 +676,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
2192     if (fm_pos >= fm_size)
2193     goto fail_bad;
2194    
2195     - add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
2196     - be32_to_cpu(fmec->ec), 1);
2197     + ret = add_aeb(ai, &used, be32_to_cpu(fmec->pnum),
2198     + be32_to_cpu(fmec->ec), 1);
2199     + if (ret)
2200     + goto fail;
2201     }
2202    
2203     /* read EC values from erase list */
2204     @@ -681,8 +689,10 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
2205     if (fm_pos >= fm_size)
2206     goto fail_bad;
2207    
2208     - add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum),
2209     - be32_to_cpu(fmec->ec), 1);
2210     + ret = add_aeb(ai, &ai->erase, be32_to_cpu(fmec->pnum),
2211     + be32_to_cpu(fmec->ec), 1);
2212     + if (ret)
2213     + goto fail;
2214     }
2215    
2216     ai->mean_ec = div_u64(ai->ec_sum, ai->ec_count);
2217     diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
2218     index d62d61d734ea1..4d01b6cbf0ebf 100644
2219     --- a/drivers/net/can/usb/ems_usb.c
2220     +++ b/drivers/net/can/usb/ems_usb.c
2221     @@ -834,7 +834,6 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
2222    
2223     usb_unanchor_urb(urb);
2224     usb_free_coherent(dev->udev, size, buf, urb->transfer_dma);
2225     - dev_kfree_skb(skb);
2226    
2227     atomic_dec(&dev->active_tx_urbs);
2228    
2229     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
2230     index 9e5251c427a36..401d9718841fc 100644
2231     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
2232     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
2233     @@ -1008,9 +1008,7 @@ static int bnxt_set_pauseparam(struct net_device *dev,
2234     }
2235    
2236     link_info->autoneg |= BNXT_AUTONEG_FLOW_CTRL;
2237     - if (bp->hwrm_spec_code >= 0x10201)
2238     - link_info->req_flow_ctrl =
2239     - PORT_PHY_CFG_REQ_AUTO_PAUSE_AUTONEG_PAUSE;
2240     + link_info->req_flow_ctrl = 0;
2241     } else {
2242     /* when transition from auto pause to force pause,
2243     * force a link change
2244     diff --git a/drivers/net/ethernet/micrel/Kconfig b/drivers/net/ethernet/micrel/Kconfig
2245     index b7e2f49696b74..aa12bace8673e 100644
2246     --- a/drivers/net/ethernet/micrel/Kconfig
2247     +++ b/drivers/net/ethernet/micrel/Kconfig
2248     @@ -45,6 +45,7 @@ config KS8851
2249     config KS8851_MLL
2250     tristate "Micrel KS8851 MLL"
2251     depends on HAS_IOMEM
2252     + depends on PTP_1588_CLOCK_OPTIONAL
2253     select MII
2254     ---help---
2255     This platform driver is for Micrel KS8851 Address/data bus
2256     diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
2257     index f4aa6331b367b..0a9d24e86715d 100644
2258     --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
2259     +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_dcb.h
2260     @@ -52,7 +52,7 @@ static inline int qlcnic_dcb_get_hw_capability(struct qlcnic_dcb *dcb)
2261     if (dcb && dcb->ops->get_hw_capability)
2262     return dcb->ops->get_hw_capability(dcb);
2263    
2264     - return 0;
2265     + return -EOPNOTSUPP;
2266     }
2267    
2268     static inline void qlcnic_dcb_free(struct qlcnic_dcb *dcb)
2269     @@ -66,7 +66,7 @@ static inline int qlcnic_dcb_attach(struct qlcnic_dcb *dcb)
2270     if (dcb && dcb->ops->attach)
2271     return dcb->ops->attach(dcb);
2272    
2273     - return 0;
2274     + return -EOPNOTSUPP;
2275     }
2276    
2277     static inline int
2278     @@ -75,7 +75,7 @@ qlcnic_dcb_query_hw_capability(struct qlcnic_dcb *dcb, char *buf)
2279     if (dcb && dcb->ops->query_hw_capability)
2280     return dcb->ops->query_hw_capability(dcb, buf);
2281    
2282     - return 0;
2283     + return -EOPNOTSUPP;
2284     }
2285    
2286     static inline void qlcnic_dcb_get_info(struct qlcnic_dcb *dcb)
2287     @@ -90,7 +90,7 @@ qlcnic_dcb_query_cee_param(struct qlcnic_dcb *dcb, char *buf, u8 type)
2288     if (dcb && dcb->ops->query_cee_param)
2289     return dcb->ops->query_cee_param(dcb, buf, type);
2290    
2291     - return 0;
2292     + return -EOPNOTSUPP;
2293     }
2294    
2295     static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
2296     @@ -98,7 +98,7 @@ static inline int qlcnic_dcb_get_cee_cfg(struct qlcnic_dcb *dcb)
2297     if (dcb && dcb->ops->get_cee_cfg)
2298     return dcb->ops->get_cee_cfg(dcb);
2299    
2300     - return 0;
2301     + return -EOPNOTSUPP;
2302     }
2303    
2304     static inline void qlcnic_dcb_aen_handler(struct qlcnic_dcb *dcb, void *msg)
2305     diff --git a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
2306     index 6a9c954492f22..6ca428a702f16 100644
2307     --- a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
2308     +++ b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.c
2309     @@ -68,10 +68,6 @@
2310     #define TSE_PCS_USE_SGMII_ENA BIT(0)
2311     #define TSE_PCS_IF_USE_SGMII 0x03
2312    
2313     -#define SGMII_ADAPTER_CTRL_REG 0x00
2314     -#define SGMII_ADAPTER_DISABLE 0x0001
2315     -#define SGMII_ADAPTER_ENABLE 0x0000
2316     -
2317     #define AUTONEGO_LINK_TIMER 20
2318    
2319     static int tse_pcs_reset(void __iomem *base, struct tse_pcs *pcs)
2320     @@ -215,12 +211,8 @@ void tse_pcs_fix_mac_speed(struct tse_pcs *pcs, struct phy_device *phy_dev,
2321     unsigned int speed)
2322     {
2323     void __iomem *tse_pcs_base = pcs->tse_pcs_base;
2324     - void __iomem *sgmii_adapter_base = pcs->sgmii_adapter_base;
2325     u32 val;
2326    
2327     - writew(SGMII_ADAPTER_ENABLE,
2328     - sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
2329     -
2330     pcs->autoneg = phy_dev->autoneg;
2331    
2332     if (phy_dev->autoneg == AUTONEG_ENABLE) {
2333     diff --git a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h
2334     index 2f5882450b06a..254199f2efdbf 100644
2335     --- a/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h
2336     +++ b/drivers/net/ethernet/stmicro/stmmac/altr_tse_pcs.h
2337     @@ -21,6 +21,10 @@
2338     #include <linux/phy.h>
2339     #include <linux/timer.h>
2340    
2341     +#define SGMII_ADAPTER_CTRL_REG 0x00
2342     +#define SGMII_ADAPTER_ENABLE 0x0000
2343     +#define SGMII_ADAPTER_DISABLE 0x0001
2344     +
2345     struct tse_pcs {
2346     struct device *dev;
2347     void __iomem *tse_pcs_base;
2348     diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2349     index c3a78c1134240..b138968b8672a 100644
2350     --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2351     +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
2352     @@ -29,9 +29,6 @@
2353    
2354     #include "altr_tse_pcs.h"
2355    
2356     -#define SGMII_ADAPTER_CTRL_REG 0x00
2357     -#define SGMII_ADAPTER_DISABLE 0x0001
2358     -
2359     #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII 0x0
2360     #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII 0x1
2361     #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII 0x2
2362     @@ -65,16 +62,14 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
2363     {
2364     struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
2365     void __iomem *splitter_base = dwmac->splitter_base;
2366     - void __iomem *tse_pcs_base = dwmac->pcs.tse_pcs_base;
2367     void __iomem *sgmii_adapter_base = dwmac->pcs.sgmii_adapter_base;
2368     struct device *dev = dwmac->dev;
2369     struct net_device *ndev = dev_get_drvdata(dev);
2370     struct phy_device *phy_dev = ndev->phydev;
2371     u32 val;
2372    
2373     - if ((tse_pcs_base) && (sgmii_adapter_base))
2374     - writew(SGMII_ADAPTER_DISABLE,
2375     - sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
2376     + writew(SGMII_ADAPTER_DISABLE,
2377     + sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
2378    
2379     if (splitter_base) {
2380     val = readl(splitter_base + EMAC_SPLITTER_CTRL_REG);
2381     @@ -96,7 +91,9 @@ static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed)
2382     writel(val, splitter_base + EMAC_SPLITTER_CTRL_REG);
2383     }
2384    
2385     - if (tse_pcs_base && sgmii_adapter_base)
2386     + writew(SGMII_ADAPTER_ENABLE,
2387     + sgmii_adapter_base + SGMII_ADAPTER_CTRL_REG);
2388     + if (phy_dev)
2389     tse_pcs_fix_mac_speed(&dwmac->pcs, phy_dev, speed);
2390     }
2391    
2392     diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2393     index 2019e163e0e9e..cbdd0deb7c565 100644
2394     --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2395     +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2396     @@ -221,8 +221,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
2397     plat->interface = of_get_phy_mode(np);
2398    
2399     /* Get max speed of operation from device tree */
2400     - if (of_property_read_u32(np, "max-speed", &plat->max_speed))
2401     - plat->max_speed = -1;
2402     + of_property_read_u32(np, "max-speed", &plat->max_speed);
2403    
2404     plat->bus_id = of_alias_get_id(np, "ethernet");
2405     if (plat->bus_id < 0)
2406     diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
2407     index cf4dcff051d5b..b38106a7cb5d8 100644
2408     --- a/drivers/net/ethernet/sun/sunhme.c
2409     +++ b/drivers/net/ethernet/sun/sunhme.c
2410     @@ -3160,7 +3160,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
2411     if (err) {
2412     printk(KERN_ERR "happymeal(PCI): Cannot register net device, "
2413     "aborting.\n");
2414     - goto err_out_iounmap;
2415     + goto err_out_free_coherent;
2416     }
2417    
2418     pci_set_drvdata(pdev, hp);
2419     @@ -3193,6 +3193,10 @@ static int happy_meal_pci_probe(struct pci_dev *pdev,
2420    
2421     return 0;
2422    
2423     +err_out_free_coherent:
2424     + dma_free_coherent(hp->dma_dev, PAGE_SIZE,
2425     + hp->happy_block, hp->hblock_dvma);
2426     +
2427     err_out_iounmap:
2428     iounmap(hp->gregs);
2429    
2430     diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
2431     index 96fb2a2a59f02..f829233a911a6 100644
2432     --- a/drivers/net/hamradio/6pack.c
2433     +++ b/drivers/net/hamradio/6pack.c
2434     @@ -685,14 +685,14 @@ static void sixpack_close(struct tty_struct *tty)
2435     */
2436     netif_stop_queue(sp->dev);
2437    
2438     + unregister_netdev(sp->dev);
2439     +
2440     del_timer_sync(&sp->tx_t);
2441     del_timer_sync(&sp->resync_t);
2442    
2443     /* Free all 6pack frame buffers. */
2444     kfree(sp->rbuff);
2445     kfree(sp->xbuff);
2446     -
2447     - unregister_netdev(sp->dev);
2448     }
2449    
2450     /* Perform I/O control on an active 6pack channel. */
2451     diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c
2452     index 870327efccf78..6bea2b219e007 100644
2453     --- a/drivers/net/phy/broadcom.c
2454     +++ b/drivers/net/phy/broadcom.c
2455     @@ -15,6 +15,7 @@
2456     */
2457    
2458     #include "bcm-phy-lib.h"
2459     +#include <linux/delay.h>
2460     #include <linux/module.h>
2461     #include <linux/phy.h>
2462     #include <linux/brcmphy.h>
2463     @@ -357,6 +358,26 @@ static int brcm_fet_config_init(struct phy_device *phydev)
2464     if (err < 0)
2465     return err;
2466    
2467     + /* The datasheet indicates the PHY needs up to 1us to complete a reset,
2468     + * build some slack here.
2469     + */
2470     + usleep_range(1000, 2000);
2471     +
2472     + /* The PHY requires 65 MDC clock cycles to complete a write operation
2473     + * and turnaround the line properly.
2474     + *
2475     + * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac)
2476     + * may flag the lack of turn-around as a read failure. This is
2477     + * particularly true with this combination since the MDIO controller
2478     + * only used 64 MDC cycles. This is not a critical failure in this
2479     + * specific case and it has no functional impact otherwise, so we let
2480     + * that one go through. If there is a genuine bus error, the next read
2481     + * of MII_BRCM_FET_INTREG will error out.
2482     + */
2483     + err = phy_read(phydev, MII_BMCR);
2484     + if (err < 0 && err != -EIO)
2485     + return err;
2486     +
2487     reg = phy_read(phydev, MII_BRCM_FET_INTREG);
2488     if (reg < 0)
2489     return reg;
2490     diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
2491     index f870396e05e15..ba26fa0ceba89 100644
2492     --- a/drivers/net/slip/slip.c
2493     +++ b/drivers/net/slip/slip.c
2494     @@ -471,7 +471,7 @@ static void sl_tx_timeout(struct net_device *dev)
2495     spin_lock(&sl->lock);
2496    
2497     if (netif_queue_stopped(dev)) {
2498     - if (!netif_running(dev))
2499     + if (!netif_running(dev) || !sl->tty)
2500     goto out;
2501    
2502     /* May be we must check transmitter timeout here ?
2503     diff --git a/drivers/net/veth.c b/drivers/net/veth.c
2504     index ee7460ee3d050..57ff2fd95f75b 100644
2505     --- a/drivers/net/veth.c
2506     +++ b/drivers/net/veth.c
2507     @@ -114,7 +114,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
2508    
2509     rcu_read_lock();
2510     rcv = rcu_dereference(priv->peer);
2511     - if (unlikely(!rcv)) {
2512     + if (unlikely(!rcv) || !pskb_may_pull(skb, ETH_HLEN)) {
2513     kfree_skb(skb);
2514     goto drop;
2515     }
2516     diff --git a/drivers/net/wireless/ath/ath5k/eeprom.c b/drivers/net/wireless/ath/ath5k/eeprom.c
2517     index 94d34ee02265d..01163b3339451 100644
2518     --- a/drivers/net/wireless/ath/ath5k/eeprom.c
2519     +++ b/drivers/net/wireless/ath/ath5k/eeprom.c
2520     @@ -746,6 +746,9 @@ ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode,
2521     }
2522     }
2523    
2524     + if (idx == AR5K_EEPROM_N_PD_CURVES)
2525     + goto err_out;
2526     +
2527     ee->ee_pd_gains[mode] = 1;
2528    
2529     pd = &chinfo[pier].pd_curves[idx];
2530     diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
2531     index 625823e45d8f0..06a6e74435502 100644
2532     --- a/drivers/net/wireless/ath/ath9k/htc_hst.c
2533     +++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
2534     @@ -31,6 +31,7 @@ static int htc_issue_send(struct htc_target *target, struct sk_buff* skb,
2535     hdr->endpoint_id = epid;
2536     hdr->flags = flags;
2537     hdr->payload_len = cpu_to_be16(len);
2538     + memset(hdr->control, 0, sizeof(hdr->control));
2539    
2540     status = target->hif->send(target->hif_dev, endpoint->ul_pipeid, skb);
2541    
2542     @@ -278,6 +279,10 @@ int htc_connect_service(struct htc_target *target,
2543     conn_msg->dl_pipeid = endpoint->dl_pipeid;
2544     conn_msg->ul_pipeid = endpoint->ul_pipeid;
2545    
2546     + /* To prevent infoleak */
2547     + conn_msg->svc_meta_len = 0;
2548     + conn_msg->pad = 0;
2549     +
2550     ret = htc_issue_send(target, skb, skb->len, 0, ENDPOINT0);
2551     if (ret)
2552     goto err;
2553     diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c
2554     index 202f421e0e375..1ea80d004d463 100644
2555     --- a/drivers/net/wireless/ath/carl9170/main.c
2556     +++ b/drivers/net/wireless/ath/carl9170/main.c
2557     @@ -1920,7 +1920,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar)
2558     WARN_ON(!(tx_streams >= 1 && tx_streams <=
2559     IEEE80211_HT_MCS_TX_MAX_STREAMS));
2560    
2561     - tx_params = (tx_streams - 1) <<
2562     + tx_params |= (tx_streams - 1) <<
2563     IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
2564    
2565     carl9170_band_2GHz.ht_cap.mcs.tx_params |= tx_params;
2566     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
2567     index d231042f19d64..33a7378164b88 100644
2568     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
2569     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
2570     @@ -216,6 +216,8 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,
2571     size = BRCMF_FW_MAX_NVRAM_SIZE;
2572     else
2573     size = data_len;
2574     + /* Add space for properties we may add */
2575     + size += strlen(BRCMF_FW_DEFAULT_BOARDREV) + 1;
2576     /* Alloc for extra 0 byte + roundup by 4 + length field */
2577     size += 1 + 3 + sizeof(u32);
2578     nvp->nvram = kzalloc(size, GFP_KERNEL);
2579     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2580     index d3d79219fbb05..9e90737f4d494 100644
2581     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2582     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2583     @@ -22,6 +22,7 @@
2584     #include <linux/interrupt.h>
2585     #include <linux/bcma/bcma.h>
2586     #include <linux/sched.h>
2587     +#include <linux/io.h>
2588     #include <asm/unaligned.h>
2589    
2590     #include <soc.h>
2591     @@ -406,47 +407,6 @@ brcmf_pcie_write_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
2592     }
2593    
2594    
2595     -static void
2596     -brcmf_pcie_copy_mem_todev(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
2597     - void *srcaddr, u32 len)
2598     -{
2599     - void __iomem *address = devinfo->tcm + mem_offset;
2600     - __le32 *src32;
2601     - __le16 *src16;
2602     - u8 *src8;
2603     -
2604     - if (((ulong)address & 4) || ((ulong)srcaddr & 4) || (len & 4)) {
2605     - if (((ulong)address & 2) || ((ulong)srcaddr & 2) || (len & 2)) {
2606     - src8 = (u8 *)srcaddr;
2607     - while (len) {
2608     - iowrite8(*src8, address);
2609     - address++;
2610     - src8++;
2611     - len--;
2612     - }
2613     - } else {
2614     - len = len / 2;
2615     - src16 = (__le16 *)srcaddr;
2616     - while (len) {
2617     - iowrite16(le16_to_cpu(*src16), address);
2618     - address += 2;
2619     - src16++;
2620     - len--;
2621     - }
2622     - }
2623     - } else {
2624     - len = len / 4;
2625     - src32 = (__le32 *)srcaddr;
2626     - while (len) {
2627     - iowrite32(le32_to_cpu(*src32), address);
2628     - address += 4;
2629     - src32++;
2630     - len--;
2631     - }
2632     - }
2633     -}
2634     -
2635     -
2636     static void
2637     brcmf_pcie_copy_dev_tomem(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
2638     void *dstaddr, u32 len)
2639     @@ -1422,8 +1382,8 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
2640     return err;
2641    
2642     brcmf_dbg(PCIE, "Download FW %s\n", devinfo->fw_name);
2643     - brcmf_pcie_copy_mem_todev(devinfo, devinfo->ci->rambase,
2644     - (void *)fw->data, fw->size);
2645     + memcpy_toio(devinfo->tcm + devinfo->ci->rambase,
2646     + (void *)fw->data, fw->size);
2647    
2648     resetintr = get_unaligned_le32(fw->data);
2649     release_firmware(fw);
2650     @@ -1437,7 +1397,7 @@ static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
2651     brcmf_dbg(PCIE, "Download NVRAM %s\n", devinfo->nvram_name);
2652     address = devinfo->ci->rambase + devinfo->ci->ramsize -
2653     nvram_len;
2654     - brcmf_pcie_copy_mem_todev(devinfo, address, nvram, nvram_len);
2655     + memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
2656     brcmf_fw_nvram_free(nvram);
2657     } else {
2658     brcmf_dbg(PCIE, "No matching NVRAM file found %s\n",
2659     diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
2660     index 8c0719468d005..6bd2486f617e1 100644
2661     --- a/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
2662     +++ b/drivers/net/wireless/intel/iwlwifi/dvm/mac80211.c
2663     @@ -315,7 +315,7 @@ static int iwlagn_mac_start(struct ieee80211_hw *hw)
2664    
2665     priv->is_open = 1;
2666     IWL_DEBUG_MAC80211(priv, "leave\n");
2667     - return 0;
2668     + return ret;
2669     }
2670    
2671     static void iwlagn_mac_stop(struct ieee80211_hw *hw)
2672     diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
2673     index c78abfc7bd96d..784063b1e60f7 100644
2674     --- a/drivers/net/wireless/ray_cs.c
2675     +++ b/drivers/net/wireless/ray_cs.c
2676     @@ -396,6 +396,8 @@ static int ray_config(struct pcmcia_device *link)
2677     goto failed;
2678     local->sram = ioremap(link->resource[2]->start,
2679     resource_size(link->resource[2]));
2680     + if (!local->sram)
2681     + goto failed;
2682    
2683     /*** Set up 16k window for shared memory (receive buffer) ***************/
2684     link->resource[3]->flags |=
2685     @@ -410,6 +412,8 @@ static int ray_config(struct pcmcia_device *link)
2686     goto failed;
2687     local->rmem = ioremap(link->resource[3]->start,
2688     resource_size(link->resource[3]));
2689     + if (!local->rmem)
2690     + goto failed;
2691    
2692     /*** Set up window for attribute memory ***********************************/
2693     link->resource[4]->flags |=
2694     @@ -424,6 +428,8 @@ static int ray_config(struct pcmcia_device *link)
2695     goto failed;
2696     local->amem = ioremap(link->resource[4]->start,
2697     resource_size(link->resource[4]));
2698     + if (!local->amem)
2699     + goto failed;
2700    
2701     dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
2702     dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
2703     diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
2704     index 8b8b096167d7a..31be1c69fd706 100644
2705     --- a/drivers/pci/hotplug/pciehp_hpc.c
2706     +++ b/drivers/pci/hotplug/pciehp_hpc.c
2707     @@ -120,6 +120,8 @@ static int pcie_poll_cmd(struct controller *ctrl, int timeout)
2708     if (slot_status & PCI_EXP_SLTSTA_CC) {
2709     pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
2710     PCI_EXP_SLTSTA_CC);
2711     + ctrl->cmd_busy = 0;
2712     + smp_mb();
2713     return 1;
2714     }
2715     if (timeout < 0)
2716     diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
2717     index f9aef2ac03a1e..4cce720171093 100644
2718     --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
2719     +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
2720     @@ -1355,6 +1355,7 @@ int mtk_pctrl_init(struct platform_device *pdev,
2721     node = of_parse_phandle(np, "mediatek,pctl-regmap", 0);
2722     if (node) {
2723     pctl->regmap1 = syscon_node_to_regmap(node);
2724     + of_node_put(node);
2725     if (IS_ERR(pctl->regmap1))
2726     return PTR_ERR(pctl->regmap1);
2727     } else if (regmap) {
2728     @@ -1368,6 +1369,7 @@ int mtk_pctrl_init(struct platform_device *pdev,
2729     node = of_parse_phandle(np, "mediatek,pctl-regmap", 1);
2730     if (node) {
2731     pctl->regmap2 = syscon_node_to_regmap(node);
2732     + of_node_put(node);
2733     if (IS_ERR(pctl->regmap2))
2734     return PTR_ERR(pctl->regmap2);
2735     }
2736     diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
2737     index d318ca0554894..6e237c46e1bd9 100644
2738     --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
2739     +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
2740     @@ -1916,8 +1916,10 @@ static int nmk_pinctrl_probe(struct platform_device *pdev)
2741     }
2742    
2743     prcm_np = of_parse_phandle(np, "prcm", 0);
2744     - if (prcm_np)
2745     + if (prcm_np) {
2746     npct->prcm_base = of_iomap(prcm_np, 0);
2747     + of_node_put(prcm_np);
2748     + }
2749     if (!npct->prcm_base) {
2750     if (version == PINCTRL_NMK_STN8815) {
2751     dev_info(&pdev->dev,
2752     diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
2753     index 5020ae5344794..074a7e044e250 100644
2754     --- a/drivers/pinctrl/pinconf-generic.c
2755     +++ b/drivers/pinctrl/pinconf-generic.c
2756     @@ -31,10 +31,10 @@ static const struct pin_config_item conf_items[] = {
2757     PCONFDUMP(PIN_CONFIG_BIAS_BUS_HOLD, "input bias bus hold", NULL, false),
2758     PCONFDUMP(PIN_CONFIG_BIAS_DISABLE, "input bias disabled", NULL, false),
2759     PCONFDUMP(PIN_CONFIG_BIAS_HIGH_IMPEDANCE, "input bias high impedance", NULL, false),
2760     - PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", NULL, false),
2761     + PCONFDUMP(PIN_CONFIG_BIAS_PULL_DOWN, "input bias pull down", "ohms", true),
2762     PCONFDUMP(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT,
2763     - "input bias pull to pin specific state", NULL, false),
2764     - PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", NULL, false),
2765     + "input bias pull to pin specific state", "ohms", true),
2766     + PCONFDUMP(PIN_CONFIG_BIAS_PULL_UP, "input bias pull up", "ohms", true),
2767     PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_DRAIN, "output drive open drain", NULL, false),
2768     PCONFDUMP(PIN_CONFIG_DRIVE_OPEN_SOURCE, "output drive open source", NULL, false),
2769     PCONFDUMP(PIN_CONFIG_DRIVE_PUSH_PULL, "output drive push pull", NULL, false),
2770     diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
2771     index 17827a88b85e1..9bcb238c2e12e 100644
2772     --- a/drivers/pinctrl/pinctrl-rockchip.c
2773     +++ b/drivers/pinctrl/pinctrl-rockchip.c
2774     @@ -2414,6 +2414,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
2775     node = of_parse_phandle(np, "rockchip,grf", 0);
2776     if (node) {
2777     info->regmap_base = syscon_node_to_regmap(node);
2778     + of_node_put(node);
2779     if (IS_ERR(info->regmap_base))
2780     return PTR_ERR(info->regmap_base);
2781     } else {
2782     @@ -2450,6 +2451,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
2783     node = of_parse_phandle(np, "rockchip,pmu", 0);
2784     if (node) {
2785     info->regmap_pmu = syscon_node_to_regmap(node);
2786     + of_node_put(node);
2787     if (IS_ERR(info->regmap_pmu))
2788     return PTR_ERR(info->regmap_pmu);
2789     }
2790     diff --git a/drivers/power/supply/ab8500_fg.c b/drivers/power/supply/ab8500_fg.c
2791     index d6079e892e11f..c07437ad1b852 100644
2792     --- a/drivers/power/supply/ab8500_fg.c
2793     +++ b/drivers/power/supply/ab8500_fg.c
2794     @@ -2545,8 +2545,10 @@ static int ab8500_fg_sysfs_init(struct ab8500_fg *di)
2795     ret = kobject_init_and_add(&di->fg_kobject,
2796     &ab8500_fg_ktype,
2797     NULL, "battery");
2798     - if (ret < 0)
2799     + if (ret < 0) {
2800     + kobject_put(&di->fg_kobject);
2801     dev_err(di->dev, "failed to create sysfs entry\n");
2802     + }
2803    
2804     return ret;
2805     }
2806     diff --git a/drivers/power/supply/wm8350_power.c b/drivers/power/supply/wm8350_power.c
2807     index 5c5880664e09b..28c7102fb24e8 100644
2808     --- a/drivers/power/supply/wm8350_power.c
2809     +++ b/drivers/power/supply/wm8350_power.c
2810     @@ -410,44 +410,112 @@ static const struct power_supply_desc wm8350_usb_desc = {
2811     * Initialisation
2812     *********************************************************************/
2813    
2814     -static void wm8350_init_charger(struct wm8350 *wm8350)
2815     +static int wm8350_init_charger(struct wm8350 *wm8350)
2816     {
2817     + int ret;
2818     +
2819     /* register our interest in charger events */
2820     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT,
2821     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT,
2822     wm8350_charger_handler, 0, "Battery hot", wm8350);
2823     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD,
2824     + if (ret)
2825     + goto err;
2826     +
2827     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD,
2828     wm8350_charger_handler, 0, "Battery cold", wm8350);
2829     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL,
2830     + if (ret)
2831     + goto free_chg_bat_hot;
2832     +
2833     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL,
2834     wm8350_charger_handler, 0, "Battery fail", wm8350);
2835     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_TO,
2836     + if (ret)
2837     + goto free_chg_bat_cold;
2838     +
2839     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_TO,
2840     wm8350_charger_handler, 0,
2841     "Charger timeout", wm8350);
2842     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_END,
2843     + if (ret)
2844     + goto free_chg_bat_fail;
2845     +
2846     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_END,
2847     wm8350_charger_handler, 0,
2848     "Charge end", wm8350);
2849     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_START,
2850     + if (ret)
2851     + goto free_chg_to;
2852     +
2853     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_START,
2854     wm8350_charger_handler, 0,
2855     "Charge start", wm8350);
2856     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY,
2857     + if (ret)
2858     + goto free_chg_end;
2859     +
2860     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY,
2861     wm8350_charger_handler, 0,
2862     "Fast charge ready", wm8350);
2863     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9,
2864     + if (ret)
2865     + goto free_chg_start;
2866     +
2867     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9,
2868     wm8350_charger_handler, 0,
2869     "Battery <3.9V", wm8350);
2870     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1,
2871     + if (ret)
2872     + goto free_chg_fast_rdy;
2873     +
2874     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1,
2875     wm8350_charger_handler, 0,
2876     "Battery <3.1V", wm8350);
2877     - wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85,
2878     + if (ret)
2879     + goto free_chg_vbatt_lt_3p9;
2880     +
2881     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85,
2882     wm8350_charger_handler, 0,
2883     "Battery <2.85V", wm8350);
2884     + if (ret)
2885     + goto free_chg_vbatt_lt_3p1;
2886    
2887     /* and supply change events */
2888     - wm8350_register_irq(wm8350, WM8350_IRQ_EXT_USB_FB,
2889     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_EXT_USB_FB,
2890     wm8350_charger_handler, 0, "USB", wm8350);
2891     - wm8350_register_irq(wm8350, WM8350_IRQ_EXT_WALL_FB,
2892     + if (ret)
2893     + goto free_chg_vbatt_lt_2p85;
2894     +
2895     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_EXT_WALL_FB,
2896     wm8350_charger_handler, 0, "Wall", wm8350);
2897     - wm8350_register_irq(wm8350, WM8350_IRQ_EXT_BAT_FB,
2898     + if (ret)
2899     + goto free_ext_usb_fb;
2900     +
2901     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_EXT_BAT_FB,
2902     wm8350_charger_handler, 0, "Battery", wm8350);
2903     + if (ret)
2904     + goto free_ext_wall_fb;
2905     +
2906     + return 0;
2907     +
2908     +free_ext_wall_fb:
2909     + wm8350_free_irq(wm8350, WM8350_IRQ_EXT_WALL_FB, wm8350);
2910     +free_ext_usb_fb:
2911     + wm8350_free_irq(wm8350, WM8350_IRQ_EXT_USB_FB, wm8350);
2912     +free_chg_vbatt_lt_2p85:
2913     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85, wm8350);
2914     +free_chg_vbatt_lt_3p1:
2915     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1, wm8350);
2916     +free_chg_vbatt_lt_3p9:
2917     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9, wm8350);
2918     +free_chg_fast_rdy:
2919     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY, wm8350);
2920     +free_chg_start:
2921     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_START, wm8350);
2922     +free_chg_end:
2923     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_END, wm8350);
2924     +free_chg_to:
2925     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_TO, wm8350);
2926     +free_chg_bat_fail:
2927     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_FAIL, wm8350);
2928     +free_chg_bat_cold:
2929     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_COLD, wm8350);
2930     +free_chg_bat_hot:
2931     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_BAT_HOT, wm8350);
2932     +err:
2933     + return ret;
2934     }
2935    
2936     static void free_charger_irq(struct wm8350 *wm8350)
2937     @@ -458,6 +526,7 @@ static void free_charger_irq(struct wm8350 *wm8350)
2938     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_TO, wm8350);
2939     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_END, wm8350);
2940     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_START, wm8350);
2941     + wm8350_free_irq(wm8350, WM8350_IRQ_CHG_FAST_RDY, wm8350);
2942     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P9, wm8350);
2943     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_3P1, wm8350);
2944     wm8350_free_irq(wm8350, WM8350_IRQ_CHG_VBATT_LT_2P85, wm8350);
2945     diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
2946     index 731d0423c8aa7..b690621b4fc8d 100644
2947     --- a/drivers/ptp/ptp_sysfs.c
2948     +++ b/drivers/ptp/ptp_sysfs.c
2949     @@ -26,7 +26,7 @@ static ssize_t clock_name_show(struct device *dev,
2950     struct device_attribute *attr, char *page)
2951     {
2952     struct ptp_clock *ptp = dev_get_drvdata(dev);
2953     - return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name);
2954     + return sysfs_emit(page, "%s\n", ptp->info->name);
2955     }
2956     static DEVICE_ATTR(clock_name, 0444, clock_name_show, NULL);
2957    
2958     @@ -240,7 +240,7 @@ static ssize_t ptp_pin_show(struct device *dev, struct device_attribute *attr,
2959    
2960     mutex_unlock(&ptp->pincfg_mux);
2961    
2962     - return snprintf(page, PAGE_SIZE, "%u %u\n", func, chan);
2963     + return sysfs_emit(page, "%u %u\n", func, chan);
2964     }
2965    
2966     static ssize_t ptp_pin_store(struct device *dev, struct device_attribute *attr,
2967     diff --git a/drivers/pwm/pwm-lpc18xx-sct.c b/drivers/pwm/pwm-lpc18xx-sct.c
2968     index d7f5f7de030dd..8b3aad06e2360 100644
2969     --- a/drivers/pwm/pwm-lpc18xx-sct.c
2970     +++ b/drivers/pwm/pwm-lpc18xx-sct.c
2971     @@ -406,12 +406,6 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
2972     lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_LIMIT,
2973     BIT(lpc18xx_pwm->period_event));
2974    
2975     - ret = pwmchip_add(&lpc18xx_pwm->chip);
2976     - if (ret < 0) {
2977     - dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
2978     - goto disable_pwmclk;
2979     - }
2980     -
2981     for (i = 0; i < lpc18xx_pwm->chip.npwm; i++) {
2982     struct lpc18xx_pwm_data *data;
2983    
2984     @@ -421,14 +415,12 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
2985     GFP_KERNEL);
2986     if (!data) {
2987     ret = -ENOMEM;
2988     - goto remove_pwmchip;
2989     + goto disable_pwmclk;
2990     }
2991    
2992     pwm_set_chip_data(pwm, data);
2993     }
2994    
2995     - platform_set_drvdata(pdev, lpc18xx_pwm);
2996     -
2997     val = lpc18xx_pwm_readl(lpc18xx_pwm, LPC18XX_PWM_CTRL);
2998     val &= ~LPC18XX_PWM_BIDIR;
2999     val &= ~LPC18XX_PWM_CTRL_HALT;
3000     @@ -436,10 +428,16 @@ static int lpc18xx_pwm_probe(struct platform_device *pdev)
3001     val |= LPC18XX_PWM_PRE(0);
3002     lpc18xx_pwm_writel(lpc18xx_pwm, LPC18XX_PWM_CTRL, val);
3003    
3004     + ret = pwmchip_add(&lpc18xx_pwm->chip);
3005     + if (ret < 0) {
3006     + dev_err(&pdev->dev, "pwmchip_add failed: %d\n", ret);
3007     + goto disable_pwmclk;
3008     + }
3009     +
3010     + platform_set_drvdata(pdev, lpc18xx_pwm);
3011     +
3012     return 0;
3013    
3014     -remove_pwmchip:
3015     - pwmchip_remove(&lpc18xx_pwm->chip);
3016     disable_pwmclk:
3017     clk_disable_unprepare(lpc18xx_pwm->pwm_clk);
3018     return ret;
3019     diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
3020     index 323b629474a6b..9f76ad9e959dc 100644
3021     --- a/drivers/remoteproc/qcom_wcnss.c
3022     +++ b/drivers/remoteproc/qcom_wcnss.c
3023     @@ -472,6 +472,7 @@ static int wcnss_alloc_memory_region(struct qcom_wcnss *wcnss)
3024     }
3025    
3026     ret = of_address_to_resource(node, 0, &r);
3027     + of_node_put(node);
3028     if (ret)
3029     return ret;
3030    
3031     diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c
3032     index fa247deb9cf40..b45d7d9b8c062 100644
3033     --- a/drivers/rtc/rtc-wm8350.c
3034     +++ b/drivers/rtc/rtc-wm8350.c
3035     @@ -443,14 +443,21 @@ static int wm8350_rtc_probe(struct platform_device *pdev)
3036     return ret;
3037     }
3038    
3039     - wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC,
3040     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC,
3041     wm8350_rtc_update_handler, 0,
3042     "RTC Seconds", wm8350);
3043     + if (ret)
3044     + return ret;
3045     +
3046     wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC);
3047    
3048     - wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM,
3049     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_RTC_ALM,
3050     wm8350_rtc_alarm_handler, 0,
3051     "RTC Alarm", wm8350);
3052     + if (ret) {
3053     + wm8350_free_irq(wm8350, WM8350_IRQ_RTC_SEC, wm8350);
3054     + return ret;
3055     + }
3056    
3057     return 0;
3058     }
3059     diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
3060     index f44d0487236e3..bd850c5faf77d 100644
3061     --- a/drivers/scsi/aha152x.c
3062     +++ b/drivers/scsi/aha152x.c
3063     @@ -3381,13 +3381,11 @@ static int __init aha152x_setup(char *str)
3064     setup[setup_count].synchronous = ints[0] >= 6 ? ints[6] : 1;
3065     setup[setup_count].delay = ints[0] >= 7 ? ints[7] : DELAY_DEFAULT;
3066     setup[setup_count].ext_trans = ints[0] >= 8 ? ints[8] : 0;
3067     - if (ints[0] > 8) { /*}*/
3068     + if (ints[0] > 8)
3069     printk(KERN_NOTICE "aha152x: usage: aha152x=<IOBASE>[,<IRQ>[,<SCSI ID>"
3070     "[,<RECONNECT>[,<PARITY>[,<SYNCHRONOUS>[,<DELAY>[,<EXT_TRANS>]]]]]]]\n");
3071     - } else {
3072     + else
3073     setup_count++;
3074     - return 0;
3075     - }
3076    
3077     return 1;
3078     }
3079     diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c
3080     index 0a70d54a4df68..47e5993524685 100644
3081     --- a/drivers/scsi/bfa/bfad_attr.c
3082     +++ b/drivers/scsi/bfa/bfad_attr.c
3083     @@ -722,7 +722,7 @@ bfad_im_serial_num_show(struct device *dev, struct device_attribute *attr,
3084     char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
3085    
3086     bfa_get_adapter_serial_num(&bfad->bfa, serial_num);
3087     - return snprintf(buf, PAGE_SIZE, "%s\n", serial_num);
3088     + return sysfs_emit(buf, "%s\n", serial_num);
3089     }
3090    
3091     static ssize_t
3092     @@ -736,7 +736,7 @@ bfad_im_model_show(struct device *dev, struct device_attribute *attr,
3093     char model[BFA_ADAPTER_MODEL_NAME_LEN];
3094    
3095     bfa_get_adapter_model(&bfad->bfa, model);
3096     - return snprintf(buf, PAGE_SIZE, "%s\n", model);
3097     + return sysfs_emit(buf, "%s\n", model);
3098     }
3099    
3100     static ssize_t
3101     @@ -816,7 +816,7 @@ bfad_im_model_desc_show(struct device *dev, struct device_attribute *attr,
3102     snprintf(model_descr, BFA_ADAPTER_MODEL_DESCR_LEN,
3103     "Invalid Model");
3104    
3105     - return snprintf(buf, PAGE_SIZE, "%s\n", model_descr);
3106     + return sysfs_emit(buf, "%s\n", model_descr);
3107     }
3108    
3109     static ssize_t
3110     @@ -830,7 +830,7 @@ bfad_im_node_name_show(struct device *dev, struct device_attribute *attr,
3111     u64 nwwn;
3112    
3113     nwwn = bfa_fcs_lport_get_nwwn(port->fcs_port);
3114     - return snprintf(buf, PAGE_SIZE, "0x%llx\n", cpu_to_be64(nwwn));
3115     + return sysfs_emit(buf, "0x%llx\n", cpu_to_be64(nwwn));
3116     }
3117    
3118     static ssize_t
3119     @@ -847,7 +847,7 @@ bfad_im_symbolic_name_show(struct device *dev, struct device_attribute *attr,
3120     bfa_fcs_lport_get_attr(&bfad->bfa_fcs.fabric.bport, &port_attr);
3121     strlcpy(symname, port_attr.port_cfg.sym_name.symname,
3122     BFA_SYMNAME_MAXLEN);
3123     - return snprintf(buf, PAGE_SIZE, "%s\n", symname);
3124     + return sysfs_emit(buf, "%s\n", symname);
3125     }
3126    
3127     static ssize_t
3128     @@ -861,14 +861,14 @@ bfad_im_hw_version_show(struct device *dev, struct device_attribute *attr,
3129     char hw_ver[BFA_VERSION_LEN];
3130    
3131     bfa_get_pci_chip_rev(&bfad->bfa, hw_ver);
3132     - return snprintf(buf, PAGE_SIZE, "%s\n", hw_ver);
3133     + return sysfs_emit(buf, "%s\n", hw_ver);
3134     }
3135    
3136     static ssize_t
3137     bfad_im_drv_version_show(struct device *dev, struct device_attribute *attr,
3138     char *buf)
3139     {
3140     - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_VERSION);
3141     + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_VERSION);
3142     }
3143    
3144     static ssize_t
3145     @@ -882,7 +882,7 @@ bfad_im_optionrom_version_show(struct device *dev,
3146     char optrom_ver[BFA_VERSION_LEN];
3147    
3148     bfa_get_adapter_optrom_ver(&bfad->bfa, optrom_ver);
3149     - return snprintf(buf, PAGE_SIZE, "%s\n", optrom_ver);
3150     + return sysfs_emit(buf, "%s\n", optrom_ver);
3151     }
3152    
3153     static ssize_t
3154     @@ -896,7 +896,7 @@ bfad_im_fw_version_show(struct device *dev, struct device_attribute *attr,
3155     char fw_ver[BFA_VERSION_LEN];
3156    
3157     bfa_get_adapter_fw_ver(&bfad->bfa, fw_ver);
3158     - return snprintf(buf, PAGE_SIZE, "%s\n", fw_ver);
3159     + return sysfs_emit(buf, "%s\n", fw_ver);
3160     }
3161    
3162     static ssize_t
3163     @@ -908,7 +908,7 @@ bfad_im_num_of_ports_show(struct device *dev, struct device_attribute *attr,
3164     (struct bfad_im_port_s *) shost->hostdata[0];
3165     struct bfad_s *bfad = im_port->bfad;
3166    
3167     - return snprintf(buf, PAGE_SIZE, "%d\n",
3168     + return sysfs_emit(buf, "%d\n",
3169     bfa_get_nports(&bfad->bfa));
3170     }
3171    
3172     @@ -916,7 +916,7 @@ static ssize_t
3173     bfad_im_drv_name_show(struct device *dev, struct device_attribute *attr,
3174     char *buf)
3175     {
3176     - return snprintf(buf, PAGE_SIZE, "%s\n", BFAD_DRIVER_NAME);
3177     + return sysfs_emit(buf, "%s\n", BFAD_DRIVER_NAME);
3178     }
3179    
3180     static ssize_t
3181     @@ -935,14 +935,14 @@ bfad_im_num_of_discovered_ports_show(struct device *dev,
3182     rports = kzalloc(sizeof(struct bfa_rport_qualifier_s) * nrports,
3183     GFP_ATOMIC);
3184     if (rports == NULL)
3185     - return snprintf(buf, PAGE_SIZE, "Failed\n");
3186     + return sysfs_emit(buf, "Failed\n");
3187    
3188     spin_lock_irqsave(&bfad->bfad_lock, flags);
3189     bfa_fcs_lport_get_rport_quals(port->fcs_port, rports, &nrports);
3190     spin_unlock_irqrestore(&bfad->bfad_lock, flags);
3191     kfree(rports);
3192    
3193     - return snprintf(buf, PAGE_SIZE, "%d\n", nrports);
3194     + return sysfs_emit(buf, "%d\n", nrports);
3195     }
3196    
3197     static DEVICE_ATTR(serial_number, S_IRUGO,
3198     diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
3199     index 5ed28111c3c33..569b662e19e7f 100644
3200     --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
3201     +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c
3202     @@ -43,7 +43,7 @@
3203    
3204     #define IBMVSCSIS_VERSION "v0.2"
3205    
3206     -#define INITIAL_SRP_LIMIT 800
3207     +#define INITIAL_SRP_LIMIT 1024
3208     #define DEFAULT_MAX_SECTORS 256
3209     #define MAX_TXU 1024 * 1024
3210    
3211     diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
3212     index 59fd6101f188b..177e494b5e477 100644
3213     --- a/drivers/scsi/libfc/fc_exch.c
3214     +++ b/drivers/scsi/libfc/fc_exch.c
3215     @@ -1663,6 +1663,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp)
3216     if (cancel_delayed_work_sync(&ep->timeout_work)) {
3217     FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n");
3218     fc_exch_release(ep); /* release from pending timer hold */
3219     + return;
3220     }
3221    
3222     spin_lock_bh(&ep->ex_lock);
3223     diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
3224     index 8800ff615bdd4..af2c7e7878b1f 100644
3225     --- a/drivers/scsi/libsas/sas_ata.c
3226     +++ b/drivers/scsi/libsas/sas_ata.c
3227     @@ -220,7 +220,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
3228     task->total_xfer_len = qc->nbytes;
3229     task->num_scatter = qc->n_elem;
3230     task->data_dir = qc->dma_dir;
3231     - } else if (qc->tf.protocol == ATA_PROT_NODATA) {
3232     + } else if (!ata_is_data(qc->tf.protocol)) {
3233     task->data_dir = DMA_NONE;
3234     } else {
3235     for_each_sg(qc->sg, sg, qc->n_elem, si)
3236     diff --git a/drivers/scsi/mvsas/mv_init.c b/drivers/scsi/mvsas/mv_init.c
3237     index 8280046fd1f0d..359fd39c6345d 100644
3238     --- a/drivers/scsi/mvsas/mv_init.c
3239     +++ b/drivers/scsi/mvsas/mv_init.c
3240     @@ -679,6 +679,7 @@ static struct pci_device_id mvs_pci_table[] = {
3241     { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1300), chip_1300 },
3242     { PCI_VDEVICE(ARECA, PCI_DEVICE_ID_ARECA_1320), chip_1320 },
3243     { PCI_VDEVICE(ADAPTEC2, 0x0450), chip_6440 },
3244     + { PCI_VDEVICE(TTI, 0x2640), chip_6440 },
3245     { PCI_VDEVICE(TTI, 0x2710), chip_9480 },
3246     { PCI_VDEVICE(TTI, 0x2720), chip_9480 },
3247     { PCI_VDEVICE(TTI, 0x2721), chip_9480 },
3248     @@ -730,7 +731,7 @@ static ssize_t
3249     mvs_show_driver_version(struct device *cdev,
3250     struct device_attribute *attr, char *buffer)
3251     {
3252     - return snprintf(buffer, PAGE_SIZE, "%s\n", DRV_VERSION);
3253     + return sysfs_emit(buffer, "%s\n", DRV_VERSION);
3254     }
3255    
3256     static DEVICE_ATTR(driver_version,
3257     @@ -782,7 +783,7 @@ mvs_store_interrupt_coalescing(struct device *cdev,
3258     static ssize_t mvs_show_interrupt_coalescing(struct device *cdev,
3259     struct device_attribute *attr, char *buffer)
3260     {
3261     - return snprintf(buffer, PAGE_SIZE, "%d\n", interrupt_coalescing);
3262     + return sysfs_emit(buffer, "%d\n", interrupt_coalescing);
3263     }
3264    
3265     static DEVICE_ATTR(interrupt_coalescing,
3266     diff --git a/drivers/scsi/pm8001/pm8001_hwi.c b/drivers/scsi/pm8001/pm8001_hwi.c
3267     index f374abfb7f1f8..cc90b5c8d4625 100644
3268     --- a/drivers/scsi/pm8001/pm8001_hwi.c
3269     +++ b/drivers/scsi/pm8001/pm8001_hwi.c
3270     @@ -1748,6 +1748,7 @@ static void pm8001_send_abort_all(struct pm8001_hba_info *pm8001_ha,
3271     ccb->device = pm8001_ha_dev;
3272     ccb->ccb_tag = ccb_tag;
3273     ccb->task = task;
3274     + ccb->n_elem = 0;
3275    
3276     circularQ = &pm8001_ha->inbnd_q_tbl[0];
3277    
3278     @@ -1810,6 +1811,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha,
3279     ccb->device = pm8001_ha_dev;
3280     ccb->ccb_tag = ccb_tag;
3281     ccb->task = task;
3282     + ccb->n_elem = 0;
3283     pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG;
3284     pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG;
3285    
3286     @@ -1826,7 +1828,7 @@ static void pm8001_send_read_log(struct pm8001_hba_info *pm8001_ha,
3287    
3288     sata_cmd.tag = cpu_to_le32(ccb_tag);
3289     sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
3290     - sata_cmd.ncqtag_atap_dir_m |= ((0x1 << 7) | (0x5 << 9));
3291     + sata_cmd.ncqtag_atap_dir_m = cpu_to_le32((0x1 << 7) | (0x5 << 9));
3292     memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis));
3293    
3294     res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, 0);
3295     @@ -3766,12 +3768,11 @@ int pm8001_mpi_task_abort_resp(struct pm8001_hba_info *pm8001_ha, void *piomb)
3296     mb();
3297    
3298     if (pm8001_dev->id & NCQ_ABORT_ALL_FLAG) {
3299     - pm8001_tag_free(pm8001_ha, tag);
3300     sas_free_task(t);
3301     - /* clear the flag */
3302     - pm8001_dev->id &= 0xBFFFFFFF;
3303     - } else
3304     + pm8001_dev->id &= ~NCQ_ABORT_ALL_FLAG;
3305     + } else {
3306     t->task_done(t);
3307     + }
3308    
3309     return 0;
3310     }
3311     @@ -4718,7 +4719,7 @@ int pm8001_chip_ssp_tm_req(struct pm8001_hba_info *pm8001_ha,
3312     memcpy(sspTMCmd.lun, task->ssp_task.LUN, 8);
3313     sspTMCmd.tag = cpu_to_le32(ccb->ccb_tag);
3314     if (pm8001_ha->chip_id != chip_8001)
3315     - sspTMCmd.ds_ads_m = 0x08;
3316     + sspTMCmd.ds_ads_m = cpu_to_le32(0x08);
3317     circularQ = &pm8001_ha->inbnd_q_tbl[0];
3318     ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sspTMCmd, 0);
3319     return ret;
3320     diff --git a/drivers/scsi/pm8001/pm80xx_hwi.c b/drivers/scsi/pm8001/pm80xx_hwi.c
3321     index df5f0bc295875..4eae727ccfbc8 100644
3322     --- a/drivers/scsi/pm8001/pm80xx_hwi.c
3323     +++ b/drivers/scsi/pm8001/pm80xx_hwi.c
3324     @@ -870,9 +870,11 @@ pm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha)
3325     else
3326     page_code = THERMAL_PAGE_CODE_8H;
3327    
3328     - payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) |
3329     - (THERMAL_ENABLE << 8) | page_code;
3330     - payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8);
3331     + payload.cfg_pg[0] =
3332     + cpu_to_le32((THERMAL_LOG_ENABLE << 9) |
3333     + (THERMAL_ENABLE << 8) | page_code);
3334     + payload.cfg_pg[1] =
3335     + cpu_to_le32((LTEMPHIL << 24) | (RTEMPHIL << 8));
3336    
3337     rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0);
3338     if (rc)
3339     @@ -1424,6 +1426,7 @@ static void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha,
3340     ccb->device = pm8001_ha_dev;
3341     ccb->ccb_tag = ccb_tag;
3342     ccb->task = task;
3343     + ccb->n_elem = 0;
3344    
3345     circularQ = &pm8001_ha->inbnd_q_tbl[0];
3346    
3347     @@ -1504,7 +1507,7 @@ static void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha,
3348    
3349     sata_cmd.tag = cpu_to_le32(ccb_tag);
3350     sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
3351     - sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9));
3352     + sata_cmd.ncqtag_atap_dir_m_dad = cpu_to_le32(((0x1 << 7) | (0x5 << 9)));
3353     memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis));
3354    
3355     res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, 0);
3356     diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
3357     index 17b1525d492bf..c41491472d445 100644
3358     --- a/drivers/scsi/qla2xxx/qla_isr.c
3359     +++ b/drivers/scsi/qla2xxx/qla_isr.c
3360     @@ -1618,6 +1618,7 @@ qla24xx_tm_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, void *tsk)
3361     iocb->u.tmf.data = QLA_FUNCTION_FAILED;
3362     } else if ((le16_to_cpu(sts->scsi_status) &
3363     SS_RESPONSE_INFO_LEN_VALID)) {
3364     + host_to_fcp_swap(sts->data, sizeof(sts->data));
3365     if (le32_to_cpu(sts->rsp_data_len) < 4) {
3366     ql_log(ql_log_warn, fcport->vha, 0x503b,
3367     "Async-%s error - hdl=%x not enough response(%d).\n",
3368     diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c
3369     index aff31991aea98..ee6d974738532 100644
3370     --- a/drivers/scsi/zorro7xx.c
3371     +++ b/drivers/scsi/zorro7xx.c
3372     @@ -158,6 +158,8 @@ static void zorro7xx_remove_one(struct zorro_dev *z)
3373     scsi_remove_host(host);
3374    
3375     NCR_700_release(host);
3376     + if (host->base > 0x01000000)
3377     + iounmap(hostdata->base);
3378     kfree(hostdata);
3379     free_irq(host->irq, host);
3380     zorro_release_device(z);
3381     diff --git a/drivers/soc/ti/wkup_m3_ipc.c b/drivers/soc/ti/wkup_m3_ipc.c
3382     index fc33bfdc957cc..ead96fe2e7f5a 100644
3383     --- a/drivers/soc/ti/wkup_m3_ipc.c
3384     +++ b/drivers/soc/ti/wkup_m3_ipc.c
3385     @@ -405,9 +405,9 @@ static int wkup_m3_ipc_probe(struct platform_device *pdev)
3386     }
3387    
3388     irq = platform_get_irq(pdev, 0);
3389     - if (!irq) {
3390     + if (irq < 0) {
3391     dev_err(&pdev->dev, "no irq resource\n");
3392     - return -ENXIO;
3393     + return irq;
3394     }
3395    
3396     ret = devm_request_irq(dev, irq, wkup_m3_txev_handler,
3397     diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
3398     index d1ca8f619b828..89a3121f4f254 100644
3399     --- a/drivers/spi/spi-tegra114.c
3400     +++ b/drivers/spi/spi-tegra114.c
3401     @@ -1098,6 +1098,10 @@ static int tegra_spi_probe(struct platform_device *pdev)
3402     tspi->phys = r->start;
3403    
3404     spi_irq = platform_get_irq(pdev, 0);
3405     + if (spi_irq < 0) {
3406     + ret = spi_irq;
3407     + goto exit_free_master;
3408     + }
3409     tspi->irq = spi_irq;
3410    
3411     tspi->clk = devm_clk_get(&pdev->dev, "spi");
3412     diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
3413     index 88bfe7682a9eb..b8a3a78730b5e 100644
3414     --- a/drivers/spi/spi-tegra20-slink.c
3415     +++ b/drivers/spi/spi-tegra20-slink.c
3416     @@ -1016,14 +1016,8 @@ static int tegra_slink_probe(struct platform_device *pdev)
3417     struct resource *r;
3418     int ret, spi_irq;
3419     const struct tegra_slink_chip_data *cdata = NULL;
3420     - const struct of_device_id *match;
3421    
3422     - match = of_match_device(tegra_slink_of_match, &pdev->dev);
3423     - if (!match) {
3424     - dev_err(&pdev->dev, "Error: No device match found\n");
3425     - return -ENODEV;
3426     - }
3427     - cdata = match->data;
3428     + cdata = of_device_get_match_data(&pdev->dev);
3429    
3430     master = spi_alloc_master(&pdev->dev, sizeof(*tspi));
3431     if (!master) {
3432     diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
3433     index d4c374cc4f74f..a8a47013ba47a 100644
3434     --- a/drivers/thermal/int340x_thermal/int3400_thermal.c
3435     +++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
3436     @@ -51,7 +51,7 @@ struct int3400_thermal_priv {
3437     struct art *arts;
3438     int trt_count;
3439     struct trt *trts;
3440     - u8 uuid_bitmap;
3441     + u32 uuid_bitmap;
3442     int rel_misc_dev_res;
3443     int current_uuid_index;
3444     };
3445     diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c
3446     index 8b70a1627356d..799bc191982cf 100644
3447     --- a/drivers/tty/hvc/hvc_iucv.c
3448     +++ b/drivers/tty/hvc/hvc_iucv.c
3449     @@ -1469,7 +1469,9 @@ out_error:
3450     */
3451     static int __init hvc_iucv_config(char *val)
3452     {
3453     - return kstrtoul(val, 10, &hvc_iucv_devices);
3454     + if (kstrtoul(val, 10, &hvc_iucv_devices))
3455     + pr_warn("hvc_iucv= invalid parameter value '%s'\n", val);
3456     + return 1;
3457     }
3458    
3459    
3460     diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
3461     index 69294ae154be0..ea7f4af85d58b 100644
3462     --- a/drivers/tty/mxser.c
3463     +++ b/drivers/tty/mxser.c
3464     @@ -860,6 +860,7 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
3465     struct mxser_port *info = container_of(port, struct mxser_port, port);
3466     unsigned long page;
3467     unsigned long flags;
3468     + int ret;
3469    
3470     page = __get_free_page(GFP_KERNEL);
3471     if (!page)
3472     @@ -869,9 +870,9 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
3473    
3474     if (!info->ioaddr || !info->type) {
3475     set_bit(TTY_IO_ERROR, &tty->flags);
3476     - free_page(page);
3477     spin_unlock_irqrestore(&info->slock, flags);
3478     - return 0;
3479     + ret = 0;
3480     + goto err_free_xmit;
3481     }
3482     info->port.xmit_buf = (unsigned char *) page;
3483    
3484     @@ -897,8 +898,10 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
3485     if (capable(CAP_SYS_ADMIN)) {
3486     set_bit(TTY_IO_ERROR, &tty->flags);
3487     return 0;
3488     - } else
3489     - return -ENODEV;
3490     + }
3491     +
3492     + ret = -ENODEV;
3493     + goto err_free_xmit;
3494     }
3495    
3496     /*
3497     @@ -943,6 +946,10 @@ static int mxser_activate(struct tty_port *port, struct tty_struct *tty)
3498     spin_unlock_irqrestore(&info->slock, flags);
3499    
3500     return 0;
3501     +err_free_xmit:
3502     + free_page(page);
3503     + info->port.xmit_buf = NULL;
3504     + return ret;
3505     }
3506    
3507     /*
3508     diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
3509     index 0314e78e31ff1..72b89702d008c 100644
3510     --- a/drivers/tty/serial/kgdboc.c
3511     +++ b/drivers/tty/serial/kgdboc.c
3512     @@ -304,16 +304,16 @@ static int kgdboc_option_setup(char *opt)
3513     {
3514     if (!opt) {
3515     pr_err("config string not provided\n");
3516     - return -EINVAL;
3517     + return 1;
3518     }
3519    
3520     if (strlen(opt) >= MAX_CONFIG_LEN) {
3521     pr_err("config string too long\n");
3522     - return -ENOSPC;
3523     + return 1;
3524     }
3525     strcpy(config, opt);
3526    
3527     - return 0;
3528     + return 1;
3529     }
3530    
3531     __setup("kgdboc=", kgdboc_option_setup);
3532     diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
3533     index 8c89697c53573..15b9bf35457b7 100644
3534     --- a/drivers/tty/serial/samsung.c
3535     +++ b/drivers/tty/serial/samsung.c
3536     @@ -764,11 +764,8 @@ static irqreturn_t s3c24xx_serial_tx_chars(int irq, void *id)
3537     goto out;
3538     }
3539    
3540     - if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) {
3541     - spin_unlock(&port->lock);
3542     + if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
3543     uart_write_wakeup(port);
3544     - spin_lock(&port->lock);
3545     - }
3546    
3547     if (uart_circ_empty(xmit))
3548     s3c24xx_serial_stop_tx(port);
3549     diff --git a/drivers/usb/dwc3/dwc3-omap.c b/drivers/usb/dwc3/dwc3-omap.c
3550     index 8e69150776f5c..a08b29fbaa50c 100644
3551     --- a/drivers/usb/dwc3/dwc3-omap.c
3552     +++ b/drivers/usb/dwc3/dwc3-omap.c
3553     @@ -245,7 +245,7 @@ static void dwc3_omap_set_mailbox(struct dwc3_omap *omap,
3554     break;
3555    
3556     case OMAP_DWC3_ID_FLOAT:
3557     - if (omap->vbus_reg)
3558     + if (omap->vbus_reg && regulator_is_enabled(omap->vbus_reg))
3559     regulator_disable(omap->vbus_reg);
3560     val = dwc3_omap_read_utmi_ctrl(omap);
3561     val |= USBOTGSS_UTMI_OTG_CTRL_IDDIG;
3562     diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
3563     index 77c3ebe860c56..b495bbecf8096 100644
3564     --- a/drivers/usb/serial/Kconfig
3565     +++ b/drivers/usb/serial/Kconfig
3566     @@ -65,6 +65,7 @@ config USB_SERIAL_SIMPLE
3567     - Libtransistor USB console
3568     - a number of Motorola phones
3569     - Motorola Tetra devices
3570     + - Nokia mobile phones
3571     - Novatel Wireless GPS receivers
3572     - Siemens USB/MPI adapter.
3573     - ViVOtech ViVOpay USB device.
3574     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
3575     index 3dd0bbb36dd27..c5fa5b704ec57 100644
3576     --- a/drivers/usb/serial/pl2303.c
3577     +++ b/drivers/usb/serial/pl2303.c
3578     @@ -105,6 +105,7 @@ static const struct usb_device_id id_table[] = {
3579     { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530GC_PRODUCT_ID) },
3580     { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) },
3581     { USB_DEVICE(AT_VENDOR_ID, AT_VTKIT3_PRODUCT_ID) },
3582     + { USB_DEVICE(IBM_VENDOR_ID, IBM_PRODUCT_ID) },
3583     { } /* Terminating entry */
3584     };
3585    
3586     diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
3587     index 62b8cd673aa11..908865495b489 100644
3588     --- a/drivers/usb/serial/pl2303.h
3589     +++ b/drivers/usb/serial/pl2303.h
3590     @@ -33,6 +33,9 @@
3591     #define ATEN_PRODUCT_UC485 0x2021
3592     #define ATEN_PRODUCT_ID2 0x2118
3593    
3594     +#define IBM_VENDOR_ID 0x04b3
3595     +#define IBM_PRODUCT_ID 0x4016
3596     +
3597     #define IODATA_VENDOR_ID 0x04bb
3598     #define IODATA_PRODUCT_ID 0x0a03
3599     #define IODATA_PRODUCT_ID_RSAQ5 0x0a0e
3600     diff --git a/drivers/usb/serial/usb-serial-simple.c b/drivers/usb/serial/usb-serial-simple.c
3601     index 15e05ebf37ac4..3681e64182620 100644
3602     --- a/drivers/usb/serial/usb-serial-simple.c
3603     +++ b/drivers/usb/serial/usb-serial-simple.c
3604     @@ -94,6 +94,11 @@ DEVICE(moto_modem, MOTO_IDS);
3605     { USB_DEVICE(0x0cad, 0x9016) } /* TPG2200 */
3606     DEVICE(motorola_tetra, MOTOROLA_TETRA_IDS);
3607    
3608     +/* Nokia mobile phone driver */
3609     +#define NOKIA_IDS() \
3610     + { USB_DEVICE(0x0421, 0x069a) } /* Nokia 130 (RM-1035) */
3611     +DEVICE(nokia, NOKIA_IDS);
3612     +
3613     /* Novatel Wireless GPS driver */
3614     #define NOVATEL_IDS() \
3615     { USB_DEVICE(0x09d7, 0x0100) } /* NovAtel FlexPack GPS */
3616     @@ -126,6 +131,7 @@ static struct usb_serial_driver * const serial_drivers[] = {
3617     &vivopay_device,
3618     &moto_modem_device,
3619     &motorola_tetra_device,
3620     + &nokia_device,
3621     &novatel_gps_device,
3622     &hp4x_device,
3623     &suunto_device,
3624     @@ -143,6 +149,7 @@ static const struct usb_device_id id_table[] = {
3625     VIVOPAY_IDS(),
3626     MOTO_IDS(),
3627     MOTOROLA_TETRA_IDS(),
3628     + NOKIA_IDS(),
3629     NOVATEL_IDS(),
3630     HP4X_IDS(),
3631     SUUNTO_IDS(),
3632     diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
3633     index 4d6eb48b2c45d..aa88ff70b078f 100644
3634     --- a/drivers/usb/storage/ene_ub6250.c
3635     +++ b/drivers/usb/storage/ene_ub6250.c
3636     @@ -251,36 +251,33 @@ static struct us_unusual_dev ene_ub6250_unusual_dev_list[] = {
3637     #define memstick_logaddr(logadr1, logadr0) ((((u16)(logadr1)) << 8) | (logadr0))
3638    
3639    
3640     -struct SD_STATUS {
3641     - u8 Insert:1;
3642     - u8 Ready:1;
3643     - u8 MediaChange:1;
3644     - u8 IsMMC:1;
3645     - u8 HiCapacity:1;
3646     - u8 HiSpeed:1;
3647     - u8 WtP:1;
3648     - u8 Reserved:1;
3649     -};
3650     -
3651     -struct MS_STATUS {
3652     - u8 Insert:1;
3653     - u8 Ready:1;
3654     - u8 MediaChange:1;
3655     - u8 IsMSPro:1;
3656     - u8 IsMSPHG:1;
3657     - u8 Reserved1:1;
3658     - u8 WtP:1;
3659     - u8 Reserved2:1;
3660     -};
3661     -
3662     -struct SM_STATUS {
3663     - u8 Insert:1;
3664     - u8 Ready:1;
3665     - u8 MediaChange:1;
3666     - u8 Reserved:3;
3667     - u8 WtP:1;
3668     - u8 IsMS:1;
3669     -};
3670     +/* SD_STATUS bits */
3671     +#define SD_Insert BIT(0)
3672     +#define SD_Ready BIT(1)
3673     +#define SD_MediaChange BIT(2)
3674     +#define SD_IsMMC BIT(3)
3675     +#define SD_HiCapacity BIT(4)
3676     +#define SD_HiSpeed BIT(5)
3677     +#define SD_WtP BIT(6)
3678     + /* Bit 7 reserved */
3679     +
3680     +/* MS_STATUS bits */
3681     +#define MS_Insert BIT(0)
3682     +#define MS_Ready BIT(1)
3683     +#define MS_MediaChange BIT(2)
3684     +#define MS_IsMSPro BIT(3)
3685     +#define MS_IsMSPHG BIT(4)
3686     + /* Bit 5 reserved */
3687     +#define MS_WtP BIT(6)
3688     + /* Bit 7 reserved */
3689     +
3690     +/* SM_STATUS bits */
3691     +#define SM_Insert BIT(0)
3692     +#define SM_Ready BIT(1)
3693     +#define SM_MediaChange BIT(2)
3694     + /* Bits 3-5 reserved */
3695     +#define SM_WtP BIT(6)
3696     +#define SM_IsMS BIT(7)
3697    
3698     struct ms_bootblock_cis {
3699     u8 bCistplDEVICE[6]; /* 0 */
3700     @@ -451,9 +448,9 @@ struct ene_ub6250_info {
3701     u8 *bbuf;
3702    
3703     /* for 6250 code */
3704     - struct SD_STATUS SD_Status;
3705     - struct MS_STATUS MS_Status;
3706     - struct SM_STATUS SM_Status;
3707     + u8 SD_Status;
3708     + u8 MS_Status;
3709     + u8 SM_Status;
3710    
3711     /* ----- SD Control Data ---------------- */
3712     /*SD_REGISTER SD_Regs; */
3713     @@ -588,7 +585,7 @@ static int sd_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
3714     {
3715     struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
3716    
3717     - if (info->SD_Status.Insert && info->SD_Status.Ready)
3718     + if ((info->SD_Status & SD_Insert) && (info->SD_Status & SD_Ready))
3719     return USB_STOR_TRANSPORT_GOOD;
3720     else {
3721     ene_sd_init(us);
3722     @@ -620,7 +617,7 @@ static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
3723     0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
3724     0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 };
3725    
3726     - if (info->SD_Status.WtP)
3727     + if (info->SD_Status & SD_WtP)
3728     usb_stor_set_xfer_buf(mediaWP, 12, srb);
3729     else
3730     usb_stor_set_xfer_buf(mediaNoWP, 12, srb);
3731     @@ -639,9 +636,9 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
3732     struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
3733    
3734     usb_stor_dbg(us, "sd_scsi_read_capacity\n");
3735     - if (info->SD_Status.HiCapacity) {
3736     + if (info->SD_Status & SD_HiCapacity) {
3737     bl_len = 0x200;
3738     - if (info->SD_Status.IsMMC)
3739     + if (info->SD_Status & SD_IsMMC)
3740     bl_num = info->HC_C_SIZE-1;
3741     else
3742     bl_num = (info->HC_C_SIZE + 1) * 1024 - 1;
3743     @@ -691,7 +688,7 @@ static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
3744     return USB_STOR_TRANSPORT_ERROR;
3745     }
3746    
3747     - if (info->SD_Status.HiCapacity)
3748     + if (info->SD_Status & SD_HiCapacity)
3749     bnByte = bn;
3750    
3751     /* set up the command wrapper */
3752     @@ -731,7 +728,7 @@ static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
3753     return USB_STOR_TRANSPORT_ERROR;
3754     }
3755    
3756     - if (info->SD_Status.HiCapacity)
3757     + if (info->SD_Status & SD_HiCapacity)
3758     bnByte = bn;
3759    
3760     /* set up the command wrapper */
3761     @@ -1447,7 +1444,7 @@ static int ms_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
3762     struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
3763    
3764     /* pr_info("MS_SCSI_Test_Unit_Ready\n"); */
3765     - if (info->MS_Status.Insert && info->MS_Status.Ready) {
3766     + if ((info->MS_Status & MS_Insert) && (info->MS_Status & MS_Ready)) {
3767     return USB_STOR_TRANSPORT_GOOD;
3768     } else {
3769     ene_ms_init(us);
3770     @@ -1480,7 +1477,7 @@ static int ms_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
3771     0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
3772     0x71, 0xc0, 0x00, 0x00, 0x02, 0x00 };
3773    
3774     - if (info->MS_Status.WtP)
3775     + if (info->MS_Status & MS_WtP)
3776     usb_stor_set_xfer_buf(mediaWP, 12, srb);
3777     else
3778     usb_stor_set_xfer_buf(mediaNoWP, 12, srb);
3779     @@ -1499,7 +1496,7 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
3780    
3781     usb_stor_dbg(us, "ms_scsi_read_capacity\n");
3782     bl_len = 0x200;
3783     - if (info->MS_Status.IsMSPro)
3784     + if (info->MS_Status & MS_IsMSPro)
3785     bl_num = info->MSP_TotalBlock - 1;
3786     else
3787     bl_num = info->MS_Lib.NumberOfLogBlock * info->MS_Lib.blockSize * 2 - 1;
3788     @@ -1654,7 +1651,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
3789     if (bn > info->bl_num)
3790     return USB_STOR_TRANSPORT_ERROR;
3791    
3792     - if (info->MS_Status.IsMSPro) {
3793     + if (info->MS_Status & MS_IsMSPro) {
3794     result = ene_load_bincode(us, MSP_RW_PATTERN);
3795     if (result != USB_STOR_XFER_GOOD) {
3796     usb_stor_dbg(us, "Load MPS RW pattern Fail !!\n");
3797     @@ -1755,7 +1752,7 @@ static int ms_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
3798     if (bn > info->bl_num)
3799     return USB_STOR_TRANSPORT_ERROR;
3800    
3801     - if (info->MS_Status.IsMSPro) {
3802     + if (info->MS_Status & MS_IsMSPro) {
3803     result = ene_load_bincode(us, MSP_RW_PATTERN);
3804     if (result != USB_STOR_XFER_GOOD) {
3805     pr_info("Load MSP RW pattern Fail !!\n");
3806     @@ -1863,12 +1860,12 @@ static int ene_get_card_status(struct us_data *us, u8 *buf)
3807    
3808     tmpreg = (u16) reg4b;
3809     reg4b = *(u32 *)(&buf[0x14]);
3810     - if (info->SD_Status.HiCapacity && !info->SD_Status.IsMMC)
3811     + if ((info->SD_Status & SD_HiCapacity) && !(info->SD_Status & SD_IsMMC))
3812     info->HC_C_SIZE = (reg4b >> 8) & 0x3fffff;
3813    
3814     info->SD_C_SIZE = ((tmpreg & 0x03) << 10) | (u16)(reg4b >> 22);
3815     info->SD_C_SIZE_MULT = (u8)(reg4b >> 7) & 0x07;
3816     - if (info->SD_Status.HiCapacity && info->SD_Status.IsMMC)
3817     + if ((info->SD_Status & SD_HiCapacity) && (info->SD_Status & SD_IsMMC))
3818     info->HC_C_SIZE = *(u32 *)(&buf[0x100]);
3819    
3820     if (info->SD_READ_BL_LEN > SD_BLOCK_LEN) {
3821     @@ -2080,6 +2077,7 @@ static int ene_ms_init(struct us_data *us)
3822     u16 MSP_BlockSize, MSP_UserAreaBlocks;
3823     struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
3824     u8 *bbuf = info->bbuf;
3825     + unsigned int s;
3826    
3827     printk(KERN_INFO "transport --- ENE_MSInit\n");
3828    
3829     @@ -2104,15 +2102,16 @@ static int ene_ms_init(struct us_data *us)
3830     return USB_STOR_TRANSPORT_ERROR;
3831     }
3832     /* the same part to test ENE */
3833     - info->MS_Status = *(struct MS_STATUS *) bbuf;
3834     -
3835     - if (info->MS_Status.Insert && info->MS_Status.Ready) {
3836     - printk(KERN_INFO "Insert = %x\n", info->MS_Status.Insert);
3837     - printk(KERN_INFO "Ready = %x\n", info->MS_Status.Ready);
3838     - printk(KERN_INFO "IsMSPro = %x\n", info->MS_Status.IsMSPro);
3839     - printk(KERN_INFO "IsMSPHG = %x\n", info->MS_Status.IsMSPHG);
3840     - printk(KERN_INFO "WtP= %x\n", info->MS_Status.WtP);
3841     - if (info->MS_Status.IsMSPro) {
3842     + info->MS_Status = bbuf[0];
3843     +
3844     + s = info->MS_Status;
3845     + if ((s & MS_Insert) && (s & MS_Ready)) {
3846     + printk(KERN_INFO "Insert = %x\n", !!(s & MS_Insert));
3847     + printk(KERN_INFO "Ready = %x\n", !!(s & MS_Ready));
3848     + printk(KERN_INFO "IsMSPro = %x\n", !!(s & MS_IsMSPro));
3849     + printk(KERN_INFO "IsMSPHG = %x\n", !!(s & MS_IsMSPHG));
3850     + printk(KERN_INFO "WtP= %x\n", !!(s & MS_WtP));
3851     + if (s & MS_IsMSPro) {
3852     MSP_BlockSize = (bbuf[6] << 8) | bbuf[7];
3853     MSP_UserAreaBlocks = (bbuf[10] << 8) | bbuf[11];
3854     info->MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks;
3855     @@ -2173,17 +2172,17 @@ static int ene_sd_init(struct us_data *us)
3856     return USB_STOR_TRANSPORT_ERROR;
3857     }
3858    
3859     - info->SD_Status = *(struct SD_STATUS *) bbuf;
3860     - if (info->SD_Status.Insert && info->SD_Status.Ready) {
3861     - struct SD_STATUS *s = &info->SD_Status;
3862     + info->SD_Status = bbuf[0];
3863     + if ((info->SD_Status & SD_Insert) && (info->SD_Status & SD_Ready)) {
3864     + unsigned int s = info->SD_Status;
3865    
3866     ene_get_card_status(us, bbuf);
3867     - usb_stor_dbg(us, "Insert = %x\n", s->Insert);
3868     - usb_stor_dbg(us, "Ready = %x\n", s->Ready);
3869     - usb_stor_dbg(us, "IsMMC = %x\n", s->IsMMC);
3870     - usb_stor_dbg(us, "HiCapacity = %x\n", s->HiCapacity);
3871     - usb_stor_dbg(us, "HiSpeed = %x\n", s->HiSpeed);
3872     - usb_stor_dbg(us, "WtP = %x\n", s->WtP);
3873     + usb_stor_dbg(us, "Insert = %x\n", !!(s & SD_Insert));
3874     + usb_stor_dbg(us, "Ready = %x\n", !!(s & SD_Ready));
3875     + usb_stor_dbg(us, "IsMMC = %x\n", !!(s & SD_IsMMC));
3876     + usb_stor_dbg(us, "HiCapacity = %x\n", !!(s & SD_HiCapacity));
3877     + usb_stor_dbg(us, "HiSpeed = %x\n", !!(s & SD_HiSpeed));
3878     + usb_stor_dbg(us, "WtP = %x\n", !!(s & SD_WtP));
3879     } else {
3880     usb_stor_dbg(us, "SD Card Not Ready --- %x\n", bbuf[0]);
3881     return USB_STOR_TRANSPORT_ERROR;
3882     @@ -2205,14 +2204,14 @@ static int ene_init(struct us_data *us)
3883    
3884     misc_reg03 = bbuf[0];
3885     if (misc_reg03 & 0x01) {
3886     - if (!info->SD_Status.Ready) {
3887     + if (!(info->SD_Status & SD_Ready)) {
3888     result = ene_sd_init(us);
3889     if (result != USB_STOR_XFER_GOOD)
3890     return USB_STOR_TRANSPORT_ERROR;
3891     }
3892     }
3893     if (misc_reg03 & 0x02) {
3894     - if (!info->MS_Status.Ready) {
3895     + if (!(info->MS_Status & MS_Ready)) {
3896     result = ene_ms_init(us);
3897     if (result != USB_STOR_XFER_GOOD)
3898     return USB_STOR_TRANSPORT_ERROR;
3899     @@ -2302,14 +2301,14 @@ static int ene_transport(struct scsi_cmnd *srb, struct us_data *us)
3900    
3901     /*US_DEBUG(usb_stor_show_command(us, srb)); */
3902     scsi_set_resid(srb, 0);
3903     - if (unlikely(!(info->SD_Status.Ready || info->MS_Status.Ready)))
3904     + if (unlikely(!(info->SD_Status & SD_Ready) || (info->MS_Status & MS_Ready)))
3905     result = ene_init(us);
3906     if (result == USB_STOR_XFER_GOOD) {
3907     result = USB_STOR_TRANSPORT_ERROR;
3908     - if (info->SD_Status.Ready)
3909     + if (info->SD_Status & SD_Ready)
3910     result = sd_scsi_irp(us, srb);
3911    
3912     - if (info->MS_Status.Ready)
3913     + if (info->MS_Status & MS_Ready)
3914     result = ms_scsi_irp(us, srb);
3915     }
3916     return result;
3917     @@ -2373,7 +2372,6 @@ static int ene_ub6250_probe(struct usb_interface *intf,
3918    
3919     static int ene_ub6250_resume(struct usb_interface *iface)
3920     {
3921     - u8 tmp = 0;
3922     struct us_data *us = usb_get_intfdata(iface);
3923     struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
3924    
3925     @@ -2385,17 +2383,16 @@ static int ene_ub6250_resume(struct usb_interface *iface)
3926     mutex_unlock(&us->dev_mutex);
3927    
3928     info->Power_IsResum = true;
3929     - /*info->SD_Status.Ready = 0; */
3930     - info->SD_Status = *(struct SD_STATUS *)&tmp;
3931     - info->MS_Status = *(struct MS_STATUS *)&tmp;
3932     - info->SM_Status = *(struct SM_STATUS *)&tmp;
3933     + /* info->SD_Status &= ~SD_Ready; */
3934     + info->SD_Status = 0;
3935     + info->MS_Status = 0;
3936     + info->SM_Status = 0;
3937    
3938     return 0;
3939     }
3940    
3941     static int ene_ub6250_reset_resume(struct usb_interface *iface)
3942     {
3943     - u8 tmp = 0;
3944     struct us_data *us = usb_get_intfdata(iface);
3945     struct ene_ub6250_info *info = (struct ene_ub6250_info *)(us->extra);
3946    
3947     @@ -2407,10 +2404,10 @@ static int ene_ub6250_reset_resume(struct usb_interface *iface)
3948     * the device
3949     */
3950     info->Power_IsResum = true;
3951     - /*info->SD_Status.Ready = 0; */
3952     - info->SD_Status = *(struct SD_STATUS *)&tmp;
3953     - info->MS_Status = *(struct MS_STATUS *)&tmp;
3954     - info->SM_Status = *(struct SM_STATUS *)&tmp;
3955     + /* info->SD_Status &= ~SD_Ready; */
3956     + info->SD_Status = 0;
3957     + info->MS_Status = 0;
3958     + info->SM_Status = 0;
3959    
3960     return 0;
3961     }
3962     diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
3963     index d955761fce6fc..d9d69637d6141 100644
3964     --- a/drivers/usb/storage/realtek_cr.c
3965     +++ b/drivers/usb/storage/realtek_cr.c
3966     @@ -377,7 +377,7 @@ static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
3967    
3968     buf = kmalloc(len, GFP_NOIO);
3969     if (buf == NULL)
3970     - return USB_STOR_TRANSPORT_ERROR;
3971     + return -ENOMEM;
3972    
3973     usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
3974    
3975     diff --git a/drivers/video/fbdev/atafb.c b/drivers/video/fbdev/atafb.c
3976     index fcd2dd670a658..770f77055682b 100644
3977     --- a/drivers/video/fbdev/atafb.c
3978     +++ b/drivers/video/fbdev/atafb.c
3979     @@ -1713,9 +1713,9 @@ static int falcon_setcolreg(unsigned int regno, unsigned int red,
3980     ((blue & 0xfc00) >> 8));
3981     if (regno < 16) {
3982     shifter_tt.color_reg[regno] =
3983     - (((red & 0xe000) >> 13) | ((red & 0x1000) >> 12) << 8) |
3984     - (((green & 0xe000) >> 13) | ((green & 0x1000) >> 12) << 4) |
3985     - ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12);
3986     + ((((red & 0xe000) >> 13) | ((red & 0x1000) >> 12)) << 8) |
3987     + ((((green & 0xe000) >> 13) | ((green & 0x1000) >> 12)) << 4) |
3988     + ((blue & 0xe000) >> 13) | ((blue & 0x1000) >> 12);
3989     ((u32 *)info->pseudo_palette)[regno] = ((red & 0xf800) |
3990     ((green & 0xfc00) >> 5) |
3991     ((blue & 0xf800) >> 11));
3992     @@ -2001,9 +2001,9 @@ static int stste_setcolreg(unsigned int regno, unsigned int red,
3993     green >>= 12;
3994     if (ATARIHW_PRESENT(EXTD_SHIFTER))
3995     shifter_tt.color_reg[regno] =
3996     - (((red & 0xe) >> 1) | ((red & 1) << 3) << 8) |
3997     - (((green & 0xe) >> 1) | ((green & 1) << 3) << 4) |
3998     - ((blue & 0xe) >> 1) | ((blue & 1) << 3);
3999     + ((((red & 0xe) >> 1) | ((red & 1) << 3)) << 8) |
4000     + ((((green & 0xe) >> 1) | ((green & 1) << 3)) << 4) |
4001     + ((blue & 0xe) >> 1) | ((blue & 1) << 3);
4002     else
4003     shifter_tt.color_reg[regno] =
4004     ((red & 0xe) << 7) |
4005     diff --git a/drivers/video/fbdev/cirrusfb.c b/drivers/video/fbdev/cirrusfb.c
4006     index d992aa5eb3f0d..a8f4967de7980 100644
4007     --- a/drivers/video/fbdev/cirrusfb.c
4008     +++ b/drivers/video/fbdev/cirrusfb.c
4009     @@ -470,7 +470,7 @@ static int cirrusfb_check_mclk(struct fb_info *info, long freq)
4010     return 0;
4011     }
4012    
4013     -static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,
4014     +static int cirrusfb_check_pixclock(struct fb_var_screeninfo *var,
4015     struct fb_info *info)
4016     {
4017     long freq;
4018     @@ -479,9 +479,7 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,
4019     unsigned maxclockidx = var->bits_per_pixel >> 3;
4020    
4021     /* convert from ps to kHz */
4022     - freq = PICOS2KHZ(var->pixclock);
4023     -
4024     - dev_dbg(info->device, "desired pixclock: %ld kHz\n", freq);
4025     + freq = PICOS2KHZ(var->pixclock ? : 1);
4026    
4027     maxclock = cirrusfb_board_info[cinfo->btype].maxclock[maxclockidx];
4028     cinfo->multiplexing = 0;
4029     @@ -489,11 +487,13 @@ static int cirrusfb_check_pixclock(const struct fb_var_screeninfo *var,
4030     /* If the frequency is greater than we can support, we might be able
4031     * to use multiplexing for the video mode */
4032     if (freq > maxclock) {
4033     - dev_err(info->device,
4034     - "Frequency greater than maxclock (%ld kHz)\n",
4035     - maxclock);
4036     - return -EINVAL;
4037     + var->pixclock = KHZ2PICOS(maxclock);
4038     +
4039     + while ((freq = PICOS2KHZ(var->pixclock)) > maxclock)
4040     + var->pixclock++;
4041     }
4042     + dev_dbg(info->device, "desired pixclock: %ld kHz\n", freq);
4043     +
4044     /*
4045     * Additional constraint: 8bpp uses DAC clock doubling to allow maximum
4046     * pixel clock
4047     diff --git a/drivers/video/fbdev/core/fbcvt.c b/drivers/video/fbdev/core/fbcvt.c
4048     index 55d2bd0ce5c02..64843464c6613 100644
4049     --- a/drivers/video/fbdev/core/fbcvt.c
4050     +++ b/drivers/video/fbdev/core/fbcvt.c
4051     @@ -214,9 +214,11 @@ static u32 fb_cvt_aspect_ratio(struct fb_cvt_data *cvt)
4052     static void fb_cvt_print_name(struct fb_cvt_data *cvt)
4053     {
4054     u32 pixcount, pixcount_mod;
4055     - int cnt = 255, offset = 0, read = 0;
4056     - u8 *buf = kzalloc(256, GFP_KERNEL);
4057     + int size = 256;
4058     + int off = 0;
4059     + u8 *buf;
4060    
4061     + buf = kzalloc(size, GFP_KERNEL);
4062     if (!buf)
4063     return;
4064    
4065     @@ -224,43 +226,30 @@ static void fb_cvt_print_name(struct fb_cvt_data *cvt)
4066     pixcount_mod = (cvt->xres * (cvt->yres/cvt->interlace)) % 1000000;
4067     pixcount_mod /= 1000;
4068    
4069     - read = snprintf(buf+offset, cnt, "fbcvt: %dx%d@%d: CVT Name - ",
4070     - cvt->xres, cvt->yres, cvt->refresh);
4071     - offset += read;
4072     - cnt -= read;
4073     + off += scnprintf(buf + off, size - off, "fbcvt: %dx%d@%d: CVT Name - ",
4074     + cvt->xres, cvt->yres, cvt->refresh);
4075    
4076     - if (cvt->status)
4077     - snprintf(buf+offset, cnt, "Not a CVT standard - %d.%03d Mega "
4078     - "Pixel Image\n", pixcount, pixcount_mod);
4079     - else {
4080     - if (pixcount) {
4081     - read = snprintf(buf+offset, cnt, "%d", pixcount);
4082     - cnt -= read;
4083     - offset += read;
4084     - }
4085     + if (cvt->status) {
4086     + off += scnprintf(buf + off, size - off,
4087     + "Not a CVT standard - %d.%03d Mega Pixel Image\n",
4088     + pixcount, pixcount_mod);
4089     + } else {
4090     + if (pixcount)
4091     + off += scnprintf(buf + off, size - off, "%d", pixcount);
4092    
4093     - read = snprintf(buf+offset, cnt, ".%03dM", pixcount_mod);
4094     - cnt -= read;
4095     - offset += read;
4096     + off += scnprintf(buf + off, size - off, ".%03dM", pixcount_mod);
4097    
4098     if (cvt->aspect_ratio == 0)
4099     - read = snprintf(buf+offset, cnt, "3");
4100     + off += scnprintf(buf + off, size - off, "3");
4101     else if (cvt->aspect_ratio == 3)
4102     - read = snprintf(buf+offset, cnt, "4");
4103     + off += scnprintf(buf + off, size - off, "4");
4104     else if (cvt->aspect_ratio == 1 || cvt->aspect_ratio == 4)
4105     - read = snprintf(buf+offset, cnt, "9");
4106     + off += scnprintf(buf + off, size - off, "9");
4107     else if (cvt->aspect_ratio == 2)
4108     - read = snprintf(buf+offset, cnt, "A");
4109     - else
4110     - read = 0;
4111     - cnt -= read;
4112     - offset += read;
4113     -
4114     - if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK) {
4115     - read = snprintf(buf+offset, cnt, "-R");
4116     - cnt -= read;
4117     - offset += read;
4118     - }
4119     + off += scnprintf(buf + off, size - off, "A");
4120     +
4121     + if (cvt->flags & FB_CVT_FLAG_REDUCED_BLANK)
4122     + off += scnprintf(buf + off, size - off, "-R");
4123     }
4124    
4125     printk(KERN_INFO "%s\n", buf);
4126     diff --git a/drivers/video/fbdev/nvidia/nv_i2c.c b/drivers/video/fbdev/nvidia/nv_i2c.c
4127     index d7994a1732459..0b48965a6420c 100644
4128     --- a/drivers/video/fbdev/nvidia/nv_i2c.c
4129     +++ b/drivers/video/fbdev/nvidia/nv_i2c.c
4130     @@ -86,7 +86,7 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name,
4131     {
4132     int rc;
4133    
4134     - strcpy(chan->adapter.name, name);
4135     + strscpy(chan->adapter.name, name, sizeof(chan->adapter.name));
4136     chan->adapter.owner = THIS_MODULE;
4137     chan->adapter.class = i2c_class;
4138     chan->adapter.algo_data = &chan->algo;
4139     diff --git a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
4140     index 06e1db34541e2..41b0db0cc0471 100644
4141     --- a/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
4142     +++ b/drivers/video/fbdev/omap2/omapfb/displays/connector-dvi.c
4143     @@ -254,6 +254,7 @@ static int dvic_probe_of(struct platform_device *pdev)
4144     adapter_node = of_parse_phandle(node, "ddc-i2c-bus", 0);
4145     if (adapter_node) {
4146     adapter = of_get_i2c_adapter_by_node(adapter_node);
4147     + of_node_put(adapter_node);
4148     if (adapter == NULL) {
4149     dev_err(&pdev->dev, "failed to parse ddc-i2c-bus\n");
4150     omap_dss_put_device(ddata->in);
4151     diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c
4152     index 8b810696a42b6..6a8f0f0fa6019 100644
4153     --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c
4154     +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c
4155     @@ -413,7 +413,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
4156     if (r)
4157     return r;
4158    
4159     - return snprintf(buf, PAGE_SIZE, "%d\n", errors);
4160     + return sysfs_emit(buf, "%d\n", errors);
4161     }
4162    
4163     static ssize_t dsicm_hw_revision_show(struct device *dev,
4164     @@ -444,7 +444,7 @@ static ssize_t dsicm_hw_revision_show(struct device *dev,
4165     if (r)
4166     return r;
4167    
4168     - return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x\n", id1, id2, id3);
4169     + return sysfs_emit(buf, "%02x.%02x.%02x\n", id1, id2, id3);
4170     }
4171    
4172     static ssize_t dsicm_store_ulps(struct device *dev,
4173     @@ -494,7 +494,7 @@ static ssize_t dsicm_show_ulps(struct device *dev,
4174     t = ddata->ulps_enabled;
4175     mutex_unlock(&ddata->lock);
4176    
4177     - return snprintf(buf, PAGE_SIZE, "%u\n", t);
4178     + return sysfs_emit(buf, "%u\n", t);
4179     }
4180    
4181     static ssize_t dsicm_store_ulps_timeout(struct device *dev,
4182     @@ -541,7 +541,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev,
4183     t = ddata->ulps_timeout;
4184     mutex_unlock(&ddata->lock);
4185    
4186     - return snprintf(buf, PAGE_SIZE, "%u\n", t);
4187     + return sysfs_emit(buf, "%u\n", t);
4188     }
4189    
4190     static DEVICE_ATTR(num_dsi_errors, S_IRUGO, dsicm_num_errors_show, NULL);
4191     diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
4192     index 468560a6daaea..0a1a82c686807 100644
4193     --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
4194     +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-sony-acx565akm.c
4195     @@ -487,7 +487,7 @@ static ssize_t show_cabc_available_modes(struct device *dev,
4196     int i;
4197    
4198     if (!ddata->has_cabc)
4199     - return snprintf(buf, PAGE_SIZE, "%s\n", cabc_modes[0]);
4200     + return sysfs_emit(buf, "%s\n", cabc_modes[0]);
4201    
4202     for (i = 0, len = 0;
4203     len < PAGE_SIZE && i < ARRAY_SIZE(cabc_modes); i++)
4204     diff --git a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
4205     index 51e628b85f4a0..2b8b6b5dc1aa2 100644
4206     --- a/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
4207     +++ b/drivers/video/fbdev/omap2/omapfb/displays/panel-tpo-td043mtea1.c
4208     @@ -173,7 +173,7 @@ static ssize_t tpo_td043_vmirror_show(struct device *dev,
4209     {
4210     struct panel_drv_data *ddata = dev_get_drvdata(dev);
4211    
4212     - return snprintf(buf, PAGE_SIZE, "%d\n", ddata->vmirror);
4213     + return sysfs_emit(buf, "%d\n", ddata->vmirror);
4214     }
4215    
4216     static ssize_t tpo_td043_vmirror_store(struct device *dev,
4217     @@ -203,7 +203,7 @@ static ssize_t tpo_td043_mode_show(struct device *dev,
4218     {
4219     struct panel_drv_data *ddata = dev_get_drvdata(dev);
4220    
4221     - return snprintf(buf, PAGE_SIZE, "%d\n", ddata->mode);
4222     + return sysfs_emit(buf, "%d\n", ddata->mode);
4223     }
4224    
4225     static ssize_t tpo_td043_mode_store(struct device *dev,
4226     diff --git a/drivers/video/fbdev/sm712fb.c b/drivers/video/fbdev/sm712fb.c
4227     index 17efcdd4dc99b..620f3152213ae 100644
4228     --- a/drivers/video/fbdev/sm712fb.c
4229     +++ b/drivers/video/fbdev/sm712fb.c
4230     @@ -1046,7 +1046,7 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
4231     if (count + p > total_size)
4232     count = total_size - p;
4233    
4234     - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
4235     + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
4236     if (!buffer)
4237     return -ENOMEM;
4238    
4239     @@ -1058,25 +1058,14 @@ static ssize_t smtcfb_read(struct fb_info *info, char __user *buf,
4240     while (count) {
4241     c = (count > PAGE_SIZE) ? PAGE_SIZE : count;
4242     dst = buffer;
4243     - for (i = c >> 2; i--;) {
4244     - *dst = fb_readl(src++);
4245     - *dst = big_swap(*dst);
4246     + for (i = (c + 3) >> 2; i--;) {
4247     + u32 val;
4248     +
4249     + val = fb_readl(src);
4250     + *dst = big_swap(val);
4251     + src++;
4252     dst++;
4253     }
4254     - if (c & 3) {
4255     - u8 *dst8 = (u8 *)dst;
4256     - u8 __iomem *src8 = (u8 __iomem *)src;
4257     -
4258     - for (i = c & 3; i--;) {
4259     - if (i & 1) {
4260     - *dst8++ = fb_readb(++src8);
4261     - } else {
4262     - *dst8++ = fb_readb(--src8);
4263     - src8 += 2;
4264     - }
4265     - }
4266     - src = (u32 __iomem *)src8;
4267     - }
4268    
4269     if (copy_to_user(buf, buffer, c)) {
4270     err = -EFAULT;
4271     @@ -1129,7 +1118,7 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
4272     count = total_size - p;
4273     }
4274    
4275     - buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, GFP_KERNEL);
4276     + buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
4277     if (!buffer)
4278     return -ENOMEM;
4279    
4280     @@ -1147,24 +1136,11 @@ static ssize_t smtcfb_write(struct fb_info *info, const char __user *buf,
4281     break;
4282     }
4283    
4284     - for (i = c >> 2; i--;) {
4285     - fb_writel(big_swap(*src), dst++);
4286     + for (i = (c + 3) >> 2; i--;) {
4287     + fb_writel(big_swap(*src), dst);
4288     + dst++;
4289     src++;
4290     }
4291     - if (c & 3) {
4292     - u8 *src8 = (u8 *)src;
4293     - u8 __iomem *dst8 = (u8 __iomem *)dst;
4294     -
4295     - for (i = c & 3; i--;) {
4296     - if (i & 1) {
4297     - fb_writeb(*src8++, ++dst8);
4298     - } else {
4299     - fb_writeb(*src8++, --dst8);
4300     - dst8 += 2;
4301     - }
4302     - }
4303     - dst = (u32 __iomem *)dst8;
4304     - }
4305    
4306     *ppos += c;
4307     buf += c;
4308     diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
4309     index ec2e7e3536859..aa387c5188e76 100644
4310     --- a/drivers/video/fbdev/smscufx.c
4311     +++ b/drivers/video/fbdev/smscufx.c
4312     @@ -1671,6 +1671,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
4313     info->par = dev;
4314     info->pseudo_palette = dev->pseudo_palette;
4315     info->fbops = &ufx_ops;
4316     + INIT_LIST_HEAD(&info->modelist);
4317    
4318     retval = fb_alloc_cmap(&info->cmap, 256, 0);
4319     if (retval < 0) {
4320     @@ -1681,8 +1682,6 @@ static int ufx_usb_probe(struct usb_interface *interface,
4321     INIT_DELAYED_WORK(&dev->free_framebuffer_work,
4322     ufx_free_framebuffer_work);
4323    
4324     - INIT_LIST_HEAD(&info->modelist);
4325     -
4326     retval = ufx_reg_read(dev, 0x3000, &id_rev);
4327     check_warn_goto_error(retval, "error %d reading 0x3000 register from device", retval);
4328     dev_dbg(dev->gdev, "ID_REV register value 0x%08x", id_rev);
4329     diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
4330     index 7bd4c27cfb149..b3b17b6adb7ed 100644
4331     --- a/drivers/video/fbdev/w100fb.c
4332     +++ b/drivers/video/fbdev/w100fb.c
4333     @@ -772,12 +772,18 @@ out:
4334     fb_dealloc_cmap(&info->cmap);
4335     kfree(info->pseudo_palette);
4336     }
4337     - if (remapped_fbuf != NULL)
4338     + if (remapped_fbuf != NULL) {
4339     iounmap(remapped_fbuf);
4340     - if (remapped_regs != NULL)
4341     + remapped_fbuf = NULL;
4342     + }
4343     + if (remapped_regs != NULL) {
4344     iounmap(remapped_regs);
4345     - if (remapped_base != NULL)
4346     + remapped_regs = NULL;
4347     + }
4348     + if (remapped_base != NULL) {
4349     iounmap(remapped_base);
4350     + remapped_base = NULL;
4351     + }
4352     if (info)
4353     framebuffer_release(info);
4354     return err;
4355     @@ -802,8 +808,11 @@ static int w100fb_remove(struct platform_device *pdev)
4356     fb_dealloc_cmap(&info->cmap);
4357    
4358     iounmap(remapped_base);
4359     + remapped_base = NULL;
4360     iounmap(remapped_regs);
4361     + remapped_regs = NULL;
4362     iounmap(remapped_fbuf);
4363     + remapped_fbuf = NULL;
4364    
4365     framebuffer_release(info);
4366    
4367     diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c
4368     index 82611f197b0a0..7d0e09867bc73 100644
4369     --- a/drivers/w1/slaves/w1_therm.c
4370     +++ b/drivers/w1/slaves/w1_therm.c
4371     @@ -589,16 +589,20 @@ static ssize_t w1_seq_show(struct device *device,
4372     if (sl->reg_num.id == reg_num->id)
4373     seq = i;
4374    
4375     + if (w1_reset_bus(sl->master))
4376     + goto error;
4377     +
4378     + /* Put the device into chain DONE state */
4379     + w1_write_8(sl->master, W1_MATCH_ROM);
4380     + w1_write_block(sl->master, (u8 *)&rn, 8);
4381     w1_write_8(sl->master, W1_42_CHAIN);
4382     w1_write_8(sl->master, W1_42_CHAIN_DONE);
4383     w1_write_8(sl->master, W1_42_CHAIN_DONE_INV);
4384     - w1_read_block(sl->master, &ack, sizeof(ack));
4385    
4386     /* check for acknowledgment */
4387     ack = w1_read_8(sl->master);
4388     if (ack != W1_42_SUCCESS_CONFIRM_BYTE)
4389     goto error;
4390     -
4391     }
4392    
4393     /* Exit from CHAIN state */
4394     diff --git a/fs/cifs/link.c b/fs/cifs/link.c
4395     index 38d26cbcad070..0c49e2aa7ea49 100644
4396     --- a/fs/cifs/link.c
4397     +++ b/fs/cifs/link.c
4398     @@ -119,6 +119,9 @@ parse_mf_symlink(const u8 *buf, unsigned int buf_len, unsigned int *_link_len,
4399     if (rc != 1)
4400     return -EINVAL;
4401    
4402     + if (link_len > CIFS_MF_SYMLINK_LINK_MAXLEN)
4403     + return -EINVAL;
4404     +
4405     rc = symlink_hash(link_len, link_str, md5_hash);
4406     if (rc) {
4407     cifs_dbg(FYI, "%s: MD5 hash failure: %d\n", __func__, rc);
4408     diff --git a/fs/ext2/super.c b/fs/ext2/super.c
4409     index 186912c9bf565..5ca1f73958b0d 100644
4410     --- a/fs/ext2/super.c
4411     +++ b/fs/ext2/super.c
4412     @@ -743,8 +743,12 @@ static loff_t ext2_max_size(int bits)
4413     res += 1LL << (bits-2);
4414     res += 1LL << (2*(bits-2));
4415     res += 1LL << (3*(bits-2));
4416     + /* Compute how many metadata blocks are needed */
4417     + meta_blocks = 1;
4418     + meta_blocks += 1 + ppb;
4419     + meta_blocks += 1 + ppb + ppb * ppb;
4420     /* Does block tree limit file size? */
4421     - if (res < upper_limit)
4422     + if (res + meta_blocks <= upper_limit)
4423     goto check_lfs;
4424    
4425     res = upper_limit;
4426     diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
4427     index 79c067f74253e..e66aa8918dee2 100644
4428     --- a/fs/ext4/inode.c
4429     +++ b/fs/ext4/inode.c
4430     @@ -2048,6 +2048,15 @@ static int ext4_writepage(struct page *page,
4431     else
4432     len = PAGE_SIZE;
4433    
4434     + /* Should never happen but for bugs in other kernel subsystems */
4435     + if (!page_has_buffers(page)) {
4436     + ext4_warning_inode(inode,
4437     + "page %lu does not have buffers attached", page->index);
4438     + ClearPageDirty(page);
4439     + unlock_page(page);
4440     + return 0;
4441     + }
4442     +
4443     page_bufs = page_buffers(page);
4444     /*
4445     * We cannot do block allocation or other extent handling in this
4446     @@ -2608,6 +2617,22 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd)
4447     wait_on_page_writeback(page);
4448     BUG_ON(PageWriteback(page));
4449    
4450     + /*
4451     + * Should never happen but for buggy code in
4452     + * other subsystems that call
4453     + * set_page_dirty() without properly warning
4454     + * the file system first. See [1] for more
4455     + * information.
4456     + *
4457     + * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz
4458     + */
4459     + if (!page_has_buffers(page)) {
4460     + ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index);
4461     + ClearPageDirty(page);
4462     + unlock_page(page);
4463     + continue;
4464     + }
4465     +
4466     if (mpd->map.m_len == 0)
4467     mpd->first_page = page->index;
4468     mpd->next_page = page->index + 1;
4469     diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
4470     index 56a94535c246f..a4182b150bb07 100644
4471     --- a/fs/gfs2/rgrp.c
4472     +++ b/fs/gfs2/rgrp.c
4473     @@ -1390,7 +1390,8 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
4474    
4475     start = r.start >> bs_shift;
4476     end = start + (r.len >> bs_shift);
4477     - minlen = max_t(u64, r.minlen,
4478     + minlen = max_t(u64, r.minlen, sdp->sd_sb.sb_bsize);
4479     + minlen = max_t(u64, minlen,
4480     q->limits.discard_granularity) >> bs_shift;
4481    
4482     if (end <= start || minlen > sdp->sd_max_rg_data)
4483     diff --git a/fs/jffs2/build.c b/fs/jffs2/build.c
4484     index b288c8ae1236b..837cd55fd4c5e 100644
4485     --- a/fs/jffs2/build.c
4486     +++ b/fs/jffs2/build.c
4487     @@ -415,13 +415,15 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
4488     jffs2_free_ino_caches(c);
4489     jffs2_free_raw_node_refs(c);
4490     ret = -EIO;
4491     - goto out_free;
4492     + goto out_sum_exit;
4493     }
4494    
4495     jffs2_calc_trigger_levels(c);
4496    
4497     return 0;
4498    
4499     + out_sum_exit:
4500     + jffs2_sum_exit(c);
4501     out_free:
4502     kvfree(c->blocks);
4503    
4504     diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
4505     index c9c47d03a690c..d3c9e4c82e57c 100644
4506     --- a/fs/jffs2/fs.c
4507     +++ b/fs/jffs2/fs.c
4508     @@ -596,8 +596,8 @@ out_root:
4509     jffs2_free_ino_caches(c);
4510     jffs2_free_raw_node_refs(c);
4511     kvfree(c->blocks);
4512     - out_inohash:
4513     jffs2_clear_xattr_subsystem(c);
4514     + out_inohash:
4515     kfree(c->inocache_list);
4516     out_wbuf:
4517     jffs2_flash_cleanup(c);
4518     diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
4519     index 08813789fcf06..664384dac6e58 100644
4520     --- a/fs/jffs2/scan.c
4521     +++ b/fs/jffs2/scan.c
4522     @@ -136,7 +136,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
4523     if (!s) {
4524     JFFS2_WARNING("Can't allocate memory for summary\n");
4525     ret = -ENOMEM;
4526     - goto out;
4527     + goto out_buf;
4528     }
4529     }
4530    
4531     @@ -274,13 +274,15 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
4532     }
4533     ret = 0;
4534     out:
4535     + jffs2_sum_reset_collected(s);
4536     + kfree(s);
4537     + out_buf:
4538     if (buf_size)
4539     kfree(flashbuf);
4540     #ifndef __ECOS
4541     else
4542     mtd_unpoint(c->mtd, 0, c->mtd->size);
4543     #endif
4544     - kfree(s);
4545     return ret;
4546     }
4547    
4548     diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
4549     index 87b41edc800d0..68779cc3609a6 100644
4550     --- a/fs/jfs/inode.c
4551     +++ b/fs/jfs/inode.c
4552     @@ -156,12 +156,13 @@ void jfs_evict_inode(struct inode *inode)
4553     dquot_initialize(inode);
4554    
4555     if (JFS_IP(inode)->fileset == FILESYSTEM_I) {
4556     + struct inode *ipimap = JFS_SBI(inode->i_sb)->ipimap;
4557     truncate_inode_pages_final(&inode->i_data);
4558    
4559     if (test_cflag(COMMIT_Freewmap, inode))
4560     jfs_free_zero_link(inode);
4561    
4562     - if (JFS_SBI(inode->i_sb)->ipimap)
4563     + if (ipimap && JFS_IP(ipimap)->i_imap)
4564     diFree(inode);
4565    
4566     /*
4567     diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
4568     index 9ff510a489cb1..6dac48e29d282 100644
4569     --- a/fs/jfs/jfs_dmap.c
4570     +++ b/fs/jfs/jfs_dmap.c
4571     @@ -161,6 +161,7 @@ static const s8 budtab[256] = {
4572     * 0 - success
4573     * -ENOMEM - insufficient memory
4574     * -EIO - i/o error
4575     + * -EINVAL - wrong bmap data
4576     */
4577     int dbMount(struct inode *ipbmap)
4578     {
4579     @@ -192,6 +193,12 @@ int dbMount(struct inode *ipbmap)
4580     bmp->db_nfree = le64_to_cpu(dbmp_le->dn_nfree);
4581     bmp->db_l2nbperpage = le32_to_cpu(dbmp_le->dn_l2nbperpage);
4582     bmp->db_numag = le32_to_cpu(dbmp_le->dn_numag);
4583     + if (!bmp->db_numag) {
4584     + release_metapage(mp);
4585     + kfree(bmp);
4586     + return -EINVAL;
4587     + }
4588     +
4589     bmp->db_maxlevel = le32_to_cpu(dbmp_le->dn_maxlevel);
4590     bmp->db_maxag = le32_to_cpu(dbmp_le->dn_maxag);
4591     bmp->db_agpref = le32_to_cpu(dbmp_le->dn_agpref);
4592     diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
4593     index 67903eeb2ca47..00e58a42e6372 100644
4594     --- a/fs/nfs/callback_xdr.c
4595     +++ b/fs/nfs/callback_xdr.c
4596     @@ -319,10 +319,6 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
4597     n = ntohl(*p++);
4598     if (n <= 0)
4599     goto out;
4600     - if (n > ULONG_MAX / sizeof(*args->devs)) {
4601     - status = htonl(NFS4ERR_BADXDR);
4602     - goto out;
4603     - }
4604    
4605     args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
4606     if (!args->devs) {
4607     diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c
4608     index 536009e503871..fd5bb6f7f5f77 100644
4609     --- a/fs/nfsd/nfsproc.c
4610     +++ b/fs/nfsd/nfsproc.c
4611     @@ -207,7 +207,7 @@ nfsd_proc_write(struct svc_rqst *rqstp, struct nfsd_writeargs *argp,
4612     int stable = 1;
4613     unsigned long cnt = argp->len;
4614    
4615     - dprintk("nfsd: WRITE %s %d bytes at %d\n",
4616     + dprintk("nfsd: WRITE %s %u bytes at %d\n",
4617     SVCFH_fmt(&argp->fh),
4618     argp->len, argp->offset);
4619    
4620     diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h
4621     index 4f0481d638048..8c78b56a93502 100644
4622     --- a/fs/nfsd/xdr.h
4623     +++ b/fs/nfsd/xdr.h
4624     @@ -32,7 +32,7 @@ struct nfsd_readargs {
4625     struct nfsd_writeargs {
4626     svc_fh fh;
4627     __u32 offset;
4628     - int len;
4629     + __u32 len;
4630     int vlen;
4631     };
4632    
4633     diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
4634     index 8cd134750ebb0..4150b3633f779 100644
4635     --- a/fs/ntfs/inode.c
4636     +++ b/fs/ntfs/inode.c
4637     @@ -1915,6 +1915,10 @@ int ntfs_read_inode_mount(struct inode *vi)
4638     }
4639     /* Now allocate memory for the attribute list. */
4640     ni->attr_list_size = (u32)ntfs_attr_size(a);
4641     + if (!ni->attr_list_size) {
4642     + ntfs_error(sb, "Attr_list_size is zero");
4643     + goto put_err_out;
4644     + }
4645     ni->attr_list = ntfs_malloc_nofs(ni->attr_list_size);
4646     if (!ni->attr_list) {
4647     ntfs_error(sb, "Not enough memory to allocate buffer "
4648     diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
4649     index 56eed54633cf2..89cebe1807d2b 100644
4650     --- a/fs/ubifs/dir.c
4651     +++ b/fs/ubifs/dir.c
4652     @@ -376,6 +376,8 @@ out_inode:
4653     make_bad_inode(inode);
4654     if (!instantiated)
4655     iput(inode);
4656     + else if (whiteout)
4657     + iput(*whiteout);
4658     out_budg:
4659     ubifs_release_budget(c, &req);
4660     if (!instantiated)
4661     diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
4662     index 3c7b29de0ca73..b5320eedec3b1 100644
4663     --- a/fs/ubifs/ioctl.c
4664     +++ b/fs/ubifs/ioctl.c
4665     @@ -105,7 +105,7 @@ static int setflags(struct inode *inode, int flags)
4666     struct ubifs_inode *ui = ubifs_inode(inode);
4667     struct ubifs_info *c = inode->i_sb->s_fs_info;
4668     struct ubifs_budget_req req = { .dirtied_ino = 1,
4669     - .dirtied_ino_d = ui->data_len };
4670     + .dirtied_ino_d = ALIGN(ui->data_len, 8) };
4671    
4672     err = ubifs_budget_space(c, &req);
4673     if (err)
4674     diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
4675     index 848aab6c69823..8050724065524 100644
4676     --- a/include/linux/blkdev.h
4677     +++ b/include/linux/blkdev.h
4678     @@ -49,6 +49,14 @@ struct pr_ops;
4679    
4680     typedef void (rq_end_io_fn)(struct request *, int);
4681    
4682     +static inline int blk_validate_block_size(unsigned int bsize)
4683     +{
4684     + if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
4685     + return -EINVAL;
4686     +
4687     + return 0;
4688     +}
4689     +
4690     #define BLK_RL_SYNCFULL (1U << 0)
4691     #define BLK_RL_ASYNCFULL (1U << 1)
4692    
4693     diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
4694     index a92fb5c5704f2..714d86dedbc2b 100644
4695     --- a/include/linux/netdevice.h
4696     +++ b/include/linux/netdevice.h
4697     @@ -3410,7 +3410,8 @@ void netdev_run_todo(void);
4698     */
4699     static inline void dev_put(struct net_device *dev)
4700     {
4701     - this_cpu_dec(*dev->pcpu_refcnt);
4702     + if (dev)
4703     + this_cpu_dec(*dev->pcpu_refcnt);
4704     }
4705    
4706     /**
4707     @@ -3421,7 +3422,8 @@ static inline void dev_put(struct net_device *dev)
4708     */
4709     static inline void dev_hold(struct net_device *dev)
4710     {
4711     - this_cpu_inc(*dev->pcpu_refcnt);
4712     + if (dev)
4713     + this_cpu_inc(*dev->pcpu_refcnt);
4714     }
4715    
4716     /* Carrier loss detection, dial on demand. The functions netif_carrier_on
4717     diff --git a/include/net/xfrm.h b/include/net/xfrm.h
4718     index b2a405c93a342..7415a98769872 100644
4719     --- a/include/net/xfrm.h
4720     +++ b/include/net/xfrm.h
4721     @@ -1595,13 +1595,16 @@ int xfrm_policy_walk(struct net *net, struct xfrm_policy_walk *walk,
4722     void *);
4723     void xfrm_policy_walk_done(struct xfrm_policy_walk *walk, struct net *net);
4724     int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl);
4725     -struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark,
4726     +struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net,
4727     + const struct xfrm_mark *mark,
4728     u8 type, int dir,
4729     struct xfrm_selector *sel,
4730     struct xfrm_sec_ctx *ctx, int delete,
4731     int *err);
4732     -struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8, int dir,
4733     - u32 id, int delete, int *err);
4734     +struct xfrm_policy *xfrm_policy_byid(struct net *net,
4735     + const struct xfrm_mark *mark,
4736     + u8 type, int dir, u32 id, int delete,
4737     + int *err);
4738     int xfrm_policy_flush(struct net *net, u8 type, bool task_valid);
4739     void xfrm_policy_hash_rebuild(struct net *net);
4740     u32 xfrm_get_acqseq(void);
4741     diff --git a/init/main.c b/init/main.c
4742     index 9e057314a15f3..0c01d4e10d2f3 100644
4743     --- a/init/main.c
4744     +++ b/init/main.c
4745     @@ -705,7 +705,7 @@ static int __init initcall_blacklist(char *str)
4746     }
4747     } while (str_entry);
4748    
4749     - return 0;
4750     + return 1;
4751     }
4752    
4753     static bool __init_or_module initcall_blacklisted(initcall_t fn)
4754     @@ -921,7 +921,9 @@ static noinline void __init kernel_init_freeable(void);
4755     bool rodata_enabled __ro_after_init = true;
4756     static int __init set_debug_rodata(char *str)
4757     {
4758     - return strtobool(str, &rodata_enabled);
4759     + if (strtobool(str, &rodata_enabled))
4760     + pr_warn("Invalid option string for rodata: '%s'\n", str);
4761     + return 1;
4762     }
4763     __setup("rodata=", set_debug_rodata);
4764     #endif
4765     diff --git a/kernel/events/core.c b/kernel/events/core.c
4766     index e56a74fd5c814..396abd52962b8 100644
4767     --- a/kernel/events/core.c
4768     +++ b/kernel/events/core.c
4769     @@ -8306,8 +8306,11 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr,
4770     }
4771    
4772     /* ready to consume more filters */
4773     + kfree(filename);
4774     + filename = NULL;
4775     state = IF_STATE_ACTION;
4776     filter = NULL;
4777     + kernel = 0;
4778     }
4779     }
4780    
4781     diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
4782     index e938fd8db056b..c17b953f1294b 100644
4783     --- a/kernel/power/hibernate.c
4784     +++ b/kernel/power/hibernate.c
4785     @@ -1185,7 +1185,7 @@ static int __init resumedelay_setup(char *str)
4786     int rc = kstrtouint(str, 0, &resume_delay);
4787    
4788     if (rc)
4789     - return rc;
4790     + pr_warn("resumedelay: bad option string '%s'\n", str);
4791     return 1;
4792     }
4793    
4794     diff --git a/kernel/power/suspend_test.c b/kernel/power/suspend_test.c
4795     index bdff5ed57f10a..5476bd8921832 100644
4796     --- a/kernel/power/suspend_test.c
4797     +++ b/kernel/power/suspend_test.c
4798     @@ -158,22 +158,22 @@ static int __init setup_test_suspend(char *value)
4799     value++;
4800     suspend_type = strsep(&value, ",");
4801     if (!suspend_type)
4802     - return 0;
4803     + return 1;
4804    
4805     repeat = strsep(&value, ",");
4806     if (repeat) {
4807     if (kstrtou32(repeat, 0, &test_repeat_count_max))
4808     - return 0;
4809     + return 1;
4810     }
4811    
4812     for (i = 0; pm_labels[i]; i++)
4813     if (!strcmp(pm_labels[i], suspend_type)) {
4814     test_state_label = pm_labels[i];
4815     - return 0;
4816     + return 1;
4817     }
4818    
4819     printk(warn_bad_state, suspend_type);
4820     - return 0;
4821     + return 1;
4822     }
4823     __setup("test_suspend", setup_test_suspend);
4824    
4825     diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
4826     index 9c17a26555512..f1f115b3ee018 100644
4827     --- a/kernel/printk/printk.c
4828     +++ b/kernel/printk/printk.c
4829     @@ -122,8 +122,10 @@ static int __control_devkmsg(char *str)
4830    
4831     static int __init control_devkmsg(char *str)
4832     {
4833     - if (__control_devkmsg(str) < 0)
4834     + if (__control_devkmsg(str) < 0) {
4835     + pr_warn("printk.devkmsg: bad option string '%s'\n", str);
4836     return 1;
4837     + }
4838    
4839     /*
4840     * Set sysctl string accordingly:
4841     @@ -145,7 +147,7 @@ static int __init control_devkmsg(char *str)
4842     */
4843     devkmsg_log |= DEVKMSG_LOG_MASK_LOCK;
4844    
4845     - return 0;
4846     + return 1;
4847     }
4848     __setup("printk.devkmsg=", control_devkmsg);
4849    
4850     diff --git a/kernel/ptrace.c b/kernel/ptrace.c
4851     index 4f10223bc7b0f..2b59212ddcc6e 100644
4852     --- a/kernel/ptrace.c
4853     +++ b/kernel/ptrace.c
4854     @@ -371,6 +371,26 @@ bool ptrace_may_access(struct task_struct *task, unsigned int mode)
4855     return !err;
4856     }
4857    
4858     +static int check_ptrace_options(unsigned long data)
4859     +{
4860     + if (data & ~(unsigned long)PTRACE_O_MASK)
4861     + return -EINVAL;
4862     +
4863     + if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
4864     + if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) ||
4865     + !IS_ENABLED(CONFIG_SECCOMP))
4866     + return -EINVAL;
4867     +
4868     + if (!capable(CAP_SYS_ADMIN))
4869     + return -EPERM;
4870     +
4871     + if (seccomp_mode(&current->seccomp) != SECCOMP_MODE_DISABLED ||
4872     + current->ptrace & PT_SUSPEND_SECCOMP)
4873     + return -EPERM;
4874     + }
4875     + return 0;
4876     +}
4877     +
4878     static int ptrace_attach(struct task_struct *task, long request,
4879     unsigned long addr,
4880     unsigned long flags)
4881     @@ -382,8 +402,16 @@ static int ptrace_attach(struct task_struct *task, long request,
4882     if (seize) {
4883     if (addr != 0)
4884     goto out;
4885     + /*
4886     + * This duplicates the check in check_ptrace_options() because
4887     + * ptrace_attach() and ptrace_setoptions() have historically
4888     + * used different error codes for unknown ptrace options.
4889     + */
4890     if (flags & ~(unsigned long)PTRACE_O_MASK)
4891     goto out;
4892     + retval = check_ptrace_options(flags);
4893     + if (retval)
4894     + return retval;
4895     flags = PT_PTRACED | PT_SEIZED | (flags << PT_OPT_FLAG_SHIFT);
4896     } else {
4897     flags = PT_PTRACED;
4898     @@ -656,22 +684,11 @@ int ptrace_writedata(struct task_struct *tsk, char __user *src, unsigned long ds
4899     static int ptrace_setoptions(struct task_struct *child, unsigned long data)
4900     {
4901     unsigned flags;
4902     + int ret;
4903    
4904     - if (data & ~(unsigned long)PTRACE_O_MASK)
4905     - return -EINVAL;
4906     -
4907     - if (unlikely(data & PTRACE_O_SUSPEND_SECCOMP)) {
4908     - if (!IS_ENABLED(CONFIG_CHECKPOINT_RESTORE) ||
4909     - !IS_ENABLED(CONFIG_SECCOMP))
4910     - return -EINVAL;
4911     -
4912     - if (!capable(CAP_SYS_ADMIN))
4913     - return -EPERM;
4914     -
4915     - if (seccomp_mode(&current->seccomp) != SECCOMP_MODE_DISABLED ||
4916     - current->ptrace & PT_SUSPEND_SECCOMP)
4917     - return -EPERM;
4918     - }
4919     + ret = check_ptrace_options(data);
4920     + if (ret)
4921     + return ret;
4922    
4923     /* Avoid intermediate state when all opts are cleared */
4924     flags = child->ptrace;
4925     diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c
4926     index fa178b62ea79b..69c3252d151ba 100644
4927     --- a/kernel/sched/debug.c
4928     +++ b/kernel/sched/debug.c
4929     @@ -836,25 +836,15 @@ void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,
4930     static void sched_show_numa(struct task_struct *p, struct seq_file *m)
4931     {
4932     #ifdef CONFIG_NUMA_BALANCING
4933     - struct mempolicy *pol;
4934     -
4935     if (p->mm)
4936     P(mm->numa_scan_seq);
4937    
4938     - task_lock(p);
4939     - pol = p->mempolicy;
4940     - if (pol && !(pol->flags & MPOL_F_MORON))
4941     - pol = NULL;
4942     - mpol_get(pol);
4943     - task_unlock(p);
4944     -
4945     P(numa_pages_migrated);
4946     P(numa_preferred_nid);
4947     P(total_numa_faults);
4948     SEQ_printf(m, "current_node=%d, numa_group_id=%d\n",
4949     task_node(p), task_numa_group_id(p));
4950     show_numa_stats(p, m);
4951     - mpol_put(pol);
4952     #endif
4953     }
4954    
4955     diff --git a/kernel/smp.c b/kernel/smp.c
4956     index 399905fdfa3f8..df9d5a64b0aad 100644
4957     --- a/kernel/smp.c
4958     +++ b/kernel/smp.c
4959     @@ -209,7 +209,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline)
4960    
4961     /* There shouldn't be any pending callbacks on an offline CPU. */
4962     if (unlikely(warn_cpu_offline && !cpu_online(smp_processor_id()) &&
4963     - !warned && !llist_empty(head))) {
4964     + !warned && entry != NULL)) {
4965     warned = true;
4966     WARN(1, "IPI on offline CPU %d\n", smp_processor_id());
4967    
4968     diff --git a/lib/raid6/test/test.c b/lib/raid6/test/test.c
4969     index b07f4d8e6b033..a7e9372482996 100644
4970     --- a/lib/raid6/test/test.c
4971     +++ b/lib/raid6/test/test.c
4972     @@ -22,7 +22,6 @@
4973     #define NDISKS 16 /* Including P and Q */
4974    
4975     const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
4976     -struct raid6_calls raid6_call;
4977    
4978     char *dataptrs[NDISKS];
4979     char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
4980     diff --git a/mm/kmemleak.c b/mm/kmemleak.c
4981     index 59bb2b9ec0e2e..c1360b2509194 100644
4982     --- a/mm/kmemleak.c
4983     +++ b/mm/kmemleak.c
4984     @@ -1130,7 +1130,7 @@ EXPORT_SYMBOL(kmemleak_no_scan);
4985     void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, int min_count,
4986     gfp_t gfp)
4987     {
4988     - if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn)
4989     + if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
4990     kmemleak_alloc(__va(phys), size, min_count, gfp);
4991     }
4992     EXPORT_SYMBOL(kmemleak_alloc_phys);
4993     @@ -1141,7 +1141,7 @@ EXPORT_SYMBOL(kmemleak_alloc_phys);
4994     */
4995     void __ref kmemleak_free_part_phys(phys_addr_t phys, size_t size)
4996     {
4997     - if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn)
4998     + if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
4999     kmemleak_free_part(__va(phys), size);
5000     }
5001     EXPORT_SYMBOL(kmemleak_free_part_phys);
5002     @@ -1152,7 +1152,7 @@ EXPORT_SYMBOL(kmemleak_free_part_phys);
5003     */
5004     void __ref kmemleak_not_leak_phys(phys_addr_t phys)
5005     {
5006     - if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn)
5007     + if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
5008     kmemleak_not_leak(__va(phys));
5009     }
5010     EXPORT_SYMBOL(kmemleak_not_leak_phys);
5011     @@ -1163,7 +1163,7 @@ EXPORT_SYMBOL(kmemleak_not_leak_phys);
5012     */
5013     void __ref kmemleak_ignore_phys(phys_addr_t phys)
5014     {
5015     - if (!IS_ENABLED(CONFIG_HIGHMEM) || PHYS_PFN(phys) < max_low_pfn)
5016     + if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn)
5017     kmemleak_ignore(__va(phys));
5018     }
5019     EXPORT_SYMBOL(kmemleak_ignore_phys);
5020     diff --git a/mm/memcontrol.c b/mm/memcontrol.c
5021     index 27b0b4f03fcdc..955e8412b9f63 100644
5022     --- a/mm/memcontrol.c
5023     +++ b/mm/memcontrol.c
5024     @@ -5840,7 +5840,7 @@ static int __init cgroup_memory(char *s)
5025     if (!strcmp(token, "nokmem"))
5026     cgroup_memory_nokmem = true;
5027     }
5028     - return 0;
5029     + return 1;
5030     }
5031     __setup("cgroup.memory=", cgroup_memory);
5032    
5033     diff --git a/mm/memory.c b/mm/memory.c
5034     index 2b2cc69ddccef..1b31cdce936e9 100644
5035     --- a/mm/memory.c
5036     +++ b/mm/memory.c
5037     @@ -1113,6 +1113,17 @@ int copy_page_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
5038     return ret;
5039     }
5040    
5041     +/* Whether we should zap all COWed (private) pages too */
5042     +static inline bool should_zap_cows(struct zap_details *details)
5043     +{
5044     + /* By default, zap all pages */
5045     + if (!details)
5046     + return true;
5047     +
5048     + /* Or, we zap COWed pages only if the caller wants to */
5049     + return !details->check_mapping;
5050     +}
5051     +
5052     static unsigned long zap_pte_range(struct mmu_gather *tlb,
5053     struct vm_area_struct *vma, pmd_t *pmd,
5054     unsigned long addr, unsigned long end,
5055     @@ -1186,17 +1197,20 @@ again:
5056     }
5057     continue;
5058     }
5059     - /* only check swap_entries if explicitly asked for in details */
5060     - if (unlikely(details && !details->check_swap_entries))
5061     - continue;
5062    
5063     entry = pte_to_swp_entry(ptent);
5064     - if (!non_swap_entry(entry))
5065     + if (!non_swap_entry(entry)) {
5066     + /* Genuine swap entry, hence a private anon page */
5067     + if (!should_zap_cows(details))
5068     + continue;
5069     rss[MM_SWAPENTS]--;
5070     - else if (is_migration_entry(entry)) {
5071     + } else if (is_migration_entry(entry)) {
5072     struct page *page;
5073    
5074     page = migration_entry_to_page(entry);
5075     + if (details && details->check_mapping &&
5076     + details->check_mapping != page_rmapping(page))
5077     + continue;
5078     rss[mm_counter(page)]--;
5079     }
5080     if (unlikely(!free_swap_and_cache(entry)))
5081     diff --git a/mm/mempolicy.c b/mm/mempolicy.c
5082     index 2f443767fd1b4..6059f85546fe9 100644
5083     --- a/mm/mempolicy.c
5084     +++ b/mm/mempolicy.c
5085     @@ -734,7 +734,6 @@ static int vma_replace_policy(struct vm_area_struct *vma,
5086     static int mbind_range(struct mm_struct *mm, unsigned long start,
5087     unsigned long end, struct mempolicy *new_pol)
5088     {
5089     - struct vm_area_struct *next;
5090     struct vm_area_struct *prev;
5091     struct vm_area_struct *vma;
5092     int err = 0;
5093     @@ -750,8 +749,7 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
5094     if (start > vma->vm_start)
5095     prev = vma;
5096    
5097     - for (; vma && vma->vm_start < end; prev = vma, vma = next) {
5098     - next = vma->vm_next;
5099     + for (; vma && vma->vm_start < end; prev = vma, vma = vma->vm_next) {
5100     vmstart = max(start, vma->vm_start);
5101     vmend = min(end, vma->vm_end);
5102    
5103     @@ -765,10 +763,6 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
5104     new_pol, vma->vm_userfaultfd_ctx);
5105     if (prev) {
5106     vma = prev;
5107     - next = vma->vm_next;
5108     - if (mpol_equal(vma_policy(vma), new_pol))
5109     - continue;
5110     - /* vma_merge() joined vma && vma->next, case 8 */
5111     goto replace;
5112     }
5113     if (vma->vm_start != vmstart) {
5114     @@ -2505,6 +2499,7 @@ alloc_new:
5115     mpol_new = kmem_cache_alloc(policy_cache, GFP_KERNEL);
5116     if (!mpol_new)
5117     goto err_out;
5118     + atomic_set(&mpol_new->refcnt, 1);
5119     goto restart;
5120     }
5121    
5122     diff --git a/mm/mmap.c b/mm/mmap.c
5123     index 7c8815636c482..18bd38ac15317 100644
5124     --- a/mm/mmap.c
5125     +++ b/mm/mmap.c
5126     @@ -2425,7 +2425,7 @@ static int __init cmdline_parse_stack_guard_gap(char *p)
5127     if (!*endptr)
5128     stack_guard_gap = val << PAGE_SHIFT;
5129    
5130     - return 0;
5131     + return 1;
5132     }
5133     __setup("stack_guard_gap=", cmdline_parse_stack_guard_gap);
5134    
5135     diff --git a/mm/mremap.c b/mm/mremap.c
5136     index b5d8d25173c61..058de6f8c9d54 100644
5137     --- a/mm/mremap.c
5138     +++ b/mm/mremap.c
5139     @@ -192,6 +192,9 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
5140     unsigned long mmun_start; /* For mmu_notifiers */
5141     unsigned long mmun_end; /* For mmu_notifiers */
5142    
5143     + if (!len)
5144     + return 0;
5145     +
5146     old_end = old_addr + len;
5147     flush_cache_range(vma, old_addr, old_end);
5148    
5149     diff --git a/mm/page_alloc.c b/mm/page_alloc.c
5150     index babcbd8b94ea8..25c21aa398f8c 100644
5151     --- a/mm/page_alloc.c
5152     +++ b/mm/page_alloc.c
5153     @@ -4503,7 +4503,7 @@ static int build_zonelists_node(pg_data_t *pgdat, struct zonelist *zonelist,
5154     do {
5155     zone_type--;
5156     zone = pgdat->node_zones + zone_type;
5157     - if (managed_zone(zone)) {
5158     + if (populated_zone(zone)) {
5159     zoneref_set_zone(zone,
5160     &zonelist->_zonerefs[nr_zones++]);
5161     check_highest_zone(zone_type);
5162     @@ -6267,10 +6267,17 @@ restart:
5163    
5164     out2:
5165     /* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */
5166     - for (nid = 0; nid < MAX_NUMNODES; nid++)
5167     + for (nid = 0; nid < MAX_NUMNODES; nid++) {
5168     + unsigned long start_pfn, end_pfn;
5169     +
5170     zone_movable_pfn[nid] =
5171     roundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES);
5172    
5173     + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
5174     + if (zone_movable_pfn[nid] >= end_pfn)
5175     + zone_movable_pfn[nid] = 0;
5176     + }
5177     +
5178     out:
5179     /* restore the node_state */
5180     node_states[N_MEMORY] = saved_node_state;
5181     diff --git a/mm/rmap.c b/mm/rmap.c
5182     index a7276d8c96f33..0a5310b76ec85 100644
5183     --- a/mm/rmap.c
5184     +++ b/mm/rmap.c
5185     @@ -1638,11 +1638,36 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
5186     */
5187     VM_BUG_ON_PAGE(!PageSwapCache(page), page);
5188    
5189     - if (!PageDirty(page) && (flags & TTU_LZFREE)) {
5190     - /* It's a freeable page by MADV_FREE */
5191     - dec_mm_counter(mm, MM_ANONPAGES);
5192     - rp->lazyfreed++;
5193     - goto discard;
5194     + if (flags & TTU_LZFREE) {
5195     + int ref_count, map_count;
5196     +
5197     + /*
5198     + * Synchronize with gup_pte_range():
5199     + * - clear PTE; barrier; read refcount
5200     + * - inc refcount; barrier; read PTE
5201     + */
5202     + smp_mb();
5203     +
5204     + ref_count = page_ref_count(page);
5205     + map_count = page_mapcount(page);
5206     +
5207     + /*
5208     + * Order reads for page refcount and dirty flag
5209     + * (see comments in __remove_mapping()).
5210     + */
5211     + smp_rmb();
5212     +
5213     + /*
5214     + * The only page refs must be one from isolation
5215     + * plus the rmap(s) (dropped by discard:).
5216     + */
5217     + if (ref_count == 1 + map_count &&
5218     + !PageDirty(page)) {
5219     + /* It's a freeable page by MADV_FREE */
5220     + dec_mm_counter(mm, MM_ANONPAGES);
5221     + rp->lazyfreed++;
5222     + goto discard;
5223     + }
5224     }
5225    
5226     if (swap_duplicate(entry) < 0) {
5227     diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
5228     index cff87c465bcb0..8face15b42d86 100644
5229     --- a/net/bluetooth/hci_event.c
5230     +++ b/net/bluetooth/hci_event.c
5231     @@ -4470,8 +4470,9 @@ static void hci_disconn_phylink_complete_evt(struct hci_dev *hdev,
5232     hci_dev_lock(hdev);
5233    
5234     hcon = hci_conn_hash_lookup_handle(hdev, ev->phy_handle);
5235     - if (hcon) {
5236     + if (hcon && hcon->type == AMP_LINK) {
5237     hcon->state = BT_CLOSED;
5238     + hci_disconn_cfm(hcon, ev->reason);
5239     hci_conn_del(hcon);
5240     }
5241    
5242     diff --git a/net/key/af_key.c b/net/key/af_key.c
5243     index adc93329e6aac..c9cc9f75b0999 100644
5244     --- a/net/key/af_key.c
5245     +++ b/net/key/af_key.c
5246     @@ -1726,7 +1726,7 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
5247    
5248     xfrm_probe_algs();
5249    
5250     - supp_skb = compose_sadb_supported(hdr, GFP_KERNEL);
5251     + supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO);
5252     if (!supp_skb) {
5253     if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)
5254     pfk->registered &= ~(1<<hdr->sadb_msg_satype);
5255     @@ -2434,7 +2434,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, const struct sa
5256     return err;
5257     }
5258    
5259     - xp = xfrm_policy_bysel_ctx(net, DUMMY_MARK, XFRM_POLICY_TYPE_MAIN,
5260     + xp = xfrm_policy_bysel_ctx(net, &dummy_mark, XFRM_POLICY_TYPE_MAIN,
5261     pol->sadb_x_policy_dir - 1, &sel, pol_ctx,
5262     1, &err);
5263     security_xfrm_policy_free(pol_ctx);
5264     @@ -2687,7 +2687,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, const struct sadb_
5265     return -EINVAL;
5266    
5267     delete = (hdr->sadb_msg_type == SADB_X_SPDDELETE2);
5268     - xp = xfrm_policy_byid(net, DUMMY_MARK, XFRM_POLICY_TYPE_MAIN,
5269     + xp = xfrm_policy_byid(net, &dummy_mark, XFRM_POLICY_TYPE_MAIN,
5270     dir, pol->sadb_x_policy_id, delete, &err);
5271     if (xp == NULL)
5272     return -ENOENT;
5273     diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
5274     index 69f687740c76b..9e9ce570bb9ec 100644
5275     --- a/net/netfilter/nf_conntrack_proto_tcp.c
5276     +++ b/net/netfilter/nf_conntrack_proto_tcp.c
5277     @@ -390,8 +390,8 @@ static void tcp_options(const struct sk_buff *skb,
5278     length, buff);
5279     BUG_ON(ptr == NULL);
5280    
5281     - state->td_scale =
5282     - state->flags = 0;
5283     + state->td_scale = 0;
5284     + state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL;
5285    
5286     while (length > 0) {
5287     int opcode=*ptr++;
5288     @@ -806,6 +806,16 @@ static unsigned int *tcp_get_timeouts(struct net *net)
5289     return tcp_pernet(net)->timeouts;
5290     }
5291    
5292     +static void nf_ct_tcp_state_reset(struct ip_ct_tcp_state *state)
5293     +{
5294     + state->td_end = 0;
5295     + state->td_maxend = 0;
5296     + state->td_maxwin = 0;
5297     + state->td_maxack = 0;
5298     + state->td_scale = 0;
5299     + state->flags &= IP_CT_TCP_FLAG_BE_LIBERAL;
5300     +}
5301     +
5302     /* Returns verdict for packet, or -1 for invalid. */
5303     static int tcp_packet(struct nf_conn *ct,
5304     const struct sk_buff *skb,
5305     @@ -907,8 +917,7 @@ static int tcp_packet(struct nf_conn *ct,
5306     ct->proto.tcp.last_flags &= ~IP_CT_EXP_CHALLENGE_ACK;
5307     ct->proto.tcp.seen[ct->proto.tcp.last_dir].flags =
5308     ct->proto.tcp.last_flags;
5309     - memset(&ct->proto.tcp.seen[dir], 0,
5310     - sizeof(struct ip_ct_tcp_state));
5311     + nf_ct_tcp_state_reset(&ct->proto.tcp.seen[dir]);
5312     break;
5313     }
5314     ct->proto.tcp.last_index = index;
5315     diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
5316     index 13d69cbd14c20..8aef475fef310 100644
5317     --- a/net/netlink/af_netlink.c
5318     +++ b/net/netlink/af_netlink.c
5319     @@ -161,6 +161,8 @@ static const struct rhashtable_params netlink_rhashtable_params;
5320    
5321     static inline u32 netlink_group_mask(u32 group)
5322     {
5323     + if (group > 32)
5324     + return 0;
5325     return group ? 1 << (group - 1) : 0;
5326     }
5327    
5328     diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
5329     index 84eedbd5716d1..df90872fcf908 100644
5330     --- a/net/nfc/nci/core.c
5331     +++ b/net/nfc/nci/core.c
5332     @@ -561,6 +561,10 @@ static int nci_close_device(struct nci_dev *ndev)
5333     mutex_lock(&ndev->req_lock);
5334    
5335     if (!test_and_clear_bit(NCI_UP, &ndev->flags)) {
5336     + /* Need to flush the cmd wq in case
5337     + * there is a queued/running cmd_work
5338     + */
5339     + flush_workqueue(ndev->cmd_wq);
5340     del_timer_sync(&ndev->cmd_timer);
5341     del_timer_sync(&ndev->data_timer);
5342     mutex_unlock(&ndev->req_lock);
5343     diff --git a/net/openvswitch/flow_netlink.c b/net/openvswitch/flow_netlink.c
5344     index 50ea76180afae..28471cfad9225 100644
5345     --- a/net/openvswitch/flow_netlink.c
5346     +++ b/net/openvswitch/flow_netlink.c
5347     @@ -1713,8 +1713,8 @@ static int __ovs_nla_put_key(const struct sw_flow_key *swkey,
5348     icmpv6_key->icmpv6_type = ntohs(output->tp.src);
5349     icmpv6_key->icmpv6_code = ntohs(output->tp.dst);
5350    
5351     - if (icmpv6_key->icmpv6_type == NDISC_NEIGHBOUR_SOLICITATION ||
5352     - icmpv6_key->icmpv6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) {
5353     + if (swkey->tp.src == htons(NDISC_NEIGHBOUR_SOLICITATION) ||
5354     + swkey->tp.src == htons(NDISC_NEIGHBOUR_ADVERTISEMENT)) {
5355     struct ovs_key_nd *nd_key;
5356    
5357     nla = nla_reserve(skb, OVS_KEY_ATTR_ND, sizeof(*nd_key));
5358     diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
5359     index 00d95fefdc6fd..ccb9fa5812d8a 100644
5360     --- a/net/sunrpc/sched.c
5361     +++ b/net/sunrpc/sched.c
5362     @@ -883,8 +883,10 @@ int rpc_malloc(struct rpc_task *task)
5363     struct rpc_buffer *buf;
5364     gfp_t gfp = GFP_NOIO | __GFP_NOWARN;
5365    
5366     + if (RPC_IS_ASYNC(task))
5367     + gfp = GFP_NOWAIT | __GFP_NOWARN;
5368     if (RPC_IS_SWAPPER(task))
5369     - gfp = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN;
5370     + gfp |= __GFP_MEMALLOC;
5371    
5372     size += sizeof(struct rpc_buffer);
5373     if (size <= RPC_BUFFER_MAXSIZE)
5374     diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
5375     index 9491fc81d50ad..ff263ece44a73 100644
5376     --- a/net/sunrpc/xprt.c
5377     +++ b/net/sunrpc/xprt.c
5378     @@ -1446,7 +1446,14 @@ static void xprt_destroy(struct rpc_xprt *xprt)
5379     /* Exclude transport connect/disconnect handlers */
5380     wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_UNINTERRUPTIBLE);
5381    
5382     + /*
5383     + * xprt_schedule_autodisconnect() can run after XPRT_LOCKED
5384     + * is cleared. We use ->transport_lock to ensure the mod_timer()
5385     + * can only run *before* del_time_sync(), never after.
5386     + */
5387     + spin_lock(&xprt->transport_lock);
5388     del_timer_sync(&xprt->timer);
5389     + spin_unlock(&xprt->transport_lock);
5390    
5391     rpc_xprt_debugfs_unregister(xprt);
5392     rpc_destroy_wait_queue(&xprt->binding);
5393     diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
5394     index 3ea3bb64b6d5c..f308f286e9aa4 100644
5395     --- a/net/sunrpc/xprtrdma/transport.c
5396     +++ b/net/sunrpc/xprtrdma/transport.c
5397     @@ -577,8 +577,10 @@ xprt_rdma_allocate(struct rpc_task *task)
5398     return -ENOMEM;
5399    
5400     flags = RPCRDMA_DEF_GFP;
5401     + if (RPC_IS_ASYNC(task))
5402     + flags = GFP_NOWAIT | __GFP_NOWARN;
5403     if (RPC_IS_SWAPPER(task))
5404     - flags = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN;
5405     + flags |= __GFP_MEMALLOC;
5406    
5407     if (!rpcrdma_get_rdmabuf(r_xprt, req, flags))
5408     goto out_fail;
5409     diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
5410     index c23c04d38a82e..cd0c800b9072b 100644
5411     --- a/net/x25/af_x25.c
5412     +++ b/net/x25/af_x25.c
5413     @@ -1795,10 +1795,15 @@ void x25_kill_by_neigh(struct x25_neigh *nb)
5414    
5415     write_lock_bh(&x25_list_lock);
5416    
5417     - sk_for_each(s, &x25_list)
5418     - if (x25_sk(s)->neighbour == nb)
5419     + sk_for_each(s, &x25_list) {
5420     + if (x25_sk(s)->neighbour == nb) {
5421     + write_unlock_bh(&x25_list_lock);
5422     + lock_sock(s);
5423     x25_disconnect(s, ENETUNREACH, 0, 0);
5424     -
5425     + release_sock(s);
5426     + write_lock_bh(&x25_list_lock);
5427     + }
5428     + }
5429     write_unlock_bh(&x25_list_lock);
5430    
5431     /* Remove any related forwards */
5432     diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
5433     index b00ed36b9aacf..9179b47e8b61f 100644
5434     --- a/net/xfrm/xfrm_policy.c
5435     +++ b/net/xfrm/xfrm_policy.c
5436     @@ -754,14 +754,10 @@ static void xfrm_policy_requeue(struct xfrm_policy *old,
5437     spin_unlock_bh(&pq->hold_queue.lock);
5438     }
5439    
5440     -static bool xfrm_policy_mark_match(struct xfrm_policy *policy,
5441     - struct xfrm_policy *pol)
5442     +static inline bool xfrm_policy_mark_match(const struct xfrm_mark *mark,
5443     + struct xfrm_policy *pol)
5444     {
5445     - if (policy->mark.v == pol->mark.v &&
5446     - policy->priority == pol->priority)
5447     - return true;
5448     -
5449     - return false;
5450     + return mark->v == pol->mark.v && mark->m == pol->mark.m;
5451     }
5452    
5453     int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
5454     @@ -779,7 +775,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
5455     hlist_for_each_entry(pol, chain, bydst) {
5456     if (pol->type == policy->type &&
5457     !selector_cmp(&pol->selector, &policy->selector) &&
5458     - xfrm_policy_mark_match(policy, pol) &&
5459     + xfrm_policy_mark_match(&policy->mark, pol) &&
5460     xfrm_sec_ctx_match(pol->security, policy->security) &&
5461     !WARN_ON(delpol)) {
5462     if (excl) {
5463     @@ -830,8 +826,8 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
5464     }
5465     EXPORT_SYMBOL(xfrm_policy_insert);
5466    
5467     -struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u8 type,
5468     - int dir, struct xfrm_selector *sel,
5469     +struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, const struct xfrm_mark *mark,
5470     + u8 type, int dir, struct xfrm_selector *sel,
5471     struct xfrm_sec_ctx *ctx, int delete,
5472     int *err)
5473     {
5474     @@ -844,7 +840,7 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u8 type,
5475     ret = NULL;
5476     hlist_for_each_entry(pol, chain, bydst) {
5477     if (pol->type == type &&
5478     - (mark & pol->mark.m) == pol->mark.v &&
5479     + xfrm_policy_mark_match(mark, pol) &&
5480     !selector_cmp(sel, &pol->selector) &&
5481     xfrm_sec_ctx_match(ctx, pol->security)) {
5482     xfrm_pol_hold(pol);
5483     @@ -869,8 +865,8 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, u8 type,
5484     }
5485     EXPORT_SYMBOL(xfrm_policy_bysel_ctx);
5486    
5487     -struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8 type,
5488     - int dir, u32 id, int delete, int *err)
5489     +struct xfrm_policy *xfrm_policy_byid(struct net *net, const struct xfrm_mark *mark,
5490     + u8 type, int dir, u32 id, int delete, int *err)
5491     {
5492     struct xfrm_policy *pol, *ret;
5493     struct hlist_head *chain;
5494     @@ -885,7 +881,7 @@ struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8 type,
5495     ret = NULL;
5496     hlist_for_each_entry(pol, chain, byidx) {
5497     if (pol->type == type && pol->index == id &&
5498     - (mark & pol->mark.m) == pol->mark.v) {
5499     + xfrm_policy_mark_match(mark, pol)) {
5500     xfrm_pol_hold(pol);
5501     if (delete) {
5502     *err = security_xfrm_policy_delete(
5503     diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
5504     index 48139e1a0ac91..eaed745221977 100644
5505     --- a/net/xfrm/xfrm_user.c
5506     +++ b/net/xfrm/xfrm_user.c
5507     @@ -1777,7 +1777,6 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
5508     struct km_event c;
5509     int delete;
5510     struct xfrm_mark m;
5511     - u32 mark = xfrm_mark_get(attrs, &m);
5512    
5513     p = nlmsg_data(nlh);
5514     delete = nlh->nlmsg_type == XFRM_MSG_DELPOLICY;
5515     @@ -1790,8 +1789,10 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
5516     if (err)
5517     return err;
5518    
5519     + xfrm_mark_get(attrs, &m);
5520     +
5521     if (p->index)
5522     - xp = xfrm_policy_byid(net, mark, type, p->dir, p->index, delete, &err);
5523     + xp = xfrm_policy_byid(net, &m, type, p->dir, p->index, delete, &err);
5524     else {
5525     struct nlattr *rt = attrs[XFRMA_SEC_CTX];
5526     struct xfrm_sec_ctx *ctx;
5527     @@ -1808,7 +1809,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
5528     if (err)
5529     return err;
5530     }
5531     - xp = xfrm_policy_bysel_ctx(net, mark, type, p->dir, &p->sel,
5532     + xp = xfrm_policy_bysel_ctx(net, &m, type, p->dir, &p->sel,
5533     ctx, delete, &err);
5534     security_xfrm_policy_free(ctx);
5535     }
5536     @@ -2072,7 +2073,6 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
5537     u8 type = XFRM_POLICY_TYPE_MAIN;
5538     int err = -ENOENT;
5539     struct xfrm_mark m;
5540     - u32 mark = xfrm_mark_get(attrs, &m);
5541    
5542     err = copy_from_user_policy_type(&type, attrs);
5543     if (err)
5544     @@ -2082,8 +2082,10 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
5545     if (err)
5546     return err;
5547    
5548     + xfrm_mark_get(attrs, &m);
5549     +
5550     if (p->index)
5551     - xp = xfrm_policy_byid(net, mark, type, p->dir, p->index, 0, &err);
5552     + xp = xfrm_policy_byid(net, &m, type, p->dir, p->index, 0, &err);
5553     else {
5554     struct nlattr *rt = attrs[XFRMA_SEC_CTX];
5555     struct xfrm_sec_ctx *ctx;
5556     @@ -2100,7 +2102,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
5557     if (err)
5558     return err;
5559     }
5560     - xp = xfrm_policy_bysel_ctx(net, mark, type, p->dir,
5561     + xp = xfrm_policy_bysel_ctx(net, &m, type, p->dir,
5562     &p->sel, ctx, 0, &err);
5563     security_xfrm_policy_free(ctx);
5564     }
5565     diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c
5566     index dff390f692a2c..4435263766ac9 100644
5567     --- a/scripts/gcc-plugins/latent_entropy_plugin.c
5568     +++ b/scripts/gcc-plugins/latent_entropy_plugin.c
5569     @@ -86,25 +86,31 @@ static struct plugin_info latent_entropy_plugin_info = {
5570     .help = "disable\tturn off latent entropy instrumentation\n",
5571     };
5572    
5573     -static unsigned HOST_WIDE_INT seed;
5574     -/*
5575     - * get_random_seed() (this is a GCC function) generates the seed.
5576     - * This is a simple random generator without any cryptographic security because
5577     - * the entropy doesn't come from here.
5578     - */
5579     +static unsigned HOST_WIDE_INT deterministic_seed;
5580     +static unsigned HOST_WIDE_INT rnd_buf[32];
5581     +static size_t rnd_idx = ARRAY_SIZE(rnd_buf);
5582     +static int urandom_fd = -1;
5583     +
5584     static unsigned HOST_WIDE_INT get_random_const(void)
5585     {
5586     - unsigned int i;
5587     - unsigned HOST_WIDE_INT ret = 0;
5588     -
5589     - for (i = 0; i < 8 * sizeof(ret); i++) {
5590     - ret = (ret << 1) | (seed & 1);
5591     - seed >>= 1;
5592     - if (ret & 1)
5593     - seed ^= 0xD800000000000000ULL;
5594     + if (deterministic_seed) {
5595     + unsigned HOST_WIDE_INT w = deterministic_seed;
5596     + w ^= w << 13;
5597     + w ^= w >> 7;
5598     + w ^= w << 17;
5599     + deterministic_seed = w;
5600     + return deterministic_seed;
5601     }
5602    
5603     - return ret;
5604     + if (urandom_fd < 0) {
5605     + urandom_fd = open("/dev/urandom", O_RDONLY);
5606     + gcc_assert(urandom_fd >= 0);
5607     + }
5608     + if (rnd_idx >= ARRAY_SIZE(rnd_buf)) {
5609     + gcc_assert(read(urandom_fd, rnd_buf, sizeof(rnd_buf)) == sizeof(rnd_buf));
5610     + rnd_idx = 0;
5611     + }
5612     + return rnd_buf[rnd_idx++];
5613     }
5614    
5615     static tree tree_get_random_const(tree type)
5616     @@ -556,8 +562,6 @@ static void latent_entropy_start_unit(void *gcc_data __unused,
5617     tree type, id;
5618     int quals;
5619    
5620     - seed = get_random_seed(false);
5621     -
5622     if (in_lto_p)
5623     return;
5624    
5625     @@ -594,6 +598,12 @@ __visible int plugin_init(struct plugin_name_args *plugin_info,
5626    
5627     struct register_pass_info latent_entropy_pass_info;
5628    
5629     + /*
5630     + * Call get_random_seed() with noinit=true, so that this returns
5631     + * 0 in the case where no seed has been passed via -frandom-seed.
5632     + */
5633     + deterministic_seed = get_random_seed(true);
5634     +
5635     latent_entropy_pass_info.pass = make_latent_entropy_pass();
5636     latent_entropy_pass_info.reference_pass_name = "optimized";
5637     latent_entropy_pass_info.ref_pass_instance_number = 1;
5638     diff --git a/security/selinux/xfrm.c b/security/selinux/xfrm.c
5639     index 56e354fcdfc66..5304dd49e054b 100644
5640     --- a/security/selinux/xfrm.c
5641     +++ b/security/selinux/xfrm.c
5642     @@ -344,7 +344,7 @@ int selinux_xfrm_state_alloc_acquire(struct xfrm_state *x,
5643     int rc;
5644     struct xfrm_sec_ctx *ctx;
5645     char *ctx_str = NULL;
5646     - int str_len;
5647     + u32 str_len;
5648    
5649     if (!polsec)
5650     return 0;
5651     diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
5652     index 589c1c2ae6db3..84ed47195cdd2 100644
5653     --- a/security/smack/smack_lsm.c
5654     +++ b/security/smack/smack_lsm.c
5655     @@ -2567,7 +2567,7 @@ static int smk_ipv6_check(struct smack_known *subject,
5656     #ifdef CONFIG_AUDIT
5657     smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
5658     ad.a.u.net->family = PF_INET6;
5659     - ad.a.u.net->dport = ntohs(address->sin6_port);
5660     + ad.a.u.net->dport = address->sin6_port;
5661     if (act == SMK_RECEIVING)
5662     ad.a.u.net->v6info.saddr = address->sin6_addr;
5663     else
5664     diff --git a/security/tomoyo/load_policy.c b/security/tomoyo/load_policy.c
5665     index 078fac0bb4c55..6766b92cb572e 100644
5666     --- a/security/tomoyo/load_policy.c
5667     +++ b/security/tomoyo/load_policy.c
5668     @@ -23,7 +23,7 @@ static const char *tomoyo_loader;
5669     static int __init tomoyo_loader_setup(char *str)
5670     {
5671     tomoyo_loader = str;
5672     - return 0;
5673     + return 1;
5674     }
5675    
5676     __setup("TOMOYO_loader=", tomoyo_loader_setup);
5677     @@ -62,7 +62,7 @@ static const char *tomoyo_trigger;
5678     static int __init tomoyo_trigger_setup(char *str)
5679     {
5680     tomoyo_trigger = str;
5681     - return 0;
5682     + return 1;
5683     }
5684    
5685     __setup("TOMOYO_trigger=", tomoyo_trigger_setup);
5686     diff --git a/sound/core/pcm_misc.c b/sound/core/pcm_misc.c
5687     index 53dc37357bca9..92519e0477c86 100644
5688     --- a/sound/core/pcm_misc.c
5689     +++ b/sound/core/pcm_misc.c
5690     @@ -412,7 +412,7 @@ int snd_pcm_format_set_silence(snd_pcm_format_t format, void *data, unsigned int
5691     return 0;
5692     width = pcm_formats[(INT)format].phys; /* physical width */
5693     pat = pcm_formats[(INT)format].silence;
5694     - if (! width)
5695     + if (!width || !pat)
5696     return -EINVAL;
5697     /* signed or 1 byte data */
5698     if (pcm_formats[(INT)format].signd == 1 || width <= 8) {
5699     diff --git a/sound/firewire/fcp.c b/sound/firewire/fcp.c
5700     index cce19768f43d0..8209856293d32 100644
5701     --- a/sound/firewire/fcp.c
5702     +++ b/sound/firewire/fcp.c
5703     @@ -234,9 +234,7 @@ int fcp_avc_transaction(struct fw_unit *unit,
5704     t.response_match_bytes = response_match_bytes;
5705     t.state = STATE_PENDING;
5706     init_waitqueue_head(&t.wait);
5707     -
5708     - if (*(const u8 *)command == 0x00 || *(const u8 *)command == 0x03)
5709     - t.deferrable = true;
5710     + t.deferrable = (*(const u8 *)command == 0x00 || *(const u8 *)command == 0x03);
5711    
5712     spin_lock_irq(&transactions_lock);
5713     list_add_tail(&t.list, &transactions);
5714     diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c
5715     index c67d379cb6d6a..9d4a2c66ea16b 100644
5716     --- a/sound/isa/cs423x/cs4236.c
5717     +++ b/sound/isa/cs423x/cs4236.c
5718     @@ -557,7 +557,7 @@ static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
5719     static int dev;
5720     int err;
5721     struct snd_card *card;
5722     - struct pnp_dev *cdev;
5723     + struct pnp_dev *cdev, *iter;
5724     char cid[PNP_ID_LEN];
5725    
5726     if (pnp_device_is_isapnp(pdev))
5727     @@ -573,9 +573,11 @@ static int snd_cs423x_pnpbios_detect(struct pnp_dev *pdev,
5728     strcpy(cid, pdev->id[0].id);
5729     cid[5] = '1';
5730     cdev = NULL;
5731     - list_for_each_entry(cdev, &(pdev->protocol->devices), protocol_list) {
5732     - if (!strcmp(cdev->id[0].id, cid))
5733     + list_for_each_entry(iter, &(pdev->protocol->devices), protocol_list) {
5734     + if (!strcmp(iter->id[0].id, cid)) {
5735     + cdev = iter;
5736     break;
5737     + }
5738     }
5739     err = snd_cs423x_card_new(&pdev->dev, dev, &card);
5740     if (err < 0)
5741     diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c
5742     index 16e459aedffe4..5958aafac8ebd 100644
5743     --- a/sound/soc/atmel/atmel_ssc_dai.c
5744     +++ b/sound/soc/atmel/atmel_ssc_dai.c
5745     @@ -296,7 +296,10 @@ static int atmel_ssc_startup(struct snd_pcm_substream *substream,
5746    
5747     /* Enable PMC peripheral clock for this SSC */
5748     pr_debug("atmel_ssc_dai: Starting clock\n");
5749     - clk_enable(ssc_p->ssc->clk);
5750     + ret = clk_enable(ssc_p->ssc->clk);
5751     + if (ret)
5752     + return ret;
5753     +
5754     ssc_p->mck_rate = clk_get_rate(ssc_p->ssc->clk);
5755    
5756     /* Reset the SSC unless initialized to keep it in a clean state */
5757     diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c
5758     index d7469cdd90dc8..39365319c3516 100644
5759     --- a/sound/soc/atmel/sam9g20_wm8731.c
5760     +++ b/sound/soc/atmel/sam9g20_wm8731.c
5761     @@ -226,6 +226,7 @@ static int at91sam9g20ek_audio_probe(struct platform_device *pdev)
5762     cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
5763     if (!cpu_np) {
5764     dev_err(&pdev->dev, "dai and pcm info missing\n");
5765     + of_node_put(codec_np);
5766     return -EINVAL;
5767     }
5768     at91sam9g20ek_dai.cpu_of_node = cpu_np;
5769     diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c
5770     index 2efc5b41ad0fe..6d719392cdbee 100644
5771     --- a/sound/soc/codecs/wm8350.c
5772     +++ b/sound/soc/codecs/wm8350.c
5773     @@ -1536,18 +1536,38 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
5774     wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
5775     WM8350_JDL_ENA | WM8350_JDR_ENA);
5776    
5777     - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L,
5778     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L,
5779     wm8350_hpl_jack_handler, 0, "Left jack detect",
5780     priv);
5781     - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R,
5782     + if (ret != 0)
5783     + goto err;
5784     +
5785     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R,
5786     wm8350_hpr_jack_handler, 0, "Right jack detect",
5787     priv);
5788     - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD,
5789     + if (ret != 0)
5790     + goto free_jck_det_l;
5791     +
5792     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICSCD,
5793     wm8350_mic_handler, 0, "Microphone short", priv);
5794     - wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD,
5795     + if (ret != 0)
5796     + goto free_jck_det_r;
5797     +
5798     + ret = wm8350_register_irq(wm8350, WM8350_IRQ_CODEC_MICD,
5799     wm8350_mic_handler, 0, "Microphone detect", priv);
5800     + if (ret != 0)
5801     + goto free_micscd;
5802    
5803     return 0;
5804     +
5805     +free_micscd:
5806     + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_MICSCD, priv);
5807     +free_jck_det_r:
5808     + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_R, priv);
5809     +free_jck_det_l:
5810     + wm8350_free_irq(wm8350, WM8350_IRQ_CODEC_JCK_DET_L, priv);
5811     +err:
5812     + return ret;
5813     }
5814    
5815     static int wm8350_codec_remove(struct snd_soc_codec *codec)
5816     diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c
5817     index 3849616519048..e5f61f1499c62 100644
5818     --- a/sound/soc/davinci/davinci-i2s.c
5819     +++ b/sound/soc/davinci/davinci-i2s.c
5820     @@ -719,7 +719,9 @@ static int davinci_i2s_probe(struct platform_device *pdev)
5821     dev->clk = clk_get(&pdev->dev, NULL);
5822     if (IS_ERR(dev->clk))
5823     return -ENODEV;
5824     - clk_enable(dev->clk);
5825     + ret = clk_enable(dev->clk);
5826     + if (ret)
5827     + goto err_put_clk;
5828    
5829     dev->dev = &pdev->dev;
5830     dev_set_drvdata(&pdev->dev, dev);
5831     @@ -741,6 +743,7 @@ err_unregister_component:
5832     snd_soc_unregister_component(&pdev->dev);
5833     err_release_clk:
5834     clk_disable(dev->clk);
5835     +err_put_clk:
5836     clk_put(dev->clk);
5837     return ret;
5838     }
5839     diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
5840     index 20e7400e2611e..5942f99019382 100644
5841     --- a/sound/soc/fsl/imx-es8328.c
5842     +++ b/sound/soc/fsl/imx-es8328.c
5843     @@ -93,6 +93,7 @@ static int imx_es8328_probe(struct platform_device *pdev)
5844     if (int_port > MUX_PORT_MAX || int_port == 0) {
5845     dev_err(dev, "mux-int-port: hardware only has %d mux ports\n",
5846     MUX_PORT_MAX);
5847     + ret = -EINVAL;
5848     goto fail;
5849     }
5850    
5851     diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
5852     index 13631003cb7c6..5977a2011d9e6 100644
5853     --- a/sound/soc/mxs/mxs-saif.c
5854     +++ b/sound/soc/mxs/mxs-saif.c
5855     @@ -442,7 +442,10 @@ static int mxs_saif_hw_params(struct snd_pcm_substream *substream,
5856     * basic clock which should be fast enough for the internal
5857     * logic.
5858     */
5859     - clk_enable(saif->clk);
5860     + ret = clk_enable(saif->clk);
5861     + if (ret)
5862     + return ret;
5863     +
5864     ret = clk_set_rate(saif->clk, 24000000);
5865     clk_disable(saif->clk);
5866     if (ret)
5867     diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c
5868     index 2b23ffbac6b12..e8aa93a654e7e 100644
5869     --- a/sound/soc/mxs/mxs-sgtl5000.c
5870     +++ b/sound/soc/mxs/mxs-sgtl5000.c
5871     @@ -112,6 +112,9 @@ static int mxs_sgtl5000_probe(struct platform_device *pdev)
5872     codec_np = of_parse_phandle(np, "audio-codec", 0);
5873     if (!saif_np[0] || !saif_np[1] || !codec_np) {
5874     dev_err(&pdev->dev, "phandle missing or invalid\n");
5875     + of_node_put(codec_np);
5876     + of_node_put(saif_np[0]);
5877     + of_node_put(saif_np[1]);
5878     return -EINVAL;
5879     }
5880    
5881     diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
5882     index ead520182e268..29be452852746 100644
5883     --- a/sound/soc/sh/fsi.c
5884     +++ b/sound/soc/sh/fsi.c
5885     @@ -821,14 +821,27 @@ static int fsi_clk_enable(struct device *dev,
5886     return ret;
5887     }
5888    
5889     - clk_enable(clock->xck);
5890     - clk_enable(clock->ick);
5891     - clk_enable(clock->div);
5892     + ret = clk_enable(clock->xck);
5893     + if (ret)
5894     + goto err;
5895     + ret = clk_enable(clock->ick);
5896     + if (ret)
5897     + goto disable_xck;
5898     + ret = clk_enable(clock->div);
5899     + if (ret)
5900     + goto disable_ick;
5901    
5902     clock->count++;
5903     }
5904    
5905     return ret;
5906     +
5907     +disable_ick:
5908     + clk_disable(clock->ick);
5909     +disable_xck:
5910     + clk_disable(clock->xck);
5911     +err:
5912     + return ret;
5913     }
5914    
5915     static int fsi_clk_disable(struct device *dev,
5916     diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
5917     index 0344d44231675..81c3aa1670382 100644
5918     --- a/sound/soc/soc-core.c
5919     +++ b/sound/soc/soc-core.c
5920     @@ -3799,7 +3799,7 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args,
5921     if (!component_of_node && pos->dev->parent)
5922     component_of_node = pos->dev->parent->of_node;
5923    
5924     - if (component_of_node != args->np)
5925     + if (component_of_node != args->np || !pos->num_dai)
5926     continue;
5927    
5928     if (pos->driver->of_xlate_dai_name) {
5929     diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c
5930     index 67d22b4baeb05..61f0c9d6f6dce 100644
5931     --- a/sound/soc/soc-generic-dmaengine-pcm.c
5932     +++ b/sound/soc/soc-generic-dmaengine-pcm.c
5933     @@ -98,10 +98,10 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream,
5934    
5935     memset(&slave_config, 0, sizeof(slave_config));
5936    
5937     - if (!pcm->config)
5938     - prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
5939     - else
5940     + if (pcm->config && pcm->config->prepare_slave_config)
5941     prepare_slave_config = pcm->config->prepare_slave_config;
5942     + else
5943     + prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config;
5944    
5945     if (prepare_slave_config) {
5946     ret = prepare_slave_config(substream, params, &slave_config);
5947     diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
5948     index 6274a50026473..7528f0d4bddff 100644
5949     --- a/sound/soc/soc-topology.c
5950     +++ b/sound/soc/soc-topology.c
5951     @@ -507,7 +507,8 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr,
5952    
5953     if (hdr->ops.info == SND_SOC_TPLG_CTL_BYTES
5954     && k->iface & SNDRV_CTL_ELEM_IFACE_MIXER
5955     - && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE
5956     + && (k->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ
5957     + || k->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE)
5958     && k->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
5959     struct soc_bytes_ext *sbe;
5960     struct snd_soc_tplg_bytes_control *be;
5961     diff --git a/sound/spi/at73c213.c b/sound/spi/at73c213.c
5962     index fac7e6eb9529c..671b4516d9303 100644
5963     --- a/sound/spi/at73c213.c
5964     +++ b/sound/spi/at73c213.c
5965     @@ -221,7 +221,9 @@ static int snd_at73c213_pcm_open(struct snd_pcm_substream *substream)
5966     runtime->hw = snd_at73c213_playback_hw;
5967     chip->substream = substream;
5968    
5969     - clk_enable(chip->ssc->clk);
5970     + err = clk_enable(chip->ssc->clk);
5971     + if (err)
5972     + return err;
5973    
5974     return 0;
5975     }
5976     @@ -787,7 +789,9 @@ static int snd_at73c213_chip_init(struct snd_at73c213 *chip)
5977     goto out;
5978    
5979     /* Enable DAC master clock. */
5980     - clk_enable(chip->board->dac_clk);
5981     + retval = clk_enable(chip->board->dac_clk);
5982     + if (retval)
5983     + goto out;
5984    
5985     /* Initialize at73c213 on SPI bus. */
5986     retval = snd_at73c213_write_reg(chip, DAC_RST, 0x04);
5987     @@ -900,7 +904,9 @@ static int snd_at73c213_dev_init(struct snd_card *card,
5988     chip->card = card;
5989     chip->irq = -1;
5990    
5991     - clk_enable(chip->ssc->clk);
5992     + retval = clk_enable(chip->ssc->clk);
5993     + if (retval)
5994     + return retval;
5995    
5996     retval = request_irq(irq, snd_at73c213_interrupt, 0, "at73c213", chip);
5997     if (retval) {
5998     @@ -1019,7 +1025,9 @@ static int snd_at73c213_remove(struct spi_device *spi)
5999     int retval;
6000    
6001     /* Stop playback. */
6002     - clk_enable(chip->ssc->clk);
6003     + retval = clk_enable(chip->ssc->clk);
6004     + if (retval)
6005     + goto out;
6006     ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXDIS));
6007     clk_disable(chip->ssc->clk);
6008    
6009     @@ -1099,9 +1107,16 @@ static int snd_at73c213_resume(struct device *dev)
6010     {
6011     struct snd_card *card = dev_get_drvdata(dev);
6012     struct snd_at73c213 *chip = card->private_data;
6013     + int retval;
6014    
6015     - clk_enable(chip->board->dac_clk);
6016     - clk_enable(chip->ssc->clk);
6017     + retval = clk_enable(chip->board->dac_clk);
6018     + if (retval)
6019     + return retval;
6020     + retval = clk_enable(chip->ssc->clk);
6021     + if (retval) {
6022     + clk_disable(chip->board->dac_clk);
6023     + return retval;
6024     + }
6025     ssc_writel(chip->ssc->regs, CR, SSC_BIT(CR_TXEN));
6026    
6027     return 0;
6028     diff --git a/tools/build/feature/Makefile b/tools/build/feature/Makefile
6029     index ac9c477a2a485..46af3bb561422 100644
6030     --- a/tools/build/feature/Makefile
6031     +++ b/tools/build/feature/Makefile
6032     @@ -162,7 +162,7 @@ strip-libs = $(filter-out -l%,$(1))
6033     PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
6034     PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
6035     PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
6036     -PERL_EMBED_CCOPTS = `perl -MExtUtils::Embed -e ccopts 2>/dev/null`
6037     +PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
6038     FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
6039    
6040     $(OUTPUT)test-libperl.bin:
6041     diff --git a/tools/testing/selftests/x86/check_cc.sh b/tools/testing/selftests/x86/check_cc.sh
6042     index 172d3293fb7be..356689c563975 100755
6043     --- a/tools/testing/selftests/x86/check_cc.sh
6044     +++ b/tools/testing/selftests/x86/check_cc.sh
6045     @@ -7,7 +7,7 @@ CC="$1"
6046     TESTPROG="$2"
6047     shift 2
6048    
6049     -if "$CC" -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then
6050     +if [ -n "$CC" ] && $CC -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then
6051     echo 1
6052     else
6053     echo 0
6054     diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
6055     index d9b7001227e3c..d251b718bf53f 100644
6056     --- a/virt/kvm/kvm_main.c
6057     +++ b/virt/kvm/kvm_main.c
6058     @@ -107,6 +107,8 @@ EXPORT_SYMBOL_GPL(kvm_debugfs_dir);
6059     static int kvm_debugfs_num_entries;
6060     static const struct file_operations *stat_fops_per_vm[];
6061    
6062     +static struct file_operations kvm_chardev_ops;
6063     +
6064     static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
6065     unsigned long arg);
6066     #ifdef CONFIG_KVM_COMPAT
6067     @@ -714,6 +716,16 @@ static struct kvm *kvm_create_vm(unsigned long type)
6068    
6069     preempt_notifier_inc();
6070    
6071     + /*
6072     + * When the fd passed to this ioctl() is opened it pins the module,
6073     + * but try_module_get() also prevents getting a reference if the module
6074     + * is in MODULE_STATE_GOING (e.g. if someone ran "rmmod --wait").
6075     + */
6076     + if (!try_module_get(kvm_chardev_ops.owner)) {
6077     + r = -ENODEV;
6078     + goto out_err;
6079     + }
6080     +
6081     return kvm;
6082    
6083     out_err:
6084     @@ -798,6 +810,7 @@ static void kvm_destroy_vm(struct kvm *kvm)
6085     preempt_notifier_dec();
6086     hardware_disable_all();
6087     mmdrop(mm);
6088     + module_put(kvm_chardev_ops.owner);
6089     }
6090    
6091     void kvm_get_kvm(struct kvm *kvm)