Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.9/0236-4.9.137-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3315 - (hide annotations) (download)
Tue Mar 12 10:44:32 2019 UTC (5 years, 3 months ago) by niro
File size: 131762 byte(s)
-linux-4.9.137
1 niro 3315 diff --git a/Makefile b/Makefile
2     index 79b8f3a44f74..41fe3014b712 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 9
8     -SUBLEVEL = 136
9     +SUBLEVEL = 137
10     EXTRAVERSION =
11     NAME = Roaring Lionus
12    
13     diff --git a/arch/arm/boot/dts/exynos3250.dtsi b/arch/arm/boot/dts/exynos3250.dtsi
14     index e9d2556c0dfd..2a531beef4c7 100644
15     --- a/arch/arm/boot/dts/exynos3250.dtsi
16     +++ b/arch/arm/boot/dts/exynos3250.dtsi
17     @@ -80,6 +80,22 @@
18     compatible = "arm,cortex-a7";
19     reg = <1>;
20     clock-frequency = <1000000000>;
21     + clocks = <&cmu CLK_ARM_CLK>;
22     + clock-names = "cpu";
23     + #cooling-cells = <2>;
24     +
25     + operating-points = <
26     + 1000000 1150000
27     + 900000 1112500
28     + 800000 1075000
29     + 700000 1037500
30     + 600000 1000000
31     + 500000 962500
32     + 400000 925000
33     + 300000 887500
34     + 200000 850000
35     + 100000 850000
36     + >;
37     };
38     };
39    
40     diff --git a/arch/arm/boot/dts/exynos4210.dtsi b/arch/arm/boot/dts/exynos4210.dtsi
41     index 2d9b02967105..b0c550e56fdb 100644
42     --- a/arch/arm/boot/dts/exynos4210.dtsi
43     +++ b/arch/arm/boot/dts/exynos4210.dtsi
44     @@ -52,8 +52,6 @@
45     400000 975000
46     200000 950000
47     >;
48     - cooling-min-level = <4>;
49     - cooling-max-level = <2>;
50     #cooling-cells = <2>; /* min followed by max */
51     };
52    
53     @@ -61,6 +59,19 @@
54     device_type = "cpu";
55     compatible = "arm,cortex-a9";
56     reg = <0x901>;
57     + clocks = <&clock CLK_ARM_CLK>;
58     + clock-names = "cpu";
59     + clock-latency = <160000>;
60     +
61     + operating-points = <
62     + 1200000 1250000
63     + 1000000 1150000
64     + 800000 1075000
65     + 500000 975000
66     + 400000 975000
67     + 200000 950000
68     + >;
69     + #cooling-cells = <2>; /* min followed by max */
70     };
71     };
72    
73     diff --git a/arch/arm/boot/dts/exynos4412.dtsi b/arch/arm/boot/dts/exynos4412.dtsi
74     index 3ebdf01d814c..63b1c5a2cecf 100644
75     --- a/arch/arm/boot/dts/exynos4412.dtsi
76     +++ b/arch/arm/boot/dts/exynos4412.dtsi
77     @@ -33,8 +33,6 @@
78     clocks = <&clock CLK_ARM_CLK>;
79     clock-names = "cpu";
80     operating-points-v2 = <&cpu0_opp_table>;
81     - cooling-min-level = <13>;
82     - cooling-max-level = <7>;
83     #cooling-cells = <2>; /* min followed by max */
84     };
85    
86     diff --git a/arch/arm/boot/dts/exynos5250.dtsi b/arch/arm/boot/dts/exynos5250.dtsi
87     index 64de33d067c9..ecc73f26eac5 100644
88     --- a/arch/arm/boot/dts/exynos5250.dtsi
89     +++ b/arch/arm/boot/dts/exynos5250.dtsi
90     @@ -57,38 +57,106 @@
91     device_type = "cpu";
92     compatible = "arm,cortex-a15";
93     reg = <0>;
94     - clock-frequency = <1700000000>;
95     clocks = <&clock CLK_ARM_CLK>;
96     clock-names = "cpu";
97     - clock-latency = <140000>;
98     -
99     - operating-points = <
100     - 1700000 1300000
101     - 1600000 1250000
102     - 1500000 1225000
103     - 1400000 1200000
104     - 1300000 1150000
105     - 1200000 1125000
106     - 1100000 1100000
107     - 1000000 1075000
108     - 900000 1050000
109     - 800000 1025000
110     - 700000 1012500
111     - 600000 1000000
112     - 500000 975000
113     - 400000 950000
114     - 300000 937500
115     - 200000 925000
116     - >;
117     - cooling-min-level = <15>;
118     - cooling-max-level = <9>;
119     + operating-points-v2 = <&cpu0_opp_table>;
120     #cooling-cells = <2>; /* min followed by max */
121     };
122     cpu@1 {
123     device_type = "cpu";
124     compatible = "arm,cortex-a15";
125     reg = <1>;
126     - clock-frequency = <1700000000>;
127     + clocks = <&clock CLK_ARM_CLK>;
128     + clock-names = "cpu";
129     + operating-points-v2 = <&cpu0_opp_table>;
130     + #cooling-cells = <2>; /* min followed by max */
131     + };
132     + };
133     +
134     + cpu0_opp_table: opp_table0 {
135     + compatible = "operating-points-v2";
136     + opp-shared;
137     +
138     + opp-200000000 {
139     + opp-hz = /bits/ 64 <200000000>;
140     + opp-microvolt = <925000>;
141     + clock-latency-ns = <140000>;
142     + };
143     + opp-300000000 {
144     + opp-hz = /bits/ 64 <300000000>;
145     + opp-microvolt = <937500>;
146     + clock-latency-ns = <140000>;
147     + };
148     + opp-400000000 {
149     + opp-hz = /bits/ 64 <400000000>;
150     + opp-microvolt = <950000>;
151     + clock-latency-ns = <140000>;
152     + };
153     + opp-500000000 {
154     + opp-hz = /bits/ 64 <500000000>;
155     + opp-microvolt = <975000>;
156     + clock-latency-ns = <140000>;
157     + };
158     + opp-600000000 {
159     + opp-hz = /bits/ 64 <600000000>;
160     + opp-microvolt = <1000000>;
161     + clock-latency-ns = <140000>;
162     + };
163     + opp-700000000 {
164     + opp-hz = /bits/ 64 <700000000>;
165     + opp-microvolt = <1012500>;
166     + clock-latency-ns = <140000>;
167     + };
168     + opp-800000000 {
169     + opp-hz = /bits/ 64 <800000000>;
170     + opp-microvolt = <1025000>;
171     + clock-latency-ns = <140000>;
172     + };
173     + opp-900000000 {
174     + opp-hz = /bits/ 64 <900000000>;
175     + opp-microvolt = <1050000>;
176     + clock-latency-ns = <140000>;
177     + };
178     + opp-1000000000 {
179     + opp-hz = /bits/ 64 <1000000000>;
180     + opp-microvolt = <1075000>;
181     + clock-latency-ns = <140000>;
182     + opp-suspend;
183     + };
184     + opp-1100000000 {
185     + opp-hz = /bits/ 64 <1100000000>;
186     + opp-microvolt = <1100000>;
187     + clock-latency-ns = <140000>;
188     + };
189     + opp-1200000000 {
190     + opp-hz = /bits/ 64 <1200000000>;
191     + opp-microvolt = <1125000>;
192     + clock-latency-ns = <140000>;
193     + };
194     + opp-1300000000 {
195     + opp-hz = /bits/ 64 <1300000000>;
196     + opp-microvolt = <1150000>;
197     + clock-latency-ns = <140000>;
198     + };
199     + opp-1400000000 {
200     + opp-hz = /bits/ 64 <1400000000>;
201     + opp-microvolt = <1200000>;
202     + clock-latency-ns = <140000>;
203     + };
204     + opp-1500000000 {
205     + opp-hz = /bits/ 64 <1500000000>;
206     + opp-microvolt = <1225000>;
207     + clock-latency-ns = <140000>;
208     + };
209     + opp-1600000000 {
210     + opp-hz = /bits/ 64 <1600000000>;
211     + opp-microvolt = <1250000>;
212     + clock-latency-ns = <140000>;
213     + };
214     + opp-1700000000 {
215     + opp-hz = /bits/ 64 <1700000000>;
216     + opp-microvolt = <1300000>;
217     + clock-latency-ns = <140000>;
218     };
219     };
220    
221     diff --git a/arch/arm/boot/dts/exynos5420-cpus.dtsi b/arch/arm/boot/dts/exynos5420-cpus.dtsi
222     index 5c052d7ff554..7e6b55561b1d 100644
223     --- a/arch/arm/boot/dts/exynos5420-cpus.dtsi
224     +++ b/arch/arm/boot/dts/exynos5420-cpus.dtsi
225     @@ -33,8 +33,6 @@
226     clock-frequency = <1800000000>;
227     cci-control-port = <&cci_control1>;
228     operating-points-v2 = <&cluster_a15_opp_table>;
229     - cooling-min-level = <0>;
230     - cooling-max-level = <11>;
231     #cooling-cells = <2>; /* min followed by max */
232     };
233    
234     @@ -45,8 +43,6 @@
235     clock-frequency = <1800000000>;
236     cci-control-port = <&cci_control1>;
237     operating-points-v2 = <&cluster_a15_opp_table>;
238     - cooling-min-level = <0>;
239     - cooling-max-level = <11>;
240     #cooling-cells = <2>; /* min followed by max */
241     };
242    
243     @@ -57,8 +53,6 @@
244     clock-frequency = <1800000000>;
245     cci-control-port = <&cci_control1>;
246     operating-points-v2 = <&cluster_a15_opp_table>;
247     - cooling-min-level = <0>;
248     - cooling-max-level = <11>;
249     #cooling-cells = <2>; /* min followed by max */
250     };
251    
252     @@ -69,8 +63,6 @@
253     clock-frequency = <1800000000>;
254     cci-control-port = <&cci_control1>;
255     operating-points-v2 = <&cluster_a15_opp_table>;
256     - cooling-min-level = <0>;
257     - cooling-max-level = <11>;
258     #cooling-cells = <2>; /* min followed by max */
259     };
260    
261     @@ -82,8 +74,6 @@
262     clock-frequency = <1000000000>;
263     cci-control-port = <&cci_control0>;
264     operating-points-v2 = <&cluster_a7_opp_table>;
265     - cooling-min-level = <0>;
266     - cooling-max-level = <7>;
267     #cooling-cells = <2>; /* min followed by max */
268     };
269    
270     @@ -94,8 +84,6 @@
271     clock-frequency = <1000000000>;
272     cci-control-port = <&cci_control0>;
273     operating-points-v2 = <&cluster_a7_opp_table>;
274     - cooling-min-level = <0>;
275     - cooling-max-level = <7>;
276     #cooling-cells = <2>; /* min followed by max */
277     };
278    
279     @@ -106,8 +94,6 @@
280     clock-frequency = <1000000000>;
281     cci-control-port = <&cci_control0>;
282     operating-points-v2 = <&cluster_a7_opp_table>;
283     - cooling-min-level = <0>;
284     - cooling-max-level = <7>;
285     #cooling-cells = <2>; /* min followed by max */
286     };
287    
288     @@ -118,8 +104,6 @@
289     clock-frequency = <1000000000>;
290     cci-control-port = <&cci_control0>;
291     operating-points-v2 = <&cluster_a7_opp_table>;
292     - cooling-min-level = <0>;
293     - cooling-max-level = <7>;
294     #cooling-cells = <2>; /* min followed by max */
295     };
296     };
297     diff --git a/arch/arm/boot/dts/exynos5422-cpus.dtsi b/arch/arm/boot/dts/exynos5422-cpus.dtsi
298     index bf3c6f1ec4ee..c8afdf821a77 100644
299     --- a/arch/arm/boot/dts/exynos5422-cpus.dtsi
300     +++ b/arch/arm/boot/dts/exynos5422-cpus.dtsi
301     @@ -32,8 +32,6 @@
302     clock-frequency = <1000000000>;
303     cci-control-port = <&cci_control0>;
304     operating-points-v2 = <&cluster_a7_opp_table>;
305     - cooling-min-level = <0>;
306     - cooling-max-level = <11>;
307     #cooling-cells = <2>; /* min followed by max */
308     };
309    
310     @@ -44,8 +42,6 @@
311     clock-frequency = <1000000000>;
312     cci-control-port = <&cci_control0>;
313     operating-points-v2 = <&cluster_a7_opp_table>;
314     - cooling-min-level = <0>;
315     - cooling-max-level = <11>;
316     #cooling-cells = <2>; /* min followed by max */
317     };
318    
319     @@ -56,8 +52,6 @@
320     clock-frequency = <1000000000>;
321     cci-control-port = <&cci_control0>;
322     operating-points-v2 = <&cluster_a7_opp_table>;
323     - cooling-min-level = <0>;
324     - cooling-max-level = <11>;
325     #cooling-cells = <2>; /* min followed by max */
326     };
327    
328     @@ -68,8 +62,6 @@
329     clock-frequency = <1000000000>;
330     cci-control-port = <&cci_control0>;
331     operating-points-v2 = <&cluster_a7_opp_table>;
332     - cooling-min-level = <0>;
333     - cooling-max-level = <11>;
334     #cooling-cells = <2>; /* min followed by max */
335     };
336    
337     @@ -81,8 +73,6 @@
338     clock-frequency = <1800000000>;
339     cci-control-port = <&cci_control1>;
340     operating-points-v2 = <&cluster_a15_opp_table>;
341     - cooling-min-level = <0>;
342     - cooling-max-level = <15>;
343     #cooling-cells = <2>; /* min followed by max */
344     };
345    
346     @@ -93,8 +83,6 @@
347     clock-frequency = <1800000000>;
348     cci-control-port = <&cci_control1>;
349     operating-points-v2 = <&cluster_a15_opp_table>;
350     - cooling-min-level = <0>;
351     - cooling-max-level = <15>;
352     #cooling-cells = <2>; /* min followed by max */
353     };
354    
355     @@ -105,8 +93,6 @@
356     clock-frequency = <1800000000>;
357     cci-control-port = <&cci_control1>;
358     operating-points-v2 = <&cluster_a15_opp_table>;
359     - cooling-min-level = <0>;
360     - cooling-max-level = <15>;
361     #cooling-cells = <2>; /* min followed by max */
362     };
363    
364     @@ -117,8 +103,6 @@
365     clock-frequency = <1800000000>;
366     cci-control-port = <&cci_control1>;
367     operating-points-v2 = <&cluster_a15_opp_table>;
368     - cooling-min-level = <0>;
369     - cooling-max-level = <15>;
370     #cooling-cells = <2>; /* min followed by max */
371     };
372     };
373     diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
374     index c2b9bcb0ef61..e79f3defe002 100644
375     --- a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
376     +++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
377     @@ -249,7 +249,7 @@
378    
379     sysmgr: sysmgr@ffd12000 {
380     compatible = "altr,sys-mgr", "syscon";
381     - reg = <0xffd12000 0x1000>;
382     + reg = <0xffd12000 0x228>;
383     };
384    
385     /* Local timer */
386     diff --git a/arch/arm64/lib/Makefile b/arch/arm64/lib/Makefile
387     index c86b7909ef31..2f7c60c8e588 100644
388     --- a/arch/arm64/lib/Makefile
389     +++ b/arch/arm64/lib/Makefile
390     @@ -11,7 +11,7 @@ lib-y := bitops.o clear_user.o delay.o copy_from_user.o \
391     # when supported by the CPU. Result and argument registers are handled
392     # correctly, based on the function prototype.
393     lib-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o
394     -CFLAGS_atomic_ll_sc.o := -fcall-used-x0 -ffixed-x1 -ffixed-x2 \
395     +CFLAGS_atomic_ll_sc.o := -ffixed-x1 -ffixed-x2 \
396     -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 \
397     -ffixed-x7 -fcall-saved-x8 -fcall-saved-x9 \
398     -fcall-saved-x10 -fcall-saved-x11 -fcall-saved-x12 \
399     diff --git a/arch/mips/cavium-octeon/executive/cvmx-helper.c b/arch/mips/cavium-octeon/executive/cvmx-helper.c
400     index 6456af642471..396236a02b8c 100644
401     --- a/arch/mips/cavium-octeon/executive/cvmx-helper.c
402     +++ b/arch/mips/cavium-octeon/executive/cvmx-helper.c
403     @@ -67,7 +67,7 @@ void (*cvmx_override_pko_queue_priority) (int pko_port,
404     void (*cvmx_override_ipd_port_setup) (int ipd_port);
405    
406     /* Port count per interface */
407     -static int interface_port_count[5];
408     +static int interface_port_count[9];
409    
410     /* Port last configured link info index by IPD/PKO port */
411     static cvmx_helper_link_info_t
412     diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
413     index 015614405755..63b140bde2a3 100644
414     --- a/arch/parisc/kernel/entry.S
415     +++ b/arch/parisc/kernel/entry.S
416     @@ -185,7 +185,7 @@
417     bv,n 0(%r3)
418     nop
419     .word 0 /* checksum (will be patched) */
420     - .word PA(os_hpmc) /* address of handler */
421     + .word 0 /* address of handler */
422     .word 0 /* length of handler */
423     .endm
424    
425     diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
426     index 378df9207406..11c91697d5f9 100644
427     --- a/arch/parisc/kernel/traps.c
428     +++ b/arch/parisc/kernel/traps.c
429     @@ -826,7 +826,8 @@ void __init initialize_ivt(const void *iva)
430     for (i = 0; i < 8; i++)
431     *ivap++ = 0;
432    
433     - /* Compute Checksum for HPMC handler */
434     + /* Setup IVA and compute checksum for HPMC handler */
435     + ivap[6] = (u32)__pa(os_hpmc);
436     length = os_hpmc_size;
437     ivap[7] = length;
438    
439     diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
440     index e02ada312be8..b9db8e529e4d 100644
441     --- a/arch/parisc/mm/init.c
442     +++ b/arch/parisc/mm/init.c
443     @@ -491,12 +491,8 @@ static void __init map_pages(unsigned long start_vaddr,
444     pte = pte_mkhuge(pte);
445     }
446    
447     - if (address >= end_paddr) {
448     - if (force)
449     - break;
450     - else
451     - pte_val(pte) = 0;
452     - }
453     + if (address >= end_paddr)
454     + break;
455    
456     set_pte(pg_table, pte);
457    
458     diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
459     index 98697611e7b3..705f4dc5073b 100644
460     --- a/arch/powerpc/include/asm/mpic.h
461     +++ b/arch/powerpc/include/asm/mpic.h
462     @@ -392,7 +392,14 @@ extern struct bus_type mpic_subsys;
463     #define MPIC_REGSET_TSI108 MPIC_REGSET(1) /* Tsi108/109 PIC */
464    
465     /* Get the version of primary MPIC */
466     +#ifdef CONFIG_MPIC
467     extern u32 fsl_mpic_primary_get_version(void);
468     +#else
469     +static inline u32 fsl_mpic_primary_get_version(void)
470     +{
471     + return 0;
472     +}
473     +#endif
474    
475     /* Allocate the controller structure and setup the linux irq descs
476     * for the range if interrupts passed in. No HW initialization is
477     diff --git a/arch/s390/kvm/sthyi.c b/arch/s390/kvm/sthyi.c
478     index 2f04ad1ea01c..029fd5e707b4 100644
479     --- a/arch/s390/kvm/sthyi.c
480     +++ b/arch/s390/kvm/sthyi.c
481     @@ -174,17 +174,19 @@ static void fill_hdr(struct sthyi_sctns *sctns)
482     static void fill_stsi_mac(struct sthyi_sctns *sctns,
483     struct sysinfo_1_1_1 *sysinfo)
484     {
485     + sclp_ocf_cpc_name_copy(sctns->mac.infmname);
486     + if (*(u64 *)sctns->mac.infmname != 0)
487     + sctns->mac.infmval1 |= MAC_NAME_VLD;
488     +
489     if (stsi(sysinfo, 1, 1, 1))
490     return;
491    
492     - sclp_ocf_cpc_name_copy(sctns->mac.infmname);
493     -
494     memcpy(sctns->mac.infmtype, sysinfo->type, sizeof(sctns->mac.infmtype));
495     memcpy(sctns->mac.infmmanu, sysinfo->manufacturer, sizeof(sctns->mac.infmmanu));
496     memcpy(sctns->mac.infmpman, sysinfo->plant, sizeof(sctns->mac.infmpman));
497     memcpy(sctns->mac.infmseq, sysinfo->sequence, sizeof(sctns->mac.infmseq));
498    
499     - sctns->mac.infmval1 |= MAC_ID_VLD | MAC_NAME_VLD;
500     + sctns->mac.infmval1 |= MAC_ID_VLD;
501     }
502    
503     static void fill_stsi_par(struct sthyi_sctns *sctns,
504     diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h
505     index 5b0ed48e5b0c..aa2bf904b582 100644
506     --- a/arch/sparc/include/asm/cpudata_64.h
507     +++ b/arch/sparc/include/asm/cpudata_64.h
508     @@ -27,7 +27,7 @@ typedef struct {
509     unsigned short sock_id; /* physical package */
510     unsigned short core_id;
511     unsigned short max_cache_id; /* groupings of highest shared cache */
512     - unsigned short proc_id; /* strand (aka HW thread) id */
513     + signed short proc_id; /* strand (aka HW thread) id */
514     } cpuinfo_sparc;
515    
516     DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
517     diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
518     index 710f3278d448..71e7f77f6776 100644
519     --- a/arch/sparc/kernel/perf_event.c
520     +++ b/arch/sparc/kernel/perf_event.c
521     @@ -926,6 +926,8 @@ static void read_in_all_counters(struct cpu_hw_events *cpuc)
522     sparc_perf_event_update(cp, &cp->hw,
523     cpuc->current_idx[i]);
524     cpuc->current_idx[i] = PIC_NO_INDEX;
525     + if (cp->hw.state & PERF_HES_STOPPED)
526     + cp->hw.state |= PERF_HES_ARCH;
527     }
528     }
529     }
530     @@ -958,10 +960,12 @@ static void calculate_single_pcr(struct cpu_hw_events *cpuc)
531    
532     enc = perf_event_get_enc(cpuc->events[i]);
533     cpuc->pcr[0] &= ~mask_for_index(idx);
534     - if (hwc->state & PERF_HES_STOPPED)
535     + if (hwc->state & PERF_HES_ARCH) {
536     cpuc->pcr[0] |= nop_for_index(idx);
537     - else
538     + } else {
539     cpuc->pcr[0] |= event_encoding(enc, idx);
540     + hwc->state = 0;
541     + }
542     }
543     out:
544     cpuc->pcr[0] |= cpuc->event[0]->hw.config_base;
545     @@ -987,6 +991,9 @@ static void calculate_multiple_pcrs(struct cpu_hw_events *cpuc)
546    
547     cpuc->current_idx[i] = idx;
548    
549     + if (cp->hw.state & PERF_HES_ARCH)
550     + continue;
551     +
552     sparc_pmu_start(cp, PERF_EF_RELOAD);
553     }
554     out:
555     @@ -1078,6 +1085,8 @@ static void sparc_pmu_start(struct perf_event *event, int flags)
556     event->hw.state = 0;
557    
558     sparc_pmu_enable_event(cpuc, &event->hw, idx);
559     +
560     + perf_event_update_userpage(event);
561     }
562    
563     static void sparc_pmu_stop(struct perf_event *event, int flags)
564     @@ -1370,9 +1379,9 @@ static int sparc_pmu_add(struct perf_event *event, int ef_flags)
565     cpuc->events[n0] = event->hw.event_base;
566     cpuc->current_idx[n0] = PIC_NO_INDEX;
567    
568     - event->hw.state = PERF_HES_UPTODATE;
569     + event->hw.state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
570     if (!(ef_flags & PERF_EF_START))
571     - event->hw.state |= PERF_HES_STOPPED;
572     + event->hw.state |= PERF_HES_ARCH;
573    
574     /*
575     * If group events scheduling transaction was started,
576     diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c
577     index 0702d2531bc7..039c4a66aca4 100644
578     --- a/arch/x86/boot/tools/build.c
579     +++ b/arch/x86/boot/tools/build.c
580     @@ -390,6 +390,13 @@ int main(int argc, char ** argv)
581     die("Unable to mmap '%s': %m", argv[2]);
582     /* Number of 16-byte paragraphs, including space for a 4-byte CRC */
583     sys_size = (sz + 15 + 4) / 16;
584     +#ifdef CONFIG_EFI_STUB
585     + /*
586     + * COFF requires minimum 32-byte alignment of sections, and
587     + * adding a signature is problematic without that alignment.
588     + */
589     + sys_size = (sys_size + 1) & ~1;
590     +#endif
591    
592     /* Patch the setup code with the appropriate size parameters */
593     buf[0x1f1] = setup_sectors-1;
594     diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
595     index f6d1bc93589c..c56c24347f15 100644
596     --- a/arch/x86/include/asm/cpufeatures.h
597     +++ b/arch/x86/include/asm/cpufeatures.h
598     @@ -213,6 +213,7 @@
599     #define X86_FEATURE_STIBP ( 7*32+27) /* Single Thread Indirect Branch Predictors */
600     #define X86_FEATURE_ZEN ( 7*32+28) /* "" CPU is AMD family 0x17 (Zen) */
601     #define X86_FEATURE_L1TF_PTEINV ( 7*32+29) /* "" L1TF workaround PTE inversion */
602     +#define X86_FEATURE_IBRS_ENHANCED ( 7*32+30) /* Enhanced IBRS */
603    
604     /* Virtualization flags: Linux defined, word 8 */
605     #define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
606     diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
607     index 8b38df98548e..1b4132161c1f 100644
608     --- a/arch/x86/include/asm/nospec-branch.h
609     +++ b/arch/x86/include/asm/nospec-branch.h
610     @@ -215,6 +215,7 @@ enum spectre_v2_mitigation {
611     SPECTRE_V2_RETPOLINE_GENERIC,
612     SPECTRE_V2_RETPOLINE_AMD,
613     SPECTRE_V2_IBRS,
614     + SPECTRE_V2_IBRS_ENHANCED,
615     };
616    
617     /* The Speculative Store Bypass disable variants */
618     diff --git a/arch/x86/kernel/check.c b/arch/x86/kernel/check.c
619     index 145863d4d343..a8b215865636 100644
620     --- a/arch/x86/kernel/check.c
621     +++ b/arch/x86/kernel/check.c
622     @@ -30,6 +30,11 @@ static __init int set_corruption_check(char *arg)
623     ssize_t ret;
624     unsigned long val;
625    
626     + if (!arg) {
627     + pr_err("memory_corruption_check config string not provided\n");
628     + return -EINVAL;
629     + }
630     +
631     ret = kstrtoul(arg, 10, &val);
632     if (ret)
633     return ret;
634     @@ -44,6 +49,11 @@ static __init int set_corruption_check_period(char *arg)
635     ssize_t ret;
636     unsigned long val;
637    
638     + if (!arg) {
639     + pr_err("memory_corruption_check_period config string not provided\n");
640     + return -EINVAL;
641     + }
642     +
643     ret = kstrtoul(arg, 10, &val);
644     if (ret)
645     return ret;
646     @@ -58,6 +68,11 @@ static __init int set_corruption_check_size(char *arg)
647     char *end;
648     unsigned size;
649    
650     + if (!arg) {
651     + pr_err("memory_corruption_check_size config string not provided\n");
652     + return -EINVAL;
653     + }
654     +
655     size = memparse(arg, &end);
656    
657     if (*end == '\0')
658     diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
659     index 8103adacbc83..647a702c29dc 100644
660     --- a/arch/x86/kernel/cpu/bugs.c
661     +++ b/arch/x86/kernel/cpu/bugs.c
662     @@ -33,12 +33,10 @@ static void __init spectre_v2_select_mitigation(void);
663     static void __init ssb_select_mitigation(void);
664     static void __init l1tf_select_mitigation(void);
665    
666     -/*
667     - * Our boot-time value of the SPEC_CTRL MSR. We read it once so that any
668     - * writes to SPEC_CTRL contain whatever reserved bits have been set.
669     - */
670     -u64 __ro_after_init x86_spec_ctrl_base;
671     +/* The base value of the SPEC_CTRL MSR that always has to be preserved. */
672     +u64 x86_spec_ctrl_base;
673     EXPORT_SYMBOL_GPL(x86_spec_ctrl_base);
674     +static DEFINE_MUTEX(spec_ctrl_mutex);
675    
676     /*
677     * The vendor and possibly platform specific bits which can be modified in
678     @@ -139,6 +137,7 @@ static const char *spectre_v2_strings[] = {
679     [SPECTRE_V2_RETPOLINE_MINIMAL_AMD] = "Vulnerable: Minimal AMD ASM retpoline",
680     [SPECTRE_V2_RETPOLINE_GENERIC] = "Mitigation: Full generic retpoline",
681     [SPECTRE_V2_RETPOLINE_AMD] = "Mitigation: Full AMD retpoline",
682     + [SPECTRE_V2_IBRS_ENHANCED] = "Mitigation: Enhanced IBRS",
683     };
684    
685     #undef pr_fmt
686     @@ -321,6 +320,46 @@ static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void)
687     return cmd;
688     }
689    
690     +static bool stibp_needed(void)
691     +{
692     + if (spectre_v2_enabled == SPECTRE_V2_NONE)
693     + return false;
694     +
695     + if (!boot_cpu_has(X86_FEATURE_STIBP))
696     + return false;
697     +
698     + return true;
699     +}
700     +
701     +static void update_stibp_msr(void *info)
702     +{
703     + wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
704     +}
705     +
706     +void arch_smt_update(void)
707     +{
708     + u64 mask;
709     +
710     + if (!stibp_needed())
711     + return;
712     +
713     + mutex_lock(&spec_ctrl_mutex);
714     + mask = x86_spec_ctrl_base;
715     + if (cpu_smt_control == CPU_SMT_ENABLED)
716     + mask |= SPEC_CTRL_STIBP;
717     + else
718     + mask &= ~SPEC_CTRL_STIBP;
719     +
720     + if (mask != x86_spec_ctrl_base) {
721     + pr_info("Spectre v2 cross-process SMT mitigation: %s STIBP\n",
722     + cpu_smt_control == CPU_SMT_ENABLED ?
723     + "Enabling" : "Disabling");
724     + x86_spec_ctrl_base = mask;
725     + on_each_cpu(update_stibp_msr, NULL, 1);
726     + }
727     + mutex_unlock(&spec_ctrl_mutex);
728     +}
729     +
730     static void __init spectre_v2_select_mitigation(void)
731     {
732     enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline();
733     @@ -340,6 +379,13 @@ static void __init spectre_v2_select_mitigation(void)
734    
735     case SPECTRE_V2_CMD_FORCE:
736     case SPECTRE_V2_CMD_AUTO:
737     + if (boot_cpu_has(X86_FEATURE_IBRS_ENHANCED)) {
738     + mode = SPECTRE_V2_IBRS_ENHANCED;
739     + /* Force it so VMEXIT will restore correctly */
740     + x86_spec_ctrl_base |= SPEC_CTRL_IBRS;
741     + wrmsrl(MSR_IA32_SPEC_CTRL, x86_spec_ctrl_base);
742     + goto specv2_set_mode;
743     + }
744     if (IS_ENABLED(CONFIG_RETPOLINE))
745     goto retpoline_auto;
746     break;
747     @@ -377,6 +423,7 @@ retpoline_auto:
748     setup_force_cpu_cap(X86_FEATURE_RETPOLINE);
749     }
750    
751     +specv2_set_mode:
752     spectre_v2_enabled = mode;
753     pr_info("%s\n", spectre_v2_strings[mode]);
754    
755     @@ -399,12 +446,22 @@ retpoline_auto:
756    
757     /*
758     * Retpoline means the kernel is safe because it has no indirect
759     - * branches. But firmware isn't, so use IBRS to protect that.
760     + * branches. Enhanced IBRS protects firmware too, so, enable restricted
761     + * speculation around firmware calls only when Enhanced IBRS isn't
762     + * supported.
763     + *
764     + * Use "mode" to check Enhanced IBRS instead of boot_cpu_has(), because
765     + * the user might select retpoline on the kernel command line and if
766     + * the CPU supports Enhanced IBRS, kernel might un-intentionally not
767     + * enable IBRS around firmware calls.
768     */
769     - if (boot_cpu_has(X86_FEATURE_IBRS)) {
770     + if (boot_cpu_has(X86_FEATURE_IBRS) && mode != SPECTRE_V2_IBRS_ENHANCED) {
771     setup_force_cpu_cap(X86_FEATURE_USE_IBRS_FW);
772     pr_info("Enabling Restricted Speculation for firmware calls\n");
773     }
774     +
775     + /* Enable STIBP if appropriate */
776     + arch_smt_update();
777     }
778    
779     #undef pr_fmt
780     @@ -797,6 +854,8 @@ static ssize_t l1tf_show_state(char *buf)
781     static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr,
782     char *buf, unsigned int bug)
783     {
784     + int ret;
785     +
786     if (!boot_cpu_has_bug(bug))
787     return sprintf(buf, "Not affected\n");
788    
789     @@ -811,10 +870,12 @@ static ssize_t cpu_show_common(struct device *dev, struct device_attribute *attr
790     return sprintf(buf, "Mitigation: __user pointer sanitization\n");
791    
792     case X86_BUG_SPECTRE_V2:
793     - return sprintf(buf, "%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
794     + ret = sprintf(buf, "%s%s%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
795     boot_cpu_has(X86_FEATURE_USE_IBPB) ? ", IBPB" : "",
796     boot_cpu_has(X86_FEATURE_USE_IBRS_FW) ? ", IBRS_FW" : "",
797     + (x86_spec_ctrl_base & SPEC_CTRL_STIBP) ? ", STIBP" : "",
798     spectre_v2_module_string());
799     + return ret;
800    
801     case X86_BUG_SPEC_STORE_BYPASS:
802     return sprintf(buf, "%s\n", ssb_strings[ssb_mode]);
803     diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
804     index dc0850bb74be..3c01610c5ba9 100644
805     --- a/arch/x86/kernel/cpu/common.c
806     +++ b/arch/x86/kernel/cpu/common.c
807     @@ -959,6 +959,9 @@ static void __init cpu_set_bug_bits(struct cpuinfo_x86 *c)
808     setup_force_cpu_bug(X86_BUG_SPECTRE_V1);
809     setup_force_cpu_bug(X86_BUG_SPECTRE_V2);
810    
811     + if (ia32_cap & ARCH_CAP_IBRS_ALL)
812     + setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
813     +
814     if (x86_match_cpu(cpu_no_meltdown))
815     return;
816    
817     diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
818     index 3a9318610c4d..ae52ef05d098 100644
819     --- a/arch/x86/kernel/fpu/signal.c
820     +++ b/arch/x86/kernel/fpu/signal.c
821     @@ -309,7 +309,6 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
822     * thread's fpu state, reconstruct fxstate from the fsave
823     * header. Sanitize the copied state etc.
824     */
825     - struct fpu *fpu = &tsk->thread.fpu;
826     struct user_i387_ia32_struct env;
827     int err = 0;
828    
829     diff --git a/arch/x86/platform/olpc/olpc-xo1-rtc.c b/arch/x86/platform/olpc/olpc-xo1-rtc.c
830     index a2b4efddd61a..8e7ddd7e313a 100644
831     --- a/arch/x86/platform/olpc/olpc-xo1-rtc.c
832     +++ b/arch/x86/platform/olpc/olpc-xo1-rtc.c
833     @@ -16,6 +16,7 @@
834    
835     #include <asm/msr.h>
836     #include <asm/olpc.h>
837     +#include <asm/x86_init.h>
838    
839     static void rtc_wake_on(struct device *dev)
840     {
841     @@ -75,6 +76,8 @@ static int __init xo1_rtc_init(void)
842     if (r)
843     return r;
844    
845     + x86_platform.legacy.rtc = 0;
846     +
847     device_init_wakeup(&xo1_rtc_device.dev, 1);
848     return 0;
849     }
850     diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
851     index 3d6e0064cbfc..8d2c6f071dcc 100644
852     --- a/arch/x86/xen/spinlock.c
853     +++ b/arch/x86/xen/spinlock.c
854     @@ -8,6 +8,7 @@
855     #include <linux/log2.h>
856     #include <linux/gfp.h>
857     #include <linux/slab.h>
858     +#include <linux/atomic.h>
859    
860     #include <asm/paravirt.h>
861    
862     @@ -19,6 +20,7 @@
863    
864     static DEFINE_PER_CPU(int, lock_kicker_irq) = -1;
865     static DEFINE_PER_CPU(char *, irq_name);
866     +static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest);
867     static bool xen_pvspin = true;
868    
869     #include <asm/qspinlock.h>
870     @@ -40,33 +42,24 @@ static void xen_qlock_kick(int cpu)
871     static void xen_qlock_wait(u8 *byte, u8 val)
872     {
873     int irq = __this_cpu_read(lock_kicker_irq);
874     + atomic_t *nest_cnt = this_cpu_ptr(&xen_qlock_wait_nest);
875    
876     /* If kicker interrupts not initialized yet, just spin */
877     - if (irq == -1)
878     + if (irq == -1 || in_nmi())
879     return;
880    
881     - /* clear pending */
882     - xen_clear_irq_pending(irq);
883     - barrier();
884     -
885     - /*
886     - * We check the byte value after clearing pending IRQ to make sure
887     - * that we won't miss a wakeup event because of the clearing.
888     - *
889     - * The sync_clear_bit() call in xen_clear_irq_pending() is atomic.
890     - * So it is effectively a memory barrier for x86.
891     - */
892     - if (READ_ONCE(*byte) != val)
893     - return;
894     + /* Detect reentry. */
895     + atomic_inc(nest_cnt);
896    
897     - /*
898     - * If an interrupt happens here, it will leave the wakeup irq
899     - * pending, which will cause xen_poll_irq() to return
900     - * immediately.
901     - */
902     + /* If irq pending already and no nested call clear it. */
903     + if (atomic_read(nest_cnt) == 1 && xen_test_irq_pending(irq)) {
904     + xen_clear_irq_pending(irq);
905     + } else if (READ_ONCE(*byte) == val) {
906     + /* Block until irq becomes pending (or a spurious wakeup) */
907     + xen_poll_irq(irq);
908     + }
909    
910     - /* Block until irq becomes pending (or perhaps a spurious wakeup) */
911     - xen_poll_irq(irq);
912     + atomic_dec(nest_cnt);
913     }
914    
915     static irqreturn_t dummy_handler(int irq, void *dev_id)
916     diff --git a/crypto/lrw.c b/crypto/lrw.c
917     index 6f9908a7ebcb..d38a382b09eb 100644
918     --- a/crypto/lrw.c
919     +++ b/crypto/lrw.c
920     @@ -132,7 +132,12 @@ static inline int get_index128(be128 *block)
921     return x + ffz(val);
922     }
923    
924     - return x;
925     + /*
926     + * If we get here, then x == 128 and we are incrementing the counter
927     + * from all ones to all zeros. This means we must return index 127, i.e.
928     + * the one corresponding to key2*{ 1,...,1 }.
929     + */
930     + return 127;
931     }
932    
933     static int crypt(struct blkcipher_desc *d,
934     diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
935     index 2a07341aca46..babbda230c07 100644
936     --- a/crypto/tcrypt.c
937     +++ b/crypto/tcrypt.c
938     @@ -729,6 +729,9 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
939     break;
940     }
941    
942     + if (speed[i].klen)
943     + crypto_ahash_setkey(tfm, tvmem[0], speed[i].klen);
944     +
945     pr_info("test%3u "
946     "(%5u byte blocks,%5u bytes per update,%4u updates): ",
947     i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
948     diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
949     index 3cdd2c3a5bfc..957d3fa3b543 100644
950     --- a/drivers/acpi/acpi_lpss.c
951     +++ b/drivers/acpi/acpi_lpss.c
952     @@ -278,9 +278,11 @@ static const struct acpi_device_id acpi_lpss_device_ids[] = {
953     { "INT33FC", },
954    
955     /* Braswell LPSS devices */
956     + { "80862286", LPSS_ADDR(lpss_dma_desc) },
957     { "80862288", LPSS_ADDR(bsw_pwm_dev_desc) },
958     { "8086228A", LPSS_ADDR(bsw_uart_dev_desc) },
959     { "8086228E", LPSS_ADDR(bsw_spi_dev_desc) },
960     + { "808622C0", LPSS_ADDR(lpss_dma_desc) },
961     { "808622C1", LPSS_ADDR(bsw_i2c_dev_desc) },
962    
963     /* Broadwell LPSS devices */
964     diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
965     index 2104b1b4ccda..9ab759bcebd5 100644
966     --- a/drivers/block/ataflop.c
967     +++ b/drivers/block/ataflop.c
968     @@ -1933,6 +1933,11 @@ static int __init atari_floppy_init (void)
969     unit[i].disk = alloc_disk(1);
970     if (!unit[i].disk)
971     goto Enomem;
972     +
973     + unit[i].disk->queue = blk_init_queue(do_fd_request,
974     + &ataflop_lock);
975     + if (!unit[i].disk->queue)
976     + goto Enomem;
977     }
978    
979     if (UseTrackbuffer < 0)
980     @@ -1964,10 +1969,6 @@ static int __init atari_floppy_init (void)
981     sprintf(unit[i].disk->disk_name, "fd%d", i);
982     unit[i].disk->fops = &floppy_fops;
983     unit[i].disk->private_data = &unit[i];
984     - unit[i].disk->queue = blk_init_queue(do_fd_request,
985     - &ataflop_lock);
986     - if (!unit[i].disk->queue)
987     - goto Enomem;
988     set_capacity(unit[i].disk, MAX_DISK_SIZE * 2);
989     add_disk(unit[i].disk);
990     }
991     @@ -1982,13 +1983,17 @@ static int __init atari_floppy_init (void)
992    
993     return 0;
994     Enomem:
995     - while (i--) {
996     - struct request_queue *q = unit[i].disk->queue;
997     + do {
998     + struct gendisk *disk = unit[i].disk;
999    
1000     - put_disk(unit[i].disk);
1001     - if (q)
1002     - blk_cleanup_queue(q);
1003     - }
1004     + if (disk) {
1005     + if (disk->queue) {
1006     + blk_cleanup_queue(disk->queue);
1007     + disk->queue = NULL;
1008     + }
1009     + put_disk(unit[i].disk);
1010     + }
1011     + } while (i--);
1012    
1013     unregister_blkdev(FLOPPY_MAJOR, "fd");
1014     return -ENOMEM;
1015     diff --git a/drivers/block/swim.c b/drivers/block/swim.c
1016     index b5afd495d482..eec6e393c124 100644
1017     --- a/drivers/block/swim.c
1018     +++ b/drivers/block/swim.c
1019     @@ -868,8 +868,17 @@ static int swim_floppy_init(struct swim_priv *swd)
1020    
1021     exit_put_disks:
1022     unregister_blkdev(FLOPPY_MAJOR, "fd");
1023     - while (drive--)
1024     - put_disk(swd->unit[drive].disk);
1025     + do {
1026     + struct gendisk *disk = swd->unit[drive].disk;
1027     +
1028     + if (disk) {
1029     + if (disk->queue) {
1030     + blk_cleanup_queue(disk->queue);
1031     + disk->queue = NULL;
1032     + }
1033     + put_disk(disk);
1034     + }
1035     + } while (drive--);
1036     return err;
1037     }
1038    
1039     diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
1040     index f11d62de2272..c08ee8cf1e29 100644
1041     --- a/drivers/block/xen-blkfront.c
1042     +++ b/drivers/block/xen-blkfront.c
1043     @@ -2524,6 +2524,9 @@ static int blkfront_remove(struct xenbus_device *xbdev)
1044    
1045     dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename);
1046    
1047     + if (!info)
1048     + return 0;
1049     +
1050     blkif_free(info, 0);
1051    
1052     mutex_lock(&info->mutex);
1053     diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
1054     index fdb44829ab6f..475f25c2451d 100644
1055     --- a/drivers/bluetooth/btbcm.c
1056     +++ b/drivers/bluetooth/btbcm.c
1057     @@ -270,6 +270,7 @@ static const struct {
1058     { 0x4103, "BCM4330B1" }, /* 002.001.003 */
1059     { 0x410e, "BCM43341B0" }, /* 002.001.014 */
1060     { 0x4406, "BCM4324B3" }, /* 002.004.006 */
1061     + { 0x6109, "BCM4335C0" }, /* 003.001.009 */
1062     { 0x610c, "BCM4354" }, /* 003.001.012 */
1063     { }
1064     };
1065     diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c
1066     index 121319198478..a0bb52bc6582 100644
1067     --- a/drivers/char/ipmi/ipmi_ssif.c
1068     +++ b/drivers/char/ipmi/ipmi_ssif.c
1069     @@ -617,8 +617,9 @@ static void msg_done_handler(struct ssif_info *ssif_info, int result,
1070     flags = ipmi_ssif_lock_cond(ssif_info, &oflags);
1071     ssif_info->waiting_alert = true;
1072     ssif_info->rtc_us_timer = SSIF_MSG_USEC;
1073     - mod_timer(&ssif_info->retry_timer,
1074     - jiffies + SSIF_MSG_JIFFIES);
1075     + if (!ssif_info->stopping)
1076     + mod_timer(&ssif_info->retry_timer,
1077     + jiffies + SSIF_MSG_JIFFIES);
1078     ipmi_ssif_unlock_cond(ssif_info, flags);
1079     return;
1080     }
1081     @@ -950,8 +951,9 @@ static void msg_written_handler(struct ssif_info *ssif_info, int result,
1082     ssif_info->waiting_alert = true;
1083     ssif_info->retries_left = SSIF_RECV_RETRIES;
1084     ssif_info->rtc_us_timer = SSIF_MSG_PART_USEC;
1085     - mod_timer(&ssif_info->retry_timer,
1086     - jiffies + SSIF_MSG_PART_JIFFIES);
1087     + if (!ssif_info->stopping)
1088     + mod_timer(&ssif_info->retry_timer,
1089     + jiffies + SSIF_MSG_PART_JIFFIES);
1090     ipmi_ssif_unlock_cond(ssif_info, flags);
1091     }
1092     }
1093     diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
1094     index faf2db122ab9..4f0b1945d020 100644
1095     --- a/drivers/char/tpm/tpm-interface.c
1096     +++ b/drivers/char/tpm/tpm-interface.c
1097     @@ -420,7 +420,8 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd,
1098     header = cmd;
1099    
1100     err = be32_to_cpu(header->return_code);
1101     - if (err != 0 && desc)
1102     + if (err != 0 && err != TPM_ERR_DISABLED && err != TPM_ERR_DEACTIVATED
1103     + && desc)
1104     dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err,
1105     desc);
1106    
1107     diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c
1108     index a2ab00831df1..97b3e312903d 100644
1109     --- a/drivers/char/tpm/xen-tpmfront.c
1110     +++ b/drivers/char/tpm/xen-tpmfront.c
1111     @@ -203,7 +203,7 @@ static int setup_ring(struct xenbus_device *dev, struct tpm_private *priv)
1112     return -ENOMEM;
1113     }
1114    
1115     - rv = xenbus_grant_ring(dev, &priv->shr, 1, &gref);
1116     + rv = xenbus_grant_ring(dev, priv->shr, 1, &gref);
1117     if (rv < 0)
1118     return rv;
1119    
1120     diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
1121     index 4d3ec92cbabf..1496617b05d5 100644
1122     --- a/drivers/cpufreq/cpufreq-dt.c
1123     +++ b/drivers/cpufreq/cpufreq-dt.c
1124     @@ -32,6 +32,7 @@ struct private_data {
1125     struct device *cpu_dev;
1126     struct thermal_cooling_device *cdev;
1127     const char *reg_name;
1128     + bool have_static_opps;
1129     };
1130    
1131     static struct freq_attr *cpufreq_dt_attr[] = {
1132     @@ -197,6 +198,15 @@ static int cpufreq_init(struct cpufreq_policy *policy)
1133     }
1134     }
1135    
1136     + priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1137     + if (!priv) {
1138     + ret = -ENOMEM;
1139     + goto out_put_regulator;
1140     + }
1141     +
1142     + priv->reg_name = name;
1143     + priv->opp_table = opp_table;
1144     +
1145     /*
1146     * Initialize OPP tables for all policy->cpus. They will be shared by
1147     * all CPUs which have marked their CPUs shared with OPP bindings.
1148     @@ -207,7 +217,8 @@ static int cpufreq_init(struct cpufreq_policy *policy)
1149     *
1150     * OPPs might be populated at runtime, don't check for error here
1151     */
1152     - dev_pm_opp_of_cpumask_add_table(policy->cpus);
1153     + if (!dev_pm_opp_of_cpumask_add_table(policy->cpus))
1154     + priv->have_static_opps = true;
1155    
1156     /*
1157     * But we need OPP table to function so if it is not there let's
1158     @@ -233,19 +244,10 @@ static int cpufreq_init(struct cpufreq_policy *policy)
1159     __func__, ret);
1160     }
1161    
1162     - priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1163     - if (!priv) {
1164     - ret = -ENOMEM;
1165     - goto out_free_opp;
1166     - }
1167     -
1168     - priv->reg_name = name;
1169     - priv->opp_table = opp_table;
1170     -
1171     ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
1172     if (ret) {
1173     dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
1174     - goto out_free_priv;
1175     + goto out_free_opp;
1176     }
1177    
1178     priv->cpu_dev = cpu_dev;
1179     @@ -284,10 +286,11 @@ static int cpufreq_init(struct cpufreq_policy *policy)
1180    
1181     out_free_cpufreq_table:
1182     dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
1183     -out_free_priv:
1184     - kfree(priv);
1185     out_free_opp:
1186     - dev_pm_opp_of_cpumask_remove_table(policy->cpus);
1187     + if (priv->have_static_opps)
1188     + dev_pm_opp_of_cpumask_remove_table(policy->cpus);
1189     + kfree(priv);
1190     +out_put_regulator:
1191     if (name)
1192     dev_pm_opp_put_regulator(opp_table);
1193     out_put_clk:
1194     @@ -302,7 +305,8 @@ static int cpufreq_exit(struct cpufreq_policy *policy)
1195    
1196     cpufreq_cooling_unregister(priv->cdev);
1197     dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
1198     - dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
1199     + if (priv->have_static_opps)
1200     + dev_pm_opp_of_cpumask_remove_table(policy->related_cpus);
1201     if (priv->reg_name)
1202     dev_pm_opp_put_regulator(priv->opp_table);
1203    
1204     diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h
1205     index 84d2f838a063..b03e6f54ec14 100644
1206     --- a/drivers/crypto/caam/regs.h
1207     +++ b/drivers/crypto/caam/regs.h
1208     @@ -68,22 +68,22 @@
1209    
1210     extern bool caam_little_end;
1211    
1212     -#define caam_to_cpu(len) \
1213     -static inline u##len caam##len ## _to_cpu(u##len val) \
1214     -{ \
1215     - if (caam_little_end) \
1216     - return le##len ## _to_cpu(val); \
1217     - else \
1218     - return be##len ## _to_cpu(val); \
1219     +#define caam_to_cpu(len) \
1220     +static inline u##len caam##len ## _to_cpu(u##len val) \
1221     +{ \
1222     + if (caam_little_end) \
1223     + return le##len ## _to_cpu((__force __le##len)val); \
1224     + else \
1225     + return be##len ## _to_cpu((__force __be##len)val); \
1226     }
1227    
1228     -#define cpu_to_caam(len) \
1229     -static inline u##len cpu_to_caam##len(u##len val) \
1230     -{ \
1231     - if (caam_little_end) \
1232     - return cpu_to_le##len(val); \
1233     - else \
1234     - return cpu_to_be##len(val); \
1235     +#define cpu_to_caam(len) \
1236     +static inline u##len cpu_to_caam##len(u##len val) \
1237     +{ \
1238     + if (caam_little_end) \
1239     + return (__force u##len)cpu_to_le##len(val); \
1240     + else \
1241     + return (__force u##len)cpu_to_be##len(val); \
1242     }
1243    
1244     caam_to_cpu(16)
1245     diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
1246     index 7373b7a555ec..803cfb4523b0 100644
1247     --- a/drivers/dma/dma-jz4780.c
1248     +++ b/drivers/dma/dma-jz4780.c
1249     @@ -754,6 +754,11 @@ static int jz4780_dma_probe(struct platform_device *pdev)
1250     struct resource *res;
1251     int i, ret;
1252    
1253     + if (!dev->of_node) {
1254     + dev_err(dev, "This driver must be probed from devicetree\n");
1255     + return -EINVAL;
1256     + }
1257     +
1258     jzdma = devm_kzalloc(dev, sizeof(*jzdma), GFP_KERNEL);
1259     if (!jzdma)
1260     return -ENOMEM;
1261     diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
1262     index 84eb83eb2efe..d139706f01fe 100644
1263     --- a/drivers/dma/ioat/init.c
1264     +++ b/drivers/dma/ioat/init.c
1265     @@ -1210,8 +1210,15 @@ static void ioat_shutdown(struct pci_dev *pdev)
1266    
1267     spin_lock_bh(&ioat_chan->prep_lock);
1268     set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
1269     - del_timer_sync(&ioat_chan->timer);
1270     spin_unlock_bh(&ioat_chan->prep_lock);
1271     + /*
1272     + * Synchronization rule for del_timer_sync():
1273     + * - The caller must not hold locks which would prevent
1274     + * completion of the timer's handler.
1275     + * So prep_lock cannot be held before calling it.
1276     + */
1277     + del_timer_sync(&ioat_chan->timer);
1278     +
1279     /* this should quiesce then reset */
1280     ioat_reset_hw(ioat_chan);
1281     }
1282     diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
1283     index b60932026e34..f95d5b9c5551 100644
1284     --- a/drivers/edac/i7core_edac.c
1285     +++ b/drivers/edac/i7core_edac.c
1286     @@ -1711,6 +1711,7 @@ static void i7core_mce_output_error(struct mem_ctl_info *mci,
1287     u32 errnum = find_first_bit(&error, 32);
1288    
1289     if (uncorrected_error) {
1290     + core_err_cnt = 1;
1291     if (ripv)
1292     tp_event = HW_EVENT_ERR_FATAL;
1293     else
1294     diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
1295     index 3c47e6361d81..e9391950a843 100644
1296     --- a/drivers/edac/sb_edac.c
1297     +++ b/drivers/edac/sb_edac.c
1298     @@ -2934,6 +2934,7 @@ static void sbridge_mce_output_error(struct mem_ctl_info *mci,
1299     recoverable = GET_BITFIELD(m->status, 56, 56);
1300    
1301     if (uncorrected_error) {
1302     + core_err_cnt = 1;
1303     if (ripv) {
1304     type = "FATAL";
1305     tp_event = HW_EVENT_ERR_FATAL;
1306     diff --git a/drivers/edac/skx_edac.c b/drivers/edac/skx_edac.c
1307     index 0ff4878c2aa1..321035ad348f 100644
1308     --- a/drivers/edac/skx_edac.c
1309     +++ b/drivers/edac/skx_edac.c
1310     @@ -606,7 +606,7 @@ sad_found:
1311     break;
1312     case 2:
1313     lchan = (addr >> shift) % 2;
1314     - lchan = (lchan << 1) | ~lchan;
1315     + lchan = (lchan << 1) | !lchan;
1316     break;
1317     case 3:
1318     lchan = ((addr >> shift) % 2) << 1;
1319     @@ -897,6 +897,7 @@ static void skx_mce_output_error(struct mem_ctl_info *mci,
1320     recoverable = GET_BITFIELD(m->status, 56, 56);
1321    
1322     if (uncorrected_error) {
1323     + core_err_cnt = 1;
1324     if (ripv) {
1325     type = "FATAL";
1326     tp_event = HW_EVENT_ERR_FATAL;
1327     diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
1328     index b59b15d4caa9..308d8432fea3 100644
1329     --- a/drivers/hid/usbhid/hiddev.c
1330     +++ b/drivers/hid/usbhid/hiddev.c
1331     @@ -521,14 +521,24 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
1332     if (cmd == HIDIOCGCOLLECTIONINDEX) {
1333     if (uref->usage_index >= field->maxusage)
1334     goto inval;
1335     + uref->usage_index =
1336     + array_index_nospec(uref->usage_index,
1337     + field->maxusage);
1338     } else if (uref->usage_index >= field->report_count)
1339     goto inval;
1340     }
1341    
1342     - if ((cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) &&
1343     - (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
1344     - uref->usage_index + uref_multi->num_values > field->report_count))
1345     - goto inval;
1346     + if (cmd == HIDIOCGUSAGES || cmd == HIDIOCSUSAGES) {
1347     + if (uref_multi->num_values > HID_MAX_MULTI_USAGES ||
1348     + uref->usage_index + uref_multi->num_values >
1349     + field->report_count)
1350     + goto inval;
1351     +
1352     + uref->usage_index =
1353     + array_index_nospec(uref->usage_index,
1354     + field->report_count -
1355     + uref_multi->num_values);
1356     + }
1357    
1358     switch (cmd) {
1359     case HIDIOCGUSAGE:
1360     diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
1361     index 44ca8a94873d..2fe5a9952127 100644
1362     --- a/drivers/hwmon/pmbus/pmbus.c
1363     +++ b/drivers/hwmon/pmbus/pmbus.c
1364     @@ -118,6 +118,8 @@ static int pmbus_identify(struct i2c_client *client,
1365     } else {
1366     info->pages = 1;
1367     }
1368     +
1369     + pmbus_clear_faults(client);
1370     }
1371    
1372     if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) {
1373     diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
1374     index d013acf3f83a..c00bad02761a 100644
1375     --- a/drivers/hwmon/pmbus/pmbus_core.c
1376     +++ b/drivers/hwmon/pmbus/pmbus_core.c
1377     @@ -1759,7 +1759,10 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data,
1378     if (ret >= 0 && (ret & PB_CAPABILITY_ERROR_CHECK))
1379     client->flags |= I2C_CLIENT_PEC;
1380    
1381     - pmbus_clear_faults(client);
1382     + if (data->info->pages)
1383     + pmbus_clear_faults(client);
1384     + else
1385     + pmbus_clear_fault_page(client, -1);
1386    
1387     if (info->identify) {
1388     ret = (*info->identify)(client, info);
1389     diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
1390     index f9af3935b427..fb03449de2e0 100644
1391     --- a/drivers/hwmon/pwm-fan.c
1392     +++ b/drivers/hwmon/pwm-fan.c
1393     @@ -306,9 +306,19 @@ static int pwm_fan_remove(struct platform_device *pdev)
1394     static int pwm_fan_suspend(struct device *dev)
1395     {
1396     struct pwm_fan_ctx *ctx = dev_get_drvdata(dev);
1397     + struct pwm_args args;
1398     + int ret;
1399     +
1400     + pwm_get_args(ctx->pwm, &args);
1401     +
1402     + if (ctx->pwm_value) {
1403     + ret = pwm_config(ctx->pwm, 0, args.period);
1404     + if (ret < 0)
1405     + return ret;
1406    
1407     - if (ctx->pwm_value)
1408     pwm_disable(ctx->pwm);
1409     + }
1410     +
1411     return 0;
1412     }
1413    
1414     diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c
1415     index d7325c6534ad..ace55385b26f 100644
1416     --- a/drivers/hwtracing/coresight/coresight-etb10.c
1417     +++ b/drivers/hwtracing/coresight/coresight-etb10.c
1418     @@ -155,6 +155,10 @@ static int etb_enable(struct coresight_device *csdev, u32 mode)
1419     if (val == CS_MODE_PERF)
1420     return -EBUSY;
1421    
1422     + /* Don't let perf disturb sysFS sessions */
1423     + if (val == CS_MODE_SYSFS && mode == CS_MODE_PERF)
1424     + return -EBUSY;
1425     +
1426     /* Nothing to do, the tracer is already enabled. */
1427     if (val == CS_MODE_SYSFS)
1428     goto out;
1429     diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
1430     index c7592fe30e6e..93b8069041bb 100644
1431     --- a/drivers/i2c/busses/i2c-rcar.c
1432     +++ b/drivers/i2c/busses/i2c-rcar.c
1433     @@ -723,8 +723,12 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap,
1434    
1435     time_left = wait_event_timeout(priv->wait, priv->flags & ID_DONE,
1436     num * adap->timeout);
1437     - if (!time_left) {
1438     +
1439     + /* cleanup DMA if it couldn't complete properly due to an error */
1440     + if (priv->dma_direction != DMA_NONE)
1441     rcar_i2c_cleanup_dma(priv);
1442     +
1443     + if (!time_left) {
1444     rcar_i2c_init(priv);
1445     ret = -ETIMEDOUT;
1446     } else if (priv->flags & ID_NACK) {
1447     diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
1448     index bbdac07f4aaa..e3e2155b0386 100644
1449     --- a/drivers/iio/adc/at91_adc.c
1450     +++ b/drivers/iio/adc/at91_adc.c
1451     @@ -247,12 +247,14 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
1452     struct iio_poll_func *pf = p;
1453     struct iio_dev *idev = pf->indio_dev;
1454     struct at91_adc_state *st = iio_priv(idev);
1455     + struct iio_chan_spec const *chan;
1456     int i, j = 0;
1457    
1458     for (i = 0; i < idev->masklength; i++) {
1459     if (!test_bit(i, idev->active_scan_mask))
1460     continue;
1461     - st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, i));
1462     + chan = idev->channels + i;
1463     + st->buffer[j] = at91_adc_readl(st, AT91_ADC_CHAN(st, chan->channel));
1464     j++;
1465     }
1466    
1467     @@ -278,6 +280,8 @@ static void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
1468     iio_trigger_poll(idev->trig);
1469     } else {
1470     st->last_value = at91_adc_readl(st, AT91_ADC_CHAN(st, st->chnb));
1471     + /* Needed to ACK the DRDY interruption */
1472     + at91_adc_readl(st, AT91_ADC_LCDR);
1473     st->done = true;
1474     wake_up_interruptible(&st->wq_data_avail);
1475     }
1476     diff --git a/drivers/iio/adc/fsl-imx25-gcq.c b/drivers/iio/adc/fsl-imx25-gcq.c
1477     index ea264fa9e567..929c617db364 100644
1478     --- a/drivers/iio/adc/fsl-imx25-gcq.c
1479     +++ b/drivers/iio/adc/fsl-imx25-gcq.c
1480     @@ -209,12 +209,14 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev,
1481     ret = of_property_read_u32(child, "reg", &reg);
1482     if (ret) {
1483     dev_err(dev, "Failed to get reg property\n");
1484     + of_node_put(child);
1485     return ret;
1486     }
1487    
1488     if (reg >= MX25_NUM_CFGS) {
1489     dev_err(dev,
1490     "reg value is greater than the number of available configuration registers\n");
1491     + of_node_put(child);
1492     return -EINVAL;
1493     }
1494    
1495     @@ -228,6 +230,7 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev,
1496     if (IS_ERR(priv->vref[refp])) {
1497     dev_err(dev, "Error, trying to use external voltage reference without a vref-%s regulator.",
1498     mx25_gcq_refp_names[refp]);
1499     + of_node_put(child);
1500     return PTR_ERR(priv->vref[refp]);
1501     }
1502     priv->channel_vref_mv[reg] =
1503     @@ -240,6 +243,7 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev,
1504     break;
1505     default:
1506     dev_err(dev, "Invalid positive reference %d\n", refp);
1507     + of_node_put(child);
1508     return -EINVAL;
1509     }
1510    
1511     @@ -254,10 +258,12 @@ static int mx25_gcq_setup_cfgs(struct platform_device *pdev,
1512    
1513     if ((refp & MX25_ADCQ_CFG_REFP_MASK) != refp) {
1514     dev_err(dev, "Invalid fsl,adc-refp property value\n");
1515     + of_node_put(child);
1516     return -EINVAL;
1517     }
1518     if ((refn & MX25_ADCQ_CFG_REFN_MASK) != refn) {
1519     dev_err(dev, "Invalid fsl,adc-refn property value\n");
1520     + of_node_put(child);
1521     return -EINVAL;
1522     }
1523    
1524     diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
1525     index 6803e4a137cd..94d4677cb51e 100644
1526     --- a/drivers/iio/dac/ad5064.c
1527     +++ b/drivers/iio/dac/ad5064.c
1528     @@ -760,6 +760,40 @@ static int ad5064_set_config(struct ad5064_state *st, unsigned int val)
1529     return ad5064_write(st, cmd, 0, val, 0);
1530     }
1531    
1532     +static int ad5064_request_vref(struct ad5064_state *st, struct device *dev)
1533     +{
1534     + unsigned int i;
1535     + int ret;
1536     +
1537     + for (i = 0; i < ad5064_num_vref(st); ++i)
1538     + st->vref_reg[i].supply = ad5064_vref_name(st, i);
1539     +
1540     + if (!st->chip_info->internal_vref)
1541     + return devm_regulator_bulk_get(dev, ad5064_num_vref(st),
1542     + st->vref_reg);
1543     +
1544     + /*
1545     + * This assumes that when the regulator has an internal VREF
1546     + * there is only one external VREF connection, which is
1547     + * currently the case for all supported devices.
1548     + */
1549     + st->vref_reg[0].consumer = devm_regulator_get_optional(dev, "vref");
1550     + if (!IS_ERR(st->vref_reg[0].consumer))
1551     + return 0;
1552     +
1553     + ret = PTR_ERR(st->vref_reg[0].consumer);
1554     + if (ret != -ENODEV)
1555     + return ret;
1556     +
1557     + /* If no external regulator was supplied use the internal VREF */
1558     + st->use_internal_vref = true;
1559     + ret = ad5064_set_config(st, AD5064_CONFIG_INT_VREF_ENABLE);
1560     + if (ret)
1561     + dev_err(dev, "Failed to enable internal vref: %d\n", ret);
1562     +
1563     + return ret;
1564     +}
1565     +
1566     static int ad5064_probe(struct device *dev, enum ad5064_type type,
1567     const char *name, ad5064_write_func write)
1568     {
1569     @@ -780,22 +814,11 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type,
1570     st->dev = dev;
1571     st->write = write;
1572    
1573     - for (i = 0; i < ad5064_num_vref(st); ++i)
1574     - st->vref_reg[i].supply = ad5064_vref_name(st, i);
1575     + ret = ad5064_request_vref(st, dev);
1576     + if (ret)
1577     + return ret;
1578    
1579     - ret = devm_regulator_bulk_get(dev, ad5064_num_vref(st),
1580     - st->vref_reg);
1581     - if (ret) {
1582     - if (!st->chip_info->internal_vref)
1583     - return ret;
1584     - st->use_internal_vref = true;
1585     - ret = ad5064_set_config(st, AD5064_CONFIG_INT_VREF_ENABLE);
1586     - if (ret) {
1587     - dev_err(dev, "Failed to enable internal vref: %d\n",
1588     - ret);
1589     - return ret;
1590     - }
1591     - } else {
1592     + if (!st->use_internal_vref) {
1593     ret = regulator_bulk_enable(ad5064_num_vref(st), st->vref_reg);
1594     if (ret)
1595     return ret;
1596     diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
1597     index 42de5f22da93..a1240ddca026 100644
1598     --- a/drivers/infiniband/core/sysfs.c
1599     +++ b/drivers/infiniband/core/sysfs.c
1600     @@ -485,7 +485,7 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
1601     ret = get_perf_mad(p->ibdev, p->port_num, tab_attr->attr_id, &data,
1602     40 + offset / 8, sizeof(data));
1603     if (ret < 0)
1604     - return sprintf(buf, "N/A (no PMA)\n");
1605     + return ret;
1606    
1607     switch (width) {
1608     case 4:
1609     @@ -1008,10 +1008,12 @@ static int add_port(struct ib_device *device, int port_num,
1610     goto err_put;
1611     }
1612    
1613     - p->pma_table = get_counter_table(device, port_num);
1614     - ret = sysfs_create_group(&p->kobj, p->pma_table);
1615     - if (ret)
1616     - goto err_put_gid_attrs;
1617     + if (device->process_mad) {
1618     + p->pma_table = get_counter_table(device, port_num);
1619     + ret = sysfs_create_group(&p->kobj, p->pma_table);
1620     + if (ret)
1621     + goto err_put_gid_attrs;
1622     + }
1623    
1624     p->gid_group.name = "gids";
1625     p->gid_group.attrs = alloc_group_attrs(show_port_gid, attr.gid_tbl_len);
1626     @@ -1124,7 +1126,8 @@ err_free_gid:
1627     p->gid_group.attrs = NULL;
1628    
1629     err_remove_pma:
1630     - sysfs_remove_group(&p->kobj, p->pma_table);
1631     + if (p->pma_table)
1632     + sysfs_remove_group(&p->kobj, p->pma_table);
1633    
1634     err_put_gid_attrs:
1635     kobject_put(&p->gid_attr_group->kobj);
1636     @@ -1236,7 +1239,9 @@ static void free_port_list_attributes(struct ib_device *device)
1637     kfree(port->hw_stats);
1638     free_hsag(&port->kobj, port->hw_stats_ag);
1639     }
1640     - sysfs_remove_group(p, port->pma_table);
1641     +
1642     + if (port->pma_table)
1643     + sysfs_remove_group(p, port->pma_table);
1644     sysfs_remove_group(p, &port->pkey_group);
1645     sysfs_remove_group(p, &port->gid_group);
1646     sysfs_remove_group(&port->gid_attr_group->kobj,
1647     diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
1648     index ad9b486ca7ea..95a3e0abd2a4 100644
1649     --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
1650     +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
1651     @@ -1422,11 +1422,15 @@ static void ipoib_cm_skb_reap(struct work_struct *work)
1652     spin_unlock_irqrestore(&priv->lock, flags);
1653     netif_tx_unlock_bh(dev);
1654    
1655     - if (skb->protocol == htons(ETH_P_IP))
1656     + if (skb->protocol == htons(ETH_P_IP)) {
1657     + memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
1658     icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, htonl(mtu));
1659     + }
1660     #if IS_ENABLED(CONFIG_IPV6)
1661     - else if (skb->protocol == htons(ETH_P_IPV6))
1662     + else if (skb->protocol == htons(ETH_P_IPV6)) {
1663     + memset(IP6CB(skb), 0, sizeof(*IP6CB(skb)));
1664     icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
1665     + }
1666     #endif
1667     dev_kfree_skb_any(skb);
1668    
1669     diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
1670     index cf7c68920b33..4e34afb6e36a 100644
1671     --- a/drivers/md/bcache/btree.c
1672     +++ b/drivers/md/bcache/btree.c
1673     @@ -2367,7 +2367,7 @@ static int refill_keybuf_fn(struct btree_op *op, struct btree *b,
1674     struct keybuf *buf = refill->buf;
1675     int ret = MAP_CONTINUE;
1676    
1677     - if (bkey_cmp(k, refill->end) >= 0) {
1678     + if (bkey_cmp(k, refill->end) > 0) {
1679     ret = MAP_DONE;
1680     goto out;
1681     }
1682     diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
1683     index b67414b5a64e..6964b252952a 100644
1684     --- a/drivers/md/dm-ioctl.c
1685     +++ b/drivers/md/dm-ioctl.c
1686     @@ -1692,8 +1692,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla
1687     }
1688    
1689     static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kernel,
1690     - int ioctl_flags,
1691     - struct dm_ioctl **param, int *param_flags)
1692     + int ioctl_flags, struct dm_ioctl **param, int *param_flags)
1693     {
1694     struct dm_ioctl *dmi;
1695     int secure_data;
1696     @@ -1738,18 +1737,13 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kern
1697    
1698     *param_flags |= DM_PARAMS_MALLOC;
1699    
1700     - if (copy_from_user(dmi, user, param_kernel->data_size))
1701     - goto bad;
1702     + /* Copy from param_kernel (which was already copied from user) */
1703     + memcpy(dmi, param_kernel, minimum_data_size);
1704    
1705     -data_copied:
1706     - /*
1707     - * Abort if something changed the ioctl data while it was being copied.
1708     - */
1709     - if (dmi->data_size != param_kernel->data_size) {
1710     - DMERR("rejecting ioctl: data size modified while processing parameters");
1711     + if (copy_from_user(&dmi->data, (char __user *)user + minimum_data_size,
1712     + param_kernel->data_size - minimum_data_size))
1713     goto bad;
1714     - }
1715     -
1716     +data_copied:
1717     /* Wipe the user buffer so we do not return it to userspace */
1718     if (secure_data && clear_user(user, param_kernel->data_size))
1719     goto bad;
1720     diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
1721     index 998102697619..53048bf0b2b8 100644
1722     --- a/drivers/md/raid1.c
1723     +++ b/drivers/md/raid1.c
1724     @@ -1589,6 +1589,7 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
1725     */
1726     if (rdev->saved_raid_disk >= 0 &&
1727     rdev->saved_raid_disk >= first &&
1728     + rdev->saved_raid_disk < conf->raid_disks &&
1729     conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
1730     first = last = rdev->saved_raid_disk;
1731    
1732     diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
1733     index b3046063402c..b62e6ab66b31 100644
1734     --- a/drivers/md/raid10.c
1735     +++ b/drivers/md/raid10.c
1736     @@ -1734,6 +1734,7 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
1737     first = last = rdev->raid_disk;
1738    
1739     if (rdev->saved_raid_disk >= first &&
1740     + rdev->saved_raid_disk < conf->geo.raid_disks &&
1741     conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
1742     mirror = rdev->saved_raid_disk;
1743     else
1744     diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
1745     index 1684810cab83..1f463f4c3024 100644
1746     --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
1747     +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
1748     @@ -1650,7 +1650,7 @@ typedef struct { u16 __; u8 _; } __packed x24;
1749     pos[7] = (chr & (0x01 << 0) ? fg : bg); \
1750     } \
1751     \
1752     - pos += (tpg->hflip ? -8 : 8) / hdiv; \
1753     + pos += (tpg->hflip ? -8 : 8) / (int)hdiv; \
1754     } \
1755     } \
1756     } while (0)
1757     diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
1758     index 59aa4dafb60b..5d9c2b03d83a 100644
1759     --- a/drivers/media/i2c/tvp5150.c
1760     +++ b/drivers/media/i2c/tvp5150.c
1761     @@ -1527,7 +1527,7 @@ static int tvp5150_probe(struct i2c_client *c,
1762     27000000, 1, 27000000);
1763     v4l2_ctrl_new_std_menu_items(&core->hdl, &tvp5150_ctrl_ops,
1764     V4L2_CID_TEST_PATTERN,
1765     - ARRAY_SIZE(tvp5150_test_patterns),
1766     + ARRAY_SIZE(tvp5150_test_patterns) - 1,
1767     0, 0, tvp5150_test_patterns);
1768     sd->ctrl_handler = &core->hdl;
1769     if (core->hdl.error) {
1770     diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
1771     index e397f544f108..e9403aa6fbd2 100644
1772     --- a/drivers/media/usb/em28xx/em28xx-cards.c
1773     +++ b/drivers/media/usb/em28xx/em28xx-cards.c
1774     @@ -2093,13 +2093,13 @@ struct em28xx_board em28xx_boards[] = {
1775     .input = { {
1776     .type = EM28XX_VMUX_COMPOSITE,
1777     .vmux = TVP5150_COMPOSITE1,
1778     - .amux = EM28XX_AUDIO_SRC_LINE,
1779     + .amux = EM28XX_AMUX_LINE_IN,
1780     .gpio = terratec_av350_unmute_gpio,
1781    
1782     }, {
1783     .type = EM28XX_VMUX_SVIDEO,
1784     .vmux = TVP5150_SVIDEO,
1785     - .amux = EM28XX_AUDIO_SRC_LINE,
1786     + .amux = EM28XX_AMUX_LINE_IN,
1787     .gpio = terratec_av350_unmute_gpio,
1788     } },
1789     },
1790     diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
1791     index 1f7fa059eb34..1ed7ba3dfdbe 100644
1792     --- a/drivers/media/usb/em28xx/em28xx-video.c
1793     +++ b/drivers/media/usb/em28xx/em28xx-video.c
1794     @@ -1290,6 +1290,8 @@ static void em28xx_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv)
1795     {
1796     struct em28xx *dev = priv;
1797    
1798     + dev->v4l2->field_count = 0;
1799     +
1800     /*
1801     * In the case of non-AC97 volume controls, we still need
1802     * to do some setups at em28xx, in order to mute/unmute
1803     @@ -1435,9 +1437,9 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
1804    
1805     fmt = format_by_fourcc(f->fmt.pix.pixelformat);
1806     if (!fmt) {
1807     - em28xx_videodbg("Fourcc format (%08x) invalid.\n",
1808     - f->fmt.pix.pixelformat);
1809     - return -EINVAL;
1810     + fmt = &format[0];
1811     + em28xx_videodbg("Fourcc format (%08x) invalid. Using default (%08x).\n",
1812     + f->fmt.pix.pixelformat, fmt->fourcc);
1813     }
1814    
1815     if (dev->board.is_em2800) {
1816     diff --git a/drivers/misc/genwqe/card_base.h b/drivers/misc/genwqe/card_base.h
1817     index cb851c14ca4b..159f35b2bd11 100644
1818     --- a/drivers/misc/genwqe/card_base.h
1819     +++ b/drivers/misc/genwqe/card_base.h
1820     @@ -404,7 +404,7 @@ struct genwqe_file {
1821     struct file *filp;
1822    
1823     struct fasync_struct *async_queue;
1824     - struct task_struct *owner;
1825     + struct pid *opener;
1826     struct list_head list; /* entry in list of open files */
1827    
1828     spinlock_t map_lock; /* lock for dma_mappings */
1829     diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c
1830     index 7f1b282d7d96..c0012ca4229e 100644
1831     --- a/drivers/misc/genwqe/card_dev.c
1832     +++ b/drivers/misc/genwqe/card_dev.c
1833     @@ -52,7 +52,7 @@ static void genwqe_add_file(struct genwqe_dev *cd, struct genwqe_file *cfile)
1834     {
1835     unsigned long flags;
1836    
1837     - cfile->owner = current;
1838     + cfile->opener = get_pid(task_tgid(current));
1839     spin_lock_irqsave(&cd->file_lock, flags);
1840     list_add(&cfile->list, &cd->file_list);
1841     spin_unlock_irqrestore(&cd->file_lock, flags);
1842     @@ -65,6 +65,7 @@ static int genwqe_del_file(struct genwqe_dev *cd, struct genwqe_file *cfile)
1843     spin_lock_irqsave(&cd->file_lock, flags);
1844     list_del(&cfile->list);
1845     spin_unlock_irqrestore(&cd->file_lock, flags);
1846     + put_pid(cfile->opener);
1847    
1848     return 0;
1849     }
1850     @@ -275,7 +276,7 @@ static int genwqe_kill_fasync(struct genwqe_dev *cd, int sig)
1851     return files;
1852     }
1853    
1854     -static int genwqe_force_sig(struct genwqe_dev *cd, int sig)
1855     +static int genwqe_terminate(struct genwqe_dev *cd)
1856     {
1857     unsigned int files = 0;
1858     unsigned long flags;
1859     @@ -283,7 +284,7 @@ static int genwqe_force_sig(struct genwqe_dev *cd, int sig)
1860    
1861     spin_lock_irqsave(&cd->file_lock, flags);
1862     list_for_each_entry(cfile, &cd->file_list, list) {
1863     - force_sig(sig, cfile->owner);
1864     + kill_pid(cfile->opener, SIGKILL, 1);
1865     files++;
1866     }
1867     spin_unlock_irqrestore(&cd->file_lock, flags);
1868     @@ -1356,7 +1357,7 @@ static int genwqe_inform_and_stop_processes(struct genwqe_dev *cd)
1869     dev_warn(&pci_dev->dev,
1870     "[%s] send SIGKILL and wait ...\n", __func__);
1871    
1872     - rc = genwqe_force_sig(cd, SIGKILL); /* force terminate */
1873     + rc = genwqe_terminate(cd);
1874     if (rc) {
1875     /* Give kill_timout more seconds to end processes */
1876     for (i = 0; (i < genwqe_kill_timeout) &&
1877     diff --git a/drivers/misc/vmw_vmci/vmci_driver.c b/drivers/misc/vmw_vmci/vmci_driver.c
1878     index d7eaf1eb11e7..003bfba40758 100644
1879     --- a/drivers/misc/vmw_vmci/vmci_driver.c
1880     +++ b/drivers/misc/vmw_vmci/vmci_driver.c
1881     @@ -113,5 +113,5 @@ module_exit(vmci_drv_exit);
1882    
1883     MODULE_AUTHOR("VMware, Inc.");
1884     MODULE_DESCRIPTION("VMware Virtual Machine Communication Interface.");
1885     -MODULE_VERSION("1.1.5.0-k");
1886     +MODULE_VERSION("1.1.6.0-k");
1887     MODULE_LICENSE("GPL v2");
1888     diff --git a/drivers/misc/vmw_vmci/vmci_resource.c b/drivers/misc/vmw_vmci/vmci_resource.c
1889     index 9a53a30de445..f1164602cec1 100644
1890     --- a/drivers/misc/vmw_vmci/vmci_resource.c
1891     +++ b/drivers/misc/vmw_vmci/vmci_resource.c
1892     @@ -56,7 +56,8 @@ static struct vmci_resource *vmci_resource_lookup(struct vmci_handle handle,
1893    
1894     if (r->type == type &&
1895     rid == handle.resource &&
1896     - (cid == handle.context || cid == VMCI_INVALID_ID)) {
1897     + (cid == handle.context || cid == VMCI_INVALID_ID ||
1898     + handle.context == VMCI_INVALID_ID)) {
1899     resource = r;
1900     break;
1901     }
1902     diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c
1903     index d48f03104b5b..e417e4274d66 100644
1904     --- a/drivers/mmc/host/sdhci-pci-o2micro.c
1905     +++ b/drivers/mmc/host/sdhci-pci-o2micro.c
1906     @@ -334,6 +334,9 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip)
1907     pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch);
1908     break;
1909     case PCI_DEVICE_ID_O2_SEABIRD0:
1910     + if (chip->pdev->revision == 0x01)
1911     + chip->quirks |= SDHCI_QUIRK_DELAY_AFTER_POWER;
1912     + /* fall through */
1913     case PCI_DEVICE_ID_O2_SEABIRD1:
1914     /* UnLock WP */
1915     ret = pci_read_config_byte(chip->pdev,
1916     diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1917     index 029513294984..75607267e656 100644
1918     --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1919     +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
1920     @@ -3419,6 +3419,10 @@ static void ixgbevf_tx_csum(struct ixgbevf_ring *tx_ring,
1921     skb_checksum_help(skb);
1922     goto no_csum;
1923     }
1924     +
1925     + if (first->protocol == htons(ETH_P_IP))
1926     + type_tucmd |= IXGBE_ADVTXD_TUCMD_IPV4;
1927     +
1928     /* update TX checksum flag */
1929     first->tx_flags |= IXGBE_TX_FLAGS_CSUM;
1930     vlan_macip_lens = skb_checksum_start_offset(skb) -
1931     diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
1932     index b09a6b80d107..355c5fb802cd 100644
1933     --- a/drivers/net/ethernet/qlogic/qla3xxx.c
1934     +++ b/drivers/net/ethernet/qlogic/qla3xxx.c
1935     @@ -380,8 +380,6 @@ static void fm93c56a_select(struct ql3_adapter *qdev)
1936    
1937     qdev->eeprom_cmd_data = AUBURN_EEPROM_CS_1;
1938     ql_write_nvram_reg(qdev, spir, ISP_NVRAM_MASK | qdev->eeprom_cmd_data);
1939     - ql_write_nvram_reg(qdev, spir,
1940     - ((ISP_NVRAM_MASK << 16) | qdev->eeprom_cmd_data));
1941     }
1942    
1943     /*
1944     diff --git a/drivers/net/tun.c b/drivers/net/tun.c
1945     index eb6dc28e5e52..0260bc15bc0c 100644
1946     --- a/drivers/net/tun.c
1947     +++ b/drivers/net/tun.c
1948     @@ -1570,6 +1570,8 @@ static void tun_setup(struct net_device *dev)
1949     */
1950     static int tun_validate(struct nlattr *tb[], struct nlattr *data[])
1951     {
1952     + if (!data)
1953     + return 0;
1954     return -EINVAL;
1955     }
1956    
1957     diff --git a/drivers/net/wireless/ath/ath10k/wmi.c b/drivers/net/wireless/ath/ath10k/wmi.c
1958     index 75f7a7b549df..21aec5c252ee 100644
1959     --- a/drivers/net/wireless/ath/ath10k/wmi.c
1960     +++ b/drivers/net/wireless/ath/ath10k/wmi.c
1961     @@ -1822,6 +1822,12 @@ int ath10k_wmi_cmd_send(struct ath10k *ar, struct sk_buff *skb, u32 cmd_id)
1962     if (ret)
1963     dev_kfree_skb_any(skb);
1964    
1965     + if (ret == -EAGAIN) {
1966     + ath10k_warn(ar, "wmi command %d timeout, restarting hardware\n",
1967     + cmd_id);
1968     + queue_work(ar->workqueue, &ar->restart_work);
1969     + }
1970     +
1971     return ret;
1972     }
1973    
1974     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmutil/d11.c b/drivers/net/wireless/broadcom/brcm80211/brcmutil/d11.c
1975     index d8b79cb72b58..e7584b842dce 100644
1976     --- a/drivers/net/wireless/broadcom/brcm80211/brcmutil/d11.c
1977     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmutil/d11.c
1978     @@ -77,6 +77,8 @@ static u16 d11ac_bw(enum brcmu_chan_bw bw)
1979     return BRCMU_CHSPEC_D11AC_BW_40;
1980     case BRCMU_CHAN_BW_80:
1981     return BRCMU_CHSPEC_D11AC_BW_80;
1982     + case BRCMU_CHAN_BW_160:
1983     + return BRCMU_CHSPEC_D11AC_BW_160;
1984     default:
1985     WARN_ON(1);
1986     }
1987     @@ -190,8 +192,38 @@ static void brcmu_d11ac_decchspec(struct brcmu_chan *ch)
1988     break;
1989     }
1990     break;
1991     - case BRCMU_CHSPEC_D11AC_BW_8080:
1992     case BRCMU_CHSPEC_D11AC_BW_160:
1993     + switch (ch->sb) {
1994     + case BRCMU_CHAN_SB_LLL:
1995     + ch->control_ch_num -= CH_70MHZ_APART;
1996     + break;
1997     + case BRCMU_CHAN_SB_LLU:
1998     + ch->control_ch_num -= CH_50MHZ_APART;
1999     + break;
2000     + case BRCMU_CHAN_SB_LUL:
2001     + ch->control_ch_num -= CH_30MHZ_APART;
2002     + break;
2003     + case BRCMU_CHAN_SB_LUU:
2004     + ch->control_ch_num -= CH_10MHZ_APART;
2005     + break;
2006     + case BRCMU_CHAN_SB_ULL:
2007     + ch->control_ch_num += CH_10MHZ_APART;
2008     + break;
2009     + case BRCMU_CHAN_SB_ULU:
2010     + ch->control_ch_num += CH_30MHZ_APART;
2011     + break;
2012     + case BRCMU_CHAN_SB_UUL:
2013     + ch->control_ch_num += CH_50MHZ_APART;
2014     + break;
2015     + case BRCMU_CHAN_SB_UUU:
2016     + ch->control_ch_num += CH_70MHZ_APART;
2017     + break;
2018     + default:
2019     + WARN_ON_ONCE(1);
2020     + break;
2021     + }
2022     + break;
2023     + case BRCMU_CHSPEC_D11AC_BW_8080:
2024     default:
2025     WARN_ON_ONCE(1);
2026     break;
2027     diff --git a/drivers/net/wireless/broadcom/brcm80211/include/brcmu_wifi.h b/drivers/net/wireless/broadcom/brcm80211/include/brcmu_wifi.h
2028     index 7b9a77981df1..75b2a0438cfa 100644
2029     --- a/drivers/net/wireless/broadcom/brcm80211/include/brcmu_wifi.h
2030     +++ b/drivers/net/wireless/broadcom/brcm80211/include/brcmu_wifi.h
2031     @@ -29,6 +29,8 @@
2032     #define CH_UPPER_SB 0x01
2033     #define CH_LOWER_SB 0x02
2034     #define CH_EWA_VALID 0x04
2035     +#define CH_70MHZ_APART 14
2036     +#define CH_50MHZ_APART 10
2037     #define CH_30MHZ_APART 6
2038     #define CH_20MHZ_APART 4
2039     #define CH_10MHZ_APART 2
2040     diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
2041     index f251c2afebfc..f45c99756aed 100644
2042     --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
2043     +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c
2044     @@ -1207,7 +1207,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2045     !(info->flags & IEEE80211_TX_STAT_AMPDU))
2046     return;
2047    
2048     - rs_rate_from_ucode_rate(tx_resp_hwrate, info->band, &tx_resp_rate);
2049     + if (rs_rate_from_ucode_rate(tx_resp_hwrate, info->band,
2050     + &tx_resp_rate)) {
2051     + WARN_ON_ONCE(1);
2052     + return;
2053     + }
2054    
2055     #ifdef CONFIG_MAC80211_DEBUGFS
2056     /* Disable last tx check if we are debugging with fixed rate but
2057     @@ -1263,7 +1267,10 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2058     */
2059     table = &lq_sta->lq;
2060     lq_hwrate = le32_to_cpu(table->rs_table[0]);
2061     - rs_rate_from_ucode_rate(lq_hwrate, info->band, &lq_rate);
2062     + if (rs_rate_from_ucode_rate(lq_hwrate, info->band, &lq_rate)) {
2063     + WARN_ON_ONCE(1);
2064     + return;
2065     + }
2066    
2067     /* Here we actually compare this rate to the latest LQ command */
2068     if (!rs_rate_equal(&tx_resp_rate, &lq_rate, allow_ant_mismatch)) {
2069     @@ -1365,8 +1372,12 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm *mvm, struct ieee80211_sta *sta,
2070     /* Collect data for each rate used during failed TX attempts */
2071     for (i = 0; i <= retries; ++i) {
2072     lq_hwrate = le32_to_cpu(table->rs_table[i]);
2073     - rs_rate_from_ucode_rate(lq_hwrate, info->band,
2074     - &lq_rate);
2075     + if (rs_rate_from_ucode_rate(lq_hwrate, info->band,
2076     + &lq_rate)) {
2077     + WARN_ON_ONCE(1);
2078     + return;
2079     + }
2080     +
2081     /*
2082     * Only collect stats if retried rate is in the same RS
2083     * table as active/search.
2084     @@ -3261,7 +3272,10 @@ static void rs_build_rates_table_from_fixed(struct iwl_mvm *mvm,
2085     for (i = 0; i < num_rates; i++)
2086     lq_cmd->rs_table[i] = ucode_rate_le32;
2087    
2088     - rs_rate_from_ucode_rate(ucode_rate, band, &rate);
2089     + if (rs_rate_from_ucode_rate(ucode_rate, band, &rate)) {
2090     + WARN_ON_ONCE(1);
2091     + return;
2092     + }
2093    
2094     if (is_mimo(&rate))
2095     lq_cmd->mimo_delim = num_rates - 1;
2096     diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2097     index 996a928142ad..e58a50d31d96 100644
2098     --- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2099     +++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
2100     @@ -1030,6 +1030,14 @@ void iwl_pcie_rx_free(struct iwl_trans *trans)
2101     kfree(trans_pcie->rxq);
2102     }
2103    
2104     +static void iwl_pcie_rx_move_to_allocator(struct iwl_rxq *rxq,
2105     + struct iwl_rb_allocator *rba)
2106     +{
2107     + spin_lock(&rba->lock);
2108     + list_splice_tail_init(&rxq->rx_used, &rba->rbd_empty);
2109     + spin_unlock(&rba->lock);
2110     +}
2111     +
2112     /*
2113     * iwl_pcie_rx_reuse_rbd - Recycle used RBDs
2114     *
2115     @@ -1061,9 +1069,7 @@ static void iwl_pcie_rx_reuse_rbd(struct iwl_trans *trans,
2116     if ((rxq->used_count % RX_CLAIM_REQ_ALLOC) == RX_POST_REQ_ALLOC) {
2117     /* Move the 2 RBDs to the allocator ownership.
2118     Allocator has another 6 from pool for the request completion*/
2119     - spin_lock(&rba->lock);
2120     - list_splice_tail_init(&rxq->rx_used, &rba->rbd_empty);
2121     - spin_unlock(&rba->lock);
2122     + iwl_pcie_rx_move_to_allocator(rxq, rba);
2123    
2124     atomic_inc(&rba->req_pending);
2125     queue_work(rba->alloc_wq, &rba->rx_alloc);
2126     @@ -1233,10 +1239,18 @@ restart:
2127     IWL_DEBUG_RX(trans, "Q %d: HW = SW = %d\n", rxq->id, r);
2128    
2129     while (i != r) {
2130     + struct iwl_rb_allocator *rba = &trans_pcie->rba;
2131     struct iwl_rx_mem_buffer *rxb;
2132     -
2133     - if (unlikely(rxq->used_count == rxq->queue_size / 2))
2134     + /* number of RBDs still waiting for page allocation */
2135     + u32 rb_pending_alloc =
2136     + atomic_read(&trans_pcie->rba.req_pending) *
2137     + RX_CLAIM_REQ_ALLOC;
2138     +
2139     + if (unlikely(rb_pending_alloc >= rxq->queue_size / 2 &&
2140     + !emergency)) {
2141     + iwl_pcie_rx_move_to_allocator(rxq, rba);
2142     emergency = true;
2143     + }
2144    
2145     if (trans->cfg->mq_rx_supported) {
2146     /*
2147     @@ -1279,17 +1293,13 @@ restart:
2148     iwl_pcie_rx_allocator_get(trans, rxq);
2149    
2150     if (rxq->used_count % RX_CLAIM_REQ_ALLOC == 0 && !emergency) {
2151     - struct iwl_rb_allocator *rba = &trans_pcie->rba;
2152     -
2153     /* Add the remaining empty RBDs for allocator use */
2154     - spin_lock(&rba->lock);
2155     - list_splice_tail_init(&rxq->rx_used, &rba->rbd_empty);
2156     - spin_unlock(&rba->lock);
2157     + iwl_pcie_rx_move_to_allocator(rxq, rba);
2158     } else if (emergency) {
2159     count++;
2160     if (count == 8) {
2161     count = 0;
2162     - if (rxq->used_count < rxq->queue_size / 3)
2163     + if (rb_pending_alloc < rxq->queue_size / 3)
2164     emergency = false;
2165    
2166     rxq->read = i;
2167     diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c
2168     index aba0c9995b14..a605d569f663 100644
2169     --- a/drivers/net/wireless/marvell/libertas/if_usb.c
2170     +++ b/drivers/net/wireless/marvell/libertas/if_usb.c
2171     @@ -468,8 +468,6 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
2172     MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn,
2173     cardp);
2174    
2175     - cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
2176     -
2177     lbs_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb);
2178     if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) {
2179     lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB failed: %d\n", ret);
2180     diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
2181     index de6d3b749c60..5768a4749564 100644
2182     --- a/drivers/nvdimm/bus.c
2183     +++ b/drivers/nvdimm/bus.c
2184     @@ -424,6 +424,8 @@ static void nd_async_device_register(void *d, async_cookie_t cookie)
2185     put_device(dev);
2186     }
2187     put_device(dev);
2188     + if (dev->parent)
2189     + put_device(dev->parent);
2190     }
2191    
2192     static void nd_async_device_unregister(void *d, async_cookie_t cookie)
2193     @@ -443,6 +445,8 @@ void __nd_device_register(struct device *dev)
2194     if (!dev)
2195     return;
2196     dev->bus = &nvdimm_bus_type;
2197     + if (dev->parent)
2198     + get_device(dev->parent);
2199     get_device(dev);
2200     async_schedule_domain(nd_async_device_register, dev,
2201     &nd_async_domain);
2202     diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
2203     index 0e9a9dbeb184..37f393f27efc 100644
2204     --- a/drivers/pci/msi.c
2205     +++ b/drivers/pci/msi.c
2206     @@ -981,7 +981,6 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
2207     }
2208     }
2209     }
2210     - WARN_ON(!!dev->msix_enabled);
2211    
2212     /* Check whether driver already requested for MSI irq */
2213     if (dev->msi_enabled) {
2214     @@ -1068,8 +1067,6 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
2215     if (!pci_msi_supported(dev, minvec))
2216     return -EINVAL;
2217    
2218     - WARN_ON(!!dev->msi_enabled);
2219     -
2220     /* Check whether driver already requested MSI-X irqs */
2221     if (dev->msix_enabled) {
2222     dev_info(&dev->dev,
2223     @@ -1080,6 +1077,9 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
2224     if (maxvec < minvec)
2225     return -ERANGE;
2226    
2227     + if (WARN_ON_ONCE(dev->msi_enabled))
2228     + return -EINVAL;
2229     +
2230     nvec = pci_msi_vec_count(dev);
2231     if (nvec < 0)
2232     return nvec;
2233     @@ -1138,6 +1138,9 @@ static int __pci_enable_msix_range(struct pci_dev *dev,
2234     if (maxvec < minvec)
2235     return -ERANGE;
2236    
2237     + if (WARN_ON_ONCE(dev->msix_enabled))
2238     + return -EINVAL;
2239     +
2240     for (;;) {
2241     if (affinity) {
2242     nvec = irq_calc_affinity_vectors(dev->irq_affinity,
2243     diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2244     index 2250f0d33481..dedb12083d86 100644
2245     --- a/drivers/pci/quirks.c
2246     +++ b/drivers/pci/quirks.c
2247     @@ -3124,7 +3124,11 @@ static void disable_igfx_irq(struct pci_dev *dev)
2248    
2249     pci_iounmap(dev, regs);
2250     }
2251     +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0042, disable_igfx_irq);
2252     +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0046, disable_igfx_irq);
2253     +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x004a, disable_igfx_irq);
2254     DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
2255     +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0106, disable_igfx_irq);
2256     DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
2257     DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq);
2258    
2259     diff --git a/drivers/pcmcia/ricoh.h b/drivers/pcmcia/ricoh.h
2260     index 01098c841f87..8ac7b138c094 100644
2261     --- a/drivers/pcmcia/ricoh.h
2262     +++ b/drivers/pcmcia/ricoh.h
2263     @@ -119,6 +119,10 @@
2264     #define RL5C4XX_MISC_CONTROL 0x2F /* 8 bit */
2265     #define RL5C4XX_ZV_ENABLE 0x08
2266    
2267     +/* Misc Control 3 Register */
2268     +#define RL5C4XX_MISC3 0x00A2 /* 16 bit */
2269     +#define RL5C47X_MISC3_CB_CLKRUN_DIS BIT(1)
2270     +
2271     #ifdef __YENTA_H
2272    
2273     #define rl_misc(socket) ((socket)->private[0])
2274     @@ -156,6 +160,35 @@ static void ricoh_set_zv(struct yenta_socket *socket)
2275     }
2276     }
2277    
2278     +static void ricoh_set_clkrun(struct yenta_socket *socket, bool quiet)
2279     +{
2280     + u16 misc3;
2281     +
2282     + /*
2283     + * RL5C475II likely has this setting, too, however no datasheet
2284     + * is publicly available for this chip
2285     + */
2286     + if (socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C476 &&
2287     + socket->dev->device != PCI_DEVICE_ID_RICOH_RL5C478)
2288     + return;
2289     +
2290     + if (socket->dev->revision < 0x80)
2291     + return;
2292     +
2293     + misc3 = config_readw(socket, RL5C4XX_MISC3);
2294     + if (misc3 & RL5C47X_MISC3_CB_CLKRUN_DIS) {
2295     + if (!quiet)
2296     + dev_dbg(&socket->dev->dev,
2297     + "CLKRUN feature already disabled\n");
2298     + } else if (disable_clkrun) {
2299     + if (!quiet)
2300     + dev_info(&socket->dev->dev,
2301     + "Disabling CLKRUN feature\n");
2302     + misc3 |= RL5C47X_MISC3_CB_CLKRUN_DIS;
2303     + config_writew(socket, RL5C4XX_MISC3, misc3);
2304     + }
2305     +}
2306     +
2307     static void ricoh_save_state(struct yenta_socket *socket)
2308     {
2309     rl_misc(socket) = config_readw(socket, RL5C4XX_MISC);
2310     @@ -172,6 +205,7 @@ static void ricoh_restore_state(struct yenta_socket *socket)
2311     config_writew(socket, RL5C4XX_16BIT_IO_0, rl_io(socket));
2312     config_writew(socket, RL5C4XX_16BIT_MEM_0, rl_mem(socket));
2313     config_writew(socket, RL5C4XX_CONFIG, rl_config(socket));
2314     + ricoh_set_clkrun(socket, true);
2315     }
2316    
2317    
2318     @@ -197,6 +231,7 @@ static int ricoh_override(struct yenta_socket *socket)
2319     config_writew(socket, RL5C4XX_CONFIG, config);
2320    
2321     ricoh_set_zv(socket);
2322     + ricoh_set_clkrun(socket, false);
2323    
2324     return 0;
2325     }
2326     diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
2327     index 5d6d9b1549bc..5034422a1d96 100644
2328     --- a/drivers/pcmcia/yenta_socket.c
2329     +++ b/drivers/pcmcia/yenta_socket.c
2330     @@ -26,7 +26,8 @@
2331    
2332     static bool disable_clkrun;
2333     module_param(disable_clkrun, bool, 0444);
2334     -MODULE_PARM_DESC(disable_clkrun, "If PC card doesn't function properly, please try this option");
2335     +MODULE_PARM_DESC(disable_clkrun,
2336     + "If PC card doesn't function properly, please try this option (TI and Ricoh bridges only)");
2337    
2338     static bool isa_probe = 1;
2339     module_param(isa_probe, bool, 0444);
2340     diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
2341     index 6556dbeae65e..ac251c62bc66 100644
2342     --- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
2343     +++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
2344     @@ -319,6 +319,8 @@ static int pmic_mpp_set_mux(struct pinctrl_dev *pctldev, unsigned function,
2345     pad->function = function;
2346    
2347     ret = pmic_mpp_write_mode_ctl(state, pad);
2348     + if (ret < 0)
2349     + return ret;
2350    
2351     val = pad->is_enabled << PMIC_MPP_REG_MASTER_EN_SHIFT;
2352    
2353     @@ -343,13 +345,12 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
2354    
2355     switch (param) {
2356     case PIN_CONFIG_BIAS_DISABLE:
2357     - arg = pad->pullup == PMIC_MPP_PULL_UP_OPEN;
2358     + if (pad->pullup != PMIC_MPP_PULL_UP_OPEN)
2359     + return -EINVAL;
2360     + arg = 1;
2361     break;
2362     case PIN_CONFIG_BIAS_PULL_UP:
2363     switch (pad->pullup) {
2364     - case PMIC_MPP_PULL_UP_OPEN:
2365     - arg = 0;
2366     - break;
2367     case PMIC_MPP_PULL_UP_0P6KOHM:
2368     arg = 600;
2369     break;
2370     @@ -364,13 +365,17 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
2371     }
2372     break;
2373     case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
2374     - arg = !pad->is_enabled;
2375     + if (pad->is_enabled)
2376     + return -EINVAL;
2377     + arg = 1;
2378     break;
2379     case PIN_CONFIG_POWER_SOURCE:
2380     arg = pad->power_source;
2381     break;
2382     case PIN_CONFIG_INPUT_ENABLE:
2383     - arg = pad->input_enabled;
2384     + if (!pad->input_enabled)
2385     + return -EINVAL;
2386     + arg = 1;
2387     break;
2388     case PIN_CONFIG_OUTPUT:
2389     arg = pad->out_value;
2390     @@ -382,7 +387,9 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
2391     arg = pad->amux_input;
2392     break;
2393     case PMIC_MPP_CONF_PAIRED:
2394     - arg = pad->paired;
2395     + if (!pad->paired)
2396     + return -EINVAL;
2397     + arg = 1;
2398     break;
2399     case PIN_CONFIG_DRIVE_STRENGTH:
2400     arg = pad->drive_strength;
2401     @@ -455,7 +462,7 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
2402     pad->dtest = arg;
2403     break;
2404     case PIN_CONFIG_DRIVE_STRENGTH:
2405     - arg = pad->drive_strength;
2406     + pad->drive_strength = arg;
2407     break;
2408     case PMIC_MPP_CONF_AMUX_ROUTE:
2409     if (arg >= PMIC_MPP_AMUX_ROUTE_ABUS4)
2410     @@ -502,6 +509,10 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
2411     if (ret < 0)
2412     return ret;
2413    
2414     + ret = pmic_mpp_write(state, pad, PMIC_MPP_REG_SINK_CTL, pad->drive_strength);
2415     + if (ret < 0)
2416     + return ret;
2417     +
2418     val = pad->is_enabled << PMIC_MPP_REG_MASTER_EN_SHIFT;
2419    
2420     return pmic_mpp_write(state, pad, PMIC_MPP_REG_EN_CTL, val);
2421     diff --git a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
2422     index d3f5501d17ee..e86c4de2f6db 100644
2423     --- a/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
2424     +++ b/drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
2425     @@ -260,22 +260,32 @@ static int pm8xxx_pin_config_get(struct pinctrl_dev *pctldev,
2426    
2427     switch (param) {
2428     case PIN_CONFIG_BIAS_DISABLE:
2429     - arg = pin->bias == PM8XXX_GPIO_BIAS_NP;
2430     + if (pin->bias != PM8XXX_GPIO_BIAS_NP)
2431     + return -EINVAL;
2432     + arg = 1;
2433     break;
2434     case PIN_CONFIG_BIAS_PULL_DOWN:
2435     - arg = pin->bias == PM8XXX_GPIO_BIAS_PD;
2436     + if (pin->bias != PM8XXX_GPIO_BIAS_PD)
2437     + return -EINVAL;
2438     + arg = 1;
2439     break;
2440     case PIN_CONFIG_BIAS_PULL_UP:
2441     - arg = pin->bias <= PM8XXX_GPIO_BIAS_PU_1P5_30;
2442     + if (pin->bias > PM8XXX_GPIO_BIAS_PU_1P5_30)
2443     + return -EINVAL;
2444     + arg = 1;
2445     break;
2446     case PM8XXX_QCOM_PULL_UP_STRENGTH:
2447     arg = pin->pull_up_strength;
2448     break;
2449     case PIN_CONFIG_BIAS_HIGH_IMPEDANCE:
2450     - arg = pin->disable;
2451     + if (!pin->disable)
2452     + return -EINVAL;
2453     + arg = 1;
2454     break;
2455     case PIN_CONFIG_INPUT_ENABLE:
2456     - arg = pin->mode == PM8XXX_GPIO_MODE_INPUT;
2457     + if (pin->mode != PM8XXX_GPIO_MODE_INPUT)
2458     + return -EINVAL;
2459     + arg = 1;
2460     break;
2461     case PIN_CONFIG_OUTPUT:
2462     if (pin->mode & PM8XXX_GPIO_MODE_OUTPUT)
2463     @@ -290,10 +300,14 @@ static int pm8xxx_pin_config_get(struct pinctrl_dev *pctldev,
2464     arg = pin->output_strength;
2465     break;
2466     case PIN_CONFIG_DRIVE_PUSH_PULL:
2467     - arg = !pin->open_drain;
2468     + if (pin->open_drain)
2469     + return -EINVAL;
2470     + arg = 1;
2471     break;
2472     case PIN_CONFIG_DRIVE_OPEN_DRAIN:
2473     - arg = pin->open_drain;
2474     + if (!pin->open_drain)
2475     + return -EINVAL;
2476     + arg = 1;
2477     break;
2478     default:
2479     return -EINVAL;
2480     diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
2481     index fd3d9419c468..312cb7fec5b0 100644
2482     --- a/drivers/rpmsg/qcom_smd.c
2483     +++ b/drivers/rpmsg/qcom_smd.c
2484     @@ -1012,8 +1012,10 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
2485    
2486     channel->edge = edge;
2487     channel->name = kstrdup(name, GFP_KERNEL);
2488     - if (!channel->name)
2489     - return ERR_PTR(-ENOMEM);
2490     + if (!channel->name) {
2491     + ret = -ENOMEM;
2492     + goto free_channel;
2493     + }
2494    
2495     mutex_init(&channel->tx_lock);
2496     spin_lock_init(&channel->recv_lock);
2497     @@ -1062,6 +1064,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
2498    
2499     free_name_and_channel:
2500     kfree(channel->name);
2501     +free_channel:
2502     kfree(channel);
2503    
2504     return ERR_PTR(ret);
2505     diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
2506     index 71cb05b1c3eb..60be0742e2c8 100644
2507     --- a/drivers/scsi/esp_scsi.c
2508     +++ b/drivers/scsi/esp_scsi.c
2509     @@ -1349,6 +1349,7 @@ static int esp_data_bytes_sent(struct esp *esp, struct esp_cmd_entry *ent,
2510    
2511     bytes_sent = esp->data_dma_len;
2512     bytes_sent -= ecount;
2513     + bytes_sent -= esp->send_cmd_residual;
2514    
2515     /*
2516     * The am53c974 has a DMA 'pecularity'. The doc states:
2517     diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
2518     index 84dcbe4a6268..55be43fe7667 100644
2519     --- a/drivers/scsi/esp_scsi.h
2520     +++ b/drivers/scsi/esp_scsi.h
2521     @@ -540,6 +540,8 @@ struct esp {
2522    
2523     void *dma;
2524     int dmarev;
2525     +
2526     + u32 send_cmd_residual;
2527     };
2528    
2529     /* A front-end driver for the ESP chip should do the following in
2530     diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
2531     index 6df06e716da1..c05fc61a383b 100644
2532     --- a/drivers/scsi/lpfc/lpfc_sli.c
2533     +++ b/drivers/scsi/lpfc/lpfc_sli.c
2534     @@ -3512,6 +3512,7 @@ lpfc_sli_handle_slow_ring_event_s4(struct lpfc_hba *phba,
2535     struct hbq_dmabuf *dmabuf;
2536     struct lpfc_cq_event *cq_event;
2537     unsigned long iflag;
2538     + int count = 0;
2539    
2540     spin_lock_irqsave(&phba->hbalock, iflag);
2541     phba->hba_flag &= ~HBA_SP_QUEUE_EVT;
2542     @@ -3533,16 +3534,22 @@ lpfc_sli_handle_slow_ring_event_s4(struct lpfc_hba *phba,
2543     if (irspiocbq)
2544     lpfc_sli_sp_handle_rspiocb(phba, pring,
2545     irspiocbq);
2546     + count++;
2547     break;
2548     case CQE_CODE_RECEIVE:
2549     case CQE_CODE_RECEIVE_V1:
2550     dmabuf = container_of(cq_event, struct hbq_dmabuf,
2551     cq_event);
2552     lpfc_sli4_handle_received_buffer(phba, dmabuf);
2553     + count++;
2554     break;
2555     default:
2556     break;
2557     }
2558     +
2559     + /* Limit the number of events to 64 to avoid soft lockups */
2560     + if (count == 64)
2561     + break;
2562     }
2563     }
2564    
2565     diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
2566     index 26c67c42985c..1002124bd8bf 100644
2567     --- a/drivers/scsi/mac_esp.c
2568     +++ b/drivers/scsi/mac_esp.c
2569     @@ -426,6 +426,8 @@ static void mac_esp_send_pio_cmd(struct esp *esp, u32 addr, u32 esp_count,
2570     scsi_esp_cmd(esp, ESP_CMD_TI);
2571     }
2572     }
2573     +
2574     + esp->send_cmd_residual = esp_count;
2575     }
2576    
2577     static int mac_esp_irq_pending(struct esp *esp)
2578     diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
2579     index 090fdcdd15c9..5de024a50e15 100644
2580     --- a/drivers/scsi/megaraid/megaraid_sas_base.c
2581     +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
2582     @@ -6901,6 +6901,9 @@ static int megasas_mgmt_compat_ioctl_fw(struct file *file, unsigned long arg)
2583     get_user(user_sense_off, &cioc->sense_off))
2584     return -EFAULT;
2585    
2586     + if (local_sense_off != user_sense_off)
2587     + return -EINVAL;
2588     +
2589     if (local_sense_len) {
2590     void __user **sense_ioc_ptr =
2591     (void __user **)((u8 *)((unsigned long)&ioc->frame.raw) + local_sense_off);
2592     diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
2593     index 7792ed88d80b..9685f9b8be07 100644
2594     --- a/drivers/soc/tegra/pmc.c
2595     +++ b/drivers/soc/tegra/pmc.c
2596     @@ -1189,7 +1189,7 @@ static void tegra_pmc_init_tsense_reset(struct tegra_pmc *pmc)
2597     if (!pmc->soc->has_tsense_reset)
2598     return;
2599    
2600     - np = of_find_node_by_name(pmc->dev->of_node, "i2c-thermtrip");
2601     + np = of_get_child_by_name(pmc->dev->of_node, "i2c-thermtrip");
2602     if (!np) {
2603     dev_warn(dev, "i2c-thermtrip node not found, %s.\n", disabled);
2604     return;
2605     diff --git a/drivers/tc/tc.c b/drivers/tc/tc.c
2606     index 3be9519654e5..cf3fad2cb871 100644
2607     --- a/drivers/tc/tc.c
2608     +++ b/drivers/tc/tc.c
2609     @@ -2,7 +2,7 @@
2610     * TURBOchannel bus services.
2611     *
2612     * Copyright (c) Harald Koerfgen, 1998
2613     - * Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki
2614     + * Copyright (c) 2001, 2003, 2005, 2006, 2018 Maciej W. Rozycki
2615     * Copyright (c) 2005 James Simmons
2616     *
2617     * This file is subject to the terms and conditions of the GNU
2618     @@ -10,6 +10,7 @@
2619     * directory of this archive for more details.
2620     */
2621     #include <linux/compiler.h>
2622     +#include <linux/dma-mapping.h>
2623     #include <linux/errno.h>
2624     #include <linux/init.h>
2625     #include <linux/ioport.h>
2626     @@ -92,6 +93,11 @@ static void __init tc_bus_add_devices(struct tc_bus *tbus)
2627     tdev->dev.bus = &tc_bus_type;
2628     tdev->slot = slot;
2629    
2630     + /* TURBOchannel has 34-bit DMA addressing (16GiB space). */
2631     + tdev->dma_mask = DMA_BIT_MASK(34);
2632     + tdev->dev.dma_mask = &tdev->dma_mask;
2633     + tdev->dev.coherent_dma_mask = DMA_BIT_MASK(34);
2634     +
2635     for (i = 0; i < 8; i++) {
2636     tdev->firmware[i] =
2637     readb(module + offset + TC_FIRM_VER + 4 * i);
2638     diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
2639     index a260cde743e2..2db68dfe497d 100644
2640     --- a/drivers/tty/serial/kgdboc.c
2641     +++ b/drivers/tty/serial/kgdboc.c
2642     @@ -133,6 +133,11 @@ static void kgdboc_unregister_kbd(void)
2643    
2644     static int kgdboc_option_setup(char *opt)
2645     {
2646     + if (!opt) {
2647     + pr_err("kgdboc: config string not provided\n");
2648     + return -EINVAL;
2649     + }
2650     +
2651     if (strlen(opt) >= MAX_CONFIG_LEN) {
2652     printk(KERN_ERR "kgdboc: config string too long\n");
2653     return -ENOSPC;
2654     diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
2655     index f0a9ea2740df..cfbfef08c94a 100644
2656     --- a/drivers/uio/uio.c
2657     +++ b/drivers/uio/uio.c
2658     @@ -249,6 +249,8 @@ static struct class uio_class = {
2659     .dev_groups = uio_groups,
2660     };
2661    
2662     +bool uio_class_registered;
2663     +
2664     /*
2665     * device functions
2666     */
2667     @@ -780,6 +782,9 @@ static int init_uio_class(void)
2668     printk(KERN_ERR "class_register failed for uio\n");
2669     goto err_class_register;
2670     }
2671     +
2672     + uio_class_registered = true;
2673     +
2674     return 0;
2675    
2676     err_class_register:
2677     @@ -790,6 +795,7 @@ exit:
2678    
2679     static void release_uio_class(void)
2680     {
2681     + uio_class_registered = false;
2682     class_unregister(&uio_class);
2683     uio_major_cleanup();
2684     }
2685     @@ -809,6 +815,9 @@ int __uio_register_device(struct module *owner,
2686     struct uio_device *idev;
2687     int ret = 0;
2688    
2689     + if (!uio_class_registered)
2690     + return -EPROBE_DEFER;
2691     +
2692     if (!parent || !info || !info->name || !info->version)
2693     return -EINVAL;
2694    
2695     diff --git a/drivers/usb/chipidea/otg.h b/drivers/usb/chipidea/otg.h
2696     index 9ecb598e48f0..a5557c70034a 100644
2697     --- a/drivers/usb/chipidea/otg.h
2698     +++ b/drivers/usb/chipidea/otg.h
2699     @@ -20,7 +20,8 @@ void ci_handle_vbus_change(struct ci_hdrc *ci);
2700     static inline void ci_otg_queue_work(struct ci_hdrc *ci)
2701     {
2702     disable_irq_nosync(ci->irq);
2703     - queue_work(ci->wq, &ci->work);
2704     + if (queue_work(ci->wq, &ci->work) == false)
2705     + enable_irq(ci->irq);
2706     }
2707    
2708     #endif /* __DRIVERS_USB_CHIPIDEA_OTG_H */
2709     diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
2710     index ad8402906f77..9705bcdbc577 100644
2711     --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
2712     +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
2713     @@ -1922,6 +1922,8 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
2714    
2715     udc->errata = match->data;
2716     udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc");
2717     + if (IS_ERR(udc->pmc))
2718     + udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9rl-pmc");
2719     if (IS_ERR(udc->pmc))
2720     udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9x5-pmc");
2721     if (udc->errata && IS_ERR(udc->pmc))
2722     diff --git a/drivers/usb/usbip/vudc_main.c b/drivers/usb/usbip/vudc_main.c
2723     index 9e655714e389..916e2eefc886 100644
2724     --- a/drivers/usb/usbip/vudc_main.c
2725     +++ b/drivers/usb/usbip/vudc_main.c
2726     @@ -85,6 +85,10 @@ static int __init init(void)
2727     cleanup:
2728     list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
2729     list_del(&udc_dev->dev_entry);
2730     + /*
2731     + * Just do platform_device_del() here, put_vudc_device()
2732     + * calls the platform_device_put()
2733     + */
2734     platform_device_del(udc_dev->pdev);
2735     put_vudc_device(udc_dev);
2736     }
2737     @@ -101,7 +105,11 @@ static void __exit cleanup(void)
2738    
2739     list_for_each_entry_safe(udc_dev, udc_dev2, &vudc_devices, dev_entry) {
2740     list_del(&udc_dev->dev_entry);
2741     - platform_device_unregister(udc_dev->pdev);
2742     + /*
2743     + * Just do platform_device_del() here, put_vudc_device()
2744     + * calls the platform_device_put()
2745     + */
2746     + platform_device_del(udc_dev->pdev);
2747     put_vudc_device(udc_dev);
2748     }
2749     platform_driver_unregister(&vudc_driver);
2750     diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
2751     index bb09de633939..86637fec4eaa 100644
2752     --- a/drivers/w1/masters/omap_hdq.c
2753     +++ b/drivers/w1/masters/omap_hdq.c
2754     @@ -784,6 +784,8 @@ static int omap_hdq_remove(struct platform_device *pdev)
2755     /* remove module dependency */
2756     pm_runtime_disable(&pdev->dev);
2757    
2758     + w1_remove_master_device(&omap_w1_master);
2759     +
2760     return 0;
2761     }
2762    
2763     diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c
2764     index 2fe7353ab720..5d04b362837d 100644
2765     --- a/drivers/xen/swiotlb-xen.c
2766     +++ b/drivers/xen/swiotlb-xen.c
2767     @@ -310,6 +310,9 @@ xen_swiotlb_alloc_coherent(struct device *hwdev, size_t size,
2768     */
2769     flags &= ~(__GFP_DMA | __GFP_HIGHMEM);
2770    
2771     + /* Convert the size to actually allocated. */
2772     + size = 1UL << (order + XEN_PAGE_SHIFT);
2773     +
2774     /* On ARM this function returns an ioremap'ped virtual address for
2775     * which virt_to_phys doesn't return the corresponding physical
2776     * address. In fact on ARM virt_to_phys only works for kernel direct
2777     @@ -359,6 +362,9 @@ xen_swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
2778     * physical address */
2779     phys = xen_bus_to_phys(dev_addr);
2780    
2781     + /* Convert the size to actually allocated. */
2782     + size = 1UL << (order + XEN_PAGE_SHIFT);
2783     +
2784     if (((dev_addr + size - 1 <= dma_mask)) ||
2785     range_straddles_page_boundary(phys, size))
2786     xen_destroy_contiguous_region(phys, order);
2787     diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
2788     index 6661116c47d9..163b61a92b59 100644
2789     --- a/fs/btrfs/extent-tree.c
2790     +++ b/fs/btrfs/extent-tree.c
2791     @@ -8263,6 +8263,19 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
2792     if (IS_ERR(buf))
2793     return buf;
2794    
2795     + /*
2796     + * Extra safety check in case the extent tree is corrupted and extent
2797     + * allocator chooses to use a tree block which is already used and
2798     + * locked.
2799     + */
2800     + if (buf->lock_owner == current->pid) {
2801     + btrfs_err_rl(root->fs_info,
2802     +"tree block %llu owner %llu already locked by pid=%d, extent tree corruption detected",
2803     + buf->start, btrfs_header_owner(buf), current->pid);
2804     + free_extent_buffer(buf);
2805     + return ERR_PTR(-EUCLEAN);
2806     + }
2807     +
2808     btrfs_set_header_generation(buf, trans->transid);
2809     btrfs_set_buffer_lockdep_class(root->root_key.objectid, buf, level);
2810     btrfs_tree_lock(buf);
2811     @@ -9100,15 +9113,14 @@ static noinline int walk_up_proc(struct btrfs_trans_handle *trans,
2812     if (eb == root->node) {
2813     if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
2814     parent = eb->start;
2815     - else
2816     - BUG_ON(root->root_key.objectid !=
2817     - btrfs_header_owner(eb));
2818     + else if (root->root_key.objectid != btrfs_header_owner(eb))
2819     + goto owner_mismatch;
2820     } else {
2821     if (wc->flags[level + 1] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
2822     parent = path->nodes[level + 1]->start;
2823     - else
2824     - BUG_ON(root->root_key.objectid !=
2825     - btrfs_header_owner(path->nodes[level + 1]));
2826     + else if (root->root_key.objectid !=
2827     + btrfs_header_owner(path->nodes[level + 1]))
2828     + goto owner_mismatch;
2829     }
2830    
2831     btrfs_free_tree_block(trans, root, eb, parent, wc->refs[level] == 1);
2832     @@ -9116,6 +9128,11 @@ out:
2833     wc->refs[level] = 0;
2834     wc->flags[level] = 0;
2835     return 0;
2836     +
2837     +owner_mismatch:
2838     + btrfs_err_rl(root->fs_info, "unexpected tree owner, have %llu expect %llu",
2839     + btrfs_header_owner(eb), root->root_key.objectid);
2840     + return -EUCLEAN;
2841     }
2842    
2843     static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
2844     @@ -9169,6 +9186,8 @@ static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
2845     ret = walk_up_proc(trans, root, path, wc);
2846     if (ret > 0)
2847     return 0;
2848     + if (ret < 0)
2849     + return ret;
2850    
2851     if (path->locks[level]) {
2852     btrfs_tree_unlock_rw(path->nodes[level],
2853     @@ -9933,6 +9952,7 @@ void btrfs_put_block_group_cache(struct btrfs_fs_info *info)
2854    
2855     block_group = btrfs_lookup_first_block_group(info, last);
2856     while (block_group) {
2857     + wait_block_group_cache_done(block_group);
2858     spin_lock(&block_group->lock);
2859     if (block_group->iref)
2860     break;
2861     @@ -10332,7 +10352,7 @@ error:
2862     void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
2863     struct btrfs_root *root)
2864     {
2865     - struct btrfs_block_group_cache *block_group, *tmp;
2866     + struct btrfs_block_group_cache *block_group;
2867     struct btrfs_root *extent_root = root->fs_info->extent_root;
2868     struct btrfs_block_group_item item;
2869     struct btrfs_key key;
2870     @@ -10340,7 +10360,10 @@ void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans,
2871     bool can_flush_pending_bgs = trans->can_flush_pending_bgs;
2872    
2873     trans->can_flush_pending_bgs = false;
2874     - list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) {
2875     + while (!list_empty(&trans->new_bgs)) {
2876     + block_group = list_first_entry(&trans->new_bgs,
2877     + struct btrfs_block_group_cache,
2878     + bg_list);
2879     if (ret)
2880     goto next;
2881    
2882     @@ -11052,6 +11075,10 @@ static int btrfs_trim_free_extents(struct btrfs_device *device,
2883    
2884     *trimmed = 0;
2885    
2886     + /* Discard not supported = nothing to do. */
2887     + if (!blk_queue_discard(bdev_get_queue(device->bdev)))
2888     + return 0;
2889     +
2890     /* Not writeable = nothing to do. */
2891     if (!device->writeable)
2892     return 0;
2893     @@ -11174,8 +11201,8 @@ int btrfs_trim_fs(struct btrfs_root *root, struct fstrim_range *range)
2894     }
2895    
2896     mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
2897     - devices = &root->fs_info->fs_devices->alloc_list;
2898     - list_for_each_entry(device, devices, dev_alloc_list) {
2899     + devices = &root->fs_info->fs_devices->devices;
2900     + list_for_each_entry(device, devices, dev_list) {
2901     ret = btrfs_trim_free_extents(device, range->minlen,
2902     &group_trimmed);
2903     if (ret)
2904     diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
2905     index c56253a1e5b4..5ca0dbb9074d 100644
2906     --- a/fs/btrfs/free-space-cache.c
2907     +++ b/fs/btrfs/free-space-cache.c
2908     @@ -1693,6 +1693,8 @@ static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
2909     bitmap_clear(info->bitmap, start, count);
2910    
2911     info->bytes -= bytes;
2912     + if (info->max_extent_size > ctl->unit)
2913     + info->max_extent_size = 0;
2914     }
2915    
2916     static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
2917     @@ -1776,6 +1778,13 @@ static int search_bitmap(struct btrfs_free_space_ctl *ctl,
2918     return -1;
2919     }
2920    
2921     +static inline u64 get_max_extent_size(struct btrfs_free_space *entry)
2922     +{
2923     + if (entry->bitmap)
2924     + return entry->max_extent_size;
2925     + return entry->bytes;
2926     +}
2927     +
2928     /* Cache the size of the max extent in bytes */
2929     static struct btrfs_free_space *
2930     find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2931     @@ -1797,8 +1806,8 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2932     for (node = &entry->offset_index; node; node = rb_next(node)) {
2933     entry = rb_entry(node, struct btrfs_free_space, offset_index);
2934     if (entry->bytes < *bytes) {
2935     - if (entry->bytes > *max_extent_size)
2936     - *max_extent_size = entry->bytes;
2937     + *max_extent_size = max(get_max_extent_size(entry),
2938     + *max_extent_size);
2939     continue;
2940     }
2941    
2942     @@ -1816,8 +1825,8 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2943     }
2944    
2945     if (entry->bytes < *bytes + align_off) {
2946     - if (entry->bytes > *max_extent_size)
2947     - *max_extent_size = entry->bytes;
2948     + *max_extent_size = max(get_max_extent_size(entry),
2949     + *max_extent_size);
2950     continue;
2951     }
2952    
2953     @@ -1829,8 +1838,10 @@ find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
2954     *offset = tmp;
2955     *bytes = size;
2956     return entry;
2957     - } else if (size > *max_extent_size) {
2958     - *max_extent_size = size;
2959     + } else {
2960     + *max_extent_size =
2961     + max(get_max_extent_size(entry),
2962     + *max_extent_size);
2963     }
2964     continue;
2965     }
2966     @@ -2689,8 +2700,8 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group,
2967    
2968     err = search_bitmap(ctl, entry, &search_start, &search_bytes, true);
2969     if (err) {
2970     - if (search_bytes > *max_extent_size)
2971     - *max_extent_size = search_bytes;
2972     + *max_extent_size = max(get_max_extent_size(entry),
2973     + *max_extent_size);
2974     return 0;
2975     }
2976    
2977     @@ -2727,8 +2738,9 @@ u64 btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group,
2978    
2979     entry = rb_entry(node, struct btrfs_free_space, offset_index);
2980     while (1) {
2981     - if (entry->bytes < bytes && entry->bytes > *max_extent_size)
2982     - *max_extent_size = entry->bytes;
2983     + if (entry->bytes < bytes)
2984     + *max_extent_size = max(get_max_extent_size(entry),
2985     + *max_extent_size);
2986    
2987     if (entry->bytes < bytes ||
2988     (!entry->bitmap && entry->offset < min_start)) {
2989     diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
2990     index 5ebdb58079e1..17e143d91fa9 100644
2991     --- a/fs/btrfs/inode.c
2992     +++ b/fs/btrfs/inode.c
2993     @@ -489,6 +489,7 @@ again:
2994     pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
2995     if (!pages) {
2996     /* just bail out to the uncompressed code */
2997     + nr_pages = 0;
2998     goto cont;
2999     }
3000    
3001     diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
3002     index 9afad8c14220..f25233093d68 100644
3003     --- a/fs/btrfs/qgroup.c
3004     +++ b/fs/btrfs/qgroup.c
3005     @@ -2498,6 +2498,7 @@ qgroup_rescan_zero_tracking(struct btrfs_fs_info *fs_info)
3006     qgroup->rfer_cmpr = 0;
3007     qgroup->excl = 0;
3008     qgroup->excl_cmpr = 0;
3009     + qgroup_dirty(fs_info, qgroup);
3010     }
3011     spin_unlock(&fs_info->qgroup_lock);
3012     }
3013     diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
3014     index 9140aede5869..b0c3a6afe664 100644
3015     --- a/fs/btrfs/relocation.c
3016     +++ b/fs/btrfs/relocation.c
3017     @@ -1325,7 +1325,7 @@ static void __del_reloc_root(struct btrfs_root *root)
3018     struct mapping_node *node = NULL;
3019     struct reloc_control *rc = root->fs_info->reloc_ctl;
3020    
3021     - if (rc) {
3022     + if (rc && root->node) {
3023     spin_lock(&rc->reloc_root_tree.lock);
3024     rb_node = tree_search(&rc->reloc_root_tree.rb_root,
3025     root->node->start);
3026     diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
3027     index 44966fd00790..47d11a30bee7 100644
3028     --- a/fs/btrfs/tree-log.c
3029     +++ b/fs/btrfs/tree-log.c
3030     @@ -3016,9 +3016,12 @@ static void free_log_tree(struct btrfs_trans_handle *trans,
3031     };
3032    
3033     ret = walk_log_tree(trans, log, &wc);
3034     - /* I don't think this can happen but just in case */
3035     - if (ret)
3036     - btrfs_abort_transaction(trans, ret);
3037     + if (ret) {
3038     + if (trans)
3039     + btrfs_abort_transaction(trans, ret);
3040     + else
3041     + btrfs_handle_fs_error(log->fs_info, ret, NULL);
3042     + }
3043    
3044     while (1) {
3045     ret = find_first_extent_bit(&log->dirty_log_pages,
3046     @@ -5370,9 +5373,33 @@ static int btrfs_log_all_parents(struct btrfs_trans_handle *trans,
3047    
3048     dir_inode = btrfs_iget(root->fs_info->sb, &inode_key,
3049     root, NULL);
3050     - /* If parent inode was deleted, skip it. */
3051     - if (IS_ERR(dir_inode))
3052     - continue;
3053     + /*
3054     + * If the parent inode was deleted, return an error to
3055     + * fallback to a transaction commit. This is to prevent
3056     + * getting an inode that was moved from one parent A to
3057     + * a parent B, got its former parent A deleted and then
3058     + * it got fsync'ed, from existing at both parents after
3059     + * a log replay (and the old parent still existing).
3060     + * Example:
3061     + *
3062     + * mkdir /mnt/A
3063     + * mkdir /mnt/B
3064     + * touch /mnt/B/bar
3065     + * sync
3066     + * mv /mnt/B/bar /mnt/A/bar
3067     + * mv -T /mnt/A /mnt/B
3068     + * fsync /mnt/B/bar
3069     + * <power fail>
3070     + *
3071     + * If we ignore the old parent B which got deleted,
3072     + * after a log replay we would have file bar linked
3073     + * at both parents and the old parent B would still
3074     + * exist.
3075     + */
3076     + if (IS_ERR(dir_inode)) {
3077     + ret = PTR_ERR(dir_inode);
3078     + goto out;
3079     + }
3080    
3081     if (ctx)
3082     ctx->log_new_dentries = false;
3083     diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
3084     index e06468f8e041..98fc77dd7b45 100644
3085     --- a/fs/cifs/cifs_debug.c
3086     +++ b/fs/cifs/cifs_debug.c
3087     @@ -284,6 +284,9 @@ static ssize_t cifs_stats_proc_write(struct file *file,
3088     atomic_set(&totBufAllocCount, 0);
3089     atomic_set(&totSmBufAllocCount, 0);
3090     #endif /* CONFIG_CIFS_STATS2 */
3091     + atomic_set(&tcpSesReconnectCount, 0);
3092     + atomic_set(&tconInfoReconnectCount, 0);
3093     +
3094     spin_lock(&GlobalMid_Lock);
3095     GlobalMaxActiveXid = 0;
3096     GlobalCurrentXid = 0;
3097     diff --git a/fs/cifs/cifs_spnego.c b/fs/cifs/cifs_spnego.c
3098     index b611fc2e8984..7f01c6e60791 100644
3099     --- a/fs/cifs/cifs_spnego.c
3100     +++ b/fs/cifs/cifs_spnego.c
3101     @@ -147,8 +147,10 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo)
3102     sprintf(dp, ";sec=krb5");
3103     else if (server->sec_mskerberos)
3104     sprintf(dp, ";sec=mskrb5");
3105     - else
3106     - goto out;
3107     + else {
3108     + cifs_dbg(VFS, "unknown or missing server auth type, use krb5\n");
3109     + sprintf(dp, ";sec=krb5");
3110     + }
3111    
3112     dp = description + strlen(description);
3113     sprintf(dp, ";uid=0x%x",
3114     diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
3115     index 77a18fe10805..57c938ffeb6e 100644
3116     --- a/fs/cifs/inode.c
3117     +++ b/fs/cifs/inode.c
3118     @@ -768,7 +768,15 @@ cifs_get_inode_info(struct inode **inode, const char *full_path,
3119     } else if (rc == -EREMOTE) {
3120     cifs_create_dfs_fattr(&fattr, sb);
3121     rc = 0;
3122     - } else if (rc == -EACCES && backup_cred(cifs_sb)) {
3123     + } else if ((rc == -EACCES) && backup_cred(cifs_sb) &&
3124     + (strcmp(server->vals->version_string, SMB1_VERSION_STRING)
3125     + == 0)) {
3126     + /*
3127     + * For SMB2 and later the backup intent flag is already
3128     + * sent if needed on open and there is no path based
3129     + * FindFirst operation to use to retry with
3130     + */
3131     +
3132     srchinf = kzalloc(sizeof(struct cifs_search_info),
3133     GFP_KERNEL);
3134     if (srchinf == NULL) {
3135     diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c
3136     index 7919967488cb..011c6f53dcda 100644
3137     --- a/fs/cramfs/inode.c
3138     +++ b/fs/cramfs/inode.c
3139     @@ -186,7 +186,8 @@ static void *cramfs_read(struct super_block *sb, unsigned int offset, unsigned i
3140     continue;
3141     blk_offset = (blocknr - buffer_blocknr[i]) << PAGE_SHIFT;
3142     blk_offset += offset;
3143     - if (blk_offset + len > BUFFER_SIZE)
3144     + if (blk_offset > BUFFER_SIZE ||
3145     + blk_offset + len > BUFFER_SIZE)
3146     continue;
3147     return read_buffers[i] + blk_offset;
3148     }
3149     diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
3150     index 6779a9f1de3b..d06cfe372609 100644
3151     --- a/fs/ext4/inline.c
3152     +++ b/fs/ext4/inline.c
3153     @@ -860,7 +860,7 @@ int ext4_da_write_inline_data_begin(struct address_space *mapping,
3154     handle_t *handle;
3155     struct page *page;
3156     struct ext4_iloc iloc;
3157     - int retries;
3158     + int retries = 0;
3159    
3160     ret = ext4_get_inode_loc(inode, &iloc);
3161     if (ret)
3162     diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
3163     index bf5ae8ebbc97..2880e017cd0a 100644
3164     --- a/fs/ext4/ioctl.c
3165     +++ b/fs/ext4/ioctl.c
3166     @@ -345,7 +345,9 @@ static int ext4_ioctl_setproject(struct file *filp, __u32 projid)
3167     }
3168     brelse(iloc.bh);
3169    
3170     - dquot_initialize(inode);
3171     + err = dquot_initialize(inode);
3172     + if (err)
3173     + return err;
3174    
3175     handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
3176     EXT4_QUOTA_INIT_BLOCKS(sb) +
3177     diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
3178     index 578f8c33fb44..c4434bdeeea7 100644
3179     --- a/fs/ext4/move_extent.c
3180     +++ b/fs/ext4/move_extent.c
3181     @@ -526,9 +526,13 @@ mext_check_arguments(struct inode *orig_inode,
3182     orig_inode->i_ino, donor_inode->i_ino);
3183     return -EINVAL;
3184     }
3185     - if (orig_eof < orig_start + *len - 1)
3186     + if (orig_eof <= orig_start)
3187     + *len = 0;
3188     + else if (orig_eof < orig_start + *len - 1)
3189     *len = orig_eof - orig_start;
3190     - if (donor_eof < donor_start + *len - 1)
3191     + if (donor_eof <= donor_start)
3192     + *len = 0;
3193     + else if (donor_eof < donor_start + *len - 1)
3194     *len = donor_eof - donor_start;
3195     if (!*len) {
3196     ext4_debug("ext4 move extent: len should not be 0 "
3197     diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
3198     index ff72ac6439c8..6d7f66816319 100644
3199     --- a/fs/gfs2/ops_fstype.c
3200     +++ b/fs/gfs2/ops_fstype.c
3201     @@ -1355,6 +1355,9 @@ static struct dentry *gfs2_mount_meta(struct file_system_type *fs_type,
3202     struct path path;
3203     int error;
3204    
3205     + if (!dev_name || !*dev_name)
3206     + return ERR_PTR(-EINVAL);
3207     +
3208     error = kern_path(dev_name, LOOKUP_FOLLOW, &path);
3209     if (error) {
3210     pr_warn("path_lookup on %s returned error %d\n",
3211     diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c
3212     index 684996c8a3a4..4d5a5a4cc017 100644
3213     --- a/fs/jbd2/checkpoint.c
3214     +++ b/fs/jbd2/checkpoint.c
3215     @@ -254,8 +254,8 @@ restart:
3216     bh = jh2bh(jh);
3217    
3218     if (buffer_locked(bh)) {
3219     - spin_unlock(&journal->j_list_lock);
3220     get_bh(bh);
3221     + spin_unlock(&journal->j_list_lock);
3222     wait_on_buffer(bh);
3223     /* the journal_head may have gone by now */
3224     BUFFER_TRACE(bh, "brelse");
3225     @@ -336,8 +336,8 @@ restart2:
3226     jh = transaction->t_checkpoint_io_list;
3227     bh = jh2bh(jh);
3228     if (buffer_locked(bh)) {
3229     - spin_unlock(&journal->j_list_lock);
3230     get_bh(bh);
3231     + spin_unlock(&journal->j_list_lock);
3232     wait_on_buffer(bh);
3233     /* the journal_head may have gone by now */
3234     BUFFER_TRACE(bh, "brelse");
3235     diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
3236     index 59c019a148f6..79b0de846f21 100644
3237     --- a/fs/jffs2/super.c
3238     +++ b/fs/jffs2/super.c
3239     @@ -285,10 +285,8 @@ static int jffs2_fill_super(struct super_block *sb, void *data, int silent)
3240     sb->s_fs_info = c;
3241    
3242     ret = jffs2_parse_options(c, data);
3243     - if (ret) {
3244     - kfree(c);
3245     + if (ret)
3246     return -EINVAL;
3247     - }
3248    
3249     /* Initialize JFFS2 superblock locks, the further initialization will
3250     * be done later */
3251     diff --git a/fs/lockd/host.c b/fs/lockd/host.c
3252     index d716c9993a26..c7eb47f2fb6c 100644
3253     --- a/fs/lockd/host.c
3254     +++ b/fs/lockd/host.c
3255     @@ -340,7 +340,7 @@ struct nlm_host *nlmsvc_lookup_host(const struct svc_rqst *rqstp,
3256     };
3257     struct lockd_net *ln = net_generic(net, lockd_net_id);
3258    
3259     - dprintk("lockd: %s(host='%*s', vers=%u, proto=%s)\n", __func__,
3260     + dprintk("lockd: %s(host='%.*s', vers=%u, proto=%s)\n", __func__,
3261     (int)hostname_len, hostname, rqstp->rq_vers,
3262     (rqstp->rq_prot == IPPROTO_UDP ? "udp" : "tcp"));
3263    
3264     diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c
3265     index f6b0848cc831..43f42cc30a60 100644
3266     --- a/fs/nfs/nfs4client.c
3267     +++ b/fs/nfs/nfs4client.c
3268     @@ -988,10 +988,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
3269    
3270     /*
3271     * Session has been established, and the client marked ready.
3272     - * Set the mount rsize and wsize with negotiated fore channel
3273     - * attributes which will be bound checked in nfs_server_set_fsinfo.
3274     + * Limit the mount rsize, wsize and dtsize using negotiated fore
3275     + * channel attributes.
3276     */
3277     -static void nfs4_session_set_rwsize(struct nfs_server *server)
3278     +static void nfs4_session_limit_rwsize(struct nfs_server *server)
3279     {
3280     #ifdef CONFIG_NFS_V4_1
3281     struct nfs4_session *sess;
3282     @@ -1004,9 +1004,11 @@ static void nfs4_session_set_rwsize(struct nfs_server *server)
3283     server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
3284     server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
3285    
3286     - if (!server->rsize || server->rsize > server_resp_sz)
3287     + if (server->dtsize > server_resp_sz)
3288     + server->dtsize = server_resp_sz;
3289     + if (server->rsize > server_resp_sz)
3290     server->rsize = server_resp_sz;
3291     - if (!server->wsize || server->wsize > server_rqst_sz)
3292     + if (server->wsize > server_rqst_sz)
3293     server->wsize = server_rqst_sz;
3294     #endif /* CONFIG_NFS_V4_1 */
3295     }
3296     @@ -1053,12 +1055,12 @@ static int nfs4_server_common_setup(struct nfs_server *server,
3297     (unsigned long long) server->fsid.minor);
3298     nfs_display_fhandle(mntfh, "Pseudo-fs root FH");
3299    
3300     - nfs4_session_set_rwsize(server);
3301     -
3302     error = nfs_probe_fsinfo(server, mntfh, fattr);
3303     if (error < 0)
3304     goto out;
3305    
3306     + nfs4_session_limit_rwsize(server);
3307     +
3308     if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
3309     server->namelen = NFS4_MAXNAMLEN;
3310    
3311     diff --git a/include/linux/tc.h b/include/linux/tc.h
3312     index f92511e57cdb..a60639f37963 100644
3313     --- a/include/linux/tc.h
3314     +++ b/include/linux/tc.h
3315     @@ -84,6 +84,7 @@ struct tc_dev {
3316     device. */
3317     struct device dev; /* Generic device interface. */
3318     struct resource resource; /* Address space of this device. */
3319     + u64 dma_mask; /* DMA addressable range. */
3320     char vendor[9];
3321     char name[9];
3322     char firmware[9];
3323     diff --git a/kernel/bounds.c b/kernel/bounds.c
3324     index e1d1d1952bfa..c37f68d758db 100644
3325     --- a/kernel/bounds.c
3326     +++ b/kernel/bounds.c
3327     @@ -12,7 +12,7 @@
3328     #include <linux/log2.h>
3329     #include <linux/spinlock_types.h>
3330    
3331     -void foo(void)
3332     +int main(void)
3333     {
3334     /* The enum constants to put into include/generated/bounds.h */
3335     DEFINE(NR_PAGEFLAGS, __NR_PAGEFLAGS);
3336     @@ -22,4 +22,6 @@ void foo(void)
3337     #endif
3338     DEFINE(SPINLOCK_SIZE, sizeof(spinlock_t));
3339     /* End of constants */
3340     +
3341     + return 0;
3342     }
3343     diff --git a/kernel/cpu.c b/kernel/cpu.c
3344     index b5a0165b7300..8d7bace9a7b2 100644
3345     --- a/kernel/cpu.c
3346     +++ b/kernel/cpu.c
3347     @@ -1970,6 +1970,12 @@ static void cpuhp_online_cpu_device(unsigned int cpu)
3348     kobject_uevent(&dev->kobj, KOBJ_ONLINE);
3349     }
3350    
3351     +/*
3352     + * Architectures that need SMT-specific errata handling during SMT hotplug
3353     + * should override this.
3354     + */
3355     +void __weak arch_smt_update(void) { };
3356     +
3357     static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
3358     {
3359     int cpu, ret = 0;
3360     @@ -1996,8 +2002,10 @@ static int cpuhp_smt_disable(enum cpuhp_smt_control ctrlval)
3361     */
3362     cpuhp_offline_cpu_device(cpu);
3363     }
3364     - if (!ret)
3365     + if (!ret) {
3366     cpu_smt_control = ctrlval;
3367     + arch_smt_update();
3368     + }
3369     cpu_maps_update_done();
3370     return ret;
3371     }
3372     @@ -2008,6 +2016,7 @@ static int cpuhp_smt_enable(void)
3373    
3374     cpu_maps_update_begin();
3375     cpu_smt_control = CPU_SMT_ENABLED;
3376     + arch_smt_update();
3377     for_each_present_cpu(cpu) {
3378     /* Skip online CPUs and CPUs on offline nodes */
3379     if (cpu_online(cpu) || !node_online(cpu_to_node(cpu)))
3380     diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
3381     index e121645bb8a1..cf94460504bb 100644
3382     --- a/kernel/irq/manage.c
3383     +++ b/kernel/irq/manage.c
3384     @@ -878,6 +878,9 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action)
3385    
3386     local_bh_disable();
3387     ret = action->thread_fn(action->irq, action->dev_id);
3388     + if (ret == IRQ_HANDLED)
3389     + atomic_inc(&desc->threads_handled);
3390     +
3391     irq_finalize_oneshot(desc, action);
3392     local_bh_enable();
3393     return ret;
3394     @@ -894,6 +897,9 @@ static irqreturn_t irq_thread_fn(struct irq_desc *desc,
3395     irqreturn_t ret;
3396    
3397     ret = action->thread_fn(action->irq, action->dev_id);
3398     + if (ret == IRQ_HANDLED)
3399     + atomic_inc(&desc->threads_handled);
3400     +
3401     irq_finalize_oneshot(desc, action);
3402     return ret;
3403     }
3404     @@ -971,8 +977,6 @@ static int irq_thread(void *data)
3405     irq_thread_check_affinity(desc, action);
3406    
3407     action_ret = handler_fn(desc, action);
3408     - if (action_ret == IRQ_HANDLED)
3409     - atomic_inc(&desc->threads_handled);
3410     if (action_ret == IRQ_WAKE_THREAD)
3411     irq_wake_secondary(desc, action);
3412    
3413     diff --git a/kernel/kprobes.c b/kernel/kprobes.c
3414     index b9e966bcdd20..f580352cc6e5 100644
3415     --- a/kernel/kprobes.c
3416     +++ b/kernel/kprobes.c
3417     @@ -665,9 +665,10 @@ static void unoptimize_kprobe(struct kprobe *p, bool force)
3418     }
3419    
3420     /* Cancel unoptimizing for reusing */
3421     -static void reuse_unused_kprobe(struct kprobe *ap)
3422     +static int reuse_unused_kprobe(struct kprobe *ap)
3423     {
3424     struct optimized_kprobe *op;
3425     + int ret;
3426    
3427     BUG_ON(!kprobe_unused(ap));
3428     /*
3429     @@ -681,8 +682,12 @@ static void reuse_unused_kprobe(struct kprobe *ap)
3430     /* Enable the probe again */
3431     ap->flags &= ~KPROBE_FLAG_DISABLED;
3432     /* Optimize it again (remove from op->list) */
3433     - BUG_ON(!kprobe_optready(ap));
3434     + ret = kprobe_optready(ap);
3435     + if (ret)
3436     + return ret;
3437     +
3438     optimize_kprobe(ap);
3439     + return 0;
3440     }
3441    
3442     /* Remove optimized instructions */
3443     @@ -894,11 +899,16 @@ static void __disarm_kprobe(struct kprobe *p, bool reopt)
3444     #define kprobe_disarmed(p) kprobe_disabled(p)
3445     #define wait_for_kprobe_optimizer() do {} while (0)
3446    
3447     -/* There should be no unused kprobes can be reused without optimization */
3448     -static void reuse_unused_kprobe(struct kprobe *ap)
3449     +static int reuse_unused_kprobe(struct kprobe *ap)
3450     {
3451     + /*
3452     + * If the optimized kprobe is NOT supported, the aggr kprobe is
3453     + * released at the same time that the last aggregated kprobe is
3454     + * unregistered.
3455     + * Thus there should be no chance to reuse unused kprobe.
3456     + */
3457     printk(KERN_ERR "Error: There should be no unused kprobe here.\n");
3458     - BUG_ON(kprobe_unused(ap));
3459     + return -EINVAL;
3460     }
3461    
3462     static void free_aggr_kprobe(struct kprobe *p)
3463     @@ -1276,9 +1286,12 @@ static int register_aggr_kprobe(struct kprobe *orig_p, struct kprobe *p)
3464     goto out;
3465     }
3466     init_aggr_kprobe(ap, orig_p);
3467     - } else if (kprobe_unused(ap))
3468     + } else if (kprobe_unused(ap)) {
3469     /* This probe is going to die. Rescue it */
3470     - reuse_unused_kprobe(ap);
3471     + ret = reuse_unused_kprobe(ap);
3472     + if (ret)
3473     + goto out;
3474     + }
3475    
3476     if (kprobe_gone(ap)) {
3477     /*
3478     diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
3479     index 61a15e538435..26fc428476b9 100644
3480     --- a/kernel/locking/lockdep.c
3481     +++ b/kernel/locking/lockdep.c
3482     @@ -4010,7 +4010,7 @@ void lock_contended(struct lockdep_map *lock, unsigned long ip)
3483     {
3484     unsigned long flags;
3485    
3486     - if (unlikely(!lock_stat))
3487     + if (unlikely(!lock_stat || !debug_locks))
3488     return;
3489    
3490     if (unlikely(current->lockdep_recursion))
3491     @@ -4030,7 +4030,7 @@ void lock_acquired(struct lockdep_map *lock, unsigned long ip)
3492     {
3493     unsigned long flags;
3494    
3495     - if (unlikely(!lock_stat))
3496     + if (unlikely(!lock_stat || !debug_locks))
3497     return;
3498    
3499     if (unlikely(current->lockdep_recursion))
3500     diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
3501     index ab6855a4218b..27adaaab96ba 100644
3502     --- a/kernel/printk/printk.c
3503     +++ b/kernel/printk/printk.c
3504     @@ -1010,7 +1010,12 @@ static void __init log_buf_len_update(unsigned size)
3505     /* save requested log_buf_len since it's too early to process it */
3506     static int __init log_buf_len_setup(char *str)
3507     {
3508     - unsigned size = memparse(str, &str);
3509     + unsigned int size;
3510     +
3511     + if (!str)
3512     + return -EINVAL;
3513     +
3514     + size = memparse(str, &str);
3515    
3516     log_buf_len_update(size);
3517    
3518     diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
3519     index 5ad109ccec35..0c91d72f3e8f 100644
3520     --- a/kernel/sched/fair.c
3521     +++ b/kernel/sched/fair.c
3522     @@ -3502,7 +3502,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
3523     * put back on, and if we advance min_vruntime, we'll be placed back
3524     * further than we started -- ie. we'll be penalized.
3525     */
3526     - if ((flags & (DEQUEUE_SAVE | DEQUEUE_MOVE)) == DEQUEUE_SAVE)
3527     + if ((flags & (DEQUEUE_SAVE | DEQUEUE_MOVE)) != DEQUEUE_SAVE)
3528     update_min_vruntime(cfs_rq);
3529     }
3530    
3531     diff --git a/kernel/signal.c b/kernel/signal.c
3532     index 4364e57e6038..424306163edc 100644
3533     --- a/kernel/signal.c
3534     +++ b/kernel/signal.c
3535     @@ -991,7 +991,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
3536    
3537     result = TRACE_SIGNAL_IGNORED;
3538     if (!prepare_signal(sig, t,
3539     - from_ancestor_ns || (info == SEND_SIG_FORCED)))
3540     + from_ancestor_ns || (info == SEND_SIG_PRIV) || (info == SEND_SIG_FORCED)))
3541     goto ret;
3542    
3543     pending = group ? &t->signal->shared_pending : &t->pending;
3544     diff --git a/lib/debug_locks.c b/lib/debug_locks.c
3545     index 96c4c633d95e..124fdf238b3d 100644
3546     --- a/lib/debug_locks.c
3547     +++ b/lib/debug_locks.c
3548     @@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(debug_locks_silent);
3549     */
3550     int debug_locks_off(void)
3551     {
3552     - if (__debug_locks_off()) {
3553     + if (debug_locks && __debug_locks_off()) {
3554     if (!debug_locks_silent) {
3555     console_verbose();
3556     return 1;
3557     diff --git a/mm/hugetlb.c b/mm/hugetlb.c
3558     index f9e735537c37..9c566e4b06ce 100644
3559     --- a/mm/hugetlb.c
3560     +++ b/mm/hugetlb.c
3561     @@ -3645,6 +3645,12 @@ int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
3562     return err;
3563     ClearPagePrivate(page);
3564    
3565     + /*
3566     + * set page dirty so that it will not be removed from cache/file
3567     + * by non-hugetlbfs specific code paths.
3568     + */
3569     + set_page_dirty(page);
3570     +
3571     spin_lock(&inode->i_lock);
3572     inode->i_blocks += blocks_per_huge_page(h);
3573     spin_unlock(&inode->i_lock);
3574     diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
3575     index 46e8830c1979..2e4eef71471d 100644
3576     --- a/net/core/netclassid_cgroup.c
3577     +++ b/net/core/netclassid_cgroup.c
3578     @@ -104,6 +104,7 @@ static int write_classid(struct cgroup_subsys_state *css, struct cftype *cft,
3579     iterate_fd(p->files, 0, update_classid_sock,
3580     (void *)(unsigned long)cs->classid);
3581     task_unlock(p);
3582     + cond_resched();
3583     }
3584     css_task_iter_end(&it);
3585    
3586     diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
3587     index 65a15889d432..571d079e262f 100644
3588     --- a/net/ipv4/cipso_ipv4.c
3589     +++ b/net/ipv4/cipso_ipv4.c
3590     @@ -1512,7 +1512,7 @@ static int cipso_v4_parsetag_loc(const struct cipso_v4_doi *doi_def,
3591     *
3592     * Description:
3593     * Parse the packet's IP header looking for a CIPSO option. Returns a pointer
3594     - * to the start of the CIPSO option on success, NULL if one if not found.
3595     + * to the start of the CIPSO option on success, NULL if one is not found.
3596     *
3597     */
3598     unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
3599     @@ -1522,10 +1522,8 @@ unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
3600     int optlen;
3601     int taglen;
3602    
3603     - for (optlen = iph->ihl*4 - sizeof(struct iphdr); optlen > 0; ) {
3604     + for (optlen = iph->ihl*4 - sizeof(struct iphdr); optlen > 1; ) {
3605     switch (optptr[0]) {
3606     - case IPOPT_CIPSO:
3607     - return optptr;
3608     case IPOPT_END:
3609     return NULL;
3610     case IPOPT_NOOP:
3611     @@ -1534,6 +1532,11 @@ unsigned char *cipso_v4_optptr(const struct sk_buff *skb)
3612     default:
3613     taglen = optptr[1];
3614     }
3615     + if (!taglen || taglen > optlen)
3616     + return NULL;
3617     + if (optptr[0] == IPOPT_CIPSO)
3618     + return optptr;
3619     +
3620     optlen -= taglen;
3621     optptr += taglen;
3622     }
3623     diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
3624     index 9c9db55a0c1e..064f20bb845a 100644
3625     --- a/net/sunrpc/svc_xprt.c
3626     +++ b/net/sunrpc/svc_xprt.c
3627     @@ -1038,7 +1038,7 @@ static void call_xpt_users(struct svc_xprt *xprt)
3628     spin_lock(&xprt->xpt_lock);
3629     while (!list_empty(&xprt->xpt_users)) {
3630     u = list_first_entry(&xprt->xpt_users, struct svc_xpt_user, list);
3631     - list_del(&u->list);
3632     + list_del_init(&u->list);
3633     u->callback(u);
3634     }
3635     spin_unlock(&xprt->xpt_lock);
3636     diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
3637     index d0dcfc68c043..155b1591b17a 100644
3638     --- a/net/xfrm/xfrm_policy.c
3639     +++ b/net/xfrm/xfrm_policy.c
3640     @@ -659,9 +659,9 @@ static void xfrm_hash_rebuild(struct work_struct *work)
3641     break;
3642     }
3643     if (newpos)
3644     - hlist_add_behind(&policy->bydst, newpos);
3645     + hlist_add_behind_rcu(&policy->bydst, newpos);
3646     else
3647     - hlist_add_head(&policy->bydst, chain);
3648     + hlist_add_head_rcu(&policy->bydst, chain);
3649     }
3650    
3651     spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
3652     @@ -800,9 +800,9 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
3653     break;
3654     }
3655     if (newpos)
3656     - hlist_add_behind(&policy->bydst, newpos);
3657     + hlist_add_behind_rcu(&policy->bydst, newpos);
3658     else
3659     - hlist_add_head(&policy->bydst, chain);
3660     + hlist_add_head_rcu(&policy->bydst, chain);
3661     __xfrm_policy_link(policy, dir);
3662     atomic_inc(&net->xfrm.flow_cache_genid);
3663    
3664     diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
3665     index 3df46906492d..44b44d7e0dbc 100644
3666     --- a/security/integrity/ima/ima_fs.c
3667     +++ b/security/integrity/ima/ima_fs.c
3668     @@ -29,14 +29,14 @@
3669     static DEFINE_MUTEX(ima_write_mutex);
3670    
3671     static int valid_policy = 1;
3672     -#define TMPBUFLEN 12
3673     +
3674     static ssize_t ima_show_htable_value(char __user *buf, size_t count,
3675     loff_t *ppos, atomic_long_t *val)
3676     {
3677     - char tmpbuf[TMPBUFLEN];
3678     + char tmpbuf[32]; /* greater than largest 'long' string value */
3679     ssize_t len;
3680    
3681     - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
3682     + len = scnprintf(tmpbuf, sizeof(tmpbuf), "%li\n", atomic_long_read(val));
3683     return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
3684     }
3685    
3686     diff --git a/sound/pci/ca0106/ca0106.h b/sound/pci/ca0106/ca0106.h
3687     index 04402c14cb23..9847b669cf3c 100644
3688     --- a/sound/pci/ca0106/ca0106.h
3689     +++ b/sound/pci/ca0106/ca0106.h
3690     @@ -582,7 +582,7 @@
3691     #define SPI_PL_BIT_R_R (2<<7) /* right channel = right */
3692     #define SPI_PL_BIT_R_C (3<<7) /* right channel = (L+R)/2 */
3693     #define SPI_IZD_REG 2
3694     -#define SPI_IZD_BIT (1<<4) /* infinite zero detect */
3695     +#define SPI_IZD_BIT (0<<4) /* infinite zero detect */
3696    
3697     #define SPI_FMT_REG 3
3698     #define SPI_FMT_BIT_RJ (0<<0) /* right justified mode */
3699     diff --git a/sound/pci/hda/hda_controller.h b/sound/pci/hda/hda_controller.h
3700     index a50e0532622a..b83feecf1e40 100644
3701     --- a/sound/pci/hda/hda_controller.h
3702     +++ b/sound/pci/hda/hda_controller.h
3703     @@ -155,6 +155,7 @@ struct azx {
3704     unsigned int msi:1;
3705     unsigned int probing:1; /* codec probing phase */
3706     unsigned int snoop:1;
3707     + unsigned int uc_buffer:1; /* non-cached pages for stream buffers */
3708     unsigned int align_buffer_size:1;
3709     unsigned int region_requested:1;
3710     unsigned int disabled:1; /* disabled by vga_switcheroo */
3711     diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
3712     index f913809a7de3..3557e3943ad5 100644
3713     --- a/sound/pci/hda/hda_intel.c
3714     +++ b/sound/pci/hda/hda_intel.c
3715     @@ -410,7 +410,7 @@ static void __mark_pages_wc(struct azx *chip, struct snd_dma_buffer *dmab, bool
3716     #ifdef CONFIG_SND_DMA_SGBUF
3717     if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_SG) {
3718     struct snd_sg_buf *sgbuf = dmab->private_data;
3719     - if (chip->driver_type == AZX_DRIVER_CMEDIA)
3720     + if (!chip->uc_buffer)
3721     return; /* deal with only CORB/RIRB buffers */
3722     if (on)
3723     set_pages_array_wc(sgbuf->page_table, sgbuf->pages);
3724     @@ -1503,6 +1503,7 @@ static void azx_check_snoop_available(struct azx *chip)
3725     dev_info(chip->card->dev, "Force to %s mode by module option\n",
3726     snoop ? "snoop" : "non-snoop");
3727     chip->snoop = snoop;
3728     + chip->uc_buffer = !snoop;
3729     return;
3730     }
3731    
3732     @@ -1523,8 +1524,12 @@ static void azx_check_snoop_available(struct azx *chip)
3733     snoop = false;
3734    
3735     chip->snoop = snoop;
3736     - if (!snoop)
3737     + if (!snoop) {
3738     dev_info(chip->card->dev, "Force to non-snoop mode\n");
3739     + /* C-Media requires non-cached pages only for CORB/RIRB */
3740     + if (chip->driver_type != AZX_DRIVER_CMEDIA)
3741     + chip->uc_buffer = true;
3742     + }
3743     }
3744    
3745     static void azx_probe_work(struct work_struct *work)
3746     @@ -1947,7 +1952,7 @@ static void pcm_mmap_prepare(struct snd_pcm_substream *substream,
3747     #ifdef CONFIG_X86
3748     struct azx_pcm *apcm = snd_pcm_substream_chip(substream);
3749     struct azx *chip = apcm->chip;
3750     - if (!azx_snoop(chip) && chip->driver_type != AZX_DRIVER_CMEDIA)
3751     + if (chip->uc_buffer)
3752     area->vm_page_prot = pgprot_writecombine(area->vm_page_prot);
3753     #endif
3754     }
3755     diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
3756     index a6e98a4d6834..d392e867e9ab 100644
3757     --- a/sound/pci/hda/patch_conexant.c
3758     +++ b/sound/pci/hda/patch_conexant.c
3759     @@ -867,6 +867,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
3760     SND_PCI_QUIRK(0x17aa, 0x21da, "Lenovo X220", CXT_PINCFG_LENOVO_TP410),
3761     SND_PCI_QUIRK(0x17aa, 0x21db, "Lenovo X220-tablet", CXT_PINCFG_LENOVO_TP410),
3762     SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo IdeaPad Z560", CXT_FIXUP_MUTE_LED_EAPD),
3763     + SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC),
3764     SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
3765     SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
3766     SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
3767     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
3768     index cc48800f95e0..6c2668b4e3bc 100644
3769     --- a/sound/pci/hda/patch_realtek.c
3770     +++ b/sound/pci/hda/patch_realtek.c
3771     @@ -6811,6 +6811,8 @@ enum {
3772     ALC662_FIXUP_ASUS_Nx50,
3773     ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3774     ALC668_FIXUP_ASUS_Nx51,
3775     + ALC668_FIXUP_MIC_COEF,
3776     + ALC668_FIXUP_ASUS_G751,
3777     ALC891_FIXUP_HEADSET_MODE,
3778     ALC891_FIXUP_DELL_MIC_NO_PRESENCE,
3779     ALC662_FIXUP_ACER_VERITON,
3780     @@ -7077,6 +7079,23 @@ static const struct hda_fixup alc662_fixups[] = {
3781     .chained = true,
3782     .chain_id = ALC668_FIXUP_ASUS_Nx51_HEADSET_MODE,
3783     },
3784     + [ALC668_FIXUP_MIC_COEF] = {
3785     + .type = HDA_FIXUP_VERBS,
3786     + .v.verbs = (const struct hda_verb[]) {
3787     + { 0x20, AC_VERB_SET_COEF_INDEX, 0xc3 },
3788     + { 0x20, AC_VERB_SET_PROC_COEF, 0x4000 },
3789     + {}
3790     + },
3791     + },
3792     + [ALC668_FIXUP_ASUS_G751] = {
3793     + .type = HDA_FIXUP_PINS,
3794     + .v.pins = (const struct hda_pintbl[]) {
3795     + { 0x16, 0x0421101f }, /* HP */
3796     + {}
3797     + },
3798     + .chained = true,
3799     + .chain_id = ALC668_FIXUP_MIC_COEF
3800     + },
3801     [ALC891_FIXUP_HEADSET_MODE] = {
3802     .type = HDA_FIXUP_FUNC,
3803     .v.func = alc_fixup_headset_mode,
3804     @@ -7132,6 +7151,7 @@ static const struct snd_pci_quirk alc662_fixup_tbl[] = {
3805     SND_PCI_QUIRK(0x1043, 0x11cd, "Asus N550", ALC662_FIXUP_ASUS_Nx50),
3806     SND_PCI_QUIRK(0x1043, 0x13df, "Asus N550JX", ALC662_FIXUP_BASS_1A),
3807     SND_PCI_QUIRK(0x1043, 0x129d, "Asus N750", ALC662_FIXUP_ASUS_Nx50),
3808     + SND_PCI_QUIRK(0x1043, 0x12ff, "ASUS G751", ALC668_FIXUP_ASUS_G751),
3809     SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_MODE4_CHMAP),
3810     SND_PCI_QUIRK(0x1043, 0x15a7, "ASUS UX51VZH", ALC662_FIXUP_BASS_16),
3811     SND_PCI_QUIRK(0x1043, 0x177d, "ASUS N551", ALC668_FIXUP_ASUS_Nx51),
3812     diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
3813     index b0c154d5924b..76e5bb425a56 100644
3814     --- a/sound/soc/intel/skylake/skl-topology.c
3815     +++ b/sound/soc/intel/skylake/skl-topology.c
3816     @@ -1780,6 +1780,7 @@ static int skl_tplg_get_token(struct device *dev,
3817    
3818     case SKL_TKN_U8_CORE_ID:
3819     mconfig->core_id = tkn_elem->value;
3820     + break;
3821    
3822     case SKL_TKN_U8_MOD_TYPE:
3823     mconfig->m_type = tkn_elem->value;
3824     diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
3825     index 663192395780..2d5744d986f0 100644
3826     --- a/tools/perf/util/event.c
3827     +++ b/tools/perf/util/event.c
3828     @@ -839,6 +839,7 @@ void *cpu_map_data__alloc(struct cpu_map *map, size_t *size, u16 *type, int *max
3829     }
3830    
3831     *size += sizeof(struct cpu_map_data);
3832     + *size = PERF_ALIGN(*size, sizeof(u64));
3833     return zalloc(*size);
3834     }
3835    
3836     diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
3837     index b1474dcadfa2..0f84371d4d6b 100644
3838     --- a/tools/perf/util/pmu.c
3839     +++ b/tools/perf/util/pmu.c
3840     @@ -685,13 +685,14 @@ static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,
3841    
3842     static __u64 pmu_format_max_value(const unsigned long *format)
3843     {
3844     - __u64 w = 0;
3845     - int fbit;
3846     -
3847     - for_each_set_bit(fbit, format, PERF_PMU_FORMAT_BITS)
3848     - w |= (1ULL << fbit);
3849     + int w;
3850    
3851     - return w;
3852     + w = bitmap_weight(format, PERF_PMU_FORMAT_BITS);
3853     + if (!w)
3854     + return 0;
3855     + if (w < 64)
3856     + return (1ULL << w) - 1;
3857     + return -1;
3858     }
3859    
3860     /*
3861     diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
3862     index 817593908d47..842cf3fd9235 100644
3863     --- a/tools/perf/util/strbuf.c
3864     +++ b/tools/perf/util/strbuf.c
3865     @@ -105,19 +105,25 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
3866    
3867     va_copy(ap_saved, ap);
3868     len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
3869     - if (len < 0)
3870     + if (len < 0) {
3871     + va_end(ap_saved);
3872     return len;
3873     + }
3874     if (len > strbuf_avail(sb)) {
3875     ret = strbuf_grow(sb, len);
3876     - if (ret)
3877     + if (ret) {
3878     + va_end(ap_saved);
3879     return ret;
3880     + }
3881     len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
3882     va_end(ap_saved);
3883     if (len > strbuf_avail(sb)) {
3884     pr_debug("this should not happen, your vsnprintf is broken");
3885     + va_end(ap_saved);
3886     return -EINVAL;
3887     }
3888     }
3889     + va_end(ap_saved);
3890     return strbuf_setlen(sb, sb->len + len);
3891     }
3892    
3893     diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
3894     index d995743cb673..58ce62088a39 100644
3895     --- a/tools/perf/util/trace-event-info.c
3896     +++ b/tools/perf/util/trace-event-info.c
3897     @@ -507,12 +507,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs,
3898     "/tmp/perf-XXXXXX");
3899     if (!mkstemp(tdata->temp_file)) {
3900     pr_debug("Can't make temp file");
3901     + free(tdata);
3902     return NULL;
3903     }
3904    
3905     temp_fd = open(tdata->temp_file, O_RDWR);
3906     if (temp_fd < 0) {
3907     pr_debug("Can't read '%s'", tdata->temp_file);
3908     + free(tdata);
3909     return NULL;
3910     }
3911    
3912     diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
3913     index b67a0ccf5ab9..23baee7b786a 100644
3914     --- a/tools/perf/util/trace-event-read.c
3915     +++ b/tools/perf/util/trace-event-read.c
3916     @@ -334,9 +334,12 @@ static int read_event_files(struct pevent *pevent)
3917     for (x=0; x < count; x++) {
3918     size = read8(pevent);
3919     ret = read_event_file(pevent, sys, size);
3920     - if (ret)
3921     + if (ret) {
3922     + free(sys);
3923     return ret;
3924     + }
3925     }
3926     + free(sys);
3927     }
3928     return 0;
3929     }
3930     diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-syntax.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-syntax.tc
3931     new file mode 100644
3932     index 000000000000..88e6c3f43006
3933     --- /dev/null
3934     +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-syntax.tc
3935     @@ -0,0 +1,80 @@
3936     +#!/bin/sh
3937     +# SPDX-License-Identifier: GPL-2.0
3938     +# description: event trigger - test synthetic_events syntax parser
3939     +
3940     +do_reset() {
3941     + reset_trigger
3942     + echo > set_event
3943     + clear_trace
3944     +}
3945     +
3946     +fail() { #msg
3947     + do_reset
3948     + echo $1
3949     + exit_fail
3950     +}
3951     +
3952     +if [ ! -f set_event ]; then
3953     + echo "event tracing is not supported"
3954     + exit_unsupported
3955     +fi
3956     +
3957     +if [ ! -f synthetic_events ]; then
3958     + echo "synthetic event is not supported"
3959     + exit_unsupported
3960     +fi
3961     +
3962     +reset_tracer
3963     +do_reset
3964     +
3965     +echo "Test synthetic_events syntax parser"
3966     +
3967     +echo > synthetic_events
3968     +
3969     +# synthetic event must have a field
3970     +! echo "myevent" >> synthetic_events
3971     +echo "myevent u64 var1" >> synthetic_events
3972     +
3973     +# synthetic event must be found in synthetic_events
3974     +grep "myevent[[:space:]]u64 var1" synthetic_events
3975     +
3976     +# it is not possible to add same name event
3977     +! echo "myevent u64 var2" >> synthetic_events
3978     +
3979     +# Non-append open will cleanup all events and add new one
3980     +echo "myevent u64 var2" > synthetic_events
3981     +
3982     +# multiple fields with different spaces
3983     +echo "myevent u64 var1; u64 var2;" > synthetic_events
3984     +grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events
3985     +echo "myevent u64 var1 ; u64 var2 ;" > synthetic_events
3986     +grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events
3987     +echo "myevent u64 var1 ;u64 var2" > synthetic_events
3988     +grep "myevent[[:space:]]u64 var1; u64 var2" synthetic_events
3989     +
3990     +# test field types
3991     +echo "myevent u32 var" > synthetic_events
3992     +echo "myevent u16 var" > synthetic_events
3993     +echo "myevent u8 var" > synthetic_events
3994     +echo "myevent s64 var" > synthetic_events
3995     +echo "myevent s32 var" > synthetic_events
3996     +echo "myevent s16 var" > synthetic_events
3997     +echo "myevent s8 var" > synthetic_events
3998     +
3999     +echo "myevent char var" > synthetic_events
4000     +echo "myevent int var" > synthetic_events
4001     +echo "myevent long var" > synthetic_events
4002     +echo "myevent pid_t var" > synthetic_events
4003     +
4004     +echo "myevent unsigned char var" > synthetic_events
4005     +echo "myevent unsigned int var" > synthetic_events
4006     +echo "myevent unsigned long var" > synthetic_events
4007     +grep "myevent[[:space:]]unsigned long var" synthetic_events
4008     +
4009     +# test string type
4010     +echo "myevent char var[10]" > synthetic_events
4011     +grep "myevent[[:space:]]char\[10\] var" synthetic_events
4012     +
4013     +do_reset
4014     +
4015     +exit 0
4016     diff --git a/tools/testing/selftests/net/reuseport_bpf.c b/tools/testing/selftests/net/reuseport_bpf.c
4017     index cad14cd0ea92..b5277106df1f 100644
4018     --- a/tools/testing/selftests/net/reuseport_bpf.c
4019     +++ b/tools/testing/selftests/net/reuseport_bpf.c
4020     @@ -437,14 +437,19 @@ void enable_fastopen(void)
4021     }
4022     }
4023    
4024     -static struct rlimit rlim_old, rlim_new;
4025     +static struct rlimit rlim_old;
4026    
4027     static __attribute__((constructor)) void main_ctor(void)
4028     {
4029     getrlimit(RLIMIT_MEMLOCK, &rlim_old);
4030     - rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
4031     - rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
4032     - setrlimit(RLIMIT_MEMLOCK, &rlim_new);
4033     +
4034     + if (rlim_old.rlim_cur != RLIM_INFINITY) {
4035     + struct rlimit rlim_new;
4036     +
4037     + rlim_new.rlim_cur = rlim_old.rlim_cur + (1UL << 20);
4038     + rlim_new.rlim_max = rlim_old.rlim_max + (1UL << 20);
4039     + setrlimit(RLIMIT_MEMLOCK, &rlim_new);
4040     + }
4041     }
4042    
4043     static __attribute__((destructor)) void main_dtor(void)