Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0310-5.4.211-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3635 - (show annotations) (download)
Mon Oct 24 12:34:12 2022 UTC (19 months ago) by niro
File size: 351379 byte(s)
-sync kernel patches
1 diff --git a/Documentation/admin-guide/pm/cpuidle.rst b/Documentation/admin-guide/pm/cpuidle.rst
2 index e70b365dbc603..80cf2ef2a5062 100644
3 --- a/Documentation/admin-guide/pm/cpuidle.rst
4 +++ b/Documentation/admin-guide/pm/cpuidle.rst
5 @@ -676,8 +676,8 @@ the ``menu`` governor to be used on the systems that use the ``ladder`` governor
6 by default this way, for example.
7
8 The other kernel command line parameters controlling CPU idle time management
9 -described below are only relevant for the *x86* architecture and some of
10 -them affect Intel processors only.
11 +described below are only relevant for the *x86* architecture and references
12 +to ``intel_idle`` affect Intel processors only.
13
14 The *x86* architecture support code recognizes three kernel command line
15 options related to CPU idle time management: ``idle=poll``, ``idle=halt``,
16 @@ -699,10 +699,13 @@ idle, so it very well may hurt single-thread computations performance as well as
17 energy-efficiency. Thus using it for performance reasons may not be a good idea
18 at all.]
19
20 -The ``idle=nomwait`` option disables the ``intel_idle`` driver and causes
21 -``acpi_idle`` to be used (as long as all of the information needed by it is
22 -there in the system's ACPI tables), but it is not allowed to use the
23 -``MWAIT`` instruction of the CPUs to ask the hardware to enter idle states.
24 +The ``idle=nomwait`` option prevents the use of ``MWAIT`` instruction of
25 +the CPU to enter idle states. When this option is used, the ``acpi_idle``
26 +driver will use the ``HLT`` instruction instead of ``MWAIT``. On systems
27 +running Intel processors, this option disables the ``intel_idle`` driver
28 +and forces the use of the ``acpi_idle`` driver instead. Note that in either
29 +case, ``acpi_idle`` driver will function only if all the information needed
30 +by it is in the system's ACPI tables.
31
32 In addition to the architecture-level kernel command line options affecting CPU
33 idle time management, there are parameters affecting individual ``CPUIdle``
34 diff --git a/Documentation/atomic_bitops.txt b/Documentation/atomic_bitops.txt
35 index 093cdaefdb373..d8b101c97031b 100644
36 --- a/Documentation/atomic_bitops.txt
37 +++ b/Documentation/atomic_bitops.txt
38 @@ -59,7 +59,7 @@ Like with atomic_t, the rule of thumb is:
39 - RMW operations that have a return value are fully ordered.
40
41 - RMW operations that are conditional are unordered on FAILURE,
42 - otherwise the above rules apply. In the case of test_and_{}_bit() operations,
43 + otherwise the above rules apply. In the case of test_and_set_bit_lock(),
44 if the bit in memory is unchanged by the operation then it is deemed to have
45 failed.
46
47 diff --git a/Documentation/devicetree/bindings/arm/qcom.yaml b/Documentation/devicetree/bindings/arm/qcom.yaml
48 index e39d8f02e33c1..3de6182cde973 100644
49 --- a/Documentation/devicetree/bindings/arm/qcom.yaml
50 +++ b/Documentation/devicetree/bindings/arm/qcom.yaml
51 @@ -112,8 +112,8 @@ properties:
52 - const: qcom,msm8974
53
54 - items:
55 - - const: qcom,msm8916-mtp/1
56 - const: qcom,msm8916-mtp
57 + - const: qcom,msm8916-mtp/1
58 - const: qcom,msm8916
59
60 - items:
61 diff --git a/Documentation/firmware-guide/acpi/apei/einj.rst b/Documentation/firmware-guide/acpi/apei/einj.rst
62 index e588bccf51583..344284236a810 100644
63 --- a/Documentation/firmware-guide/acpi/apei/einj.rst
64 +++ b/Documentation/firmware-guide/acpi/apei/einj.rst
65 @@ -168,7 +168,7 @@ An error injection example::
66 0x00000008 Memory Correctable
67 0x00000010 Memory Uncorrectable non-fatal
68 # echo 0x12345000 > param1 # Set memory address for injection
69 - # echo $((-1 << 12)) > param2 # Mask 0xfffffffffffff000 - anywhere in this page
70 + # echo 0xfffffffffffff000 > param2 # Mask - anywhere in this page
71 # echo 0x8 > error_type # Choose correctable memory error
72 # echo 1 > error_inject # Inject now
73
74 diff --git a/Makefile b/Makefile
75 index 74abb7e389f33..e54b9a1659b4f 100644
76 --- a/Makefile
77 +++ b/Makefile
78 @@ -1,7 +1,7 @@
79 # SPDX-License-Identifier: GPL-2.0
80 VERSION = 5
81 PATCHLEVEL = 4
82 -SUBLEVEL = 210
83 +SUBLEVEL = 211
84 EXTRAVERSION =
85 NAME = Kleptomaniac Octopus
86
87 @@ -932,6 +932,9 @@ KBUILD_CFLAGS += $(KCFLAGS)
88 KBUILD_LDFLAGS_MODULE += --build-id
89 LDFLAGS_vmlinux += --build-id
90
91 +KBUILD_LDFLAGS += -z noexecstack
92 +KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
93 +
94 ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
95 LDFLAGS_vmlinux += $(call ld-option, -X,)
96 endif
97 diff --git a/arch/arm/boot/dts/aspeed-ast2500-evb.dts b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
98 index c9d88c90135e6..9db4d42d0deb3 100644
99 --- a/arch/arm/boot/dts/aspeed-ast2500-evb.dts
100 +++ b/arch/arm/boot/dts/aspeed-ast2500-evb.dts
101 @@ -5,7 +5,7 @@
102
103 / {
104 model = "AST2500 EVB";
105 - compatible = "aspeed,ast2500";
106 + compatible = "aspeed,ast2500-evb", "aspeed,ast2500";
107
108 aliases {
109 serial4 = &uart5;
110 diff --git a/arch/arm/boot/dts/aspeed-ast2600-evb.dts b/arch/arm/boot/dts/aspeed-ast2600-evb.dts
111 index 9870553919b7c..f00b19ad4fa62 100644
112 --- a/arch/arm/boot/dts/aspeed-ast2600-evb.dts
113 +++ b/arch/arm/boot/dts/aspeed-ast2600-evb.dts
114 @@ -7,7 +7,7 @@
115
116 / {
117 model = "AST2600 EVB";
118 - compatible = "aspeed,ast2600";
119 + compatible = "aspeed,ast2600-evb-a1", "aspeed,ast2600";
120
121 aliases {
122 serial4 = &uart5;
123 diff --git a/arch/arm/boot/dts/imx6ul.dtsi b/arch/arm/boot/dts/imx6ul.dtsi
124 index f008036e92948..ae0722b93b9d7 100644
125 --- a/arch/arm/boot/dts/imx6ul.dtsi
126 +++ b/arch/arm/boot/dts/imx6ul.dtsi
127 @@ -62,20 +62,18 @@
128 clock-frequency = <696000000>;
129 clock-latency = <61036>; /* two CLK32 periods */
130 #cooling-cells = <2>;
131 - operating-points = <
132 + operating-points =
133 /* kHz uV */
134 - 696000 1275000
135 - 528000 1175000
136 - 396000 1025000
137 - 198000 950000
138 - >;
139 - fsl,soc-operating-points = <
140 + <696000 1275000>,
141 + <528000 1175000>,
142 + <396000 1025000>,
143 + <198000 950000>;
144 + fsl,soc-operating-points =
145 /* KHz uV */
146 - 696000 1275000
147 - 528000 1175000
148 - 396000 1175000
149 - 198000 1175000
150 - >;
151 + <696000 1275000>,
152 + <528000 1175000>,
153 + <396000 1175000>,
154 + <198000 1175000>;
155 clocks = <&clks IMX6UL_CLK_ARM>,
156 <&clks IMX6UL_CLK_PLL2_BUS>,
157 <&clks IMX6UL_CLK_PLL2_PFD2>,
158 @@ -157,6 +155,9 @@
159 ocram: sram@900000 {
160 compatible = "mmio-sram";
161 reg = <0x00900000 0x20000>;
162 + ranges = <0 0x00900000 0x20000>;
163 + #address-cells = <1>;
164 + #size-cells = <1>;
165 };
166
167 intc: interrupt-controller@a01000 {
168 @@ -966,7 +967,7 @@
169 };
170
171 csi: csi@21c4000 {
172 - compatible = "fsl,imx6ul-csi", "fsl,imx7-csi";
173 + compatible = "fsl,imx6ul-csi";
174 reg = <0x021c4000 0x4000>;
175 interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
176 clocks = <&clks IMX6UL_CLK_CSI>;
177 @@ -975,7 +976,7 @@
178 };
179
180 lcdif: lcdif@21c8000 {
181 - compatible = "fsl,imx6ul-lcdif", "fsl,imx28-lcdif";
182 + compatible = "fsl,imx6ul-lcdif", "fsl,imx6sx-lcdif";
183 reg = <0x021c8000 0x4000>;
184 interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
185 clocks = <&clks IMX6UL_CLK_LCDIF_PIX>,
186 @@ -996,7 +997,7 @@
187 qspi: spi@21e0000 {
188 #address-cells = <1>;
189 #size-cells = <0>;
190 - compatible = "fsl,imx6ul-qspi", "fsl,imx6sx-qspi";
191 + compatible = "fsl,imx6ul-qspi";
192 reg = <0x021e0000 0x4000>, <0x60000000 0x10000000>;
193 reg-names = "QuadSPI", "QuadSPI-memory";
194 interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
195 diff --git a/arch/arm/boot/dts/qcom-mdm9615.dtsi b/arch/arm/boot/dts/qcom-mdm9615.dtsi
196 index 356e9535f7a68..ffb4dcdb62d2b 100644
197 --- a/arch/arm/boot/dts/qcom-mdm9615.dtsi
198 +++ b/arch/arm/boot/dts/qcom-mdm9615.dtsi
199 @@ -323,6 +323,7 @@
200
201 pmicgpio: gpio@150 {
202 compatible = "qcom,pm8018-gpio", "qcom,ssbi-gpio";
203 + reg = <0x150>;
204 interrupt-controller;
205 #interrupt-cells = <2>;
206 gpio-controller;
207 diff --git a/arch/arm/boot/dts/qcom-pm8841.dtsi b/arch/arm/boot/dts/qcom-pm8841.dtsi
208 index 2fd59c440903d..c73e5b149ac5e 100644
209 --- a/arch/arm/boot/dts/qcom-pm8841.dtsi
210 +++ b/arch/arm/boot/dts/qcom-pm8841.dtsi
211 @@ -25,6 +25,7 @@
212 compatible = "qcom,spmi-temp-alarm";
213 reg = <0x2400>;
214 interrupts = <4 0x24 0 IRQ_TYPE_EDGE_RISING>;
215 + #thermal-sensor-cells = <0>;
216 };
217 };
218
219 diff --git a/arch/arm/boot/dts/uniphier-pxs2.dtsi b/arch/arm/boot/dts/uniphier-pxs2.dtsi
220 index 60a588ce45e10..049ca941b4790 100644
221 --- a/arch/arm/boot/dts/uniphier-pxs2.dtsi
222 +++ b/arch/arm/boot/dts/uniphier-pxs2.dtsi
223 @@ -585,8 +585,8 @@
224 compatible = "socionext,uniphier-dwc3", "snps,dwc3";
225 status = "disabled";
226 reg = <0x65a00000 0xcd00>;
227 - interrupt-names = "host", "peripheral";
228 - interrupts = <0 134 4>, <0 135 4>;
229 + interrupt-names = "dwc_usb3";
230 + interrupts = <0 134 4>;
231 pinctrl-names = "default";
232 pinctrl-0 = <&pinctrl_usb0>, <&pinctrl_usb2>;
233 clock-names = "ref", "bus_early", "suspend";
234 @@ -681,8 +681,8 @@
235 compatible = "socionext,uniphier-dwc3", "snps,dwc3";
236 status = "disabled";
237 reg = <0x65c00000 0xcd00>;
238 - interrupt-names = "host", "peripheral";
239 - interrupts = <0 137 4>, <0 138 4>;
240 + interrupt-names = "dwc_usb3";
241 + interrupts = <0 137 4>;
242 pinctrl-names = "default";
243 pinctrl-0 = <&pinctrl_usb1>, <&pinctrl_usb3>;
244 clock-names = "ref", "bus_early", "suspend";
245 diff --git a/arch/arm/lib/findbit.S b/arch/arm/lib/findbit.S
246 index b5e8b9ae4c7d4..7fd3600db8efd 100644
247 --- a/arch/arm/lib/findbit.S
248 +++ b/arch/arm/lib/findbit.S
249 @@ -40,8 +40,8 @@ ENDPROC(_find_first_zero_bit_le)
250 * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
251 */
252 ENTRY(_find_next_zero_bit_le)
253 - teq r1, #0
254 - beq 3b
255 + cmp r2, r1
256 + bhs 3b
257 ands ip, r2, #7
258 beq 1b @ If new byte, goto old routine
259 ARM( ldrb r3, [r0, r2, lsr #3] )
260 @@ -81,8 +81,8 @@ ENDPROC(_find_first_bit_le)
261 * Prototype: int find_next_zero_bit(void *addr, unsigned int maxbit, int offset)
262 */
263 ENTRY(_find_next_bit_le)
264 - teq r1, #0
265 - beq 3b
266 + cmp r2, r1
267 + bhs 3b
268 ands ip, r2, #7
269 beq 1b @ If new byte, goto old routine
270 ARM( ldrb r3, [r0, r2, lsr #3] )
271 @@ -115,8 +115,8 @@ ENTRY(_find_first_zero_bit_be)
272 ENDPROC(_find_first_zero_bit_be)
273
274 ENTRY(_find_next_zero_bit_be)
275 - teq r1, #0
276 - beq 3b
277 + cmp r2, r1
278 + bhs 3b
279 ands ip, r2, #7
280 beq 1b @ If new byte, goto old routine
281 eor r3, r2, #0x18 @ big endian byte ordering
282 @@ -149,8 +149,8 @@ ENTRY(_find_first_bit_be)
283 ENDPROC(_find_first_bit_be)
284
285 ENTRY(_find_next_bit_be)
286 - teq r1, #0
287 - beq 3b
288 + cmp r2, r1
289 + bhs 3b
290 ands ip, r2, #7
291 beq 1b @ If new byte, goto old routine
292 eor r3, r2, #0x18 @ big endian byte ordering
293 diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c
294 index 541e850a736c9..9175c130967ed 100644
295 --- a/arch/arm/mach-bcm/bcm_kona_smc.c
296 +++ b/arch/arm/mach-bcm/bcm_kona_smc.c
297 @@ -54,6 +54,7 @@ int __init bcm_kona_smc_init(void)
298 return -ENODEV;
299
300 prop_val = of_get_address(node, 0, &prop_size, NULL);
301 + of_node_put(node);
302 if (!prop_val)
303 return -EINVAL;
304
305 diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
306 index 1bd64f6ba8cfe..1de25166414e8 100644
307 --- a/arch/arm/mach-omap2/display.c
308 +++ b/arch/arm/mach-omap2/display.c
309 @@ -211,6 +211,7 @@ static int __init omapdss_init_fbdev(void)
310 node = of_find_node_by_name(NULL, "omap4_padconf_global");
311 if (node)
312 omap4_dsi_mux_syscon = syscon_node_to_regmap(node);
313 + of_node_put(node);
314
315 return 0;
316 }
317 @@ -259,11 +260,13 @@ static int __init omapdss_init_of(void)
318
319 if (!pdev) {
320 pr_err("Unable to find DSS platform device\n");
321 + of_node_put(node);
322 return -ENODEV;
323 }
324
325 r = of_platform_populate(node, NULL, NULL, &pdev->dev);
326 put_device(&pdev->dev);
327 + of_node_put(node);
328 if (r) {
329 pr_err("Unable to populate DSS submodule devices\n");
330 return r;
331 diff --git a/arch/arm/mach-omap2/prm3xxx.c b/arch/arm/mach-omap2/prm3xxx.c
332 index 1b442b1285693..63e73e9b82bc6 100644
333 --- a/arch/arm/mach-omap2/prm3xxx.c
334 +++ b/arch/arm/mach-omap2/prm3xxx.c
335 @@ -708,6 +708,7 @@ static int omap3xxx_prm_late_init(void)
336 }
337
338 irq_num = of_irq_get(np, 0);
339 + of_node_put(np);
340 if (irq_num == -EPROBE_DEFER)
341 return irq_num;
342
343 diff --git a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
344 index 09ef73b99dd86..ba44cec5e59ac 100644
345 --- a/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
346 +++ b/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
347 @@ -125,6 +125,7 @@ remove:
348
349 list_for_each_entry_safe(pos, tmp, &quirk_list, list) {
350 list_del(&pos->list);
351 + of_node_put(pos->np);
352 kfree(pos);
353 }
354
355 @@ -174,11 +175,12 @@ static int __init rcar_gen2_regulator_quirk(void)
356 memcpy(&quirk->i2c_msg, id->data, sizeof(quirk->i2c_msg));
357
358 quirk->id = id;
359 - quirk->np = np;
360 + quirk->np = of_node_get(np);
361 quirk->i2c_msg.addr = addr;
362
363 ret = of_irq_parse_one(np, 0, argsa);
364 if (ret) { /* Skip invalid entry and continue */
365 + of_node_put(np);
366 kfree(quirk);
367 continue;
368 }
369 @@ -225,6 +227,7 @@ err_free:
370 err_mem:
371 list_for_each_entry_safe(pos, tmp, &quirk_list, list) {
372 list_del(&pos->list);
373 + of_node_put(pos->np);
374 kfree(pos);
375 }
376
377 diff --git a/arch/arm/mach-zynq/common.c b/arch/arm/mach-zynq/common.c
378 index 3a4248fd79628..25530ddae1fa1 100644
379 --- a/arch/arm/mach-zynq/common.c
380 +++ b/arch/arm/mach-zynq/common.c
381 @@ -77,6 +77,7 @@ static int __init zynq_get_revision(void)
382 }
383
384 zynq_devcfg_base = of_iomap(np, 0);
385 + of_node_put(np);
386 if (!zynq_devcfg_base) {
387 pr_err("%s: Unable to map I/O memory\n", __func__);
388 return -1;
389 diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts
390 index a0db02504b69e..963a7c505e30f 100644
391 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts
392 +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-orangepi-win.dts
393 @@ -78,7 +78,7 @@
394 leds {
395 compatible = "gpio-leds";
396
397 - status {
398 + led-0 {
399 label = "orangepi:green:status";
400 gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
401 };
402 diff --git a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
403 index 83e10591e0e5d..81215cc3759a8 100644
404 --- a/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
405 +++ b/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
406 @@ -49,7 +49,7 @@
407 wps {
408 label = "wps";
409 linux,code = <KEY_WPS_BUTTON>;
410 - gpios = <&pio 102 GPIO_ACTIVE_HIGH>;
411 + gpios = <&pio 102 GPIO_ACTIVE_LOW>;
412 };
413 };
414
415 diff --git a/arch/arm64/boot/dts/qcom/ipq8074.dtsi b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
416 index 7822592664ffb..1e9fa049c5502 100644
417 --- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi
418 +++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
419 @@ -253,7 +253,7 @@
420 status = "disabled";
421 };
422
423 - qpic_nand: nand@79b0000 {
424 + qpic_nand: nand-controller@79b0000 {
425 compatible = "qcom,ipq8074-nand";
426 reg = <0x79b0000 0x10000>;
427 #address-cells = <1>;
428 diff --git a/arch/arm64/boot/dts/socionext/uniphier-pxs3.dtsi b/arch/arm64/boot/dts/socionext/uniphier-pxs3.dtsi
429 index 6537c69de3dd3..b793a43e06124 100644
430 --- a/arch/arm64/boot/dts/socionext/uniphier-pxs3.dtsi
431 +++ b/arch/arm64/boot/dts/socionext/uniphier-pxs3.dtsi
432 @@ -544,8 +544,8 @@
433 compatible = "socionext,uniphier-dwc3", "snps,dwc3";
434 status = "disabled";
435 reg = <0x65a00000 0xcd00>;
436 - interrupt-names = "host", "peripheral";
437 - interrupts = <0 134 4>, <0 135 4>;
438 + interrupt-names = "dwc_usb3";
439 + interrupts = <0 134 4>;
440 pinctrl-names = "default";
441 pinctrl-0 = <&pinctrl_usb0>, <&pinctrl_usb2>;
442 clock-names = "ref", "bus_early", "suspend";
443 @@ -646,8 +646,8 @@
444 compatible = "socionext,uniphier-dwc3", "snps,dwc3";
445 status = "disabled";
446 reg = <0x65c00000 0xcd00>;
447 - interrupt-names = "host", "peripheral";
448 - interrupts = <0 137 4>, <0 138 4>;
449 + interrupt-names = "dwc_usb3";
450 + interrupts = <0 137 4>;
451 pinctrl-names = "default";
452 pinctrl-0 = <&pinctrl_usb1>, <&pinctrl_usb3>;
453 clock-names = "ref", "bus_early", "suspend";
454 diff --git a/arch/arm64/crypto/Kconfig b/arch/arm64/crypto/Kconfig
455 index 4922c4451e7c3..99cddf1145c2f 100644
456 --- a/arch/arm64/crypto/Kconfig
457 +++ b/arch/arm64/crypto/Kconfig
458 @@ -59,6 +59,7 @@ config CRYPTO_GHASH_ARM64_CE
459 select CRYPTO_HASH
460 select CRYPTO_GF128MUL
461 select CRYPTO_LIB_AES
462 + select CRYPTO_AEAD
463
464 config CRYPTO_CRCT10DIF_ARM64_CE
465 tristate "CRCT10DIF digest algorithm using PMULL instructions"
466 diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
467 index 5623685c7d138..65834b84f0e16 100644
468 --- a/arch/arm64/include/asm/processor.h
469 +++ b/arch/arm64/include/asm/processor.h
470 @@ -184,8 +184,9 @@ void tls_preserve_current_state(void);
471
472 static inline void start_thread_common(struct pt_regs *regs, unsigned long pc)
473 {
474 + s32 previous_syscall = regs->syscallno;
475 memset(regs, 0, sizeof(*regs));
476 - forget_syscall(regs);
477 + regs->syscallno = previous_syscall;
478 regs->pc = pc;
479
480 if (system_uses_irq_prio_masking())
481 diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
482 index bcb14d11232f9..fbf66e0973aab 100644
483 --- a/arch/arm64/kernel/armv8_deprecated.c
484 +++ b/arch/arm64/kernel/armv8_deprecated.c
485 @@ -59,6 +59,7 @@ struct insn_emulation {
486 static LIST_HEAD(insn_emulation);
487 static int nr_insn_emulated __initdata;
488 static DEFINE_RAW_SPINLOCK(insn_emulation_lock);
489 +static DEFINE_MUTEX(insn_emulation_mutex);
490
491 static void register_emulation_hooks(struct insn_emulation_ops *ops)
492 {
493 @@ -207,10 +208,10 @@ static int emulation_proc_handler(struct ctl_table *table, int write,
494 loff_t *ppos)
495 {
496 int ret = 0;
497 - struct insn_emulation *insn = (struct insn_emulation *) table->data;
498 + struct insn_emulation *insn = container_of(table->data, struct insn_emulation, current_mode);
499 enum insn_emulation_mode prev_mode = insn->current_mode;
500
501 - table->data = &insn->current_mode;
502 + mutex_lock(&insn_emulation_mutex);
503 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
504
505 if (ret || !write || prev_mode == insn->current_mode)
506 @@ -223,7 +224,7 @@ static int emulation_proc_handler(struct ctl_table *table, int write,
507 update_insn_emulation_mode(insn, INSN_UNDEF);
508 }
509 ret:
510 - table->data = insn;
511 + mutex_unlock(&insn_emulation_mutex);
512 return ret;
513 }
514
515 @@ -247,7 +248,7 @@ static void __init register_insn_emulation_sysctl(void)
516 sysctl->maxlen = sizeof(int);
517
518 sysctl->procname = insn->ops->name;
519 - sysctl->data = insn;
520 + sysctl->data = &insn->current_mode;
521 sysctl->extra1 = &insn->min;
522 sysctl->extra2 = &insn->max;
523 sysctl->proc_handler = emulation_proc_handler;
524 diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
525 index 95a2ec37400fb..0025f890b5a38 100644
526 --- a/arch/ia64/include/asm/processor.h
527 +++ b/arch/ia64/include/asm/processor.h
528 @@ -552,7 +552,7 @@ ia64_get_irr(unsigned int vector)
529 {
530 unsigned int reg = vector / 64;
531 unsigned int bit = vector % 64;
532 - u64 irr;
533 + unsigned long irr;
534
535 switch (reg) {
536 case 0: irr = ia64_getreg(_IA64_REG_CR_IRR0); break;
537 diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
538 index c214fe4e678bb..04bc347147270 100644
539 --- a/arch/mips/cavium-octeon/octeon-platform.c
540 +++ b/arch/mips/cavium-octeon/octeon-platform.c
541 @@ -86,11 +86,12 @@ static void octeon2_usb_clocks_start(struct device *dev)
542 "refclk-frequency", &clock_rate);
543 if (i) {
544 dev_err(dev, "No UCTL \"refclk-frequency\"\n");
545 + of_node_put(uctl_node);
546 goto exit;
547 }
548 i = of_property_read_string(uctl_node,
549 "refclk-type", &clock_type);
550 -
551 + of_node_put(uctl_node);
552 if (!i && strcmp("crystal", clock_type) == 0)
553 is_crystal_clock = true;
554 }
555 diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
556 index f8d36710cd581..d408b3a5bfd57 100644
557 --- a/arch/mips/kernel/proc.c
558 +++ b/arch/mips/kernel/proc.c
559 @@ -168,7 +168,7 @@ static void *c_start(struct seq_file *m, loff_t *pos)
560 {
561 unsigned long i = *pos;
562
563 - return i < NR_CPUS ? (void *) (i + 1) : NULL;
564 + return i < nr_cpu_ids ? (void *) (i + 1) : NULL;
565 }
566
567 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
568 diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
569 index 547d813ead488..061dc5c97d5ad 100644
570 --- a/arch/mips/mm/tlbex.c
571 +++ b/arch/mips/mm/tlbex.c
572 @@ -629,7 +629,7 @@ static __maybe_unused void build_convert_pte_to_entrylo(u32 **p,
573 return;
574 }
575
576 - if (cpu_has_rixi && !!_PAGE_NO_EXEC) {
577 + if (cpu_has_rixi && _PAGE_NO_EXEC != 0) {
578 if (fill_includes_sw_bits) {
579 UASM_i_ROTR(p, reg, reg, ilog2(_PAGE_GLOBAL));
580 } else {
581 @@ -2568,7 +2568,7 @@ static void check_pabits(void)
582 unsigned long entry;
583 unsigned pabits, fillbits;
584
585 - if (!cpu_has_rixi || !_PAGE_NO_EXEC) {
586 + if (!cpu_has_rixi || _PAGE_NO_EXEC == 0) {
587 /*
588 * We'll only be making use of the fact that we can rotate bits
589 * into the fill if the CPU supports RIXI, so don't bother
590 diff --git a/arch/nios2/include/asm/entry.h b/arch/nios2/include/asm/entry.h
591 index cf37f55efbc22..bafb7b2ca59fc 100644
592 --- a/arch/nios2/include/asm/entry.h
593 +++ b/arch/nios2/include/asm/entry.h
594 @@ -50,7 +50,8 @@
595 stw r13, PT_R13(sp)
596 stw r14, PT_R14(sp)
597 stw r15, PT_R15(sp)
598 - stw r2, PT_ORIG_R2(sp)
599 + movi r24, -1
600 + stw r24, PT_ORIG_R2(sp)
601 stw r7, PT_ORIG_R7(sp)
602
603 stw ra, PT_RA(sp)
604 diff --git a/arch/nios2/include/asm/ptrace.h b/arch/nios2/include/asm/ptrace.h
605 index 6424621448728..9da34c3022a27 100644
606 --- a/arch/nios2/include/asm/ptrace.h
607 +++ b/arch/nios2/include/asm/ptrace.h
608 @@ -74,6 +74,8 @@ extern void show_regs(struct pt_regs *);
609 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE)\
610 - 1)
611
612 +#define force_successful_syscall_return() (current_pt_regs()->orig_r2 = -1)
613 +
614 int do_syscall_trace_enter(void);
615 void do_syscall_trace_exit(void);
616 #endif /* __ASSEMBLY__ */
617 diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
618 index 1e515ccd698e3..af556588248e7 100644
619 --- a/arch/nios2/kernel/entry.S
620 +++ b/arch/nios2/kernel/entry.S
621 @@ -185,6 +185,7 @@ ENTRY(handle_system_call)
622 ldw r5, PT_R5(sp)
623
624 local_restart:
625 + stw r2, PT_ORIG_R2(sp)
626 /* Check that the requested system call is within limits */
627 movui r1, __NR_syscalls
628 bgeu r2, r1, ret_invsyscall
629 @@ -192,7 +193,6 @@ local_restart:
630 movhi r11, %hiadj(sys_call_table)
631 add r1, r1, r11
632 ldw r1, %lo(sys_call_table)(r1)
633 - beq r1, r0, ret_invsyscall
634
635 /* Check if we are being traced */
636 GET_THREAD_INFO r11
637 @@ -213,6 +213,9 @@ local_restart:
638 translate_rc_and_ret:
639 movi r1, 0
640 bge r2, zero, 3f
641 + ldw r1, PT_ORIG_R2(sp)
642 + addi r1, r1, 1
643 + beq r1, zero, 3f
644 sub r2, zero, r2
645 movi r1, 1
646 3:
647 @@ -255,9 +258,9 @@ traced_system_call:
648 ldw r6, PT_R6(sp)
649 ldw r7, PT_R7(sp)
650
651 - /* Fetch the syscall function, we don't need to check the boundaries
652 - * since this is already done.
653 - */
654 + /* Fetch the syscall function. */
655 + movui r1, __NR_syscalls
656 + bgeu r2, r1, traced_invsyscall
657 slli r1, r2, 2
658 movhi r11,%hiadj(sys_call_table)
659 add r1, r1, r11
660 @@ -276,6 +279,9 @@ traced_system_call:
661 translate_rc_and_ret2:
662 movi r1, 0
663 bge r2, zero, 4f
664 + ldw r1, PT_ORIG_R2(sp)
665 + addi r1, r1, 1
666 + beq r1, zero, 4f
667 sub r2, zero, r2
668 movi r1, 1
669 4:
670 @@ -287,6 +293,11 @@ end_translate_rc_and_ret2:
671 RESTORE_SWITCH_STACK
672 br ret_from_exception
673
674 + /* If the syscall number was invalid return ENOSYS */
675 +traced_invsyscall:
676 + movi r2, -ENOSYS
677 + br translate_rc_and_ret2
678 +
679 Luser_return:
680 GET_THREAD_INFO r11 /* get thread_info pointer */
681 ldw r10, TI_FLAGS(r11) /* get thread_info->flags */
682 @@ -336,9 +347,6 @@ external_interrupt:
683 /* skip if no interrupt is pending */
684 beq r12, r0, ret_from_interrupt
685
686 - movi r24, -1
687 - stw r24, PT_ORIG_R2(sp)
688 -
689 /*
690 * Process an external hardware interrupt.
691 */
692 diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
693 index a42dd09c65783..bfb20821a8f49 100644
694 --- a/arch/nios2/kernel/signal.c
695 +++ b/arch/nios2/kernel/signal.c
696 @@ -240,7 +240,7 @@ static int do_signal(struct pt_regs *regs)
697 /*
698 * If we were from a system call, check for system call restarting...
699 */
700 - if (regs->orig_r2 >= 0) {
701 + if (regs->orig_r2 >= 0 && regs->r1) {
702 continue_addr = regs->ea;
703 restart_addr = continue_addr - 4;
704 retval = regs->r2;
705 @@ -261,6 +261,7 @@ static int do_signal(struct pt_regs *regs)
706 regs->ea = restart_addr;
707 break;
708 }
709 + regs->orig_r2 = -1;
710 }
711
712 if (get_signal(&ksig)) {
713 diff --git a/arch/nios2/kernel/syscall_table.c b/arch/nios2/kernel/syscall_table.c
714 index 6176d63023c1d..c2875a6dd5a4a 100644
715 --- a/arch/nios2/kernel/syscall_table.c
716 +++ b/arch/nios2/kernel/syscall_table.c
717 @@ -13,5 +13,6 @@
718 #define __SYSCALL(nr, call) [nr] = (call),
719
720 void *sys_call_table[__NR_syscalls] = {
721 + [0 ... __NR_syscalls-1] = sys_ni_syscall,
722 #include <asm/unistd.h>
723 };
724 diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
725 index a5f3e50fe9761..516f3891e793f 100644
726 --- a/arch/parisc/kernel/drivers.c
727 +++ b/arch/parisc/kernel/drivers.c
728 @@ -520,7 +520,6 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
729 dev->id.hversion_rev = iodc_data[1] & 0x0f;
730 dev->id.sversion = ((iodc_data[4] & 0x0f) << 16) |
731 (iodc_data[5] << 8) | iodc_data[6];
732 - dev->hpa.name = parisc_pathname(dev);
733 dev->hpa.start = hpa;
734 /* This is awkward. The STI spec says that gfx devices may occupy
735 * 32MB or 64MB. Unfortunately, we don't know how to tell whether
736 @@ -534,10 +533,10 @@ alloc_pa_dev(unsigned long hpa, struct hardware_path *mod_path)
737 dev->hpa.end = hpa + 0xfff;
738 }
739 dev->hpa.flags = IORESOURCE_MEM;
740 - name = parisc_hardware_description(&dev->id);
741 - if (name) {
742 - strlcpy(dev->name, name, sizeof(dev->name));
743 - }
744 + dev->hpa.name = dev->name;
745 + name = parisc_hardware_description(&dev->id) ? : "unknown";
746 + snprintf(dev->name, sizeof(dev->name), "%s [%s]",
747 + name, parisc_pathname(dev));
748
749 /* Silently fail things like mouse ports which are subsumed within
750 * the keyboard controller
751 diff --git a/arch/parisc/kernel/syscalls/syscall.tbl b/arch/parisc/kernel/syscalls/syscall.tbl
752 index 285ff516150cf..51f15a414e29a 100644
753 --- a/arch/parisc/kernel/syscalls/syscall.tbl
754 +++ b/arch/parisc/kernel/syscalls/syscall.tbl
755 @@ -413,7 +413,7 @@
756 412 32 utimensat_time64 sys_utimensat sys_utimensat
757 413 32 pselect6_time64 sys_pselect6 compat_sys_pselect6_time64
758 414 32 ppoll_time64 sys_ppoll compat_sys_ppoll_time64
759 -416 32 io_pgetevents_time64 sys_io_pgetevents sys_io_pgetevents
760 +416 32 io_pgetevents_time64 sys_io_pgetevents compat_sys_io_pgetevents_time64
761 417 32 recvmmsg_time64 sys_recvmmsg compat_sys_recvmmsg_time64
762 418 32 mq_timedsend_time64 sys_mq_timedsend sys_mq_timedsend
763 419 32 mq_timedreceive_time64 sys_mq_timedreceive sys_mq_timedreceive
764 diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
765 index b9d2fcf030d0d..eedd114a017c7 100644
766 --- a/arch/powerpc/Makefile
767 +++ b/arch/powerpc/Makefile
768 @@ -17,23 +17,6 @@ HAS_BIARCH := $(call cc-option-yn, -m32)
769 # Set default 32 bits cross compilers for vdso and boot wrapper
770 CROSS32_COMPILE ?=
771
772 -ifeq ($(HAS_BIARCH),y)
773 -ifeq ($(CROSS32_COMPILE),)
774 -ifdef CONFIG_PPC32
775 -# These options will be overridden by any -mcpu option that the CPU
776 -# or platform code sets later on the command line, but they are needed
777 -# to set a sane 32-bit cpu target for the 64-bit cross compiler which
778 -# may default to the wrong ISA.
779 -KBUILD_CFLAGS += -mcpu=powerpc
780 -KBUILD_AFLAGS += -mcpu=powerpc
781 -endif
782 -endif
783 -endif
784 -
785 -ifdef CONFIG_PPC_BOOK3S_32
786 -KBUILD_CFLAGS += -mcpu=powerpc
787 -endif
788 -
789 # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
790 # ppc64_defconfig because we have nothing better to go on.
791 uname := $(shell uname -m)
792 @@ -192,6 +175,7 @@ endif
793 endif
794
795 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
796 +AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
797
798 # Altivec option not allowed with e500mc64 in GCC.
799 ifdef CONFIG_ALTIVEC
800 @@ -202,14 +186,6 @@ endif
801 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
802 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
803
804 -ifdef CONFIG_PPC32
805 -ifdef CONFIG_PPC_E500MC
806 -CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
807 -else
808 -CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
809 -endif
810 -endif
811 -
812 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
813
814 KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr)
815 diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
816 index a2c258a8d7367..b9cb9fa9207a6 100644
817 --- a/arch/powerpc/kernel/pci-common.c
818 +++ b/arch/powerpc/kernel/pci-common.c
819 @@ -66,23 +66,35 @@ void set_pci_dma_ops(const struct dma_map_ops *dma_ops)
820 pci_dma_ops = dma_ops;
821 }
822
823 -/*
824 - * This function should run under locking protection, specifically
825 - * hose_spinlock.
826 - */
827 static int get_phb_number(struct device_node *dn)
828 {
829 int ret, phb_id = -1;
830 - u32 prop_32;
831 u64 prop;
832
833 /*
834 * Try fixed PHB numbering first, by checking archs and reading
835 - * the respective device-tree properties. Firstly, try powernv by
836 - * reading "ibm,opal-phbid", only present in OPAL environment.
837 + * the respective device-tree properties. Firstly, try reading
838 + * standard "linux,pci-domain", then try reading "ibm,opal-phbid"
839 + * (only present in powernv OPAL environment), then try device-tree
840 + * alias and as the last try to use lower bits of "reg" property.
841 */
842 - ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
843 + ret = of_get_pci_domain_nr(dn);
844 + if (ret >= 0) {
845 + prop = ret;
846 + ret = 0;
847 + }
848 + if (ret)
849 + ret = of_property_read_u64(dn, "ibm,opal-phbid", &prop);
850 +
851 if (ret) {
852 + ret = of_alias_get_id(dn, "pci");
853 + if (ret >= 0) {
854 + prop = ret;
855 + ret = 0;
856 + }
857 + }
858 + if (ret) {
859 + u32 prop_32;
860 ret = of_property_read_u32_index(dn, "reg", 1, &prop_32);
861 prop = prop_32;
862 }
863 @@ -90,18 +102,20 @@ static int get_phb_number(struct device_node *dn)
864 if (!ret)
865 phb_id = (int)(prop & (MAX_PHBS - 1));
866
867 + spin_lock(&hose_spinlock);
868 +
869 /* We need to be sure to not use the same PHB number twice. */
870 if ((phb_id >= 0) && !test_and_set_bit(phb_id, phb_bitmap))
871 - return phb_id;
872 + goto out_unlock;
873
874 - /*
875 - * If not pseries nor powernv, or if fixed PHB numbering tried to add
876 - * the same PHB number twice, then fallback to dynamic PHB numbering.
877 - */
878 + /* If everything fails then fallback to dynamic PHB numbering. */
879 phb_id = find_first_zero_bit(phb_bitmap, MAX_PHBS);
880 BUG_ON(phb_id >= MAX_PHBS);
881 set_bit(phb_id, phb_bitmap);
882
883 +out_unlock:
884 + spin_unlock(&hose_spinlock);
885 +
886 return phb_id;
887 }
888
889 @@ -112,10 +126,13 @@ struct pci_controller *pcibios_alloc_controller(struct device_node *dev)
890 phb = zalloc_maybe_bootmem(sizeof(struct pci_controller), GFP_KERNEL);
891 if (phb == NULL)
892 return NULL;
893 - spin_lock(&hose_spinlock);
894 +
895 phb->global_number = get_phb_number(dev);
896 +
897 + spin_lock(&hose_spinlock);
898 list_add_tail(&phb->list_node, &hose_list);
899 spin_unlock(&hose_spinlock);
900 +
901 phb->dn = dev;
902 phb->is_dynamic = slab_is_available();
903 #ifdef CONFIG_PPC64
904 diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
905 index 537142b877b88..d1ba175013430 100644
906 --- a/arch/powerpc/kernel/prom.c
907 +++ b/arch/powerpc/kernel/prom.c
908 @@ -740,6 +740,13 @@ void __init early_init_devtree(void *params)
909 of_scan_flat_dt(early_init_dt_scan_root, NULL);
910 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
911
912 + /*
913 + * As generic code authors expect to be able to use static keys
914 + * in early_param() handlers, we initialize the static keys just
915 + * before parsing early params (it's fine to call jump_label_init()
916 + * more than once).
917 + */
918 + jump_label_init();
919 parse_early_param();
920
921 /* make sure we've parsed cmdline for mem= before this */
922 diff --git a/arch/powerpc/mm/ptdump/shared.c b/arch/powerpc/mm/ptdump/shared.c
923 index 784f8df17f732..f10f2158c8afb 100644
924 --- a/arch/powerpc/mm/ptdump/shared.c
925 +++ b/arch/powerpc/mm/ptdump/shared.c
926 @@ -17,9 +17,9 @@ static const struct flag_info flag_array[] = {
927 .clear = " ",
928 }, {
929 .mask = _PAGE_RW,
930 - .val = _PAGE_RW,
931 - .set = "rw",
932 - .clear = "r ",
933 + .val = 0,
934 + .set = "r ",
935 + .clear = "rw",
936 }, {
937 .mask = _PAGE_EXEC,
938 .val = _PAGE_EXEC,
939 diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
940 index f0330ce498d1e..325dc8b534228 100644
941 --- a/arch/powerpc/platforms/Kconfig.cputype
942 +++ b/arch/powerpc/platforms/Kconfig.cputype
943 @@ -118,9 +118,9 @@ config GENERIC_CPU
944 depends on PPC64 && CPU_LITTLE_ENDIAN
945 select ARCH_HAS_FAST_MULTIPLIER
946
947 -config GENERIC_CPU
948 +config POWERPC_CPU
949 bool "Generic 32 bits powerpc"
950 - depends on PPC32 && !PPC_8xx
951 + depends on PPC32 && !PPC_8xx && !PPC_85xx
952
953 config CELL_CPU
954 bool "Cell Broadband Engine"
955 @@ -151,11 +151,11 @@ config POWER9_CPU
956
957 config E5500_CPU
958 bool "Freescale e5500"
959 - depends on E500
960 + depends on PPC64 && E500
961
962 config E6500_CPU
963 bool "Freescale e6500"
964 - depends on E500
965 + depends on PPC64 && E500
966
967 config 860_CPU
968 bool "8xx family"
969 @@ -174,11 +174,23 @@ config G4_CPU
970 depends on PPC_BOOK3S_32
971 select ALTIVEC
972
973 +config E500_CPU
974 + bool "e500 (8540)"
975 + depends on PPC_85xx && !PPC_E500MC
976 +
977 +config E500MC_CPU
978 + bool "e500mc"
979 + depends on PPC_85xx && PPC_E500MC
980 +
981 +config TOOLCHAIN_DEFAULT_CPU
982 + bool "Rely on the toolchain's implicit default CPU"
983 + depends on PPC32
984 +
985 endchoice
986
987 config TARGET_CPU_BOOL
988 bool
989 - default !GENERIC_CPU
990 + default !GENERIC_CPU && !TOOLCHAIN_DEFAULT_CPU
991
992 config TARGET_CPU
993 string
994 @@ -193,6 +205,9 @@ config TARGET_CPU
995 default "e300c2" if E300C2_CPU
996 default "e300c3" if E300C3_CPU
997 default "G4" if G4_CPU
998 + default "8540" if E500_CPU
999 + default "e500mc" if E500MC_CPU
1000 + default "powerpc" if POWERPC_CPU
1001
1002 config PPC_BOOK3S
1003 def_bool y
1004 diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
1005 index 57c4e0e86c884..ba33140e671da 100644
1006 --- a/arch/powerpc/platforms/cell/axon_msi.c
1007 +++ b/arch/powerpc/platforms/cell/axon_msi.c
1008 @@ -226,6 +226,7 @@ static int setup_msi_msg_address(struct pci_dev *dev, struct msi_msg *msg)
1009 if (!prop) {
1010 dev_dbg(&dev->dev,
1011 "axon_msi: no msi-address-(32|64) properties found\n");
1012 + of_node_put(dn);
1013 return -ENOENT;
1014 }
1015
1016 diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
1017 index 2dd452a047cd6..99e688498a9cb 100644
1018 --- a/arch/powerpc/platforms/cell/spufs/inode.c
1019 +++ b/arch/powerpc/platforms/cell/spufs/inode.c
1020 @@ -671,6 +671,7 @@ spufs_init_isolated_loader(void)
1021 return;
1022
1023 loader = of_get_property(dn, "loader", &size);
1024 + of_node_put(dn);
1025 if (!loader)
1026 return;
1027
1028 diff --git a/arch/powerpc/platforms/powernv/rng.c b/arch/powerpc/platforms/powernv/rng.c
1029 index 7186e17cfd3dc..ace6497017830 100644
1030 --- a/arch/powerpc/platforms/powernv/rng.c
1031 +++ b/arch/powerpc/platforms/powernv/rng.c
1032 @@ -63,6 +63,8 @@ int powernv_get_random_real_mode(unsigned long *v)
1033 struct powernv_rng *rng;
1034
1035 rng = raw_cpu_read(powernv_rng);
1036 + if (!rng)
1037 + return 0;
1038
1039 *v = rng_whiten(rng, __raw_rm_readq(rng->regs_real));
1040
1041 diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
1042 index ff0e2b156cb5f..6adf2fdec799e 100644
1043 --- a/arch/powerpc/sysdev/fsl_pci.c
1044 +++ b/arch/powerpc/sysdev/fsl_pci.c
1045 @@ -520,6 +520,7 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)
1046 struct resource rsrc;
1047 const int *bus_range;
1048 u8 hdr_type, progif;
1049 + u32 class_code;
1050 struct device_node *dev;
1051 struct ccsr_pci __iomem *pci;
1052 u16 temp;
1053 @@ -593,6 +594,13 @@ int fsl_add_bridge(struct platform_device *pdev, int is_primary)
1054 PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS;
1055 if (fsl_pcie_check_link(hose))
1056 hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK;
1057 + /* Fix Class Code to PCI_CLASS_BRIDGE_PCI_NORMAL for pre-3.0 controller */
1058 + if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0) {
1059 + early_read_config_dword(hose, 0, 0, PCIE_FSL_CSR_CLASSCODE, &class_code);
1060 + class_code &= 0xff;
1061 + class_code |= PCI_CLASS_BRIDGE_PCI_NORMAL << 8;
1062 + early_write_config_dword(hose, 0, 0, PCIE_FSL_CSR_CLASSCODE, class_code);
1063 + }
1064 } else {
1065 /*
1066 * Set PBFR(PCI Bus Function Register)[10] = 1 to
1067 diff --git a/arch/powerpc/sysdev/fsl_pci.h b/arch/powerpc/sysdev/fsl_pci.h
1068 index 1d7a412056959..5ffaa60f1fa09 100644
1069 --- a/arch/powerpc/sysdev/fsl_pci.h
1070 +++ b/arch/powerpc/sysdev/fsl_pci.h
1071 @@ -18,6 +18,7 @@ struct platform_device;
1072
1073 #define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */
1074 #define PCIE_LTSSM_L0 0x16 /* L0 state */
1075 +#define PCIE_FSL_CSR_CLASSCODE 0x474 /* FSL GPEX CSR */
1076 #define PCIE_IP_REV_2_2 0x02080202 /* PCIE IP block version Rev2.2 */
1077 #define PCIE_IP_REV_3_0 0x02080300 /* PCIE IP block version Rev3.0 */
1078 #define PIWAR_EN 0x80000000 /* Enable */
1079 diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
1080 index 3f15615712b5b..b21d71badaec9 100644
1081 --- a/arch/powerpc/sysdev/xive/spapr.c
1082 +++ b/arch/powerpc/sysdev/xive/spapr.c
1083 @@ -683,6 +683,7 @@ static bool xive_get_max_prio(u8 *max_prio)
1084 }
1085
1086 reg = of_get_property(rootdn, "ibm,plat-res-int-priorities", &len);
1087 + of_node_put(rootdn);
1088 if (!reg) {
1089 pr_err("Failed to read 'ibm,plat-res-int-priorities' property\n");
1090 return false;
1091 diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c
1092 index 12f8a7fce78b1..8a7880b9c433e 100644
1093 --- a/arch/riscv/kernel/sys_riscv.c
1094 +++ b/arch/riscv/kernel/sys_riscv.c
1095 @@ -18,9 +18,8 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len,
1096 if (unlikely(offset & (~PAGE_MASK >> page_shift_offset)))
1097 return -EINVAL;
1098
1099 - if ((prot & PROT_WRITE) && (prot & PROT_EXEC))
1100 - if (unlikely(!(prot & PROT_READ)))
1101 - return -EINVAL;
1102 + if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ)))
1103 + return -EINVAL;
1104
1105 return ksys_mmap_pgoff(addr, len, prot, flags, fd,
1106 offset >> (PAGE_SHIFT - page_shift_offset));
1107 diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c
1108 index 473de3ae8bb75..ae462037910be 100644
1109 --- a/arch/riscv/kernel/traps.c
1110 +++ b/arch/riscv/kernel/traps.c
1111 @@ -15,6 +15,7 @@
1112 #include <linux/mm.h>
1113 #include <linux/module.h>
1114 #include <linux/irq.h>
1115 +#include <linux/kexec.h>
1116
1117 #include <asm/processor.h>
1118 #include <asm/ptrace.h>
1119 @@ -43,6 +44,9 @@ void die(struct pt_regs *regs, const char *str)
1120
1121 ret = notify_die(DIE_OOPS, str, regs, 0, regs->scause, SIGSEGV);
1122
1123 + if (regs && kexec_should_crash(current))
1124 + crash_kexec(regs);
1125 +
1126 bust_spinlocks(0);
1127 add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
1128 spin_unlock_irq(&die_lock);
1129 diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c
1130 index 76cd09879eaf4..53da174754d97 100644
1131 --- a/arch/s390/kernel/machine_kexec_file.c
1132 +++ b/arch/s390/kernel/machine_kexec_file.c
1133 @@ -29,6 +29,7 @@ int s390_verify_sig(const char *kernel, unsigned long kernel_len)
1134 const unsigned long marker_len = sizeof(MODULE_SIG_STRING) - 1;
1135 struct module_signature *ms;
1136 unsigned long sig_len;
1137 + int ret;
1138
1139 /* Skip signature verification when not secure IPLed. */
1140 if (!ipl_secure_flag)
1141 @@ -63,11 +64,18 @@ int s390_verify_sig(const char *kernel, unsigned long kernel_len)
1142 return -EBADMSG;
1143 }
1144
1145 - return verify_pkcs7_signature(kernel, kernel_len,
1146 - kernel + kernel_len, sig_len,
1147 - VERIFY_USE_PLATFORM_KEYRING,
1148 - VERIFYING_MODULE_SIGNATURE,
1149 - NULL, NULL);
1150 + ret = verify_pkcs7_signature(kernel, kernel_len,
1151 + kernel + kernel_len, sig_len,
1152 + VERIFY_USE_SECONDARY_KEYRING,
1153 + VERIFYING_MODULE_SIGNATURE,
1154 + NULL, NULL);
1155 + if (ret == -ENOKEY && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING))
1156 + ret = verify_pkcs7_signature(kernel, kernel_len,
1157 + kernel + kernel_len, sig_len,
1158 + VERIFY_USE_PLATFORM_KEYRING,
1159 + VERIFYING_MODULE_SIGNATURE,
1160 + NULL, NULL);
1161 + return ret;
1162 }
1163 #endif /* CONFIG_KEXEC_SIG */
1164
1165 diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
1166 index 4fb877b99dded..0571cc0a30fcc 100644
1167 --- a/arch/um/os-Linux/skas/process.c
1168 +++ b/arch/um/os-Linux/skas/process.c
1169 @@ -5,6 +5,7 @@
1170 */
1171
1172 #include <stdlib.h>
1173 +#include <stdbool.h>
1174 #include <unistd.h>
1175 #include <sched.h>
1176 #include <errno.h>
1177 @@ -641,10 +642,24 @@ void halt_skas(void)
1178 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_HALT);
1179 }
1180
1181 +static bool noreboot;
1182 +
1183 +static int __init noreboot_cmd_param(char *str, int *add)
1184 +{
1185 + noreboot = true;
1186 + return 0;
1187 +}
1188 +
1189 +__uml_setup("noreboot", noreboot_cmd_param,
1190 +"noreboot\n"
1191 +" Rather than rebooting, exit always, akin to QEMU's -no-reboot option.\n"
1192 +" This is useful if you're using CONFIG_PANIC_TIMEOUT in order to catch\n"
1193 +" crashes in CI\n");
1194 +
1195 void reboot_skas(void)
1196 {
1197 block_signals_trace();
1198 - UML_LONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
1199 + UML_LONGJMP(&initial_jmpbuf, noreboot ? INIT_JMP_HALT : INIT_JMP_REBOOT);
1200 }
1201
1202 void __switch_mm(struct mm_id *mm_idp)
1203 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
1204 index 6539c50fb9aae..82500962f1b3d 100644
1205 --- a/arch/x86/boot/Makefile
1206 +++ b/arch/x86/boot/Makefile
1207 @@ -100,7 +100,7 @@ $(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
1208 AFLAGS_header.o += -I$(objtree)/$(obj)
1209 $(obj)/header.o: $(obj)/zoffset.h
1210
1211 -LDFLAGS_setup.elf := -m elf_i386 -T
1212 +LDFLAGS_setup.elf := -m elf_i386 -z noexecstack -T
1213 $(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
1214 $(call if_changed,ld)
1215
1216 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
1217 index 292b5bc6e3a30..edfb1a7185109 100644
1218 --- a/arch/x86/boot/compressed/Makefile
1219 +++ b/arch/x86/boot/compressed/Makefile
1220 @@ -57,6 +57,10 @@ else
1221 KBUILD_LDFLAGS += $(shell $(LD) --help 2>&1 | grep -q "\-z noreloc-overflow" \
1222 && echo "-z noreloc-overflow -pie --no-dynamic-linker")
1223 endif
1224 +
1225 +KBUILD_LDFLAGS += -z noexecstack
1226 +KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
1227 +
1228 LDFLAGS_vmlinux := -T
1229
1230 hostprogs-y := mkpiggy
1231 diff --git a/arch/x86/entry/vdso/Makefile b/arch/x86/entry/vdso/Makefile
1232 index 0f2154106d016..5aae81f40bc3a 100644
1233 --- a/arch/x86/entry/vdso/Makefile
1234 +++ b/arch/x86/entry/vdso/Makefile
1235 @@ -178,7 +178,7 @@ quiet_cmd_vdso = VDSO $@
1236 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
1237
1238 VDSO_LDFLAGS = -shared --hash-style=both --build-id \
1239 - $(call ld-option, --eh-frame-hdr) -Bsymbolic
1240 + $(call ld-option, --eh-frame-hdr) -Bsymbolic -z noexecstack
1241 GCOV_PROFILE := n
1242
1243 quiet_cmd_vdso_and_check = VDSO $@
1244 diff --git a/arch/x86/kernel/pmem.c b/arch/x86/kernel/pmem.c
1245 index 6b07faaa15798..23154d24b1173 100644
1246 --- a/arch/x86/kernel/pmem.c
1247 +++ b/arch/x86/kernel/pmem.c
1248 @@ -27,6 +27,11 @@ static __init int register_e820_pmem(void)
1249 * simply here to trigger the module to load on demand.
1250 */
1251 pdev = platform_device_alloc("e820_pmem", -1);
1252 - return platform_device_add(pdev);
1253 +
1254 + rc = platform_device_add(pdev);
1255 + if (rc)
1256 + platform_device_put(pdev);
1257 +
1258 + return rc;
1259 }
1260 device_initcall(register_e820_pmem);
1261 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
1262 index 571e38c9ee1d3..068715a52ac10 100644
1263 --- a/arch/x86/kernel/process.c
1264 +++ b/arch/x86/kernel/process.c
1265 @@ -659,6 +659,10 @@ static void amd_e400_idle(void)
1266 */
1267 static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
1268 {
1269 + /* User has disallowed the use of MWAIT. Fallback to HALT */
1270 + if (boot_option_idle_override == IDLE_NOMWAIT)
1271 + return 0;
1272 +
1273 if (c->x86_vendor != X86_VENDOR_INTEL)
1274 return 0;
1275
1276 @@ -769,9 +773,8 @@ static int __init idle_setup(char *str)
1277 } else if (!strcmp(str, "nomwait")) {
1278 /*
1279 * If the boot option of "idle=nomwait" is added,
1280 - * it means that mwait will be disabled for CPU C2/C3
1281 - * states. In such case it won't touch the variable
1282 - * of boot_option_idle_override.
1283 + * it means that mwait will be disabled for CPU C1/C2/C3
1284 + * states.
1285 */
1286 boot_option_idle_override = IDLE_NOMWAIT;
1287 } else
1288 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
1289 index ea48a2fb1677d..fcb59dc54bf56 100644
1290 --- a/arch/x86/kvm/emulate.c
1291 +++ b/arch/x86/kvm/emulate.c
1292 @@ -1753,16 +1753,6 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1293 case VCPU_SREG_TR:
1294 if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9))
1295 goto exception;
1296 - if (!seg_desc.p) {
1297 - err_vec = NP_VECTOR;
1298 - goto exception;
1299 - }
1300 - old_desc = seg_desc;
1301 - seg_desc.type |= 2; /* busy */
1302 - ret = ctxt->ops->cmpxchg_emulated(ctxt, desc_addr, &old_desc, &seg_desc,
1303 - sizeof(seg_desc), &ctxt->exception);
1304 - if (ret != X86EMUL_CONTINUE)
1305 - return ret;
1306 break;
1307 case VCPU_SREG_LDTR:
1308 if (seg_desc.s || seg_desc.type != 2)
1309 @@ -1800,8 +1790,17 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
1310 if (ret != X86EMUL_CONTINUE)
1311 return ret;
1312 if (emul_is_noncanonical_address(get_desc_base(&seg_desc) |
1313 - ((u64)base3 << 32), ctxt))
1314 - return emulate_gp(ctxt, 0);
1315 + ((u64)base3 << 32), ctxt))
1316 + return emulate_gp(ctxt, err_code);
1317 + }
1318 +
1319 + if (seg == VCPU_SREG_TR) {
1320 + old_desc = seg_desc;
1321 + seg_desc.type |= 2; /* busy */
1322 + ret = ctxt->ops->cmpxchg_emulated(ctxt, desc_addr, &old_desc, &seg_desc,
1323 + sizeof(seg_desc), &ctxt->exception);
1324 + if (ret != X86EMUL_CONTINUE)
1325 + return ret;
1326 }
1327 load:
1328 ctxt->ops->set_segment(ctxt, selector, &seg_desc, base3, seg);
1329 diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c
1330 index ca66459a2e895..f9603df799bf1 100644
1331 --- a/arch/x86/kvm/hyperv.c
1332 +++ b/arch/x86/kvm/hyperv.c
1333 @@ -309,6 +309,9 @@ static int synic_set_irq(struct kvm_vcpu_hv_synic *synic, u32 sint)
1334 struct kvm_lapic_irq irq;
1335 int ret, vector;
1336
1337 + if (KVM_BUG_ON(!lapic_in_kernel(vcpu), vcpu->kvm))
1338 + return -EINVAL;
1339 +
1340 if (sint >= ARRAY_SIZE(synic->sint))
1341 return -EINVAL;
1342
1343 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
1344 index 3696b4de9d99d..23480d8e4ef17 100644
1345 --- a/arch/x86/kvm/lapic.c
1346 +++ b/arch/x86/kvm/lapic.c
1347 @@ -955,6 +955,10 @@ bool kvm_irq_delivery_to_apic_fast(struct kvm *kvm, struct kvm_lapic *src,
1348 *r = -1;
1349
1350 if (irq->shorthand == APIC_DEST_SELF) {
1351 + if (KVM_BUG_ON(!src, kvm)) {
1352 + *r = 0;
1353 + return true;
1354 + }
1355 *r = kvm_apic_set_irq(src->vcpu, irq, dest_map);
1356 return true;
1357 }
1358 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
1359 index 125970286f289..1efcc7d4bc88e 100644
1360 --- a/arch/x86/kvm/svm.c
1361 +++ b/arch/x86/kvm/svm.c
1362 @@ -5137,8 +5137,6 @@ static void svm_set_irq(struct kvm_vcpu *vcpu)
1363 {
1364 struct vcpu_svm *svm = to_svm(vcpu);
1365
1366 - BUG_ON(!(gif_set(svm)));
1367 -
1368 trace_kvm_inj_virq(vcpu->arch.interrupt.nr);
1369 ++vcpu->stat.irq_injections;
1370
1371 diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
1372 index 9f61ae64b7277..34ee4835b0177 100644
1373 --- a/arch/x86/kvm/vmx/nested.c
1374 +++ b/arch/x86/kvm/vmx/nested.c
1375 @@ -1060,7 +1060,7 @@ static int vmx_restore_vmx_basic(struct vcpu_vmx *vmx, u64 data)
1376 BIT_ULL(49) | BIT_ULL(54) | BIT_ULL(55) |
1377 /* reserved */
1378 BIT_ULL(31) | GENMASK_ULL(47, 45) | GENMASK_ULL(63, 56);
1379 - u64 vmx_basic = vmx->nested.msrs.basic;
1380 + u64 vmx_basic = vmcs_config.nested.basic;
1381
1382 if (!is_bitwise_subset(vmx_basic, data, feature_and_reserved))
1383 return -EINVAL;
1384 @@ -1083,36 +1083,42 @@ static int vmx_restore_vmx_basic(struct vcpu_vmx *vmx, u64 data)
1385 return 0;
1386 }
1387
1388 -static int
1389 -vmx_restore_control_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1390 +static void vmx_get_control_msr(struct nested_vmx_msrs *msrs, u32 msr_index,
1391 + u32 **low, u32 **high)
1392 {
1393 - u64 supported;
1394 - u32 *lowp, *highp;
1395 -
1396 switch (msr_index) {
1397 case MSR_IA32_VMX_TRUE_PINBASED_CTLS:
1398 - lowp = &vmx->nested.msrs.pinbased_ctls_low;
1399 - highp = &vmx->nested.msrs.pinbased_ctls_high;
1400 + *low = &msrs->pinbased_ctls_low;
1401 + *high = &msrs->pinbased_ctls_high;
1402 break;
1403 case MSR_IA32_VMX_TRUE_PROCBASED_CTLS:
1404 - lowp = &vmx->nested.msrs.procbased_ctls_low;
1405 - highp = &vmx->nested.msrs.procbased_ctls_high;
1406 + *low = &msrs->procbased_ctls_low;
1407 + *high = &msrs->procbased_ctls_high;
1408 break;
1409 case MSR_IA32_VMX_TRUE_EXIT_CTLS:
1410 - lowp = &vmx->nested.msrs.exit_ctls_low;
1411 - highp = &vmx->nested.msrs.exit_ctls_high;
1412 + *low = &msrs->exit_ctls_low;
1413 + *high = &msrs->exit_ctls_high;
1414 break;
1415 case MSR_IA32_VMX_TRUE_ENTRY_CTLS:
1416 - lowp = &vmx->nested.msrs.entry_ctls_low;
1417 - highp = &vmx->nested.msrs.entry_ctls_high;
1418 + *low = &msrs->entry_ctls_low;
1419 + *high = &msrs->entry_ctls_high;
1420 break;
1421 case MSR_IA32_VMX_PROCBASED_CTLS2:
1422 - lowp = &vmx->nested.msrs.secondary_ctls_low;
1423 - highp = &vmx->nested.msrs.secondary_ctls_high;
1424 + *low = &msrs->secondary_ctls_low;
1425 + *high = &msrs->secondary_ctls_high;
1426 break;
1427 default:
1428 BUG();
1429 }
1430 +}
1431 +
1432 +static int
1433 +vmx_restore_control_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1434 +{
1435 + u32 *lowp, *highp;
1436 + u64 supported;
1437 +
1438 + vmx_get_control_msr(&vmcs_config.nested, msr_index, &lowp, &highp);
1439
1440 supported = vmx_control_msr(*lowp, *highp);
1441
1442 @@ -1124,6 +1130,7 @@ vmx_restore_control_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1443 if (!is_bitwise_subset(supported, data, GENMASK_ULL(63, 32)))
1444 return -EINVAL;
1445
1446 + vmx_get_control_msr(&vmx->nested.msrs, msr_index, &lowp, &highp);
1447 *lowp = data;
1448 *highp = data >> 32;
1449 return 0;
1450 @@ -1137,10 +1144,8 @@ static int vmx_restore_vmx_misc(struct vcpu_vmx *vmx, u64 data)
1451 BIT_ULL(28) | BIT_ULL(29) | BIT_ULL(30) |
1452 /* reserved */
1453 GENMASK_ULL(13, 9) | BIT_ULL(31);
1454 - u64 vmx_misc;
1455 -
1456 - vmx_misc = vmx_control_msr(vmx->nested.msrs.misc_low,
1457 - vmx->nested.msrs.misc_high);
1458 + u64 vmx_misc = vmx_control_msr(vmcs_config.nested.misc_low,
1459 + vmcs_config.nested.misc_high);
1460
1461 if (!is_bitwise_subset(vmx_misc, data, feature_and_reserved_bits))
1462 return -EINVAL;
1463 @@ -1168,10 +1173,8 @@ static int vmx_restore_vmx_misc(struct vcpu_vmx *vmx, u64 data)
1464
1465 static int vmx_restore_vmx_ept_vpid_cap(struct vcpu_vmx *vmx, u64 data)
1466 {
1467 - u64 vmx_ept_vpid_cap;
1468 -
1469 - vmx_ept_vpid_cap = vmx_control_msr(vmx->nested.msrs.ept_caps,
1470 - vmx->nested.msrs.vpid_caps);
1471 + u64 vmx_ept_vpid_cap = vmx_control_msr(vmcs_config.nested.ept_caps,
1472 + vmcs_config.nested.vpid_caps);
1473
1474 /* Every bit is either reserved or a feature bit. */
1475 if (!is_bitwise_subset(vmx_ept_vpid_cap, data, -1ULL))
1476 @@ -1182,20 +1185,21 @@ static int vmx_restore_vmx_ept_vpid_cap(struct vcpu_vmx *vmx, u64 data)
1477 return 0;
1478 }
1479
1480 -static int vmx_restore_fixed0_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1481 +static u64 *vmx_get_fixed0_msr(struct nested_vmx_msrs *msrs, u32 msr_index)
1482 {
1483 - u64 *msr;
1484 -
1485 switch (msr_index) {
1486 case MSR_IA32_VMX_CR0_FIXED0:
1487 - msr = &vmx->nested.msrs.cr0_fixed0;
1488 - break;
1489 + return &msrs->cr0_fixed0;
1490 case MSR_IA32_VMX_CR4_FIXED0:
1491 - msr = &vmx->nested.msrs.cr4_fixed0;
1492 - break;
1493 + return &msrs->cr4_fixed0;
1494 default:
1495 BUG();
1496 }
1497 +}
1498 +
1499 +static int vmx_restore_fixed0_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1500 +{
1501 + const u64 *msr = vmx_get_fixed0_msr(&vmcs_config.nested, msr_index);
1502
1503 /*
1504 * 1 bits (which indicates bits which "must-be-1" during VMX operation)
1505 @@ -1204,7 +1208,7 @@ static int vmx_restore_fixed0_msr(struct vcpu_vmx *vmx, u32 msr_index, u64 data)
1506 if (!is_bitwise_subset(data, *msr, -1ULL))
1507 return -EINVAL;
1508
1509 - *msr = data;
1510 + *vmx_get_fixed0_msr(&vmx->nested.msrs, msr_index) = data;
1511 return 0;
1512 }
1513
1514 @@ -1265,7 +1269,7 @@ int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
1515 vmx->nested.msrs.vmcs_enum = data;
1516 return 0;
1517 case MSR_IA32_VMX_VMFUNC:
1518 - if (data & ~vmx->nested.msrs.vmfunc_controls)
1519 + if (data & ~vmcs_config.nested.vmfunc_controls)
1520 return -EINVAL;
1521 vmx->nested.msrs.vmfunc_controls = data;
1522 return 0;
1523 @@ -3065,10 +3069,12 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,
1524 if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu))
1525 evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu);
1526
1527 - if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
1528 + if (!vmx->nested.nested_run_pending ||
1529 + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
1530 vmx->nested.vmcs01_debugctl = vmcs_read64(GUEST_IA32_DEBUGCTL);
1531 if (kvm_mpx_supported() &&
1532 - !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS))
1533 + (!vmx->nested.nested_run_pending ||
1534 + !(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)))
1535 vmx->nested.vmcs01_guest_bndcfgs = vmcs_read64(GUEST_BNDCFGS);
1536
1537 /*
1538 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
1539 index 4123100e0eafe..67c617c4a7f20 100644
1540 --- a/arch/x86/mm/numa.c
1541 +++ b/arch/x86/mm/numa.c
1542 @@ -822,7 +822,7 @@ void debug_cpumask_set_cpu(int cpu, int node, bool enable)
1543 return;
1544 }
1545 mask = node_to_cpumask_map[node];
1546 - if (!mask) {
1547 + if (!cpumask_available(mask)) {
1548 pr_err("node_to_cpumask_map[%i] NULL\n", node);
1549 dump_stack();
1550 return;
1551 @@ -868,7 +868,7 @@ const struct cpumask *cpumask_of_node(int node)
1552 dump_stack();
1553 return cpu_none_mask;
1554 }
1555 - if (node_to_cpumask_map[node] == NULL) {
1556 + if (!cpumask_available(node_to_cpumask_map[node])) {
1557 printk(KERN_WARNING
1558 "cpumask_of_node(%d): no node_to_cpumask_map!\n",
1559 node);
1560 diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c
1561 index 99a28ce2244c7..90735895aa443 100644
1562 --- a/arch/x86/platform/olpc/olpc-xo1-sci.c
1563 +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c
1564 @@ -81,7 +81,7 @@ static void send_ebook_state(void)
1565 return;
1566 }
1567
1568 - if (!!test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == state)
1569 + if (test_bit(SW_TABLET_MODE, ebook_switch_idev->sw) == !!state)
1570 return; /* Nothing new to report. */
1571
1572 input_report_switch(ebook_switch_idev, SW_TABLET_MODE, state);
1573 diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
1574 index 121f4c1e0697b..772a6c6b16342 100644
1575 --- a/block/blk-mq-debugfs.c
1576 +++ b/block/blk-mq-debugfs.c
1577 @@ -883,6 +883,9 @@ void blk_mq_debugfs_register_hctx(struct request_queue *q,
1578 char name[20];
1579 int i;
1580
1581 + if (!q->debugfs_dir)
1582 + return;
1583 +
1584 snprintf(name, sizeof(name), "hctx%u", hctx->queue_num);
1585 hctx->debugfs_dir = debugfs_create_dir(name, q->debugfs_dir);
1586
1587 diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
1588 index 751ed38f2a10e..b939a6736d0ba 100644
1589 --- a/drivers/acpi/acpi_lpss.c
1590 +++ b/drivers/acpi/acpi_lpss.c
1591 @@ -401,6 +401,9 @@ static int register_device_clock(struct acpi_device *adev,
1592 if (!lpss_clk_dev)
1593 lpt_register_clock_device();
1594
1595 + if (IS_ERR(lpss_clk_dev))
1596 + return PTR_ERR(lpss_clk_dev);
1597 +
1598 clk_data = platform_get_drvdata(lpss_clk_dev);
1599 if (!clk_data)
1600 return -ENODEV;
1601 diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
1602 index 0521b1d4c2fd0..d24cbba14e919 100644
1603 --- a/drivers/acpi/cppc_acpi.c
1604 +++ b/drivers/acpi/cppc_acpi.c
1605 @@ -626,33 +626,6 @@ int pcc_data_alloc(int pcc_ss_id)
1606 return 0;
1607 }
1608
1609 -/* Check if CPPC revision + num_ent combination is supported */
1610 -static bool is_cppc_supported(int revision, int num_ent)
1611 -{
1612 - int expected_num_ent;
1613 -
1614 - switch (revision) {
1615 - case CPPC_V2_REV:
1616 - expected_num_ent = CPPC_V2_NUM_ENT;
1617 - break;
1618 - case CPPC_V3_REV:
1619 - expected_num_ent = CPPC_V3_NUM_ENT;
1620 - break;
1621 - default:
1622 - pr_debug("Firmware exports unsupported CPPC revision: %d\n",
1623 - revision);
1624 - return false;
1625 - }
1626 -
1627 - if (expected_num_ent != num_ent) {
1628 - pr_debug("Firmware exports %d entries. Expected: %d for CPPC rev:%d\n",
1629 - num_ent, expected_num_ent, revision);
1630 - return false;
1631 - }
1632 -
1633 - return true;
1634 -}
1635 -
1636 /*
1637 * An example CPC table looks like the following.
1638 *
1639 @@ -748,7 +721,6 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
1640 cpc_obj->type);
1641 goto out_free;
1642 }
1643 - cpc_ptr->num_entries = num_ent;
1644
1645 /* Second entry should be revision. */
1646 cpc_obj = &out_obj->package.elements[1];
1647 @@ -759,10 +731,32 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
1648 cpc_obj->type);
1649 goto out_free;
1650 }
1651 - cpc_ptr->version = cpc_rev;
1652
1653 - if (!is_cppc_supported(cpc_rev, num_ent))
1654 + if (cpc_rev < CPPC_V2_REV) {
1655 + pr_debug("Unsupported _CPC Revision (%d) for CPU:%d\n", cpc_rev,
1656 + pr->id);
1657 goto out_free;
1658 + }
1659 +
1660 + /*
1661 + * Disregard _CPC if the number of entries in the return pachage is not
1662 + * as expected, but support future revisions being proper supersets of
1663 + * the v3 and only causing more entries to be returned by _CPC.
1664 + */
1665 + if ((cpc_rev == CPPC_V2_REV && num_ent != CPPC_V2_NUM_ENT) ||
1666 + (cpc_rev == CPPC_V3_REV && num_ent != CPPC_V3_NUM_ENT) ||
1667 + (cpc_rev > CPPC_V3_REV && num_ent <= CPPC_V3_NUM_ENT)) {
1668 + pr_debug("Unexpected number of _CPC return package entries (%d) for CPU:%d\n",
1669 + num_ent, pr->id);
1670 + goto out_free;
1671 + }
1672 + if (cpc_rev > CPPC_V3_REV) {
1673 + num_ent = CPPC_V3_NUM_ENT;
1674 + cpc_rev = CPPC_V3_REV;
1675 + }
1676 +
1677 + cpc_ptr->num_entries = num_ent;
1678 + cpc_ptr->version = cpc_rev;
1679
1680 /* Iterate through remaining entries in _CPC */
1681 for (i = 2; i < num_ent; i++) {
1682 diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
1683 index e5b92958c299e..defc5796b5084 100644
1684 --- a/drivers/acpi/ec.c
1685 +++ b/drivers/acpi/ec.c
1686 @@ -2118,13 +2118,6 @@ static const struct dmi_system_id acpi_ec_no_wakeup[] = {
1687 DMI_MATCH(DMI_PRODUCT_FAMILY, "Thinkpad X1 Carbon 6th"),
1688 },
1689 },
1690 - {
1691 - .ident = "ThinkPad X1 Carbon 6th",
1692 - .matches = {
1693 - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1694 - DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Carbon 6th"),
1695 - },
1696 - },
1697 {
1698 .ident = "ThinkPad X1 Yoga 3rd",
1699 .matches = {
1700 diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c
1701 index 47e43c9498257..ed2f880b63b5f 100644
1702 --- a/drivers/acpi/pci_mcfg.c
1703 +++ b/drivers/acpi/pci_mcfg.c
1704 @@ -41,6 +41,8 @@ struct mcfg_fixup {
1705 static struct mcfg_fixup mcfg_quirks[] = {
1706 /* { OEM_ID, OEM_TABLE_ID, REV, SEGMENT, BUS_RANGE, ops, cfgres }, */
1707
1708 +#ifdef CONFIG_ARM64
1709 +
1710 #define AL_ECAM(table_id, rev, seg, ops) \
1711 { "AMAZON", table_id, rev, seg, MCFG_BUS_ANY, ops }
1712
1713 @@ -162,6 +164,7 @@ static struct mcfg_fixup mcfg_quirks[] = {
1714 ALTRA_ECAM_QUIRK(1, 13),
1715 ALTRA_ECAM_QUIRK(1, 14),
1716 ALTRA_ECAM_QUIRK(1, 15),
1717 +#endif /* ARM64 */
1718 };
1719
1720 static char mcfg_oem_id[ACPI_OEM_ID_SIZE];
1721 diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c
1722 index 1b0aeb8320448..479856ceda9fb 100644
1723 --- a/drivers/acpi/property.c
1724 +++ b/drivers/acpi/property.c
1725 @@ -152,10 +152,10 @@ static bool acpi_nondev_subnode_ok(acpi_handle scope,
1726 return acpi_nondev_subnode_data_ok(handle, link, list, parent);
1727 }
1728
1729 -static int acpi_add_nondev_subnodes(acpi_handle scope,
1730 - const union acpi_object *links,
1731 - struct list_head *list,
1732 - struct fwnode_handle *parent)
1733 +static bool acpi_add_nondev_subnodes(acpi_handle scope,
1734 + const union acpi_object *links,
1735 + struct list_head *list,
1736 + struct fwnode_handle *parent)
1737 {
1738 bool ret = false;
1739 int i;
1740 diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
1741 index 34966128293b1..b9d203569ac1d 100644
1742 --- a/drivers/acpi/sleep.c
1743 +++ b/drivers/acpi/sleep.c
1744 @@ -361,6 +361,14 @@ static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
1745 DMI_MATCH(DMI_PRODUCT_NAME, "80E3"),
1746 },
1747 },
1748 + {
1749 + .callback = init_nvs_save_s3,
1750 + .ident = "Lenovo G40-45",
1751 + .matches = {
1752 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1753 + DMI_MATCH(DMI_PRODUCT_NAME, "80E1"),
1754 + },
1755 + },
1756 /*
1757 * ThinkPad X1 Tablet(2016) cannot do suspend-to-idle using
1758 * the Low Power S0 Idle firmware interface (see
1759 diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
1760 index c6a21a784ec65..5c91183b5b736 100644
1761 --- a/drivers/ata/libata-eh.c
1762 +++ b/drivers/ata/libata-eh.c
1763 @@ -2329,6 +2329,7 @@ const char *ata_get_cmd_descript(u8 command)
1764 { ATA_CMD_WRITE_QUEUED_FUA_EXT, "WRITE DMA QUEUED FUA EXT" },
1765 { ATA_CMD_FPDMA_READ, "READ FPDMA QUEUED" },
1766 { ATA_CMD_FPDMA_WRITE, "WRITE FPDMA QUEUED" },
1767 + { ATA_CMD_NCQ_NON_DATA, "NCQ NON-DATA" },
1768 { ATA_CMD_FPDMA_SEND, "SEND FPDMA QUEUED" },
1769 { ATA_CMD_FPDMA_RECV, "RECEIVE FPDMA QUEUED" },
1770 { ATA_CMD_PIO_READ, "READ SECTOR(S)" },
1771 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
1772 index 363073e7b6538..a95a9448984fe 100644
1773 --- a/drivers/atm/idt77252.c
1774 +++ b/drivers/atm/idt77252.c
1775 @@ -3766,6 +3766,7 @@ static void __exit idt77252_exit(void)
1776 card = idt77252_chain;
1777 dev = card->atmdev;
1778 idt77252_chain = card->next;
1779 + del_timer_sync(&card->tst_timer);
1780
1781 if (dev->phy->stop)
1782 dev->phy->stop(dev);
1783 diff --git a/drivers/base/dd.c b/drivers/base/dd.c
1784 index 6f85280fef8d3..4e45c87ed1778 100644
1785 --- a/drivers/base/dd.c
1786 +++ b/drivers/base/dd.c
1787 @@ -1037,6 +1037,7 @@ static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
1788 static int __driver_attach(struct device *dev, void *data)
1789 {
1790 struct device_driver *drv = data;
1791 + bool async = false;
1792 int ret;
1793
1794 /*
1795 @@ -1074,9 +1075,11 @@ static int __driver_attach(struct device *dev, void *data)
1796 if (!dev->driver) {
1797 get_device(dev);
1798 dev->p->async_driver = drv;
1799 - async_schedule_dev(__driver_attach_async_helper, dev);
1800 + async = true;
1801 }
1802 device_unlock(dev);
1803 + if (async)
1804 + async_schedule_dev(__driver_attach_async_helper, dev);
1805 return 0;
1806 }
1807
1808 diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
1809 index 13eae973eaea4..6cbdd8a691d2b 100644
1810 --- a/drivers/block/null_blk_main.c
1811 +++ b/drivers/block/null_blk_main.c
1812 @@ -1711,8 +1711,13 @@ static int null_add_dev(struct nullb_device *dev)
1813 blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, nullb->q);
1814
1815 mutex_lock(&lock);
1816 - nullb->index = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL);
1817 - dev->index = nullb->index;
1818 + rv = ida_simple_get(&nullb_indexes, 0, 0, GFP_KERNEL);
1819 + if (rv < 0) {
1820 + mutex_unlock(&lock);
1821 + goto out_cleanup_zone;
1822 + }
1823 + nullb->index = rv;
1824 + dev->index = rv;
1825 mutex_unlock(&lock);
1826
1827 blk_queue_logical_block_size(nullb->q, dev->blocksize);
1828 @@ -1724,13 +1729,16 @@ static int null_add_dev(struct nullb_device *dev)
1829
1830 rv = null_gendisk_register(nullb);
1831 if (rv)
1832 - goto out_cleanup_zone;
1833 + goto out_ida_free;
1834
1835 mutex_lock(&lock);
1836 list_add_tail(&nullb->list, &nullb_list);
1837 mutex_unlock(&lock);
1838
1839 return 0;
1840 +
1841 +out_ida_free:
1842 + ida_free(&nullb_indexes, nullb->index);
1843 out_cleanup_zone:
1844 if (dev->zoned)
1845 null_zone_exit(dev);
1846 diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
1847 index 31f25153087d7..02c96c603768a 100644
1848 --- a/drivers/bluetooth/hci_intel.c
1849 +++ b/drivers/bluetooth/hci_intel.c
1850 @@ -1230,7 +1230,11 @@ static struct platform_driver intel_driver = {
1851
1852 int __init intel_init(void)
1853 {
1854 - platform_driver_register(&intel_driver);
1855 + int err;
1856 +
1857 + err = platform_driver_register(&intel_driver);
1858 + if (err)
1859 + return err;
1860
1861 return hci_uart_register_proto(&intel_proto);
1862 }
1863 diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c
1864 index 2e9252d37a18f..0922cbe8900b4 100644
1865 --- a/drivers/bus/hisi_lpc.c
1866 +++ b/drivers/bus/hisi_lpc.c
1867 @@ -504,13 +504,13 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
1868 {
1869 struct acpi_device *adev = ACPI_COMPANION(hostdev);
1870 struct acpi_device *child;
1871 + struct platform_device *pdev;
1872 int ret;
1873
1874 /* Only consider the children of the host */
1875 list_for_each_entry(child, &adev->children, node) {
1876 const char *hid = acpi_device_hid(child);
1877 const struct hisi_lpc_acpi_cell *cell;
1878 - struct platform_device *pdev;
1879 const struct resource *res;
1880 bool found = false;
1881 int num_res;
1882 @@ -572,22 +572,24 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
1883
1884 ret = platform_device_add_resources(pdev, res, num_res);
1885 if (ret)
1886 - goto fail;
1887 + goto fail_put_device;
1888
1889 ret = platform_device_add_data(pdev, cell->pdata,
1890 cell->pdata_size);
1891 if (ret)
1892 - goto fail;
1893 + goto fail_put_device;
1894
1895 ret = platform_device_add(pdev);
1896 if (ret)
1897 - goto fail;
1898 + goto fail_put_device;
1899
1900 acpi_device_set_enumerated(child);
1901 }
1902
1903 return 0;
1904
1905 +fail_put_device:
1906 + platform_device_put(pdev);
1907 fail:
1908 hisi_lpc_acpi_remove(hostdev);
1909 return ret;
1910 diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
1911 index cb939c071b0cc..89916acf0bc32 100644
1912 --- a/drivers/clk/mediatek/reset.c
1913 +++ b/drivers/clk/mediatek/reset.c
1914 @@ -25,7 +25,7 @@ static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
1915 struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
1916 unsigned int reg = data->regofs + ((id / 32) << 4);
1917
1918 - return regmap_write(data->regmap, reg, 1);
1919 + return regmap_write(data->regmap, reg, BIT(id % 32));
1920 }
1921
1922 static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
1923 @@ -34,7 +34,7 @@ static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
1924 struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev);
1925 unsigned int reg = data->regofs + ((id / 32) << 4) + 0x4;
1926
1927 - return regmap_write(data->regmap, reg, 1);
1928 + return regmap_write(data->regmap, reg, BIT(id % 32));
1929 }
1930
1931 static int mtk_reset_assert(struct reset_controller_dev *rcdev,
1932 diff --git a/drivers/clk/qcom/camcc-sdm845.c b/drivers/clk/qcom/camcc-sdm845.c
1933 index 1b2cefef7431d..a8a2cfa83290a 100644
1934 --- a/drivers/clk/qcom/camcc-sdm845.c
1935 +++ b/drivers/clk/qcom/camcc-sdm845.c
1936 @@ -1521,6 +1521,8 @@ static struct clk_branch cam_cc_sys_tmr_clk = {
1937 },
1938 };
1939
1940 +static struct gdsc titan_top_gdsc;
1941 +
1942 static struct gdsc bps_gdsc = {
1943 .gdscr = 0x6004,
1944 .pd = {
1945 @@ -1554,6 +1556,7 @@ static struct gdsc ife_0_gdsc = {
1946 .name = "ife_0_gdsc",
1947 },
1948 .flags = POLL_CFG_GDSCR,
1949 + .parent = &titan_top_gdsc.pd,
1950 .pwrsts = PWRSTS_OFF_ON,
1951 };
1952
1953 @@ -1563,6 +1566,7 @@ static struct gdsc ife_1_gdsc = {
1954 .name = "ife_1_gdsc",
1955 },
1956 .flags = POLL_CFG_GDSCR,
1957 + .parent = &titan_top_gdsc.pd,
1958 .pwrsts = PWRSTS_OFF_ON,
1959 };
1960
1961 diff --git a/drivers/clk/qcom/clk-krait.c b/drivers/clk/qcom/clk-krait.c
1962 index 59f1af415b580..90046428693c2 100644
1963 --- a/drivers/clk/qcom/clk-krait.c
1964 +++ b/drivers/clk/qcom/clk-krait.c
1965 @@ -32,11 +32,16 @@ static void __krait_mux_set_sel(struct krait_mux_clk *mux, int sel)
1966 regval |= (sel & mux->mask) << (mux->shift + LPL_SHIFT);
1967 }
1968 krait_set_l2_indirect_reg(mux->offset, regval);
1969 - spin_unlock_irqrestore(&krait_clock_reg_lock, flags);
1970
1971 /* Wait for switch to complete. */
1972 mb();
1973 udelay(1);
1974 +
1975 + /*
1976 + * Unlock now to make sure the mux register is not
1977 + * modified while switching to the new parent.
1978 + */
1979 + spin_unlock_irqrestore(&krait_clock_reg_lock, flags);
1980 }
1981
1982 static int krait_mux_set_parent(struct clk_hw *hw, u8 index)
1983 diff --git a/drivers/clk/qcom/gcc-ipq8074.c b/drivers/clk/qcom/gcc-ipq8074.c
1984 index de48ba7eba3a1..e9835db941d88 100644
1985 --- a/drivers/clk/qcom/gcc-ipq8074.c
1986 +++ b/drivers/clk/qcom/gcc-ipq8074.c
1987 @@ -667,6 +667,7 @@ static struct clk_branch gcc_sleep_clk_src = {
1988 },
1989 .num_parents = 1,
1990 .ops = &clk_branch2_ops,
1991 + .flags = CLK_IS_CRITICAL,
1992 },
1993 },
1994 };
1995 @@ -1788,8 +1789,10 @@ static struct clk_regmap_div nss_port4_tx_div_clk_src = {
1996 static const struct freq_tbl ftbl_nss_port5_rx_clk_src[] = {
1997 F(19200000, P_XO, 1, 0, 0),
1998 F(25000000, P_UNIPHY1_RX, 12.5, 0, 0),
1999 + F(25000000, P_UNIPHY0_RX, 5, 0, 0),
2000 F(78125000, P_UNIPHY1_RX, 4, 0, 0),
2001 F(125000000, P_UNIPHY1_RX, 2.5, 0, 0),
2002 + F(125000000, P_UNIPHY0_RX, 1, 0, 0),
2003 F(156250000, P_UNIPHY1_RX, 2, 0, 0),
2004 F(312500000, P_UNIPHY1_RX, 1, 0, 0),
2005 { }
2006 @@ -1828,8 +1831,10 @@ static struct clk_regmap_div nss_port5_rx_div_clk_src = {
2007 static const struct freq_tbl ftbl_nss_port5_tx_clk_src[] = {
2008 F(19200000, P_XO, 1, 0, 0),
2009 F(25000000, P_UNIPHY1_TX, 12.5, 0, 0),
2010 + F(25000000, P_UNIPHY0_TX, 5, 0, 0),
2011 F(78125000, P_UNIPHY1_TX, 4, 0, 0),
2012 F(125000000, P_UNIPHY1_TX, 2.5, 0, 0),
2013 + F(125000000, P_UNIPHY0_TX, 1, 0, 0),
2014 F(156250000, P_UNIPHY1_TX, 2, 0, 0),
2015 F(312500000, P_UNIPHY1_TX, 1, 0, 0),
2016 { }
2017 @@ -1867,8 +1872,10 @@ static struct clk_regmap_div nss_port5_tx_div_clk_src = {
2018
2019 static const struct freq_tbl ftbl_nss_port6_rx_clk_src[] = {
2020 F(19200000, P_XO, 1, 0, 0),
2021 + F(25000000, P_UNIPHY2_RX, 5, 0, 0),
2022 F(25000000, P_UNIPHY2_RX, 12.5, 0, 0),
2023 F(78125000, P_UNIPHY2_RX, 4, 0, 0),
2024 + F(125000000, P_UNIPHY2_RX, 1, 0, 0),
2025 F(125000000, P_UNIPHY2_RX, 2.5, 0, 0),
2026 F(156250000, P_UNIPHY2_RX, 2, 0, 0),
2027 F(312500000, P_UNIPHY2_RX, 1, 0, 0),
2028 @@ -1907,8 +1914,10 @@ static struct clk_regmap_div nss_port6_rx_div_clk_src = {
2029
2030 static const struct freq_tbl ftbl_nss_port6_tx_clk_src[] = {
2031 F(19200000, P_XO, 1, 0, 0),
2032 + F(25000000, P_UNIPHY2_TX, 5, 0, 0),
2033 F(25000000, P_UNIPHY2_TX, 12.5, 0, 0),
2034 F(78125000, P_UNIPHY2_TX, 4, 0, 0),
2035 + F(125000000, P_UNIPHY2_TX, 1, 0, 0),
2036 F(125000000, P_UNIPHY2_TX, 2.5, 0, 0),
2037 F(156250000, P_UNIPHY2_TX, 2, 0, 0),
2038 F(312500000, P_UNIPHY2_TX, 1, 0, 0),
2039 @@ -3346,6 +3355,7 @@ static struct clk_branch gcc_nssnoc_ubi1_ahb_clk = {
2040
2041 static struct clk_branch gcc_ubi0_ahb_clk = {
2042 .halt_reg = 0x6820c,
2043 + .halt_check = BRANCH_HALT_DELAY,
2044 .clkr = {
2045 .enable_reg = 0x6820c,
2046 .enable_mask = BIT(0),
2047 @@ -3363,6 +3373,7 @@ static struct clk_branch gcc_ubi0_ahb_clk = {
2048
2049 static struct clk_branch gcc_ubi0_axi_clk = {
2050 .halt_reg = 0x68200,
2051 + .halt_check = BRANCH_HALT_DELAY,
2052 .clkr = {
2053 .enable_reg = 0x68200,
2054 .enable_mask = BIT(0),
2055 @@ -3380,6 +3391,7 @@ static struct clk_branch gcc_ubi0_axi_clk = {
2056
2057 static struct clk_branch gcc_ubi0_nc_axi_clk = {
2058 .halt_reg = 0x68204,
2059 + .halt_check = BRANCH_HALT_DELAY,
2060 .clkr = {
2061 .enable_reg = 0x68204,
2062 .enable_mask = BIT(0),
2063 @@ -3397,6 +3409,7 @@ static struct clk_branch gcc_ubi0_nc_axi_clk = {
2064
2065 static struct clk_branch gcc_ubi0_core_clk = {
2066 .halt_reg = 0x68210,
2067 + .halt_check = BRANCH_HALT_DELAY,
2068 .clkr = {
2069 .enable_reg = 0x68210,
2070 .enable_mask = BIT(0),
2071 @@ -3414,6 +3427,7 @@ static struct clk_branch gcc_ubi0_core_clk = {
2072
2073 static struct clk_branch gcc_ubi0_mpt_clk = {
2074 .halt_reg = 0x68208,
2075 + .halt_check = BRANCH_HALT_DELAY,
2076 .clkr = {
2077 .enable_reg = 0x68208,
2078 .enable_mask = BIT(0),
2079 @@ -3431,6 +3445,7 @@ static struct clk_branch gcc_ubi0_mpt_clk = {
2080
2081 static struct clk_branch gcc_ubi1_ahb_clk = {
2082 .halt_reg = 0x6822c,
2083 + .halt_check = BRANCH_HALT_DELAY,
2084 .clkr = {
2085 .enable_reg = 0x6822c,
2086 .enable_mask = BIT(0),
2087 @@ -3448,6 +3463,7 @@ static struct clk_branch gcc_ubi1_ahb_clk = {
2088
2089 static struct clk_branch gcc_ubi1_axi_clk = {
2090 .halt_reg = 0x68220,
2091 + .halt_check = BRANCH_HALT_DELAY,
2092 .clkr = {
2093 .enable_reg = 0x68220,
2094 .enable_mask = BIT(0),
2095 @@ -3465,6 +3481,7 @@ static struct clk_branch gcc_ubi1_axi_clk = {
2096
2097 static struct clk_branch gcc_ubi1_nc_axi_clk = {
2098 .halt_reg = 0x68224,
2099 + .halt_check = BRANCH_HALT_DELAY,
2100 .clkr = {
2101 .enable_reg = 0x68224,
2102 .enable_mask = BIT(0),
2103 @@ -3482,6 +3499,7 @@ static struct clk_branch gcc_ubi1_nc_axi_clk = {
2104
2105 static struct clk_branch gcc_ubi1_core_clk = {
2106 .halt_reg = 0x68230,
2107 + .halt_check = BRANCH_HALT_DELAY,
2108 .clkr = {
2109 .enable_reg = 0x68230,
2110 .enable_mask = BIT(0),
2111 @@ -3499,6 +3517,7 @@ static struct clk_branch gcc_ubi1_core_clk = {
2112
2113 static struct clk_branch gcc_ubi1_mpt_clk = {
2114 .halt_reg = 0x68228,
2115 + .halt_check = BRANCH_HALT_DELAY,
2116 .clkr = {
2117 .enable_reg = 0x68228,
2118 .enable_mask = BIT(0),
2119 diff --git a/drivers/clk/renesas/r9a06g032-clocks.c b/drivers/clk/renesas/r9a06g032-clocks.c
2120 index f2dc625b745da..80df4eb041cc2 100644
2121 --- a/drivers/clk/renesas/r9a06g032-clocks.c
2122 +++ b/drivers/clk/renesas/r9a06g032-clocks.c
2123 @@ -286,8 +286,8 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
2124 .name = "uart_group_012",
2125 .type = K_BITSEL,
2126 .source = 1 + R9A06G032_DIV_UART,
2127 - /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG1_PR2 */
2128 - .dual.sel = ((0xec / 4) << 5) | 24,
2129 + /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG0_0 */
2130 + .dual.sel = ((0x34 / 4) << 5) | 30,
2131 .dual.group = 0,
2132 },
2133 {
2134 @@ -295,8 +295,8 @@ static const struct r9a06g032_clkdesc r9a06g032_clocks[] = {
2135 .name = "uart_group_34567",
2136 .type = K_BITSEL,
2137 .source = 1 + R9A06G032_DIV_P2_PG,
2138 - /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG0_0 */
2139 - .dual.sel = ((0x34 / 4) << 5) | 30,
2140 + /* R9A06G032_SYSCTRL_REG_PWRCTRL_PG1_PR2 */
2141 + .dual.sel = ((0xec / 4) << 5) | 24,
2142 .dual.group = 1,
2143 },
2144 D_UGATE(CLK_UART0, "clk_uart0", UART_GROUP_012, 0, 0, 0x1b2, 0x1b3, 0x1b4, 0x1b5),
2145 diff --git a/drivers/clk/rockchip/clk-rk3188.c b/drivers/clk/rockchip/clk-rk3188.c
2146 index 77aebfb1d6d5b..730020fcc7fed 100644
2147 --- a/drivers/clk/rockchip/clk-rk3188.c
2148 +++ b/drivers/clk/rockchip/clk-rk3188.c
2149 @@ -751,6 +751,7 @@ static const char *const rk3188_critical_clocks[] __initconst = {
2150 "pclk_peri",
2151 "hclk_cpubus",
2152 "hclk_vio_bus",
2153 + "sclk_mac_lbtest",
2154 };
2155
2156 static struct rockchip_clk_provider *__init rk3188_common_clk_init(struct device_node *np)
2157 diff --git a/drivers/crypto/hisilicon/sec/sec_algs.c b/drivers/crypto/hisilicon/sec/sec_algs.c
2158 index 4ad4ffd90ceec..2402941a7f2fd 100644
2159 --- a/drivers/crypto/hisilicon/sec/sec_algs.c
2160 +++ b/drivers/crypto/hisilicon/sec/sec_algs.c
2161 @@ -449,7 +449,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,
2162 */
2163 }
2164
2165 - mutex_lock(&ctx->queue->queuelock);
2166 + spin_lock_bh(&ctx->queue->queuelock);
2167 /* Put the IV in place for chained cases */
2168 switch (ctx->cipher_alg) {
2169 case SEC_C_AES_CBC_128:
2170 @@ -509,7 +509,7 @@ static void sec_skcipher_alg_callback(struct sec_bd_info *sec_resp,
2171 list_del(&backlog_req->backlog_head);
2172 }
2173 }
2174 - mutex_unlock(&ctx->queue->queuelock);
2175 + spin_unlock_bh(&ctx->queue->queuelock);
2176
2177 mutex_lock(&sec_req->lock);
2178 list_del(&sec_req_el->head);
2179 @@ -798,7 +798,7 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2180 */
2181
2182 /* Grab a big lock for a long time to avoid concurrency issues */
2183 - mutex_lock(&queue->queuelock);
2184 + spin_lock_bh(&queue->queuelock);
2185
2186 /*
2187 * Can go on to queue if we have space in either:
2188 @@ -814,15 +814,15 @@ static int sec_alg_skcipher_crypto(struct skcipher_request *skreq,
2189 ret = -EBUSY;
2190 if ((skreq->base.flags & CRYPTO_TFM_REQ_MAY_BACKLOG)) {
2191 list_add_tail(&sec_req->backlog_head, &ctx->backlog);
2192 - mutex_unlock(&queue->queuelock);
2193 + spin_unlock_bh(&queue->queuelock);
2194 goto out;
2195 }
2196
2197 - mutex_unlock(&queue->queuelock);
2198 + spin_unlock_bh(&queue->queuelock);
2199 goto err_free_elements;
2200 }
2201 ret = sec_send_request(sec_req, queue);
2202 - mutex_unlock(&queue->queuelock);
2203 + spin_unlock_bh(&queue->queuelock);
2204 if (ret)
2205 goto err_free_elements;
2206
2207 @@ -881,7 +881,7 @@ static int sec_alg_skcipher_init(struct crypto_skcipher *tfm)
2208 if (IS_ERR(ctx->queue))
2209 return PTR_ERR(ctx->queue);
2210
2211 - mutex_init(&ctx->queue->queuelock);
2212 + spin_lock_init(&ctx->queue->queuelock);
2213 ctx->queue->havesoftqueue = false;
2214
2215 return 0;
2216 diff --git a/drivers/crypto/hisilicon/sec/sec_drv.h b/drivers/crypto/hisilicon/sec/sec_drv.h
2217 index 4d9063a8b10b1..0bf4d7c3856ca 100644
2218 --- a/drivers/crypto/hisilicon/sec/sec_drv.h
2219 +++ b/drivers/crypto/hisilicon/sec/sec_drv.h
2220 @@ -347,7 +347,7 @@ struct sec_queue {
2221 DECLARE_BITMAP(unprocessed, SEC_QUEUE_LEN);
2222 DECLARE_KFIFO_PTR(softqueue, typeof(struct sec_request_el *));
2223 bool havesoftqueue;
2224 - struct mutex queuelock;
2225 + spinlock_t queuelock;
2226 void *shadow[SEC_QUEUE_LEN];
2227 };
2228
2229 diff --git a/drivers/crypto/inside-secure/safexcel.c b/drivers/crypto/inside-secure/safexcel.c
2230 index 4d9d97c59ee36..9534f52210af0 100644
2231 --- a/drivers/crypto/inside-secure/safexcel.c
2232 +++ b/drivers/crypto/inside-secure/safexcel.c
2233 @@ -1658,6 +1658,8 @@ static const struct of_device_id safexcel_of_match_table[] = {
2234 {},
2235 };
2236
2237 +MODULE_DEVICE_TABLE(of, safexcel_of_match_table);
2238 +
2239 static struct platform_driver crypto_safexcel = {
2240 .probe = safexcel_probe,
2241 .remove = safexcel_remove,
2242 diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
2243 index b966115bfad1d..4f0c501063210 100644
2244 --- a/drivers/dma/sprd-dma.c
2245 +++ b/drivers/dma/sprd-dma.c
2246 @@ -1201,11 +1201,8 @@ static int sprd_dma_remove(struct platform_device *pdev)
2247 {
2248 struct sprd_dma_dev *sdev = platform_get_drvdata(pdev);
2249 struct sprd_dma_chn *c, *cn;
2250 - int ret;
2251
2252 - ret = pm_runtime_get_sync(&pdev->dev);
2253 - if (ret < 0)
2254 - return ret;
2255 + pm_runtime_get_sync(&pdev->dev);
2256
2257 /* explicitly free the irq */
2258 if (sdev->irq > 0)
2259 diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
2260 index e2995ec144010..72634e9d81169 100644
2261 --- a/drivers/firmware/arm_scpi.c
2262 +++ b/drivers/firmware/arm_scpi.c
2263 @@ -815,7 +815,7 @@ static int scpi_init_versions(struct scpi_drvinfo *info)
2264 info->firmware_version = le32_to_cpu(caps.platform_version);
2265 }
2266 /* Ignore error if not implemented */
2267 - if (scpi_info->is_legacy && ret == -EOPNOTSUPP)
2268 + if (info->is_legacy && ret == -EOPNOTSUPP)
2269 return 0;
2270
2271 return ret;
2272 @@ -905,13 +905,14 @@ static int scpi_probe(struct platform_device *pdev)
2273 struct resource res;
2274 struct device *dev = &pdev->dev;
2275 struct device_node *np = dev->of_node;
2276 + struct scpi_drvinfo *scpi_drvinfo;
2277
2278 - scpi_info = devm_kzalloc(dev, sizeof(*scpi_info), GFP_KERNEL);
2279 - if (!scpi_info)
2280 + scpi_drvinfo = devm_kzalloc(dev, sizeof(*scpi_drvinfo), GFP_KERNEL);
2281 + if (!scpi_drvinfo)
2282 return -ENOMEM;
2283
2284 if (of_match_device(legacy_scpi_of_match, &pdev->dev))
2285 - scpi_info->is_legacy = true;
2286 + scpi_drvinfo->is_legacy = true;
2287
2288 count = of_count_phandle_with_args(np, "mboxes", "#mbox-cells");
2289 if (count < 0) {
2290 @@ -919,19 +920,19 @@ static int scpi_probe(struct platform_device *pdev)
2291 return -ENODEV;
2292 }
2293
2294 - scpi_info->channels = devm_kcalloc(dev, count, sizeof(struct scpi_chan),
2295 - GFP_KERNEL);
2296 - if (!scpi_info->channels)
2297 + scpi_drvinfo->channels =
2298 + devm_kcalloc(dev, count, sizeof(struct scpi_chan), GFP_KERNEL);
2299 + if (!scpi_drvinfo->channels)
2300 return -ENOMEM;
2301
2302 - ret = devm_add_action(dev, scpi_free_channels, scpi_info);
2303 + ret = devm_add_action(dev, scpi_free_channels, scpi_drvinfo);
2304 if (ret)
2305 return ret;
2306
2307 - for (; scpi_info->num_chans < count; scpi_info->num_chans++) {
2308 + for (; scpi_drvinfo->num_chans < count; scpi_drvinfo->num_chans++) {
2309 resource_size_t size;
2310 - int idx = scpi_info->num_chans;
2311 - struct scpi_chan *pchan = scpi_info->channels + idx;
2312 + int idx = scpi_drvinfo->num_chans;
2313 + struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
2314 struct mbox_client *cl = &pchan->cl;
2315 struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
2316
2317 @@ -975,45 +976,53 @@ static int scpi_probe(struct platform_device *pdev)
2318 return ret;
2319 }
2320
2321 - scpi_info->commands = scpi_std_commands;
2322 + scpi_drvinfo->commands = scpi_std_commands;
2323
2324 - platform_set_drvdata(pdev, scpi_info);
2325 + platform_set_drvdata(pdev, scpi_drvinfo);
2326
2327 - if (scpi_info->is_legacy) {
2328 + if (scpi_drvinfo->is_legacy) {
2329 /* Replace with legacy variants */
2330 scpi_ops.clk_set_val = legacy_scpi_clk_set_val;
2331 - scpi_info->commands = scpi_legacy_commands;
2332 + scpi_drvinfo->commands = scpi_legacy_commands;
2333
2334 /* Fill priority bitmap */
2335 for (idx = 0; idx < ARRAY_SIZE(legacy_hpriority_cmds); idx++)
2336 set_bit(legacy_hpriority_cmds[idx],
2337 - scpi_info->cmd_priority);
2338 + scpi_drvinfo->cmd_priority);
2339 }
2340
2341 - ret = scpi_init_versions(scpi_info);
2342 + scpi_info = scpi_drvinfo;
2343 +
2344 + ret = scpi_init_versions(scpi_drvinfo);
2345 if (ret) {
2346 dev_err(dev, "incorrect or no SCP firmware found\n");
2347 + scpi_info = NULL;
2348 return ret;
2349 }
2350
2351 - if (scpi_info->is_legacy && !scpi_info->protocol_version &&
2352 - !scpi_info->firmware_version)
2353 + if (scpi_drvinfo->is_legacy && !scpi_drvinfo->protocol_version &&
2354 + !scpi_drvinfo->firmware_version)
2355 dev_info(dev, "SCP Protocol legacy pre-1.0 firmware\n");
2356 else
2357 dev_info(dev, "SCP Protocol %lu.%lu Firmware %lu.%lu.%lu version\n",
2358 FIELD_GET(PROTO_REV_MAJOR_MASK,
2359 - scpi_info->protocol_version),
2360 + scpi_drvinfo->protocol_version),
2361 FIELD_GET(PROTO_REV_MINOR_MASK,
2362 - scpi_info->protocol_version),
2363 + scpi_drvinfo->protocol_version),
2364 FIELD_GET(FW_REV_MAJOR_MASK,
2365 - scpi_info->firmware_version),
2366 + scpi_drvinfo->firmware_version),
2367 FIELD_GET(FW_REV_MINOR_MASK,
2368 - scpi_info->firmware_version),
2369 + scpi_drvinfo->firmware_version),
2370 FIELD_GET(FW_REV_PATCH_MASK,
2371 - scpi_info->firmware_version));
2372 - scpi_info->scpi_ops = &scpi_ops;
2373 + scpi_drvinfo->firmware_version));
2374 +
2375 + scpi_drvinfo->scpi_ops = &scpi_ops;
2376
2377 - return devm_of_platform_populate(dev);
2378 + ret = devm_of_platform_populate(dev);
2379 + if (ret)
2380 + scpi_info = NULL;
2381 +
2382 + return ret;
2383 }
2384
2385 static const struct of_device_id scpi_of_match[] = {
2386 diff --git a/drivers/fpga/altera-pr-ip-core.c b/drivers/fpga/altera-pr-ip-core.c
2387 index 2cf25fd5e8979..75b4b3ec933a5 100644
2388 --- a/drivers/fpga/altera-pr-ip-core.c
2389 +++ b/drivers/fpga/altera-pr-ip-core.c
2390 @@ -108,7 +108,7 @@ static int alt_pr_fpga_write(struct fpga_manager *mgr, const char *buf,
2391 u32 *buffer_32 = (u32 *)buf;
2392 size_t i = 0;
2393
2394 - if (count <= 0)
2395 + if (!count)
2396 return -EINVAL;
2397
2398 /* Write out the complete 32-bit chunks */
2399 diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
2400 index b1dcd2dd52e6b..73807c897391c 100644
2401 --- a/drivers/gpio/gpiolib-of.c
2402 +++ b/drivers/gpio/gpiolib-of.c
2403 @@ -734,7 +734,8 @@ int of_mm_gpiochip_add_data(struct device_node *np,
2404 if (mm_gc->save_regs)
2405 mm_gc->save_regs(mm_gc);
2406
2407 - mm_gc->gc.of_node = np;
2408 + of_node_put(mm_gc->gc.of_node);
2409 + mm_gc->gc.of_node = of_node_get(np);
2410
2411 ret = gpiochip_add_data(gc, data);
2412 if (ret)
2413 @@ -742,6 +743,7 @@ int of_mm_gpiochip_add_data(struct device_node *np,
2414
2415 return 0;
2416 err2:
2417 + of_node_put(np);
2418 iounmap(mm_gc->regs);
2419 err1:
2420 kfree(gc->label);
2421 diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2422 index 4cc0dd494a42b..fc508927c6f60 100644
2423 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2424 +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
2425 @@ -892,6 +892,10 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
2426 if (WARN_ON_ONCE(min_offset > max_offset))
2427 return -EINVAL;
2428
2429 + /* Check domain to be pinned to against preferred domains */
2430 + if (bo->preferred_domains & domain)
2431 + domain = bo->preferred_domains & domain;
2432 +
2433 /* A shared bo cannot be migrated to VRAM */
2434 if (bo->prime_shared_count) {
2435 if (domain & AMDGPU_GEM_DOMAIN_GTT)
2436 diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
2437 index e7bf32f234d71..62ef603627b77 100644
2438 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
2439 +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
2440 @@ -985,6 +985,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv)
2441 ADV7511_CEC_I2C_ADDR_DEFAULT);
2442 if (IS_ERR(adv->i2c_cec))
2443 return PTR_ERR(adv->i2c_cec);
2444 +
2445 + regmap_write(adv->regmap, ADV7511_REG_CEC_I2C_ADDR,
2446 + adv->i2c_cec->addr << 1);
2447 +
2448 i2c_set_clientdata(adv->i2c_cec, adv);
2449
2450 adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec,
2451 @@ -1189,9 +1193,6 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
2452 if (ret)
2453 goto err_i2c_unregister_packet;
2454
2455 - regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR,
2456 - adv7511->i2c_cec->addr << 1);
2457 -
2458 INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work);
2459
2460 if (i2c->irq) {
2461 @@ -1301,10 +1302,21 @@ static struct i2c_driver adv7511_driver = {
2462
2463 static int __init adv7511_init(void)
2464 {
2465 - if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
2466 - mipi_dsi_driver_register(&adv7533_dsi_driver);
2467 + int ret;
2468
2469 - return i2c_add_driver(&adv7511_driver);
2470 + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI)) {
2471 + ret = mipi_dsi_driver_register(&adv7533_dsi_driver);
2472 + if (ret)
2473 + return ret;
2474 + }
2475 +
2476 + ret = i2c_add_driver(&adv7511_driver);
2477 + if (ret) {
2478 + if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
2479 + mipi_dsi_driver_unregister(&adv7533_dsi_driver);
2480 + }
2481 +
2482 + return ret;
2483 }
2484 module_init(adv7511_init);
2485
2486 diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
2487 index fb0b64c965b74..970bc00d2aaf6 100644
2488 --- a/drivers/gpu/drm/bridge/sil-sii8620.c
2489 +++ b/drivers/gpu/drm/bridge/sil-sii8620.c
2490 @@ -604,7 +604,7 @@ static void *sii8620_burst_get_tx_buf(struct sii8620 *ctx, int len)
2491 u8 *buf = &ctx->burst.tx_buf[ctx->burst.tx_count];
2492 int size = len + 2;
2493
2494 - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) {
2495 + if (ctx->burst.tx_count + size >= ARRAY_SIZE(ctx->burst.tx_buf)) {
2496 dev_err(ctx->dev, "TX-BLK buffer exhausted\n");
2497 ctx->error = -EINVAL;
2498 return NULL;
2499 @@ -621,7 +621,7 @@ static u8 *sii8620_burst_get_rx_buf(struct sii8620 *ctx, int len)
2500 u8 *buf = &ctx->burst.rx_buf[ctx->burst.rx_count];
2501 int size = len + 1;
2502
2503 - if (ctx->burst.tx_count + size > ARRAY_SIZE(ctx->burst.tx_buf)) {
2504 + if (ctx->burst.rx_count + size >= ARRAY_SIZE(ctx->burst.rx_buf)) {
2505 dev_err(ctx->dev, "RX-BLK buffer exhausted\n");
2506 ctx->error = -EINVAL;
2507 return NULL;
2508 diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
2509 index 1fdc85a71cec4..25a2d80287d67 100644
2510 --- a/drivers/gpu/drm/drm_gem.c
2511 +++ b/drivers/gpu/drm/drm_gem.c
2512 @@ -1292,7 +1292,7 @@ retry:
2513 ret = dma_resv_lock_slow_interruptible(obj->resv,
2514 acquire_ctx);
2515 if (ret) {
2516 - ww_acquire_done(acquire_ctx);
2517 + ww_acquire_fini(acquire_ctx);
2518 return ret;
2519 }
2520 }
2521 @@ -1317,7 +1317,7 @@ retry:
2522 goto retry;
2523 }
2524
2525 - ww_acquire_done(acquire_ctx);
2526 + ww_acquire_fini(acquire_ctx);
2527 return ret;
2528 }
2529 }
2530 diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
2531 index 4042f5b397657..2a7ef1051b397 100644
2532 --- a/drivers/gpu/drm/drm_mipi_dbi.c
2533 +++ b/drivers/gpu/drm/drm_mipi_dbi.c
2534 @@ -1156,6 +1156,13 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz,
2535 size_t chunk;
2536 int ret;
2537
2538 + /* In __spi_validate, there's a validation that no partial transfers
2539 + * are accepted (xfer->len % w_size must be zero).
2540 + * Here we align max_chunk to multiple of 2 (16bits),
2541 + * to prevent transfers from being rejected.
2542 + */
2543 + max_chunk = ALIGN_DOWN(max_chunk, 2);
2544 +
2545 spi_message_init_with_transfers(&m, &tr, 1);
2546
2547 while (len) {
2548 diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
2549 index 6fd40410dfd2e..afca5fc460200 100644
2550 --- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
2551 +++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
2552 @@ -800,31 +800,40 @@ static int exynos7_decon_resume(struct device *dev)
2553 if (ret < 0) {
2554 DRM_DEV_ERROR(dev, "Failed to prepare_enable the pclk [%d]\n",
2555 ret);
2556 - return ret;
2557 + goto err_pclk_enable;
2558 }
2559
2560 ret = clk_prepare_enable(ctx->aclk);
2561 if (ret < 0) {
2562 DRM_DEV_ERROR(dev, "Failed to prepare_enable the aclk [%d]\n",
2563 ret);
2564 - return ret;
2565 + goto err_aclk_enable;
2566 }
2567
2568 ret = clk_prepare_enable(ctx->eclk);
2569 if (ret < 0) {
2570 DRM_DEV_ERROR(dev, "Failed to prepare_enable the eclk [%d]\n",
2571 ret);
2572 - return ret;
2573 + goto err_eclk_enable;
2574 }
2575
2576 ret = clk_prepare_enable(ctx->vclk);
2577 if (ret < 0) {
2578 DRM_DEV_ERROR(dev, "Failed to prepare_enable the vclk [%d]\n",
2579 ret);
2580 - return ret;
2581 + goto err_vclk_enable;
2582 }
2583
2584 return 0;
2585 +
2586 +err_vclk_enable:
2587 + clk_disable_unprepare(ctx->eclk);
2588 +err_eclk_enable:
2589 + clk_disable_unprepare(ctx->aclk);
2590 +err_aclk_enable:
2591 + clk_disable_unprepare(ctx->pclk);
2592 +err_pclk_enable:
2593 + return ret;
2594 }
2595 #endif
2596
2597 diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
2598 index 8c8c92fc82e97..a580b9cadb0cf 100644
2599 --- a/drivers/gpu/drm/mcde/mcde_dsi.c
2600 +++ b/drivers/gpu/drm/mcde/mcde_dsi.c
2601 @@ -942,6 +942,7 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
2602 bridge = of_drm_find_bridge(child);
2603 if (!bridge) {
2604 dev_err(dev, "failed to find bridge\n");
2605 + of_node_put(child);
2606 return -EINVAL;
2607 }
2608 }
2609 diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c
2610 index 48de07e9059e2..4a64d8aed9da9 100644
2611 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c
2612 +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c
2613 @@ -50,13 +50,7 @@ enum mtk_dpi_out_channel_swap {
2614 };
2615
2616 enum mtk_dpi_out_color_format {
2617 - MTK_DPI_COLOR_FORMAT_RGB,
2618 - MTK_DPI_COLOR_FORMAT_RGB_FULL,
2619 - MTK_DPI_COLOR_FORMAT_YCBCR_444,
2620 - MTK_DPI_COLOR_FORMAT_YCBCR_422,
2621 - MTK_DPI_COLOR_FORMAT_XV_YCC,
2622 - MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL,
2623 - MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL
2624 + MTK_DPI_COLOR_FORMAT_RGB
2625 };
2626
2627 struct mtk_dpi {
2628 @@ -355,24 +349,11 @@ static void mtk_dpi_config_disable_edge(struct mtk_dpi *dpi)
2629 static void mtk_dpi_config_color_format(struct mtk_dpi *dpi,
2630 enum mtk_dpi_out_color_format format)
2631 {
2632 - if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_444) ||
2633 - (format == MTK_DPI_COLOR_FORMAT_YCBCR_444_FULL)) {
2634 - mtk_dpi_config_yuv422_enable(dpi, false);
2635 - mtk_dpi_config_csc_enable(dpi, true);
2636 - mtk_dpi_config_swap_input(dpi, false);
2637 - mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_BGR);
2638 - } else if ((format == MTK_DPI_COLOR_FORMAT_YCBCR_422) ||
2639 - (format == MTK_DPI_COLOR_FORMAT_YCBCR_422_FULL)) {
2640 - mtk_dpi_config_yuv422_enable(dpi, true);
2641 - mtk_dpi_config_csc_enable(dpi, true);
2642 - mtk_dpi_config_swap_input(dpi, true);
2643 - mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
2644 - } else {
2645 - mtk_dpi_config_yuv422_enable(dpi, false);
2646 - mtk_dpi_config_csc_enable(dpi, false);
2647 - mtk_dpi_config_swap_input(dpi, false);
2648 - mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
2649 - }
2650 + /* only support RGB888 */
2651 + mtk_dpi_config_yuv422_enable(dpi, false);
2652 + mtk_dpi_config_csc_enable(dpi, false);
2653 + mtk_dpi_config_swap_input(dpi, false);
2654 + mtk_dpi_config_channel_swap(dpi, MTK_DPI_OUT_CHANNEL_SWAP_RGB);
2655 }
2656
2657 static void mtk_dpi_power_off(struct mtk_dpi *dpi)
2658 @@ -413,7 +394,6 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi)
2659 if (dpi->pinctrl && dpi->pins_dpi)
2660 pinctrl_select_state(dpi->pinctrl, dpi->pins_dpi);
2661
2662 - mtk_dpi_enable(dpi);
2663 return 0;
2664
2665 err_pixel:
2666 @@ -557,6 +537,7 @@ static void mtk_dpi_encoder_enable(struct drm_encoder *encoder)
2667
2668 mtk_dpi_power_on(dpi);
2669 mtk_dpi_set_display_mode(dpi, &dpi->mode);
2670 + mtk_dpi_enable(dpi);
2671 }
2672
2673 static int mtk_dpi_atomic_check(struct drm_encoder *encoder,
2674 diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
2675 index 224afb666881c..e82705a33acfd 100644
2676 --- a/drivers/gpu/drm/mediatek/mtk_dsi.c
2677 +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
2678 @@ -645,6 +645,8 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
2679 mtk_dsi_reset_engine(dsi);
2680 mtk_dsi_lane0_ulp_mode_enter(dsi);
2681 mtk_dsi_clk_ulp_mode_enter(dsi);
2682 + /* set the lane number as 0 to pull down mipi */
2683 + writel(0, dsi->regs + DSI_TXRX_CTRL);
2684
2685 mtk_dsi_disable(dsi);
2686
2687 diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
2688 index 61a6536e7e61a..9a39afc3939bc 100644
2689 --- a/drivers/gpu/drm/meson/meson_drv.c
2690 +++ b/drivers/gpu/drm/meson/meson_drv.c
2691 @@ -124,8 +124,11 @@ static bool meson_vpu_has_available_connectors(struct device *dev)
2692 for_each_endpoint_of_node(dev->of_node, ep) {
2693 /* If the endpoint node exists, consider it enabled */
2694 remote = of_graph_get_remote_port(ep);
2695 - if (remote)
2696 + if (remote) {
2697 + of_node_put(remote);
2698 + of_node_put(ep);
2699 return true;
2700 + }
2701 }
2702
2703 return false;
2704 diff --git a/drivers/gpu/drm/meson/meson_viu.c b/drivers/gpu/drm/meson/meson_viu.c
2705 index 33698814c022f..9991f0a43b1ab 100644
2706 --- a/drivers/gpu/drm/meson/meson_viu.c
2707 +++ b/drivers/gpu/drm/meson/meson_viu.c
2708 @@ -400,17 +400,17 @@ void meson_viu_init(struct meson_drm *priv)
2709 priv->io_base + _REG(VD2_IF0_LUMA_FIFO_SIZE));
2710
2711 if (meson_vpu_is_compatible(priv, VPU_COMPATIBLE_G12A)) {
2712 - writel_relaxed(VIU_OSD_BLEND_REORDER(0, 1) |
2713 - VIU_OSD_BLEND_REORDER(1, 0) |
2714 - VIU_OSD_BLEND_REORDER(2, 0) |
2715 - VIU_OSD_BLEND_REORDER(3, 0) |
2716 - VIU_OSD_BLEND_DIN_EN(1) |
2717 - VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 |
2718 - VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 |
2719 - VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 |
2720 - VIU_OSD_BLEND_BLEN2_PREMULT_EN(1) |
2721 - VIU_OSD_BLEND_HOLD_LINES(4),
2722 - priv->io_base + _REG(VIU_OSD_BLEND_CTRL));
2723 + u32 val = (u32)VIU_OSD_BLEND_REORDER(0, 1) |
2724 + (u32)VIU_OSD_BLEND_REORDER(1, 0) |
2725 + (u32)VIU_OSD_BLEND_REORDER(2, 0) |
2726 + (u32)VIU_OSD_BLEND_REORDER(3, 0) |
2727 + (u32)VIU_OSD_BLEND_DIN_EN(1) |
2728 + (u32)VIU_OSD_BLEND1_DIN3_BYPASS_TO_DOUT1 |
2729 + (u32)VIU_OSD_BLEND1_DOUT_BYPASS_TO_BLEND2 |
2730 + (u32)VIU_OSD_BLEND_DIN0_BYPASS_TO_DOUT0 |
2731 + (u32)VIU_OSD_BLEND_BLEN2_PREMULT_EN(1) |
2732 + (u32)VIU_OSD_BLEND_HOLD_LINES(4);
2733 + writel_relaxed(val, priv->io_base + _REG(VIU_OSD_BLEND_CTRL));
2734
2735 writel_relaxed(OSD_BLEND_PATH_SEL_ENABLE,
2736 priv->io_base + _REG(OSD1_BLEND_SRC_CTRL));
2737 diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c
2738 index a4f5cb90f3e80..e4b8a789835a4 100644
2739 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c
2740 +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c
2741 @@ -123,12 +123,13 @@ int mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe)
2742 {
2743 struct msm_drm_private *priv = s->dev->dev_private;
2744 struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
2745 - struct mdp5_global_state *state = mdp5_get_global_state(s);
2746 + struct mdp5_global_state *state;
2747 struct mdp5_hw_pipe_state *new_state;
2748
2749 if (!hwpipe)
2750 return 0;
2751
2752 + state = mdp5_get_global_state(s);
2753 if (IS_ERR(state))
2754 return PTR_ERR(state);
2755
2756 diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c
2757 index 8bff14ae16b0e..f0368d9a0154d 100644
2758 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c
2759 +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/base.c
2760 @@ -33,7 +33,7 @@ nvbios_addr(struct nvkm_bios *bios, u32 *addr, u8 size)
2761 {
2762 u32 p = *addr;
2763
2764 - if (*addr > bios->image0_size && bios->imaged_addr) {
2765 + if (*addr >= bios->image0_size && bios->imaged_addr) {
2766 *addr -= bios->image0_size;
2767 *addr += bios->imaged_addr;
2768 }
2769 diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c
2770 index bd2e577c701f2..288ec3039bc2c 100644
2771 --- a/drivers/gpu/drm/radeon/ni_dpm.c
2772 +++ b/drivers/gpu/drm/radeon/ni_dpm.c
2773 @@ -2740,10 +2740,10 @@ static int ni_set_mc_special_registers(struct radeon_device *rdev,
2774 table->mc_reg_table_entry[k].mc_data[j] |= 0x100;
2775 }
2776 j++;
2777 - if (j > SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE)
2778 - return -EINVAL;
2779 break;
2780 case MC_SEQ_RESERVE_M >> 2:
2781 + if (j >= SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE)
2782 + return -EINVAL;
2783 temp_reg = RREG32(MC_PMG_CMD_MRS1);
2784 table->mc_reg_address[j].s1 = MC_PMG_CMD_MRS1 >> 2;
2785 table->mc_reg_address[j].s0 = MC_SEQ_PMG_CMD_MRS1_LP >> 2;
2786 @@ -2752,8 +2752,6 @@ static int ni_set_mc_special_registers(struct radeon_device *rdev,
2787 (temp_reg & 0xffff0000) |
2788 (table->mc_reg_table_entry[k].mc_data[i] & 0x0000ffff);
2789 j++;
2790 - if (j > SMC_NISLANDS_MC_REGISTER_ARRAY_SIZE)
2791 - return -EINVAL;
2792 break;
2793 default:
2794 break;
2795 diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
2796 index ce98c08aa8b44..48281e29b5d45 100644
2797 --- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
2798 +++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
2799 @@ -401,7 +401,15 @@ static int rockchip_dp_probe(struct platform_device *pdev)
2800 if (IS_ERR(dp->adp))
2801 return PTR_ERR(dp->adp);
2802
2803 - return component_add(dev, &rockchip_dp_component_ops);
2804 + ret = component_add(dev, &rockchip_dp_component_ops);
2805 + if (ret)
2806 + goto err_dp_remove;
2807 +
2808 + return 0;
2809 +
2810 +err_dp_remove:
2811 + analogix_dp_remove(dp->adp);
2812 + return ret;
2813 }
2814
2815 static int rockchip_dp_remove(struct platform_device *pdev)
2816 diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
2817 index 2e4e1933a43c1..57e0396662c34 100644
2818 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
2819 +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
2820 @@ -1288,6 +1288,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
2821 {
2822 struct rockchip_crtc_state *rockchip_state;
2823
2824 + if (WARN_ON(!crtc->state))
2825 + return NULL;
2826 +
2827 rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL);
2828 if (!rockchip_state)
2829 return NULL;
2830 diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c
2831 index 0983949cc8c98..e249ab378700e 100644
2832 --- a/drivers/gpu/drm/vc4/vc4_dsi.c
2833 +++ b/drivers/gpu/drm/vc4/vc4_dsi.c
2834 @@ -791,11 +791,9 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder,
2835 /* Find what divider gets us a faster clock than the requested
2836 * pixel clock.
2837 */
2838 - for (divider = 1; divider < 8; divider++) {
2839 - if (parent_rate / divider < pll_clock) {
2840 - divider--;
2841 + for (divider = 1; divider < 255; divider++) {
2842 + if (parent_rate / (divider + 1) < pll_clock)
2843 break;
2844 - }
2845 }
2846
2847 /* Now that we've picked a PLL divider, calculate back to its
2848 diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
2849 index 363f456ea7134..cdcd19698b3c5 100644
2850 --- a/drivers/gpu/drm/vc4/vc4_plane.c
2851 +++ b/drivers/gpu/drm/vc4/vc4_plane.c
2852 @@ -288,16 +288,16 @@ static int vc4_plane_margins_adj(struct drm_plane_state *pstate)
2853 adjhdisplay,
2854 crtc_state->mode.hdisplay);
2855 vc4_pstate->crtc_x += left;
2856 - if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - left)
2857 - vc4_pstate->crtc_x = crtc_state->mode.hdisplay - left;
2858 + if (vc4_pstate->crtc_x > crtc_state->mode.hdisplay - right)
2859 + vc4_pstate->crtc_x = crtc_state->mode.hdisplay - right;
2860
2861 adjvdisplay = crtc_state->mode.vdisplay - (top + bottom);
2862 vc4_pstate->crtc_y = DIV_ROUND_CLOSEST(vc4_pstate->crtc_y *
2863 adjvdisplay,
2864 crtc_state->mode.vdisplay);
2865 vc4_pstate->crtc_y += top;
2866 - if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - top)
2867 - vc4_pstate->crtc_y = crtc_state->mode.vdisplay - top;
2868 + if (vc4_pstate->crtc_y > crtc_state->mode.vdisplay - bottom)
2869 + vc4_pstate->crtc_y = crtc_state->mode.vdisplay - bottom;
2870
2871 vc4_pstate->crtc_w = DIV_ROUND_CLOSEST(vc4_pstate->crtc_w *
2872 adjhdisplay,
2873 @@ -317,7 +317,6 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
2874 struct vc4_plane_state *vc4_state = to_vc4_plane_state(state);
2875 struct drm_framebuffer *fb = state->fb;
2876 struct drm_gem_cma_object *bo = drm_fb_cma_get_gem_obj(fb, 0);
2877 - u32 subpixel_src_mask = (1 << 16) - 1;
2878 int num_planes = fb->format->num_planes;
2879 struct drm_crtc_state *crtc_state;
2880 u32 h_subsample = fb->format->hsub;
2881 @@ -339,18 +338,15 @@ static int vc4_plane_setup_clipping_and_scaling(struct drm_plane_state *state)
2882 for (i = 0; i < num_planes; i++)
2883 vc4_state->offsets[i] = bo->paddr + fb->offsets[i];
2884
2885 - /* We don't support subpixel source positioning for scaling. */
2886 - if ((state->src.x1 & subpixel_src_mask) ||
2887 - (state->src.x2 & subpixel_src_mask) ||
2888 - (state->src.y1 & subpixel_src_mask) ||
2889 - (state->src.y2 & subpixel_src_mask)) {
2890 - return -EINVAL;
2891 - }
2892 -
2893 - vc4_state->src_x = state->src.x1 >> 16;
2894 - vc4_state->src_y = state->src.y1 >> 16;
2895 - vc4_state->src_w[0] = (state->src.x2 - state->src.x1) >> 16;
2896 - vc4_state->src_h[0] = (state->src.y2 - state->src.y1) >> 16;
2897 + /*
2898 + * We don't support subpixel source positioning for scaling,
2899 + * but fractional coordinates can be generated by clipping
2900 + * so just round for now
2901 + */
2902 + vc4_state->src_x = DIV_ROUND_CLOSEST(state->src.x1, 1 << 16);
2903 + vc4_state->src_y = DIV_ROUND_CLOSEST(state->src.y1, 1 << 16);
2904 + vc4_state->src_w[0] = DIV_ROUND_CLOSEST(state->src.x2, 1 << 16) - vc4_state->src_x;
2905 + vc4_state->src_h[0] = DIV_ROUND_CLOSEST(state->src.y2, 1 << 16) - vc4_state->src_y;
2906
2907 vc4_state->crtc_x = state->dst.x1;
2908 vc4_state->crtc_y = state->dst.y1;
2909 diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c
2910 index 2477b2a3f7c3a..464a48906d01f 100644
2911 --- a/drivers/hid/hid-alps.c
2912 +++ b/drivers/hid/hid-alps.c
2913 @@ -831,6 +831,8 @@ static const struct hid_device_id alps_id[] = {
2914 USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_DUAL) },
2915 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
2916 USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1) },
2917 + { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
2918 + USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_U1_UNICORN_LEGACY) },
2919 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
2920 USB_VENDOR_ID_ALPS_JP, HID_DEVICE_ID_ALPS_T4_BTNLESS) },
2921 { }
2922 diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
2923 index db1b55df0d131..340408f8c8ab2 100644
2924 --- a/drivers/hid/hid-cp2112.c
2925 +++ b/drivers/hid/hid-cp2112.c
2926 @@ -787,6 +787,11 @@ static int cp2112_xfer(struct i2c_adapter *adap, u16 addr,
2927 data->word = le16_to_cpup((__le16 *)buf);
2928 break;
2929 case I2C_SMBUS_I2C_BLOCK_DATA:
2930 + if (read_length > I2C_SMBUS_BLOCK_MAX) {
2931 + ret = -EINVAL;
2932 + goto power_normal;
2933 + }
2934 +
2935 memcpy(data->block + 1, buf, read_length);
2936 break;
2937 case I2C_SMBUS_BLOCK_DATA:
2938 diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
2939 index 329bb1a46f90e..4dbf69078387f 100644
2940 --- a/drivers/hid/wacom_sys.c
2941 +++ b/drivers/hid/wacom_sys.c
2942 @@ -2124,7 +2124,7 @@ static int wacom_register_inputs(struct wacom *wacom)
2943
2944 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
2945 if (error) {
2946 - /* no pad in use on this interface */
2947 + /* no pad events using this interface */
2948 input_free_device(pad_input_dev);
2949 wacom_wac->pad_input = NULL;
2950 pad_input_dev = NULL;
2951 diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
2952 index de69ea5f5a4be..c3dff7501af28 100644
2953 --- a/drivers/hid/wacom_wac.c
2954 +++ b/drivers/hid/wacom_wac.c
2955 @@ -638,9 +638,26 @@ static int wacom_intuos_id_mangle(int tool_id)
2956 return (tool_id & ~0xFFF) << 4 | (tool_id & 0xFFF);
2957 }
2958
2959 +static bool wacom_is_art_pen(int tool_id)
2960 +{
2961 + bool is_art_pen = false;
2962 +
2963 + switch (tool_id) {
2964 + case 0x885: /* Intuos3 Marker Pen */
2965 + case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
2966 + case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
2967 + is_art_pen = true;
2968 + break;
2969 + }
2970 + return is_art_pen;
2971 +}
2972 +
2973 static int wacom_intuos_get_tool_type(int tool_id)
2974 {
2975 - int tool_type;
2976 + int tool_type = BTN_TOOL_PEN;
2977 +
2978 + if (wacom_is_art_pen(tool_id))
2979 + return tool_type;
2980
2981 switch (tool_id) {
2982 case 0x812: /* Inking pen */
2983 @@ -655,12 +672,9 @@ static int wacom_intuos_get_tool_type(int tool_id)
2984 case 0x852:
2985 case 0x823: /* Intuos3 Grip Pen */
2986 case 0x813: /* Intuos3 Classic Pen */
2987 - case 0x885: /* Intuos3 Marker Pen */
2988 case 0x802: /* Intuos4/5 13HD/24HD General Pen */
2989 - case 0x804: /* Intuos4/5 13HD/24HD Marker Pen */
2990 case 0x8e2: /* IntuosHT2 pen */
2991 case 0x022:
2992 - case 0x10804: /* Intuos4/5 13HD/24HD Art Pen */
2993 case 0x10842: /* MobileStudio Pro Pro Pen slim */
2994 case 0x14802: /* Intuos4/5 13HD/24HD Classic Pen */
2995 case 0x16802: /* Cintiq 13HD Pro Pen */
2996 @@ -718,10 +732,6 @@ static int wacom_intuos_get_tool_type(int tool_id)
2997 case 0x10902: /* Intuos4/5 13HD/24HD Airbrush */
2998 tool_type = BTN_TOOL_AIRBRUSH;
2999 break;
3000 -
3001 - default: /* Unknown tool */
3002 - tool_type = BTN_TOOL_PEN;
3003 - break;
3004 }
3005 return tool_type;
3006 }
3007 @@ -2006,7 +2016,6 @@ static void wacom_wac_pad_usage_mapping(struct hid_device *hdev,
3008 wacom_wac->has_mute_touch_switch = true;
3009 usage->type = EV_SW;
3010 usage->code = SW_MUTE_DEVICE;
3011 - features->device_type |= WACOM_DEVICETYPE_PAD;
3012 break;
3013 case WACOM_HID_WD_TOUCHSTRIP:
3014 wacom_map_usage(input, usage, field, EV_ABS, ABS_RX, 0);
3015 @@ -2086,6 +2095,30 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
3016 wacom_wac->hid_data.inrange_state |= value;
3017 }
3018
3019 + /* Process touch switch state first since it is reported through touch interface,
3020 + * which is indepentent of pad interface. In the case when there are no other pad
3021 + * events, the pad interface will not even be created.
3022 + */
3023 + if ((equivalent_usage == WACOM_HID_WD_MUTE_DEVICE) ||
3024 + (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)) {
3025 + if (wacom_wac->shared->touch_input) {
3026 + bool *is_touch_on = &wacom_wac->shared->is_touch_on;
3027 +
3028 + if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
3029 + *is_touch_on = !(*is_touch_on);
3030 + else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
3031 + *is_touch_on = value;
3032 +
3033 + input_report_switch(wacom_wac->shared->touch_input,
3034 + SW_MUTE_DEVICE, !(*is_touch_on));
3035 + input_sync(wacom_wac->shared->touch_input);
3036 + }
3037 + return;
3038 + }
3039 +
3040 + if (!input)
3041 + return;
3042 +
3043 switch (equivalent_usage) {
3044 case WACOM_HID_WD_TOUCHRING:
3045 /*
3046 @@ -2121,22 +2154,6 @@ static void wacom_wac_pad_event(struct hid_device *hdev, struct hid_field *field
3047 input_event(input, usage->type, usage->code, 0);
3048 break;
3049
3050 - case WACOM_HID_WD_MUTE_DEVICE:
3051 - case WACOM_HID_WD_TOUCHONOFF:
3052 - if (wacom_wac->shared->touch_input) {
3053 - bool *is_touch_on = &wacom_wac->shared->is_touch_on;
3054 -
3055 - if (equivalent_usage == WACOM_HID_WD_MUTE_DEVICE && value)
3056 - *is_touch_on = !(*is_touch_on);
3057 - else if (equivalent_usage == WACOM_HID_WD_TOUCHONOFF)
3058 - *is_touch_on = value;
3059 -
3060 - input_report_switch(wacom_wac->shared->touch_input,
3061 - SW_MUTE_DEVICE, !(*is_touch_on));
3062 - input_sync(wacom_wac->shared->touch_input);
3063 - }
3064 - break;
3065 -
3066 case WACOM_HID_WD_MODE_CHANGE:
3067 if (wacom_wac->is_direct_mode != value) {
3068 wacom_wac->is_direct_mode = value;
3069 @@ -2312,6 +2329,9 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
3070 }
3071 return;
3072 case HID_DG_TWIST:
3073 + /* don't modify the value if the pen doesn't support the feature */
3074 + if (!wacom_is_art_pen(wacom_wac->id[0])) return;
3075 +
3076 /*
3077 * Userspace expects pen twist to have its zero point when
3078 * the buttons/finger is on the tablet's left. HID values
3079 @@ -2763,7 +2783,7 @@ void wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
3080 /* usage tests must precede field tests */
3081 if (WACOM_BATTERY_USAGE(usage))
3082 wacom_wac_battery_event(hdev, field, usage, value);
3083 - else if (WACOM_PAD_FIELD(field) && wacom->wacom_wac.pad_input)
3084 + else if (WACOM_PAD_FIELD(field))
3085 wacom_wac_pad_event(hdev, field, usage, value);
3086 else if (WACOM_PEN_FIELD(field) && wacom->wacom_wac.pen_input)
3087 wacom_wac_pen_event(hdev, field, usage, value);
3088 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
3089 index 0bbce0d291582..7d64d77d5b7a4 100644
3090 --- a/drivers/hwtracing/coresight/coresight.c
3091 +++ b/drivers/hwtracing/coresight/coresight.c
3092 @@ -1073,6 +1073,7 @@ static int coresight_remove_match(struct device *dev, void *data)
3093 * platform data.
3094 */
3095 fwnode_handle_put(conn->child_fwnode);
3096 + conn->child_fwnode = NULL;
3097 /* No need to continue */
3098 break;
3099 }
3100 diff --git a/drivers/hwtracing/intel_th/msu-sink.c b/drivers/hwtracing/intel_th/msu-sink.c
3101 index 2c7f5116be126..891b28ea25fe6 100644
3102 --- a/drivers/hwtracing/intel_th/msu-sink.c
3103 +++ b/drivers/hwtracing/intel_th/msu-sink.c
3104 @@ -71,6 +71,9 @@ static int msu_sink_alloc_window(void *data, struct sg_table **sgt, size_t size)
3105 block = dma_alloc_coherent(priv->dev->parent->parent,
3106 PAGE_SIZE, &sg_dma_address(sg_ptr),
3107 GFP_KERNEL);
3108 + if (!block)
3109 + return -ENOMEM;
3110 +
3111 sg_set_buf(sg_ptr, block, PAGE_SIZE);
3112 }
3113
3114 diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
3115 index 3cd2489d398c5..640b0aae7eb48 100644
3116 --- a/drivers/hwtracing/intel_th/msu.c
3117 +++ b/drivers/hwtracing/intel_th/msu.c
3118 @@ -1050,6 +1050,16 @@ msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {}
3119 static inline void msc_buffer_set_wb(struct msc_window *win) {}
3120 #endif /* CONFIG_X86 */
3121
3122 +static struct page *msc_sg_page(struct scatterlist *sg)
3123 +{
3124 + void *addr = sg_virt(sg);
3125 +
3126 + if (is_vmalloc_addr(addr))
3127 + return vmalloc_to_page(addr);
3128 +
3129 + return sg_page(sg);
3130 +}
3131 +
3132 /**
3133 * msc_buffer_win_alloc() - alloc a window for a multiblock mode
3134 * @msc: MSC device
3135 @@ -1122,7 +1132,7 @@ static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win)
3136 int i;
3137
3138 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) {
3139 - struct page *page = sg_page(sg);
3140 + struct page *page = msc_sg_page(sg);
3141
3142 page->mapping = NULL;
3143 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE,
3144 @@ -1384,7 +1394,7 @@ found:
3145 pgoff -= win->pgoff;
3146
3147 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) {
3148 - struct page *page = sg_page(sg);
3149 + struct page *page = msc_sg_page(sg);
3150 size_t pgsz = PFN_DOWN(sg->length);
3151
3152 if (pgoff < pgsz)
3153 diff --git a/drivers/hwtracing/intel_th/pci.c b/drivers/hwtracing/intel_th/pci.c
3154 index a723c8c330876..6fcc20e0bc7b9 100644
3155 --- a/drivers/hwtracing/intel_th/pci.c
3156 +++ b/drivers/hwtracing/intel_th/pci.c
3157 @@ -100,8 +100,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev,
3158 }
3159
3160 th = intel_th_alloc(&pdev->dev, drvdata, resource, r);
3161 - if (IS_ERR(th))
3162 - return PTR_ERR(th);
3163 + if (IS_ERR(th)) {
3164 + err = PTR_ERR(th);
3165 + goto err_free_irq;
3166 + }
3167
3168 th->activate = intel_th_pci_activate;
3169 th->deactivate = intel_th_pci_deactivate;
3170 @@ -109,6 +111,10 @@ static int intel_th_pci_probe(struct pci_dev *pdev,
3171 pci_set_master(pdev);
3172
3173 return 0;
3174 +
3175 +err_free_irq:
3176 + pci_free_irq_vectors(pdev);
3177 + return err;
3178 }
3179
3180 static void intel_th_pci_remove(struct pci_dev *pdev)
3181 @@ -273,6 +279,21 @@ static const struct pci_device_id intel_th_pci_id_table[] = {
3182 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x54a6),
3183 .driver_data = (kernel_ulong_t)&intel_th_2x,
3184 },
3185 + {
3186 + /* Raptor Lake-S CPU */
3187 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0xa76f),
3188 + .driver_data = (kernel_ulong_t)&intel_th_2x,
3189 + },
3190 + {
3191 + /* Meteor Lake-P */
3192 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7e24),
3193 + .driver_data = (kernel_ulong_t)&intel_th_2x,
3194 + },
3195 + {
3196 + /* Raptor Lake-S */
3197 + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x7a26),
3198 + .driver_data = (kernel_ulong_t)&intel_th_2x,
3199 + },
3200 {
3201 /* Rocket Lake CPU */
3202 PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x4c19),
3203 diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
3204 index 8750e444f4492..72699fdd5d113 100644
3205 --- a/drivers/i2c/busses/i2c-cadence.c
3206 +++ b/drivers/i2c/busses/i2c-cadence.c
3207 @@ -348,8 +348,13 @@ static void cdns_i2c_mrecv(struct cdns_i2c *id)
3208 ctrl_reg = cdns_i2c_readreg(CDNS_I2C_CR_OFFSET);
3209 ctrl_reg |= CDNS_I2C_CR_RW | CDNS_I2C_CR_CLR_FIFO;
3210
3211 + /*
3212 + * Receive up to I2C_SMBUS_BLOCK_MAX data bytes, plus one message length
3213 + * byte, plus one checksum byte if PEC is enabled. p_msg->len will be 2 if
3214 + * PEC is enabled, otherwise 1.
3215 + */
3216 if (id->p_msg->flags & I2C_M_RECV_LEN)
3217 - id->recv_count = I2C_SMBUS_BLOCK_MAX + 1;
3218 + id->recv_count = I2C_SMBUS_BLOCK_MAX + id->p_msg->len;
3219
3220 id->curr_recv_count = id->recv_count;
3221
3222 @@ -535,6 +540,9 @@ static int cdns_i2c_process_msg(struct cdns_i2c *id, struct i2c_msg *msg,
3223 if (id->err_status & CDNS_I2C_IXR_ARB_LOST)
3224 return -EAGAIN;
3225
3226 + if (msg->flags & I2C_M_RECV_LEN)
3227 + msg->len += min_t(unsigned int, msg->buf[0], I2C_SMBUS_BLOCK_MAX);
3228 +
3229 return 0;
3230 }
3231
3232 diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
3233 index 1b93fae58ec75..964e8a29b27b4 100644
3234 --- a/drivers/i2c/i2c-core-base.c
3235 +++ b/drivers/i2c/i2c-core-base.c
3236 @@ -2358,8 +2358,9 @@ void i2c_put_adapter(struct i2c_adapter *adap)
3237 if (!adap)
3238 return;
3239
3240 - put_device(&adap->dev);
3241 module_put(adap->owner);
3242 + /* Should be last, otherwise we risk use-after-free with 'adap' */
3243 + put_device(&adap->dev);
3244 }
3245 EXPORT_SYMBOL(i2c_put_adapter);
3246
3247 diff --git a/drivers/i2c/muxes/i2c-mux-gpmux.c b/drivers/i2c/muxes/i2c-mux-gpmux.c
3248 index f830535cff122..480ec74e6134d 100644
3249 --- a/drivers/i2c/muxes/i2c-mux-gpmux.c
3250 +++ b/drivers/i2c/muxes/i2c-mux-gpmux.c
3251 @@ -138,6 +138,7 @@ static int i2c_mux_probe(struct platform_device *pdev)
3252 return 0;
3253
3254 err_children:
3255 + of_node_put(child);
3256 i2c_mux_del_adapters(muxc);
3257 err_parent:
3258 i2c_put_adapter(parent);
3259 diff --git a/drivers/iio/light/isl29028.c b/drivers/iio/light/isl29028.c
3260 index 4d220c835c758..14e150c52dfae 100644
3261 --- a/drivers/iio/light/isl29028.c
3262 +++ b/drivers/iio/light/isl29028.c
3263 @@ -628,7 +628,7 @@ static int isl29028_probe(struct i2c_client *client,
3264 ISL29028_POWER_OFF_DELAY_MS);
3265 pm_runtime_use_autosuspend(&client->dev);
3266
3267 - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev);
3268 + ret = iio_device_register(indio_dev);
3269 if (ret < 0) {
3270 dev_err(&client->dev,
3271 "%s(): iio registration failed with error %d\n",
3272 diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
3273 index 8c7ba7bad42b9..efd977f70f9ea 100644
3274 --- a/drivers/infiniband/hw/hfi1/file_ops.c
3275 +++ b/drivers/infiniband/hw/hfi1/file_ops.c
3276 @@ -1224,8 +1224,10 @@ static int setup_base_ctxt(struct hfi1_filedata *fd,
3277 goto done;
3278
3279 ret = init_user_ctxt(fd, uctxt);
3280 - if (ret)
3281 + if (ret) {
3282 + hfi1_free_ctxt_rcv_groups(uctxt);
3283 goto done;
3284 + }
3285
3286 user_init(uctxt);
3287
3288 diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3289 index d01e3222c00cf..28bbc4708fd48 100644
3290 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3291 +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c
3292 @@ -5216,8 +5216,8 @@ static irqreturn_t hns_roce_v2_msix_interrupt_abn(int irq, void *dev_id)
3293
3294 dev_err(dev, "AEQ overflow!\n");
3295
3296 - int_st |= 1 << HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S;
3297 - roce_write(hr_dev, ROCEE_VF_ABN_INT_ST_REG, int_st);
3298 + roce_write(hr_dev, ROCEE_VF_ABN_INT_ST_REG,
3299 + 1 << HNS_ROCE_V2_VF_INT_ST_AEQ_OVERFLOW_S);
3300
3301 /* Set reset level for reset_event() */
3302 if (ops->set_default_reset_request)
3303 diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
3304 index 53166b9ae67e5..57f111fe54430 100644
3305 --- a/drivers/infiniband/sw/rxe/rxe_qp.c
3306 +++ b/drivers/infiniband/sw/rxe/rxe_qp.c
3307 @@ -211,6 +211,14 @@ static void rxe_qp_init_misc(struct rxe_dev *rxe, struct rxe_qp *qp,
3308 spin_lock_init(&qp->grp_lock);
3309 spin_lock_init(&qp->state_lock);
3310
3311 + spin_lock_init(&qp->req.task.state_lock);
3312 + spin_lock_init(&qp->resp.task.state_lock);
3313 + spin_lock_init(&qp->comp.task.state_lock);
3314 +
3315 + spin_lock_init(&qp->sq.sq_lock);
3316 + spin_lock_init(&qp->rq.producer_lock);
3317 + spin_lock_init(&qp->rq.consumer_lock);
3318 +
3319 atomic_set(&qp->ssn, 0);
3320 atomic_set(&qp->skb_out, 0);
3321 }
3322 @@ -268,7 +276,6 @@ static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
3323 qp->req.opcode = -1;
3324 qp->comp.opcode = -1;
3325
3326 - spin_lock_init(&qp->sq.sq_lock);
3327 skb_queue_head_init(&qp->req_pkts);
3328
3329 rxe_init_task(rxe, &qp->req.task, qp,
3330 @@ -318,9 +325,6 @@ static int rxe_qp_init_resp(struct rxe_dev *rxe, struct rxe_qp *qp,
3331 }
3332 }
3333
3334 - spin_lock_init(&qp->rq.producer_lock);
3335 - spin_lock_init(&qp->rq.consumer_lock);
3336 -
3337 skb_queue_head_init(&qp->resp_pkts);
3338
3339 rxe_init_task(rxe, &qp->resp.task, qp,
3340 diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
3341 index 3aed597103d3d..69fcf21eaf528 100644
3342 --- a/drivers/infiniband/sw/siw/siw_cm.c
3343 +++ b/drivers/infiniband/sw/siw/siw_cm.c
3344 @@ -725,11 +725,11 @@ static int siw_proc_mpareply(struct siw_cep *cep)
3345 enum mpa_v2_ctrl mpa_p2p_mode = MPA_V2_RDMA_NO_RTR;
3346
3347 rv = siw_recv_mpa_rr(cep);
3348 - if (rv != -EAGAIN)
3349 - siw_cancel_mpatimer(cep);
3350 if (rv)
3351 goto out_err;
3352
3353 + siw_cancel_mpatimer(cep);
3354 +
3355 rep = &cep->mpa.hdr;
3356
3357 if (__mpa_rr_revision(rep->params.bits) > MPA_REVISION_2) {
3358 @@ -895,7 +895,8 @@ static int siw_proc_mpareply(struct siw_cep *cep)
3359 }
3360
3361 out_err:
3362 - siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, -EINVAL);
3363 + if (rv != -EAGAIN)
3364 + siw_cm_upcall(cep, IW_CM_EVENT_CONNECT_REPLY, -EINVAL);
3365
3366 return rv;
3367 }
3368 diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
3369 index 9f7c1e29e86a3..9f881fc102f73 100644
3370 --- a/drivers/iommu/dmar.c
3371 +++ b/drivers/iommu/dmar.c
3372 @@ -475,7 +475,7 @@ static int dmar_parse_one_rhsa(struct acpi_dmar_header *header, void *arg)
3373 if (drhd->reg_base_addr == rhsa->base_address) {
3374 int node = acpi_map_pxm_to_node(rhsa->proximity_domain);
3375
3376 - if (!node_online(node))
3377 + if (node != NUMA_NO_NODE && !node_online(node))
3378 node = NUMA_NO_NODE;
3379 drhd->iommu->node = node;
3380 return 0;
3381 diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
3382 index 55ed857f804f7..31a9b9885653f 100644
3383 --- a/drivers/iommu/exynos-iommu.c
3384 +++ b/drivers/iommu/exynos-iommu.c
3385 @@ -635,7 +635,7 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
3386
3387 ret = iommu_device_register(&data->iommu);
3388 if (ret)
3389 - return ret;
3390 + goto err_iommu_register;
3391
3392 platform_set_drvdata(pdev, data);
3393
3394 @@ -662,6 +662,10 @@ static int exynos_sysmmu_probe(struct platform_device *pdev)
3395 pm_runtime_enable(dev);
3396
3397 return 0;
3398 +
3399 +err_iommu_register:
3400 + iommu_device_sysfs_remove(&data->iommu);
3401 + return ret;
3402 }
3403
3404 static int __maybe_unused exynos_sysmmu_suspend(struct device *dev)
3405 diff --git a/drivers/iommu/qcom_iommu.c b/drivers/iommu/qcom_iommu.c
3406 index 280de92b332ed..b6e546b62a7cb 100644
3407 --- a/drivers/iommu/qcom_iommu.c
3408 +++ b/drivers/iommu/qcom_iommu.c
3409 @@ -785,9 +785,12 @@ static bool qcom_iommu_has_secure_context(struct qcom_iommu_dev *qcom_iommu)
3410 {
3411 struct device_node *child;
3412
3413 - for_each_child_of_node(qcom_iommu->dev->of_node, child)
3414 - if (of_device_is_compatible(child, "qcom,msm-iommu-v1-sec"))
3415 + for_each_child_of_node(qcom_iommu->dev->of_node, child) {
3416 + if (of_device_is_compatible(child, "qcom,msm-iommu-v1-sec")) {
3417 + of_node_put(child);
3418 return true;
3419 + }
3420 + }
3421
3422 return false;
3423 }
3424 diff --git a/drivers/irqchip/irq-tegra.c b/drivers/irqchip/irq-tegra.c
3425 index e1f771c72fc4c..ad3e2c1b3c87b 100644
3426 --- a/drivers/irqchip/irq-tegra.c
3427 +++ b/drivers/irqchip/irq-tegra.c
3428 @@ -148,10 +148,10 @@ static int tegra_ictlr_suspend(void)
3429 lic->cop_iep[i] = readl_relaxed(ictlr + ICTLR_COP_IEP_CLASS);
3430
3431 /* Disable COP interrupts */
3432 - writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
3433 + writel_relaxed(GENMASK(31, 0), ictlr + ICTLR_COP_IER_CLR);
3434
3435 /* Disable CPU interrupts */
3436 - writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR);
3437 + writel_relaxed(GENMASK(31, 0), ictlr + ICTLR_CPU_IER_CLR);
3438
3439 /* Enable the wakeup sources of ictlr */
3440 writel_relaxed(lic->ictlr_wake_mask[i], ictlr + ICTLR_CPU_IER_SET);
3441 @@ -172,12 +172,12 @@ static void tegra_ictlr_resume(void)
3442
3443 writel_relaxed(lic->cpu_iep[i],
3444 ictlr + ICTLR_CPU_IEP_CLASS);
3445 - writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR);
3446 + writel_relaxed(GENMASK(31, 0), ictlr + ICTLR_CPU_IER_CLR);
3447 writel_relaxed(lic->cpu_ier[i],
3448 ictlr + ICTLR_CPU_IER_SET);
3449 writel_relaxed(lic->cop_iep[i],
3450 ictlr + ICTLR_COP_IEP_CLASS);
3451 - writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR);
3452 + writel_relaxed(GENMASK(31, 0), ictlr + ICTLR_COP_IER_CLR);
3453 writel_relaxed(lic->cop_ier[i],
3454 ictlr + ICTLR_COP_IER_SET);
3455 }
3456 @@ -312,7 +312,7 @@ static int __init tegra_ictlr_init(struct device_node *node,
3457 lic->base[i] = base;
3458
3459 /* Disable all interrupts */
3460 - writel_relaxed(~0UL, base + ICTLR_CPU_IER_CLR);
3461 + writel_relaxed(GENMASK(31, 0), base + ICTLR_CPU_IER_CLR);
3462 /* All interrupts target IRQ */
3463 writel_relaxed(0, base + ICTLR_CPU_IEP_CLASS);
3464
3465 diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
3466 index 42151c9fc6e56..882e83d51ef43 100644
3467 --- a/drivers/md/dm-raid.c
3468 +++ b/drivers/md/dm-raid.c
3469 @@ -3528,7 +3528,7 @@ static void raid_status(struct dm_target *ti, status_type_t type,
3470 {
3471 struct raid_set *rs = ti->private;
3472 struct mddev *mddev = &rs->md;
3473 - struct r5conf *conf = mddev->private;
3474 + struct r5conf *conf = rs_is_raid456(rs) ? mddev->private : NULL;
3475 int i, max_nr_stripes = conf ? conf->max_nr_stripes : 0;
3476 unsigned long recovery;
3477 unsigned int raid_param_cnt = 1; /* at least 1 for chunksize */
3478 @@ -3808,7 +3808,7 @@ static void attempt_restore_of_faulty_devices(struct raid_set *rs)
3479
3480 memset(cleared_failed_devices, 0, sizeof(cleared_failed_devices));
3481
3482 - for (i = 0; i < mddev->raid_disks; i++) {
3483 + for (i = 0; i < rs->raid_disks; i++) {
3484 r = &rs->dev[i].rdev;
3485 /* HM FIXME: enhance journal device recovery processing */
3486 if (test_bit(Journal, &r->flags))
3487 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
3488 index a5ed59eafdc51..784468f3cb747 100644
3489 --- a/drivers/md/dm-thin-metadata.c
3490 +++ b/drivers/md/dm-thin-metadata.c
3491 @@ -2060,10 +2060,13 @@ int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd,
3492 dm_sm_threshold_fn fn,
3493 void *context)
3494 {
3495 - int r;
3496 + int r = -EINVAL;
3497
3498 pmd_write_lock_in_core(pmd);
3499 - r = dm_sm_register_threshold_callback(pmd->metadata_sm, threshold, fn, context);
3500 + if (!pmd->fail_io) {
3501 + r = dm_sm_register_threshold_callback(pmd->metadata_sm,
3502 + threshold, fn, context);
3503 + }
3504 pmd_write_unlock(pmd);
3505
3506 return r;
3507 diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
3508 index 1b2c98b43519f..bf0b67e72254c 100644
3509 --- a/drivers/md/dm-thin.c
3510 +++ b/drivers/md/dm-thin.c
3511 @@ -3425,8 +3425,10 @@ static int pool_ctr(struct dm_target *ti, unsigned argc, char **argv)
3512 calc_metadata_threshold(pt),
3513 metadata_low_callback,
3514 pool);
3515 - if (r)
3516 + if (r) {
3517 + ti->error = "Error registering metadata threshold";
3518 goto out_flags_changed;
3519 + }
3520
3521 pt->callbacks.congested_fn = pool_is_congested;
3522 dm_table_add_target_callbacks(ti->table, &pt->callbacks);
3523 diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
3524 index ec10fda3f24f4..961498d8f4062 100644
3525 --- a/drivers/md/dm-writecache.c
3526 +++ b/drivers/md/dm-writecache.c
3527 @@ -20,7 +20,7 @@
3528
3529 #define HIGH_WATERMARK 50
3530 #define LOW_WATERMARK 45
3531 -#define MAX_WRITEBACK_JOBS 0
3532 +#define MAX_WRITEBACK_JOBS min(0x10000000 / PAGE_SIZE, totalram_pages() / 16)
3533 #define ENDIO_LATENCY 16
3534 #define WRITEBACK_LATENCY 64
3535 #define AUTOCOMMIT_BLOCKS_SSD 65536
3536 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
3537 index 77e28f77c59f4..d4cebb38709bd 100644
3538 --- a/drivers/md/dm.c
3539 +++ b/drivers/md/dm.c
3540 @@ -3080,6 +3080,11 @@ static int dm_call_pr(struct block_device *bdev, iterate_devices_callout_fn fn,
3541 goto out;
3542 ti = dm_table_get_target(table, 0);
3543
3544 + if (dm_suspended_md(md)) {
3545 + ret = -EAGAIN;
3546 + goto out;
3547 + }
3548 +
3549 ret = -EINVAL;
3550 if (!ti->type->iterate_devices)
3551 goto out;
3552 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
3553 index deddabfb07d79..9fcc141e1ad64 100644
3554 --- a/drivers/md/raid10.c
3555 +++ b/drivers/md/raid10.c
3556 @@ -1826,9 +1826,12 @@ static int raid10_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
3557 int err = 0;
3558 int number = rdev->raid_disk;
3559 struct md_rdev **rdevp;
3560 - struct raid10_info *p = conf->mirrors + number;
3561 + struct raid10_info *p;
3562
3563 print_conf(conf);
3564 + if (unlikely(number >= mddev->raid_disks))
3565 + return 0;
3566 + p = conf->mirrors + number;
3567 if (rdev == p->rdev)
3568 rdevp = &p->rdev;
3569 else if (rdev == p->replacement)
3570 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
3571 index 474cf6abefea5..fe99e8cdc026f 100644
3572 --- a/drivers/md/raid5.c
3573 +++ b/drivers/md/raid5.c
3574 @@ -2666,10 +2666,10 @@ static void raid5_end_write_request(struct bio *bi)
3575 if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
3576 clear_bit(R5_LOCKED, &sh->dev[i].flags);
3577 set_bit(STRIPE_HANDLE, &sh->state);
3578 - raid5_release_stripe(sh);
3579
3580 if (sh->batch_head && sh != sh->batch_head)
3581 raid5_release_stripe(sh->batch_head);
3582 + raid5_release_stripe(sh);
3583 }
3584
3585 static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
3586 diff --git a/drivers/media/pci/tw686x/tw686x-core.c b/drivers/media/pci/tw686x/tw686x-core.c
3587 index 74ae4f0dcee76..8a25a0dac4aeb 100644
3588 --- a/drivers/media/pci/tw686x/tw686x-core.c
3589 +++ b/drivers/media/pci/tw686x/tw686x-core.c
3590 @@ -315,13 +315,6 @@ static int tw686x_probe(struct pci_dev *pci_dev,
3591
3592 spin_lock_init(&dev->lock);
3593
3594 - err = request_irq(pci_dev->irq, tw686x_irq, IRQF_SHARED,
3595 - dev->name, dev);
3596 - if (err < 0) {
3597 - dev_err(&pci_dev->dev, "unable to request interrupt\n");
3598 - goto iounmap;
3599 - }
3600 -
3601 timer_setup(&dev->dma_delay_timer, tw686x_dma_delay, 0);
3602
3603 /*
3604 @@ -333,18 +326,23 @@ static int tw686x_probe(struct pci_dev *pci_dev,
3605 err = tw686x_video_init(dev);
3606 if (err) {
3607 dev_err(&pci_dev->dev, "can't register video\n");
3608 - goto free_irq;
3609 + goto iounmap;
3610 }
3611
3612 err = tw686x_audio_init(dev);
3613 if (err)
3614 dev_warn(&pci_dev->dev, "can't register audio\n");
3615
3616 + err = request_irq(pci_dev->irq, tw686x_irq, IRQF_SHARED,
3617 + dev->name, dev);
3618 + if (err < 0) {
3619 + dev_err(&pci_dev->dev, "unable to request interrupt\n");
3620 + goto iounmap;
3621 + }
3622 +
3623 pci_set_drvdata(pci_dev, dev);
3624 return 0;
3625
3626 -free_irq:
3627 - free_irq(pci_dev->irq, dev);
3628 iounmap:
3629 pci_iounmap(pci_dev, dev->mmio);
3630 free_region:
3631 diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h b/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
3632 index 2cb8cecb30771..b810c96695c83 100644
3633 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
3634 +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_ipi.h
3635 @@ -40,12 +40,14 @@ struct mdp_ipi_init {
3636 * @ipi_id : IPI_MDP
3637 * @ap_inst : AP mtk_mdp_vpu address
3638 * @vpu_inst_addr : VPU MDP instance address
3639 + * @padding : Alignment padding
3640 */
3641 struct mdp_ipi_comm {
3642 uint32_t msg_id;
3643 uint32_t ipi_id;
3644 uint64_t ap_inst;
3645 uint32_t vpu_inst_addr;
3646 + uint32_t padding;
3647 };
3648
3649 /**
3650 diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
3651 index 7849f1fbbcc4d..4f1505b94338e 100644
3652 --- a/drivers/media/usb/hdpvr/hdpvr-video.c
3653 +++ b/drivers/media/usb/hdpvr/hdpvr-video.c
3654 @@ -409,7 +409,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
3655 struct hdpvr_device *dev = video_drvdata(file);
3656 struct hdpvr_buffer *buf = NULL;
3657 struct urb *urb;
3658 - unsigned int ret = 0;
3659 + int ret = 0;
3660 int rem, cnt;
3661
3662 if (*pos)
3663 diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
3664 index 55907e4c36b18..6014fcb49d7ec 100644
3665 --- a/drivers/memstick/core/ms_block.c
3666 +++ b/drivers/memstick/core/ms_block.c
3667 @@ -1335,17 +1335,17 @@ static int msb_ftl_initialize(struct msb_data *msb)
3668 msb->zone_count = msb->block_count / MS_BLOCKS_IN_ZONE;
3669 msb->logical_block_count = msb->zone_count * 496 - 2;
3670
3671 - msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
3672 - msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
3673 + msb->used_blocks_bitmap = bitmap_zalloc(msb->block_count, GFP_KERNEL);
3674 + msb->erased_blocks_bitmap = bitmap_zalloc(msb->block_count, GFP_KERNEL);
3675 msb->lba_to_pba_table =
3676 kmalloc_array(msb->logical_block_count, sizeof(u16),
3677 GFP_KERNEL);
3678
3679 if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table ||
3680 !msb->erased_blocks_bitmap) {
3681 - kfree(msb->used_blocks_bitmap);
3682 + bitmap_free(msb->used_blocks_bitmap);
3683 + bitmap_free(msb->erased_blocks_bitmap);
3684 kfree(msb->lba_to_pba_table);
3685 - kfree(msb->erased_blocks_bitmap);
3686 return -ENOMEM;
3687 }
3688
3689 @@ -1953,7 +1953,8 @@ static int msb_bd_open(struct block_device *bdev, fmode_t mode)
3690 static void msb_data_clear(struct msb_data *msb)
3691 {
3692 kfree(msb->boot_page);
3693 - kfree(msb->used_blocks_bitmap);
3694 + bitmap_free(msb->used_blocks_bitmap);
3695 + bitmap_free(msb->erased_blocks_bitmap);
3696 kfree(msb->lba_to_pba_table);
3697 kfree(msb->cache);
3698 msb->card = NULL;
3699 diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
3700 index a851ff473a446..2bf5bcbc88524 100644
3701 --- a/drivers/mfd/max77620.c
3702 +++ b/drivers/mfd/max77620.c
3703 @@ -418,9 +418,11 @@ static int max77620_initialise_fps(struct max77620_chip *chip)
3704 ret = max77620_config_fps(chip, fps_child);
3705 if (ret < 0) {
3706 of_node_put(fps_child);
3707 + of_node_put(fps_np);
3708 return ret;
3709 }
3710 }
3711 + of_node_put(fps_np);
3712
3713 config = chip->enable_global_lpm ? MAX77620_ONOFFCNFG2_SLP_LPM_MSK : 0;
3714 ret = regmap_update_bits(chip->rmap, MAX77620_REG_ONOFFCNFG2,
3715 diff --git a/drivers/mfd/t7l66xb.c b/drivers/mfd/t7l66xb.c
3716 index 70da0c4ae457e..58811c5ab564f 100644
3717 --- a/drivers/mfd/t7l66xb.c
3718 +++ b/drivers/mfd/t7l66xb.c
3719 @@ -405,11 +405,8 @@ err_noirq:
3720
3721 static int t7l66xb_remove(struct platform_device *dev)
3722 {
3723 - struct t7l66xb_platform_data *pdata = dev_get_platdata(&dev->dev);
3724 struct t7l66xb *t7l66xb = platform_get_drvdata(dev);
3725 - int ret;
3726
3727 - ret = pdata->disable(dev);
3728 clk_disable_unprepare(t7l66xb->clk48m);
3729 clk_put(t7l66xb->clk48m);
3730 clk_disable_unprepare(t7l66xb->clk32k);
3731 @@ -420,8 +417,7 @@ static int t7l66xb_remove(struct platform_device *dev)
3732 mfd_remove_devices(&dev->dev);
3733 kfree(t7l66xb);
3734
3735 - return ret;
3736 -
3737 + return 0;
3738 }
3739
3740 static struct platform_driver t7l66xb_platform_driver = {
3741 diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
3742 index 4c707d8dc3eb3..5807aefd4c886 100644
3743 --- a/drivers/misc/cardreader/rtsx_pcr.c
3744 +++ b/drivers/misc/cardreader/rtsx_pcr.c
3745 @@ -1485,7 +1485,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,
3746 pcr->remap_addr = ioremap_nocache(base, len);
3747 if (!pcr->remap_addr) {
3748 ret = -ENOMEM;
3749 - goto free_handle;
3750 + goto free_idr;
3751 }
3752
3753 pcr->rtsx_resv_buf = dma_alloc_coherent(&(pcidev->dev),
3754 @@ -1547,6 +1547,10 @@ disable_msi:
3755 pcr->rtsx_resv_buf, pcr->rtsx_resv_buf_addr);
3756 unmap:
3757 iounmap(pcr->remap_addr);
3758 +free_idr:
3759 + spin_lock(&rtsx_pci_lock);
3760 + idr_remove(&rtsx_pci_idr, pcr->id);
3761 + spin_unlock(&rtsx_pci_lock);
3762 free_handle:
3763 kfree(handle);
3764 free_pcr:
3765 diff --git a/drivers/misc/cxl/irq.c b/drivers/misc/cxl/irq.c
3766 index 4cb829d5d873c..2e4dcfebf19af 100644
3767 --- a/drivers/misc/cxl/irq.c
3768 +++ b/drivers/misc/cxl/irq.c
3769 @@ -349,6 +349,7 @@ int afu_allocate_irqs(struct cxl_context *ctx, u32 count)
3770
3771 out:
3772 cxl_ops->release_irq_ranges(&ctx->irqs, ctx->afu->adapter);
3773 + bitmap_free(ctx->irq_bitmap);
3774 afu_irq_name_free(ctx);
3775 return -ENOMEM;
3776 }
3777 diff --git a/drivers/mmc/host/cavium-octeon.c b/drivers/mmc/host/cavium-octeon.c
3778 index 22aded1065ae8..2245452a44c86 100644
3779 --- a/drivers/mmc/host/cavium-octeon.c
3780 +++ b/drivers/mmc/host/cavium-octeon.c
3781 @@ -288,6 +288,7 @@ static int octeon_mmc_probe(struct platform_device *pdev)
3782 if (ret) {
3783 dev_err(&pdev->dev, "Error populating slots\n");
3784 octeon_mmc_set_shared_power(host, 0);
3785 + of_node_put(cn);
3786 goto error;
3787 }
3788 i++;
3789 diff --git a/drivers/mmc/host/cavium-thunderx.c b/drivers/mmc/host/cavium-thunderx.c
3790 index eee08d81b2421..f79806e31e7ea 100644
3791 --- a/drivers/mmc/host/cavium-thunderx.c
3792 +++ b/drivers/mmc/host/cavium-thunderx.c
3793 @@ -138,8 +138,10 @@ static int thunder_mmc_probe(struct pci_dev *pdev,
3794 continue;
3795
3796 ret = cvm_mmc_of_slot_probe(&host->slot_pdev[i]->dev, host);
3797 - if (ret)
3798 + if (ret) {
3799 + of_node_put(child_node);
3800 goto error;
3801 + }
3802 }
3803 i++;
3804 }
3805 diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
3806 index 953e7457137a2..99f3958a037ce 100644
3807 --- a/drivers/mmc/host/pxamci.c
3808 +++ b/drivers/mmc/host/pxamci.c
3809 @@ -648,7 +648,7 @@ static int pxamci_probe(struct platform_device *pdev)
3810
3811 ret = pxamci_of_init(pdev, mmc);
3812 if (ret)
3813 - return ret;
3814 + goto out;
3815
3816 host = mmc_priv(mmc);
3817 host->mmc = mmc;
3818 @@ -672,7 +672,7 @@ static int pxamci_probe(struct platform_device *pdev)
3819
3820 ret = pxamci_init_ocr(host);
3821 if (ret < 0)
3822 - return ret;
3823 + goto out;
3824
3825 mmc->caps = 0;
3826 host->cmdat = 0;
3827 diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
3828 index 881f8138e7de3..03698d78a4027 100644
3829 --- a/drivers/mmc/host/sdhci-of-at91.c
3830 +++ b/drivers/mmc/host/sdhci-of-at91.c
3831 @@ -109,8 +109,13 @@ static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
3832 static void sdhci_at91_set_uhs_signaling(struct sdhci_host *host,
3833 unsigned int timing)
3834 {
3835 - if (timing == MMC_TIMING_MMC_DDR52)
3836 - sdhci_writeb(host, SDMMC_MC1R_DDR, SDMMC_MC1R);
3837 + u8 mc1r;
3838 +
3839 + if (timing == MMC_TIMING_MMC_DDR52) {
3840 + mc1r = sdhci_readb(host, SDMMC_MC1R);
3841 + mc1r |= SDMMC_MC1R_DDR;
3842 + sdhci_writeb(host, mc1r, SDMMC_MC1R);
3843 + }
3844 sdhci_set_uhs_signaling(host, timing);
3845 }
3846
3847 diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
3848 index 0ff339004d8a5..69c133e7ced05 100644
3849 --- a/drivers/mmc/host/sdhci-of-esdhc.c
3850 +++ b/drivers/mmc/host/sdhci-of-esdhc.c
3851 @@ -844,6 +844,7 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc,
3852 scfg_node = of_find_matching_node(NULL, scfg_device_ids);
3853 if (scfg_node)
3854 scfg_base = of_iomap(scfg_node, 0);
3855 + of_node_put(scfg_node);
3856 if (scfg_base) {
3857 sdhciovselcr = SDHCIOVSELCR_TGLEN |
3858 SDHCIOVSELCR_VSELVAL;
3859 diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c
3860 index f4d1667daaf99..41b5a236276b4 100644
3861 --- a/drivers/mtd/devices/st_spi_fsm.c
3862 +++ b/drivers/mtd/devices/st_spi_fsm.c
3863 @@ -2116,10 +2116,12 @@ static int stfsm_probe(struct platform_device *pdev)
3864 (long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
3865 fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
3866
3867 - return mtd_device_register(&fsm->mtd, NULL, 0);
3868 -
3869 + ret = mtd_device_register(&fsm->mtd, NULL, 0);
3870 + if (ret) {
3871 err_clk_unprepare:
3872 - clk_disable_unprepare(fsm->clk);
3873 + clk_disable_unprepare(fsm->clk);
3874 + }
3875 +
3876 return ret;
3877 }
3878
3879 diff --git a/drivers/mtd/maps/physmap-versatile.c b/drivers/mtd/maps/physmap-versatile.c
3880 index ad7cd9cfaee04..a1b8b7b25f88b 100644
3881 --- a/drivers/mtd/maps/physmap-versatile.c
3882 +++ b/drivers/mtd/maps/physmap-versatile.c
3883 @@ -93,6 +93,7 @@ static int ap_flash_init(struct platform_device *pdev)
3884 return -ENODEV;
3885 }
3886 ebi_base = of_iomap(ebi, 0);
3887 + of_node_put(ebi);
3888 if (!ebi_base)
3889 return -ENODEV;
3890
3891 @@ -207,6 +208,7 @@ int of_flash_probe_versatile(struct platform_device *pdev,
3892
3893 versatile_flashprot = (enum versatile_flashprot)devid->data;
3894 rmap = syscon_node_to_regmap(sysnp);
3895 + of_node_put(sysnp);
3896 if (IS_ERR(rmap))
3897 return PTR_ERR(rmap);
3898
3899 diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
3900 index ab7ab6a279aac..28dc26e1a20af 100644
3901 --- a/drivers/mtd/nand/raw/meson_nand.c
3902 +++ b/drivers/mtd/nand/raw/meson_nand.c
3903 @@ -1304,7 +1304,6 @@ static int meson_nfc_nand_chip_cleanup(struct meson_nfc *nfc)
3904 if (ret)
3905 return ret;
3906
3907 - meson_nfc_free_buffer(&meson_chip->nand);
3908 nand_cleanup(&meson_chip->nand);
3909 list_del(&meson_chip->node);
3910 }
3911 diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c
3912 index 3ccd6363ee8cb..4f3bcc59a6385 100644
3913 --- a/drivers/mtd/parsers/redboot.c
3914 +++ b/drivers/mtd/parsers/redboot.c
3915 @@ -58,6 +58,7 @@ static void parse_redboot_of(struct mtd_info *master)
3916 return;
3917
3918 ret = of_property_read_u32(npart, "fis-index-block", &dirblock);
3919 + of_node_put(npart);
3920 if (ret)
3921 return;
3922
3923 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
3924 index 4744bf94ad9a9..d4e72fd5e5b3a 100644
3925 --- a/drivers/mtd/sm_ftl.c
3926 +++ b/drivers/mtd/sm_ftl.c
3927 @@ -1097,9 +1097,9 @@ static void sm_release(struct mtd_blktrans_dev *dev)
3928 {
3929 struct sm_ftl *ftl = dev->priv;
3930
3931 - mutex_lock(&ftl->mutex);
3932 del_timer_sync(&ftl->timer);
3933 cancel_work_sync(&ftl->flush_work);
3934 + mutex_lock(&ftl->mutex);
3935 sm_cache_flush(ftl);
3936 mutex_unlock(&ftl->mutex);
3937 }
3938 diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
3939 index e90651f7b2eaf..586bda050d284 100644
3940 --- a/drivers/net/can/pch_can.c
3941 +++ b/drivers/net/can/pch_can.c
3942 @@ -489,6 +489,7 @@ static void pch_can_error(struct net_device *ndev, u32 status)
3943 if (!skb)
3944 return;
3945
3946 + errc = ioread32(&priv->regs->errc);
3947 if (status & PCH_BUS_OFF) {
3948 pch_can_set_tx_all(priv, 0);
3949 pch_can_set_rx_all(priv, 0);
3950 @@ -496,9 +497,11 @@ static void pch_can_error(struct net_device *ndev, u32 status)
3951 cf->can_id |= CAN_ERR_BUSOFF;
3952 priv->can.can_stats.bus_off++;
3953 can_bus_off(ndev);
3954 + } else {
3955 + cf->data[6] = errc & PCH_TEC;
3956 + cf->data[7] = (errc & PCH_REC) >> 8;
3957 }
3958
3959 - errc = ioread32(&priv->regs->errc);
3960 /* Warning interrupt. */
3961 if (status & PCH_EWARN) {
3962 state = CAN_STATE_ERROR_WARNING;
3963 @@ -556,9 +559,6 @@ static void pch_can_error(struct net_device *ndev, u32 status)
3964 break;
3965 }
3966
3967 - cf->data[6] = errc & PCH_TEC;
3968 - cf->data[7] = (errc & PCH_REC) >> 8;
3969 -
3970 priv->can.state = state;
3971 netif_receive_skb(skb);
3972
3973 diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c
3974 index ac52288fa3bfe..b99b1b235348c 100644
3975 --- a/drivers/net/can/rcar/rcar_can.c
3976 +++ b/drivers/net/can/rcar/rcar_can.c
3977 @@ -235,11 +235,8 @@ static void rcar_can_error(struct net_device *ndev)
3978 if (eifr & (RCAR_CAN_EIFR_EWIF | RCAR_CAN_EIFR_EPIF)) {
3979 txerr = readb(&priv->regs->tecr);
3980 rxerr = readb(&priv->regs->recr);
3981 - if (skb) {
3982 + if (skb)
3983 cf->can_id |= CAN_ERR_CRTL;
3984 - cf->data[6] = txerr;
3985 - cf->data[7] = rxerr;
3986 - }
3987 }
3988 if (eifr & RCAR_CAN_EIFR_BEIF) {
3989 int rx_errors = 0, tx_errors = 0;
3990 @@ -339,6 +336,9 @@ static void rcar_can_error(struct net_device *ndev)
3991 can_bus_off(ndev);
3992 if (skb)
3993 cf->can_id |= CAN_ERR_BUSOFF;
3994 + } else if (skb) {
3995 + cf->data[6] = txerr;
3996 + cf->data[7] = rxerr;
3997 }
3998 if (eifr & RCAR_CAN_EIFR_ORIF) {
3999 netdev_dbg(priv->ndev, "Receive overrun error interrupt\n");
4000 diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
4001 index 9f107798f904b..e7327ceabb76e 100644
4002 --- a/drivers/net/can/sja1000/sja1000.c
4003 +++ b/drivers/net/can/sja1000/sja1000.c
4004 @@ -405,9 +405,6 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
4005 txerr = priv->read_reg(priv, SJA1000_TXERR);
4006 rxerr = priv->read_reg(priv, SJA1000_RXERR);
4007
4008 - cf->data[6] = txerr;
4009 - cf->data[7] = rxerr;
4010 -
4011 if (isrc & IRQ_DOI) {
4012 /* data overrun interrupt */
4013 netdev_dbg(dev, "data overrun interrupt\n");
4014 @@ -429,6 +426,10 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
4015 else
4016 state = CAN_STATE_ERROR_ACTIVE;
4017 }
4018 + if (state != CAN_STATE_BUS_OFF) {
4019 + cf->data[6] = txerr;
4020 + cf->data[7] = rxerr;
4021 + }
4022 if (isrc & IRQ_BEI) {
4023 /* bus error interrupt */
4024 priv->can.can_stats.bus_error++;
4025 diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
4026 index 7d2315c8cacb1..28273e84171a2 100644
4027 --- a/drivers/net/can/spi/hi311x.c
4028 +++ b/drivers/net/can/spi/hi311x.c
4029 @@ -670,8 +670,6 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id)
4030
4031 txerr = hi3110_read(spi, HI3110_READ_TEC);
4032 rxerr = hi3110_read(spi, HI3110_READ_REC);
4033 - cf->data[6] = txerr;
4034 - cf->data[7] = rxerr;
4035 tx_state = txerr >= rxerr ? new_state : 0;
4036 rx_state = txerr <= rxerr ? new_state : 0;
4037 can_change_state(net, cf, tx_state, rx_state);
4038 @@ -684,6 +682,9 @@ static irqreturn_t hi3110_can_ist(int irq, void *dev_id)
4039 hi3110_hw_sleep(spi);
4040 break;
4041 }
4042 + } else {
4043 + cf->data[6] = txerr;
4044 + cf->data[7] = rxerr;
4045 }
4046 }
4047
4048 diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
4049 index bb20a9b75cc66..32bd593a39f13 100644
4050 --- a/drivers/net/can/spi/mcp251x.c
4051 +++ b/drivers/net/can/spi/mcp251x.c
4052 @@ -756,9 +756,6 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
4053
4054 mcp251x_read_2regs(spi, CANINTF, &intf, &eflag);
4055
4056 - /* mask out flags we don't care about */
4057 - intf &= CANINTF_RX | CANINTF_TX | CANINTF_ERR;
4058 -
4059 /* receive buffer 0 */
4060 if (intf & CANINTF_RX0IF) {
4061 mcp251x_hw_rx(spi, 0);
4062 @@ -768,6 +765,18 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
4063 if (mcp251x_is_2510(spi))
4064 mcp251x_write_bits(spi, CANINTF,
4065 CANINTF_RX0IF, 0x00);
4066 +
4067 + /* check if buffer 1 is already known to be full, no need to re-read */
4068 + if (!(intf & CANINTF_RX1IF)) {
4069 + u8 intf1, eflag1;
4070 +
4071 + /* intf needs to be read again to avoid a race condition */
4072 + mcp251x_read_2regs(spi, CANINTF, &intf1, &eflag1);
4073 +
4074 + /* combine flags from both operations for error handling */
4075 + intf |= intf1;
4076 + eflag |= eflag1;
4077 + }
4078 }
4079
4080 /* receive buffer 1 */
4081 @@ -778,6 +787,9 @@ static irqreturn_t mcp251x_can_ist(int irq, void *dev_id)
4082 clear_intf |= CANINTF_RX1IF;
4083 }
4084
4085 + /* mask out flags we don't care about */
4086 + intf &= CANINTF_RX | CANINTF_TX | CANINTF_ERR;
4087 +
4088 /* any error or tx interrupt we need to clear? */
4089 if (intf & (CANINTF_ERR | CANINTF_TX))
4090 clear_intf |= intf & (CANINTF_ERR | CANINTF_TX);
4091 diff --git a/drivers/net/can/sun4i_can.c b/drivers/net/can/sun4i_can.c
4092 index f4cd881964042..c519b6f63b33a 100644
4093 --- a/drivers/net/can/sun4i_can.c
4094 +++ b/drivers/net/can/sun4i_can.c
4095 @@ -525,11 +525,6 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
4096 rxerr = (errc >> 16) & 0xFF;
4097 txerr = errc & 0xFF;
4098
4099 - if (skb) {
4100 - cf->data[6] = txerr;
4101 - cf->data[7] = rxerr;
4102 - }
4103 -
4104 if (isrc & SUN4I_INT_DATA_OR) {
4105 /* data overrun interrupt */
4106 netdev_dbg(dev, "data overrun interrupt\n");
4107 @@ -560,6 +555,10 @@ static int sun4i_can_err(struct net_device *dev, u8 isrc, u8 status)
4108 else
4109 state = CAN_STATE_ERROR_ACTIVE;
4110 }
4111 + if (skb && state != CAN_STATE_BUS_OFF) {
4112 + cf->data[6] = txerr;
4113 + cf->data[7] = rxerr;
4114 + }
4115 if (isrc & SUN4I_INT_BUS_ERR) {
4116 /* bus error interrupt */
4117 netdev_dbg(dev, "bus error interrupt\n");
4118 diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
4119 index 6458da9c13b95..ff05b5230f0b8 100644
4120 --- a/drivers/net/can/usb/ems_usb.c
4121 +++ b/drivers/net/can/usb/ems_usb.c
4122 @@ -194,7 +194,7 @@ struct __packed ems_cpc_msg {
4123 __le32 ts_sec; /* timestamp in seconds */
4124 __le32 ts_nsec; /* timestamp in nano seconds */
4125
4126 - union {
4127 + union __packed {
4128 u8 generic[64];
4129 struct cpc_can_msg can_msg;
4130 struct cpc_can_params can_params;
4131 diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
4132 index a7c408acb0c09..01d4a731b579c 100644
4133 --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
4134 +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
4135 @@ -890,8 +890,10 @@ static void kvaser_usb_hydra_update_state(struct kvaser_usb_net_priv *priv,
4136 new_state < CAN_STATE_BUS_OFF)
4137 priv->can.can_stats.restarts++;
4138
4139 - cf->data[6] = bec->txerr;
4140 - cf->data[7] = bec->rxerr;
4141 + if (new_state != CAN_STATE_BUS_OFF) {
4142 + cf->data[6] = bec->txerr;
4143 + cf->data[7] = bec->rxerr;
4144 + }
4145
4146 stats = &netdev->stats;
4147 stats->rx_packets++;
4148 @@ -1045,8 +1047,10 @@ kvaser_usb_hydra_error_frame(struct kvaser_usb_net_priv *priv,
4149 shhwtstamps->hwtstamp = hwtstamp;
4150
4151 cf->can_id |= CAN_ERR_BUSERROR;
4152 - cf->data[6] = bec.txerr;
4153 - cf->data[7] = bec.rxerr;
4154 + if (new_state != CAN_STATE_BUS_OFF) {
4155 + cf->data[6] = bec.txerr;
4156 + cf->data[7] = bec.rxerr;
4157 + }
4158
4159 stats->rx_packets++;
4160 stats->rx_bytes += cf->can_dlc;
4161 diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
4162 index 0e0403dd05500..5e281249ad5fe 100644
4163 --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
4164 +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
4165 @@ -857,8 +857,10 @@ static void kvaser_usb_leaf_rx_error(const struct kvaser_usb *dev,
4166 break;
4167 }
4168
4169 - cf->data[6] = es->txerr;
4170 - cf->data[7] = es->rxerr;
4171 + if (new_state != CAN_STATE_BUS_OFF) {
4172 + cf->data[6] = es->txerr;
4173 + cf->data[7] = es->rxerr;
4174 + }
4175
4176 stats->rx_packets++;
4177 stats->rx_bytes += cf->can_dlc;
4178 diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
4179 index b514b2eaa3180..89a94c16fc080 100644
4180 --- a/drivers/net/can/usb/usb_8dev.c
4181 +++ b/drivers/net/can/usb/usb_8dev.c
4182 @@ -442,9 +442,10 @@ static void usb_8dev_rx_err_msg(struct usb_8dev_priv *priv,
4183
4184 if (rx_errors)
4185 stats->rx_errors++;
4186 -
4187 - cf->data[6] = txerr;
4188 - cf->data[7] = rxerr;
4189 + if (priv->can.state != CAN_STATE_BUS_OFF) {
4190 + cf->data[6] = txerr;
4191 + cf->data[7] = rxerr;
4192 + }
4193
4194 priv->bec.txerr = txerr;
4195 priv->bec.rxerr = rxerr;
4196 diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
4197 index 0370e71ed6e0d..c66e78b2870d7 100644
4198 --- a/drivers/net/dsa/microchip/ksz9477.c
4199 +++ b/drivers/net/dsa/microchip/ksz9477.c
4200 @@ -766,6 +766,9 @@ static int ksz9477_port_fdb_dump(struct dsa_switch *ds, int port,
4201 goto exit;
4202 }
4203
4204 + if (!(ksz_data & ALU_VALID))
4205 + continue;
4206 +
4207 /* read ALU table */
4208 ksz9477_read_table(dev, alu_table);
4209
4210 diff --git a/drivers/net/dsa/mv88e6060.c b/drivers/net/dsa/mv88e6060.c
4211 index 2a2489b5196d7..51ef8f262ca95 100644
4212 --- a/drivers/net/dsa/mv88e6060.c
4213 +++ b/drivers/net/dsa/mv88e6060.c
4214 @@ -117,6 +117,9 @@ static int mv88e6060_setup_port(struct mv88e6060_priv *priv, int p)
4215 int addr = REG_PORT(p);
4216 int ret;
4217
4218 + if (dsa_is_unused_port(priv->ds, p))
4219 + return 0;
4220 +
4221 /* Do not force flow control, disable Ingress and Egress
4222 * Header tagging, disable VLAN tunneling, and set the port
4223 * state to Forwarding. Additionally, if this is the CPU
4224 diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
4225 index 148734b166f04..979af8e878e3a 100644
4226 --- a/drivers/net/ethernet/broadcom/bgmac.c
4227 +++ b/drivers/net/ethernet/broadcom/bgmac.c
4228 @@ -189,8 +189,8 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,
4229 }
4230
4231 slot->skb = skb;
4232 - ring->end += nr_frags + 1;
4233 netdev_sent_queue(net_dev, skb->len);
4234 + ring->end += nr_frags + 1;
4235
4236 wmb();
4237
4238 diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
4239 index 34540e604f748..ad0d070f7f172 100644
4240 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
4241 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
4242 @@ -971,8 +971,8 @@ static int add_bufs(struct dpaa2_eth_priv *priv,
4243 buf_array[i] = addr;
4244
4245 /* tracing point */
4246 - trace_dpaa2_eth_buf_seed(priv->net_dev,
4247 - page, DPAA2_ETH_RX_BUF_RAW_SIZE,
4248 + trace_dpaa2_eth_buf_seed(priv->net_dev, page_address(page),
4249 + DPAA2_ETH_RX_BUF_RAW_SIZE,
4250 addr, priv->rx_buf_size,
4251 bpid);
4252 }
4253 diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
4254 index 3b54a37e780eb..6fd0c73b327e2 100644
4255 --- a/drivers/net/ethernet/freescale/fec_ptp.c
4256 +++ b/drivers/net/ethernet/freescale/fec_ptp.c
4257 @@ -141,11 +141,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
4258 * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
4259 * to current timer would be next second.
4260 */
4261 - tempval = readl(fep->hwp + FEC_ATIME_CTRL);
4262 - tempval |= FEC_T_CTRL_CAPTURE;
4263 - writel(tempval, fep->hwp + FEC_ATIME_CTRL);
4264 -
4265 - tempval = readl(fep->hwp + FEC_ATIME);
4266 + tempval = fep->cc.read(&fep->cc);
4267 /* Convert the ptp local counter to 1588 timestamp */
4268 ns = timecounter_cyc2time(&fep->tc, tempval);
4269 ts = ns_to_timespec64(ns);
4270 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
4271 index 637f6ed78b489..2d01eaeb703af 100644
4272 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
4273 +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
4274 @@ -409,7 +409,9 @@ static void i40e_tx_timeout(struct net_device *netdev)
4275 set_bit(__I40E_GLOBAL_RESET_REQUESTED, pf->state);
4276 break;
4277 default:
4278 - netdev_err(netdev, "tx_timeout recovery unsuccessful\n");
4279 + netdev_err(netdev, "tx_timeout recovery unsuccessful, device is in non-recoverable state.\n");
4280 + set_bit(__I40E_DOWN_REQUESTED, pf->state);
4281 + set_bit(__I40E_VSI_DOWN_REQUESTED, vsi->state);
4282 break;
4283 }
4284
4285 diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
4286 index 81ca6472937d2..85275b6ede4d3 100644
4287 --- a/drivers/net/ethernet/intel/iavf/iavf.h
4288 +++ b/drivers/net/ethernet/intel/iavf/iavf.h
4289 @@ -86,6 +86,7 @@ struct iavf_vsi {
4290 #define IAVF_HKEY_ARRAY_SIZE ((IAVF_VFQF_HKEY_MAX_INDEX + 1) * 4)
4291 #define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)
4292 #define IAVF_MBPS_DIVISOR 125000 /* divisor to convert to Mbps */
4293 +#define IAVF_MBPS_QUANTA 50
4294
4295 #define IAVF_VIRTCHNL_VF_RESOURCE_SIZE (sizeof(struct virtchnl_vf_resource) + \
4296 (IAVF_MAX_VF_VSI * \
4297 diff --git a/drivers/net/ethernet/intel/iavf/iavf_adminq.c b/drivers/net/ethernet/intel/iavf/iavf_adminq.c
4298 index 9fa3fa99b4c20..897b349cdaf1c 100644
4299 --- a/drivers/net/ethernet/intel/iavf/iavf_adminq.c
4300 +++ b/drivers/net/ethernet/intel/iavf/iavf_adminq.c
4301 @@ -324,6 +324,7 @@ static enum iavf_status iavf_config_arq_regs(struct iavf_hw *hw)
4302 static enum iavf_status iavf_init_asq(struct iavf_hw *hw)
4303 {
4304 enum iavf_status ret_code = 0;
4305 + int i;
4306
4307 if (hw->aq.asq.count > 0) {
4308 /* queue already initialized */
4309 @@ -354,12 +355,17 @@ static enum iavf_status iavf_init_asq(struct iavf_hw *hw)
4310 /* initialize base registers */
4311 ret_code = iavf_config_asq_regs(hw);
4312 if (ret_code)
4313 - goto init_adminq_free_rings;
4314 + goto init_free_asq_bufs;
4315
4316 /* success! */
4317 hw->aq.asq.count = hw->aq.num_asq_entries;
4318 goto init_adminq_exit;
4319
4320 +init_free_asq_bufs:
4321 + for (i = 0; i < hw->aq.num_asq_entries; i++)
4322 + iavf_free_dma_mem(hw, &hw->aq.asq.r.asq_bi[i]);
4323 + iavf_free_virt_mem(hw, &hw->aq.asq.dma_head);
4324 +
4325 init_adminq_free_rings:
4326 iavf_free_adminq_asq(hw);
4327
4328 @@ -383,6 +389,7 @@ init_adminq_exit:
4329 static enum iavf_status iavf_init_arq(struct iavf_hw *hw)
4330 {
4331 enum iavf_status ret_code = 0;
4332 + int i;
4333
4334 if (hw->aq.arq.count > 0) {
4335 /* queue already initialized */
4336 @@ -413,12 +420,16 @@ static enum iavf_status iavf_init_arq(struct iavf_hw *hw)
4337 /* initialize base registers */
4338 ret_code = iavf_config_arq_regs(hw);
4339 if (ret_code)
4340 - goto init_adminq_free_rings;
4341 + goto init_free_arq_bufs;
4342
4343 /* success! */
4344 hw->aq.arq.count = hw->aq.num_arq_entries;
4345 goto init_adminq_exit;
4346
4347 +init_free_arq_bufs:
4348 + for (i = 0; i < hw->aq.num_arq_entries; i++)
4349 + iavf_free_dma_mem(hw, &hw->aq.arq.r.arq_bi[i]);
4350 + iavf_free_virt_mem(hw, &hw->aq.arq.dma_head);
4351 init_adminq_free_rings:
4352 iavf_free_adminq_arq(hw);
4353
4354 diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
4355 index e8850ba5604c4..4c41bb47fc1a6 100644
4356 --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
4357 +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
4358 @@ -2581,6 +2581,7 @@ static int iavf_validate_ch_config(struct iavf_adapter *adapter,
4359 struct tc_mqprio_qopt_offload *mqprio_qopt)
4360 {
4361 u64 total_max_rate = 0;
4362 + u32 tx_rate_rem = 0;
4363 int i, num_qps = 0;
4364 u64 tx_rate = 0;
4365 int ret = 0;
4366 @@ -2595,12 +2596,32 @@ static int iavf_validate_ch_config(struct iavf_adapter *adapter,
4367 return -EINVAL;
4368 if (mqprio_qopt->min_rate[i]) {
4369 dev_err(&adapter->pdev->dev,
4370 - "Invalid min tx rate (greater than 0) specified\n");
4371 + "Invalid min tx rate (greater than 0) specified for TC%d\n",
4372 + i);
4373 return -EINVAL;
4374 }
4375 - /*convert to Mbps */
4376 +
4377 + /* convert to Mbps */
4378 tx_rate = div_u64(mqprio_qopt->max_rate[i],
4379 IAVF_MBPS_DIVISOR);
4380 +
4381 + if (mqprio_qopt->max_rate[i] &&
4382 + tx_rate < IAVF_MBPS_QUANTA) {
4383 + dev_err(&adapter->pdev->dev,
4384 + "Invalid max tx rate for TC%d, minimum %dMbps\n",
4385 + i, IAVF_MBPS_QUANTA);
4386 + return -EINVAL;
4387 + }
4388 +
4389 + (void)div_u64_rem(tx_rate, IAVF_MBPS_QUANTA, &tx_rate_rem);
4390 +
4391 + if (tx_rate_rem != 0) {
4392 + dev_err(&adapter->pdev->dev,
4393 + "Invalid max tx rate for TC%d, not divisible by %d\n",
4394 + i, IAVF_MBPS_QUANTA);
4395 + return -EINVAL;
4396 + }
4397 +
4398 total_max_rate += tx_rate;
4399 num_qps += mqprio_qopt->qopt.count[i];
4400 }
4401 diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
4402 index 7ff2e07f6d38a..0c71995e1a70b 100644
4403 --- a/drivers/net/ethernet/intel/ice/ice_switch.c
4404 +++ b/drivers/net/ethernet/intel/ice/ice_switch.c
4405 @@ -2627,7 +2627,7 @@ ice_set_vlan_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 promisc_mask,
4406 else
4407 status = ice_set_vsi_promisc(hw, vsi_handle,
4408 promisc_mask, vlan_id);
4409 - if (status)
4410 + if (status && status != -EEXIST)
4411 break;
4412 }
4413
4414 diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h
4415 index ca54e268d157b..33cbe4f70d590 100644
4416 --- a/drivers/net/ethernet/intel/igb/igb.h
4417 +++ b/drivers/net/ethernet/intel/igb/igb.h
4418 @@ -594,6 +594,8 @@ struct igb_adapter {
4419 struct igb_mac_addr *mac_table;
4420 struct vf_mac_filter vf_macs;
4421 struct vf_mac_filter *vf_mac_list;
4422 + /* lock for VF resources */
4423 + spinlock_t vfs_lock;
4424 };
4425
4426 /* flags controlling PTP/1588 function */
4427 diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
4428 index 8734dfd001bbd..f718eadd87744 100644
4429 --- a/drivers/net/ethernet/intel/igb/igb_main.c
4430 +++ b/drivers/net/ethernet/intel/igb/igb_main.c
4431 @@ -3491,6 +3491,7 @@ static int igb_disable_sriov(struct pci_dev *pdev)
4432 struct net_device *netdev = pci_get_drvdata(pdev);
4433 struct igb_adapter *adapter = netdev_priv(netdev);
4434 struct e1000_hw *hw = &adapter->hw;
4435 + unsigned long flags;
4436
4437 /* reclaim resources allocated to VFs */
4438 if (adapter->vf_data) {
4439 @@ -3503,12 +3504,13 @@ static int igb_disable_sriov(struct pci_dev *pdev)
4440 pci_disable_sriov(pdev);
4441 msleep(500);
4442 }
4443 -
4444 + spin_lock_irqsave(&adapter->vfs_lock, flags);
4445 kfree(adapter->vf_mac_list);
4446 adapter->vf_mac_list = NULL;
4447 kfree(adapter->vf_data);
4448 adapter->vf_data = NULL;
4449 adapter->vfs_allocated_count = 0;
4450 + spin_unlock_irqrestore(&adapter->vfs_lock, flags);
4451 wr32(E1000_IOVCTL, E1000_IOVCTL_REUSE_VFQ);
4452 wrfl();
4453 msleep(100);
4454 @@ -3668,7 +3670,9 @@ static void igb_remove(struct pci_dev *pdev)
4455 igb_release_hw_control(adapter);
4456
4457 #ifdef CONFIG_PCI_IOV
4458 + rtnl_lock();
4459 igb_disable_sriov(pdev);
4460 + rtnl_unlock();
4461 #endif
4462
4463 unregister_netdev(netdev);
4464 @@ -3829,6 +3833,9 @@ static int igb_sw_init(struct igb_adapter *adapter)
4465
4466 spin_lock_init(&adapter->nfc_lock);
4467 spin_lock_init(&adapter->stats64_lock);
4468 +
4469 + /* init spinlock to avoid concurrency of VF resources */
4470 + spin_lock_init(&adapter->vfs_lock);
4471 #ifdef CONFIG_PCI_IOV
4472 switch (hw->mac.type) {
4473 case e1000_82576:
4474 @@ -7569,8 +7576,10 @@ unlock:
4475 static void igb_msg_task(struct igb_adapter *adapter)
4476 {
4477 struct e1000_hw *hw = &adapter->hw;
4478 + unsigned long flags;
4479 u32 vf;
4480
4481 + spin_lock_irqsave(&adapter->vfs_lock, flags);
4482 for (vf = 0; vf < adapter->vfs_allocated_count; vf++) {
4483 /* process any reset requests */
4484 if (!igb_check_for_rst(hw, vf))
4485 @@ -7584,6 +7593,7 @@ static void igb_msg_task(struct igb_adapter *adapter)
4486 if (!igb_check_for_ack(hw, vf))
4487 igb_rcv_ack_from_vf(adapter, vf);
4488 }
4489 + spin_unlock_irqrestore(&adapter->vfs_lock, flags);
4490 }
4491
4492 /**
4493 diff --git a/drivers/net/ethernet/intel/igc/igc_base.c b/drivers/net/ethernet/intel/igc/igc_base.c
4494 index db289bcce21d3..d66429eb14a59 100644
4495 --- a/drivers/net/ethernet/intel/igc/igc_base.c
4496 +++ b/drivers/net/ethernet/intel/igc/igc_base.c
4497 @@ -187,15 +187,7 @@ static s32 igc_init_phy_params_base(struct igc_hw *hw)
4498
4499 igc_check_for_copper_link(hw);
4500
4501 - /* Verify phy id and set remaining function pointers */
4502 - switch (phy->id) {
4503 - case I225_I_PHY_ID:
4504 - phy->type = igc_phy_i225;
4505 - break;
4506 - default:
4507 - ret_val = -IGC_ERR_PHY;
4508 - goto out;
4509 - }
4510 + phy->type = igc_phy_i225;
4511
4512 out:
4513 return ret_val;
4514 diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
4515 index 9ba05d9aa8e08..b8297a63a7fd2 100644
4516 --- a/drivers/net/ethernet/intel/igc/igc_main.c
4517 +++ b/drivers/net/ethernet/intel/igc/igc_main.c
4518 @@ -2884,8 +2884,7 @@ bool igc_has_link(struct igc_adapter *adapter)
4519 break;
4520 }
4521
4522 - if (hw->mac.type == igc_i225 &&
4523 - hw->phy.id == I225_I_PHY_ID) {
4524 + if (hw->mac.type == igc_i225) {
4525 if (!netif_carrier_ok(adapter->netdev)) {
4526 adapter->flags &= ~IGC_FLAG_NEED_LINK_UPDATE;
4527 } else if (!(adapter->flags & IGC_FLAG_NEED_LINK_UPDATE)) {
4528 diff --git a/drivers/net/ethernet/intel/igc/igc_phy.c b/drivers/net/ethernet/intel/igc/igc_phy.c
4529 index 6156c76d765ff..1be112ce6774b 100644
4530 --- a/drivers/net/ethernet/intel/igc/igc_phy.c
4531 +++ b/drivers/net/ethernet/intel/igc/igc_phy.c
4532 @@ -235,8 +235,7 @@ static s32 igc_phy_setup_autoneg(struct igc_hw *hw)
4533 return ret_val;
4534 }
4535
4536 - if ((phy->autoneg_mask & ADVERTISE_2500_FULL) &&
4537 - hw->phy.id == I225_I_PHY_ID) {
4538 + if (phy->autoneg_mask & ADVERTISE_2500_FULL) {
4539 /* Read the MULTI GBT AN Control Register - reg 7.32 */
4540 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK <<
4541 MMD_DEVADDR_SHIFT) |
4542 @@ -376,8 +375,7 @@ static s32 igc_phy_setup_autoneg(struct igc_hw *hw)
4543 ret_val = phy->ops.write_reg(hw, PHY_1000T_CTRL,
4544 mii_1000t_ctrl_reg);
4545
4546 - if ((phy->autoneg_mask & ADVERTISE_2500_FULL) &&
4547 - hw->phy.id == I225_I_PHY_ID)
4548 + if (phy->autoneg_mask & ADVERTISE_2500_FULL)
4549 ret_val = phy->ops.write_reg(hw,
4550 (STANDARD_AN_REG_MASK <<
4551 MMD_DEVADDR_SHIFT) |
4552 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
4553 index b5c8afe8cd10d..3209decdcff02 100644
4554 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
4555 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
4556 @@ -101,7 +101,7 @@ struct page_pool;
4557 #define MLX5E_LOG_ALIGNED_MPWQE_PPW (ilog2(MLX5E_REQUIRED_WQE_MTTS))
4558 #define MLX5E_REQUIRED_MTTS(wqes) (wqes * MLX5E_REQUIRED_WQE_MTTS)
4559 #define MLX5E_MAX_RQ_NUM_MTTS \
4560 - ((1 << 16) * 2) /* So that MLX5_MTT_OCTW(num_mtts) fits into u16 */
4561 + (ALIGN_DOWN(U16_MAX, 4) * 2) /* So that MLX5_MTT_OCTW(num_mtts) fits into u16 */
4562 #define MLX5E_ORDER2_MAX_PACKET_MTU (order_base_2(10 * 1024))
4563 #define MLX5E_PARAMS_MAXIMUM_LOG_RQ_SIZE_MPW \
4564 (ilog2(MLX5E_MAX_RQ_NUM_MTTS / MLX5E_REQUIRED_WQE_MTTS))
4565 diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
4566 index 13714827f4525..383d72415c659 100644
4567 --- a/drivers/net/ethernet/moxa/moxart_ether.c
4568 +++ b/drivers/net/ethernet/moxa/moxart_ether.c
4569 @@ -77,7 +77,7 @@ static void moxart_mac_free_memory(struct net_device *ndev)
4570 int i;
4571
4572 for (i = 0; i < RX_DESC_NUM; i++)
4573 - dma_unmap_single(&ndev->dev, priv->rx_mapping[i],
4574 + dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
4575 priv->rx_buf_size, DMA_FROM_DEVICE);
4576
4577 if (priv->tx_desc_base)
4578 @@ -147,11 +147,11 @@ static void moxart_mac_setup_desc_ring(struct net_device *ndev)
4579 desc + RX_REG_OFFSET_DESC1);
4580
4581 priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i;
4582 - priv->rx_mapping[i] = dma_map_single(&ndev->dev,
4583 + priv->rx_mapping[i] = dma_map_single(&priv->pdev->dev,
4584 priv->rx_buf[i],
4585 priv->rx_buf_size,
4586 DMA_FROM_DEVICE);
4587 - if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i]))
4588 + if (dma_mapping_error(&priv->pdev->dev, priv->rx_mapping[i]))
4589 netdev_err(ndev, "DMA mapping error\n");
4590
4591 moxart_desc_write(priv->rx_mapping[i],
4592 @@ -240,7 +240,7 @@ static int moxart_rx_poll(struct napi_struct *napi, int budget)
4593 if (len > RX_BUF_SIZE)
4594 len = RX_BUF_SIZE;
4595
4596 - dma_sync_single_for_cpu(&ndev->dev,
4597 + dma_sync_single_for_cpu(&priv->pdev->dev,
4598 priv->rx_mapping[rx_head],
4599 priv->rx_buf_size, DMA_FROM_DEVICE);
4600 skb = netdev_alloc_skb_ip_align(ndev, len);
4601 @@ -294,7 +294,7 @@ static void moxart_tx_finished(struct net_device *ndev)
4602 unsigned int tx_tail = priv->tx_tail;
4603
4604 while (tx_tail != tx_head) {
4605 - dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail],
4606 + dma_unmap_single(&priv->pdev->dev, priv->tx_mapping[tx_tail],
4607 priv->tx_len[tx_tail], DMA_TO_DEVICE);
4608
4609 ndev->stats.tx_packets++;
4610 @@ -357,9 +357,9 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
4611
4612 len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len;
4613
4614 - priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data,
4615 + priv->tx_mapping[tx_head] = dma_map_single(&priv->pdev->dev, skb->data,
4616 len, DMA_TO_DEVICE);
4617 - if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) {
4618 + if (dma_mapping_error(&priv->pdev->dev, priv->tx_mapping[tx_head])) {
4619 netdev_err(ndev, "DMA mapping error\n");
4620 goto out_unlock;
4621 }
4622 @@ -378,7 +378,7 @@ static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
4623 len = ETH_ZLEN;
4624 }
4625
4626 - dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head],
4627 + dma_sync_single_for_device(&priv->pdev->dev, priv->tx_mapping[tx_head],
4628 priv->tx_buf_size, DMA_TO_DEVICE);
4629
4630 txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
4631 @@ -498,7 +498,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
4632 priv->tx_buf_size = TX_BUF_SIZE;
4633 priv->rx_buf_size = RX_BUF_SIZE;
4634
4635 - priv->tx_desc_base = dma_alloc_coherent(&pdev->dev, TX_REG_DESC_SIZE *
4636 + priv->tx_desc_base = dma_alloc_coherent(p_dev, TX_REG_DESC_SIZE *
4637 TX_DESC_NUM, &priv->tx_base,
4638 GFP_DMA | GFP_KERNEL);
4639 if (!priv->tx_desc_base) {
4640 @@ -506,7 +506,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
4641 goto init_fail;
4642 }
4643
4644 - priv->rx_desc_base = dma_alloc_coherent(&pdev->dev, RX_REG_DESC_SIZE *
4645 + priv->rx_desc_base = dma_alloc_coherent(p_dev, RX_REG_DESC_SIZE *
4646 RX_DESC_NUM, &priv->rx_base,
4647 GFP_DMA | GFP_KERNEL);
4648 if (!priv->rx_desc_base) {
4649 diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
4650 index 10857914c552b..46d6988829ff1 100644
4651 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
4652 +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
4653 @@ -1127,6 +1127,8 @@ nfp_port_get_module_info(struct net_device *netdev,
4654 u8 data;
4655
4656 port = nfp_port_from_netdev(netdev);
4657 + /* update port state to get latest interface */
4658 + set_bit(NFP_PORT_CHANGED, &port->flags);
4659 eth_port = nfp_port_get_eth_port(port);
4660 if (!eth_port)
4661 return -EOPNOTSUPP;
4662 diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
4663 index 84f5717c01e2a..5636673b84e7d 100644
4664 --- a/drivers/net/geneve.c
4665 +++ b/drivers/net/geneve.c
4666 @@ -851,8 +851,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb,
4667 use_cache = false;
4668 }
4669
4670 - fl6->flowlabel = ip6_make_flowinfo(RT_TOS(prio),
4671 - info->key.label);
4672 + fl6->flowlabel = ip6_make_flowinfo(prio, info->key.label);
4673 dst_cache = (struct dst_cache *)&info->dst_cache;
4674 if (use_cache) {
4675 dst = dst_cache_get_ip6(dst_cache, &fl6->saddr);
4676 diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
4677 index e0a4acc6144bf..8e47755cc1595 100644
4678 --- a/drivers/net/netdevsim/bpf.c
4679 +++ b/drivers/net/netdevsim/bpf.c
4680 @@ -347,10 +347,12 @@ nsim_map_alloc_elem(struct bpf_offloaded_map *offmap, unsigned int idx)
4681 {
4682 struct nsim_bpf_bound_map *nmap = offmap->dev_priv;
4683
4684 - nmap->entry[idx].key = kmalloc(offmap->map.key_size, GFP_USER);
4685 + nmap->entry[idx].key = kmalloc(offmap->map.key_size,
4686 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
4687 if (!nmap->entry[idx].key)
4688 return -ENOMEM;
4689 - nmap->entry[idx].value = kmalloc(offmap->map.value_size, GFP_USER);
4690 + nmap->entry[idx].value = kmalloc(offmap->map.value_size,
4691 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
4692 if (!nmap->entry[idx].value) {
4693 kfree(nmap->entry[idx].key);
4694 nmap->entry[idx].key = NULL;
4695 @@ -492,7 +494,7 @@ nsim_bpf_map_alloc(struct netdevsim *ns, struct bpf_offloaded_map *offmap)
4696 if (offmap->map.map_flags)
4697 return -EINVAL;
4698
4699 - nmap = kzalloc(sizeof(*nmap), GFP_USER);
4700 + nmap = kzalloc(sizeof(*nmap), GFP_KERNEL_ACCOUNT);
4701 if (!nmap)
4702 return -ENOMEM;
4703
4704 diff --git a/drivers/net/plip/plip.c b/drivers/net/plip/plip.c
4705 index e89cdebae6f13..e8b7d596d7492 100644
4706 --- a/drivers/net/plip/plip.c
4707 +++ b/drivers/net/plip/plip.c
4708 @@ -1103,7 +1103,7 @@ plip_open(struct net_device *dev)
4709 /* Any address will do - we take the first. We already
4710 have the first two bytes filled with 0xfc, from
4711 plip_init_dev(). */
4712 - const struct in_ifaddr *ifa = rcu_dereference(in_dev->ifa_list);
4713 + const struct in_ifaddr *ifa = rtnl_dereference(in_dev->ifa_list);
4714 if (ifa != NULL) {
4715 memcpy(dev->dev_addr+2, &ifa->ifa_local, 4);
4716 }
4717 diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
4718 index 5ee3e457a79c7..ea9c8361bf464 100644
4719 --- a/drivers/net/usb/ax88179_178a.c
4720 +++ b/drivers/net/usb/ax88179_178a.c
4721 @@ -1690,7 +1690,7 @@ static const struct driver_info ax88179_info = {
4722 .link_reset = ax88179_link_reset,
4723 .reset = ax88179_reset,
4724 .stop = ax88179_stop,
4725 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4726 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4727 .rx_fixup = ax88179_rx_fixup,
4728 .tx_fixup = ax88179_tx_fixup,
4729 };
4730 @@ -1703,7 +1703,7 @@ static const struct driver_info ax88178a_info = {
4731 .link_reset = ax88179_link_reset,
4732 .reset = ax88179_reset,
4733 .stop = ax88179_stop,
4734 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4735 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4736 .rx_fixup = ax88179_rx_fixup,
4737 .tx_fixup = ax88179_tx_fixup,
4738 };
4739 @@ -1716,7 +1716,7 @@ static const struct driver_info cypress_GX3_info = {
4740 .link_reset = ax88179_link_reset,
4741 .reset = ax88179_reset,
4742 .stop = ax88179_stop,
4743 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4744 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4745 .rx_fixup = ax88179_rx_fixup,
4746 .tx_fixup = ax88179_tx_fixup,
4747 };
4748 @@ -1729,7 +1729,7 @@ static const struct driver_info dlink_dub1312_info = {
4749 .link_reset = ax88179_link_reset,
4750 .reset = ax88179_reset,
4751 .stop = ax88179_stop,
4752 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4753 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4754 .rx_fixup = ax88179_rx_fixup,
4755 .tx_fixup = ax88179_tx_fixup,
4756 };
4757 @@ -1742,7 +1742,7 @@ static const struct driver_info sitecom_info = {
4758 .link_reset = ax88179_link_reset,
4759 .reset = ax88179_reset,
4760 .stop = ax88179_stop,
4761 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4762 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4763 .rx_fixup = ax88179_rx_fixup,
4764 .tx_fixup = ax88179_tx_fixup,
4765 };
4766 @@ -1755,7 +1755,7 @@ static const struct driver_info samsung_info = {
4767 .link_reset = ax88179_link_reset,
4768 .reset = ax88179_reset,
4769 .stop = ax88179_stop,
4770 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4771 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4772 .rx_fixup = ax88179_rx_fixup,
4773 .tx_fixup = ax88179_tx_fixup,
4774 };
4775 @@ -1768,7 +1768,7 @@ static const struct driver_info lenovo_info = {
4776 .link_reset = ax88179_link_reset,
4777 .reset = ax88179_reset,
4778 .stop = ax88179_stop,
4779 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4780 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4781 .rx_fixup = ax88179_rx_fixup,
4782 .tx_fixup = ax88179_tx_fixup,
4783 };
4784 @@ -1781,7 +1781,7 @@ static const struct driver_info belkin_info = {
4785 .link_reset = ax88179_link_reset,
4786 .reset = ax88179_reset,
4787 .stop = ax88179_stop,
4788 - .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_SEND_ZLP,
4789 + .flags = FLAG_ETHER | FLAG_FRAMING_AX,
4790 .rx_fixup = ax88179_rx_fixup,
4791 .tx_fixup = ax88179_tx_fixup,
4792 };
4793 diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
4794 index 6598a4cba158a..7a8324d2a9686 100644
4795 --- a/drivers/net/usb/usbnet.c
4796 +++ b/drivers/net/usb/usbnet.c
4797 @@ -833,13 +833,11 @@ int usbnet_stop (struct net_device *net)
4798
4799 mpn = !test_and_clear_bit(EVENT_NO_RUNTIME_PM, &dev->flags);
4800
4801 - /* deferred work (task, timer, softirq) must also stop.
4802 - * can't flush_scheduled_work() until we drop rtnl (later),
4803 - * else workers could deadlock; so make workers a NOP.
4804 - */
4805 + /* deferred work (timer, softirq, task) must also stop */
4806 dev->flags = 0;
4807 del_timer_sync (&dev->delay);
4808 tasklet_kill (&dev->bh);
4809 + cancel_work_sync(&dev->kevent);
4810 if (!pm)
4811 usb_autopm_put_interface(dev->intf);
4812
4813 @@ -1603,8 +1601,6 @@ void usbnet_disconnect (struct usb_interface *intf)
4814 net = dev->net;
4815 unregister_netdev (net);
4816
4817 - cancel_work_sync(&dev->kevent);
4818 -
4819 usb_scuttle_anchored_urbs(&dev->deferred);
4820
4821 if (dev->driver_info->unbind)
4822 diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
4823 index d4589b2ab3b6d..b6762fe2efe26 100644
4824 --- a/drivers/net/wireless/ath/ath10k/snoc.c
4825 +++ b/drivers/net/wireless/ath/ath10k/snoc.c
4826 @@ -1192,13 +1192,12 @@ static void ath10k_snoc_init_napi(struct ath10k *ar)
4827 static int ath10k_snoc_request_irq(struct ath10k *ar)
4828 {
4829 struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar);
4830 - int irqflags = IRQF_TRIGGER_RISING;
4831 int ret, id;
4832
4833 for (id = 0; id < CE_COUNT_MAX; id++) {
4834 ret = request_irq(ar_snoc->ce_irqs[id].irq_line,
4835 - ath10k_snoc_per_engine_handler,
4836 - irqflags, ce_name[id], ar);
4837 + ath10k_snoc_per_engine_handler, 0,
4838 + ce_name[id], ar);
4839 if (ret) {
4840 ath10k_err(ar,
4841 "failed to register IRQ handler for CE %d: %d",
4842 diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
4843 index 9f64e32381f94..81107100e3682 100644
4844 --- a/drivers/net/wireless/ath/ath9k/htc.h
4845 +++ b/drivers/net/wireless/ath/ath9k/htc.h
4846 @@ -325,11 +325,11 @@ static inline struct ath9k_htc_tx_ctl *HTC_SKB_CB(struct sk_buff *skb)
4847 }
4848
4849 #ifdef CONFIG_ATH9K_HTC_DEBUGFS
4850 -
4851 -#define TX_STAT_INC(c) (hif_dev->htc_handle->drv_priv->debug.tx_stats.c++)
4852 -#define TX_STAT_ADD(c, a) (hif_dev->htc_handle->drv_priv->debug.tx_stats.c += a)
4853 -#define RX_STAT_INC(c) (hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c++)
4854 -#define RX_STAT_ADD(c, a) (hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c += a)
4855 +#define __STAT_SAFE(expr) (hif_dev->htc_handle->drv_priv ? (expr) : 0)
4856 +#define TX_STAT_INC(c) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.tx_stats.c++)
4857 +#define TX_STAT_ADD(c, a) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.tx_stats.c += a)
4858 +#define RX_STAT_INC(c) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c++)
4859 +#define RX_STAT_ADD(c, a) __STAT_SAFE(hif_dev->htc_handle->drv_priv->debug.skbrx_stats.c += a)
4860 #define CAB_STAT_INC priv->debug.tx_stats.cab_queued++
4861
4862 #define TX_QSTAT_INC(q) (priv->debug.tx_stats.queue_stats[q]++)
4863 diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
4864 index 11054c17a9b54..eaaafa64a3eef 100644
4865 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
4866 +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
4867 @@ -944,7 +944,6 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
4868 priv->hw = hw;
4869 priv->htc = htc_handle;
4870 priv->dev = dev;
4871 - htc_handle->drv_priv = priv;
4872 SET_IEEE80211_DEV(hw, priv->dev);
4873
4874 ret = ath9k_htc_wait_for_target(priv);
4875 @@ -965,6 +964,8 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
4876 if (ret)
4877 goto err_init;
4878
4879 + htc_handle->drv_priv = priv;
4880 +
4881 return 0;
4882
4883 err_init:
4884 diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
4885 index 304b4d4e506a2..1e38fdf92d1db 100644
4886 --- a/drivers/net/wireless/ath/wil6210/debugfs.c
4887 +++ b/drivers/net/wireless/ath/wil6210/debugfs.c
4888 @@ -1021,20 +1021,14 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
4889 void *cmd;
4890 int cmdlen = len - sizeof(struct wmi_cmd_hdr);
4891 u16 cmdid;
4892 - int rc, rc1;
4893 + int rc1;
4894
4895 - if (cmdlen < 0)
4896 + if (cmdlen < 0 || *ppos != 0)
4897 return -EINVAL;
4898
4899 - wmi = kmalloc(len, GFP_KERNEL);
4900 - if (!wmi)
4901 - return -ENOMEM;
4902 -
4903 - rc = simple_write_to_buffer(wmi, len, ppos, buf, len);
4904 - if (rc < 0) {
4905 - kfree(wmi);
4906 - return rc;
4907 - }
4908 + wmi = memdup_user(buf, len);
4909 + if (IS_ERR(wmi))
4910 + return PTR_ERR(wmi);
4911
4912 cmd = (cmdlen > 0) ? &wmi[1] : NULL;
4913 cmdid = le16_to_cpu(wmi->command_id);
4914 @@ -1044,7 +1038,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
4915
4916 wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1);
4917
4918 - return rc;
4919 + return len;
4920 }
4921
4922 static const struct file_operations fops_wmi = {
4923 diff --git a/drivers/net/wireless/intel/iwlegacy/4965-rs.c b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
4924 index 0a02d8aca3206..ce891ac32388f 100644
4925 --- a/drivers/net/wireless/intel/iwlegacy/4965-rs.c
4926 +++ b/drivers/net/wireless/intel/iwlegacy/4965-rs.c
4927 @@ -2403,7 +2403,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
4928 /* Repeat initial/next rate.
4929 * For legacy IL_NUMBER_TRY == 1, this loop will not execute.
4930 * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */
4931 - while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) {
4932 + while (repeat_rate > 0) {
4933 if (is_legacy(tbl_type.lq_type)) {
4934 if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE)
4935 ant_toggle_cnt++;
4936 @@ -2422,6 +2422,8 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
4937 cpu_to_le32(new_rate);
4938 repeat_rate--;
4939 idx++;
4940 + if (idx >= LINK_QUAL_MAX_RETRY_NUM)
4941 + goto out;
4942 }
4943
4944 il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band,
4945 @@ -2466,6 +2468,7 @@ il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta,
4946 repeat_rate--;
4947 }
4948
4949 +out:
4950 lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
4951 lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF;
4952
4953 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
4954 index 5df4bbb6c6de3..a3255100e3fee 100644
4955 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
4956 +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c
4957 @@ -1810,6 +1810,7 @@ static void iwl_mvm_disable_sta_queues(struct iwl_mvm *mvm,
4958 iwl_mvm_txq_from_mac80211(sta->txq[i]);
4959
4960 mvmtxq->txq_id = IWL_MVM_INVALID_QUEUE;
4961 + list_del_init(&mvmtxq->list);
4962 }
4963 }
4964
4965 diff --git a/drivers/net/wireless/intersil/p54/main.c b/drivers/net/wireless/intersil/p54/main.c
4966 index a3ca6620dc0c6..8fa3ec71603e3 100644
4967 --- a/drivers/net/wireless/intersil/p54/main.c
4968 +++ b/drivers/net/wireless/intersil/p54/main.c
4969 @@ -682,7 +682,7 @@ static void p54_flush(struct ieee80211_hw *dev, struct ieee80211_vif *vif,
4970 * queues have already been stopped and no new frames can sneak
4971 * up from behind.
4972 */
4973 - while ((total = p54_flush_count(priv) && i--)) {
4974 + while ((total = p54_flush_count(priv)) && i--) {
4975 /* waste time */
4976 msleep(20);
4977 }
4978 diff --git a/drivers/net/wireless/intersil/p54/p54spi.c b/drivers/net/wireless/intersil/p54/p54spi.c
4979 index ab0fe85658518..cdb57819684ae 100644
4980 --- a/drivers/net/wireless/intersil/p54/p54spi.c
4981 +++ b/drivers/net/wireless/intersil/p54/p54spi.c
4982 @@ -164,7 +164,7 @@ static int p54spi_request_firmware(struct ieee80211_hw *dev)
4983
4984 ret = p54_parse_firmware(dev, priv->firmware);
4985 if (ret) {
4986 - release_firmware(priv->firmware);
4987 + /* the firmware is released by the caller */
4988 return ret;
4989 }
4990
4991 @@ -659,6 +659,7 @@ static int p54spi_probe(struct spi_device *spi)
4992 return 0;
4993
4994 err_free_common:
4995 + release_firmware(priv->firmware);
4996 free_irq(gpio_to_irq(p54spi_gpio_irq), spi);
4997 err_free_gpio_irq:
4998 gpio_free(p54spi_gpio_irq);
4999 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
5000 index ffe27104f654b..6b0ad6b4dd4b1 100644
5001 --- a/drivers/net/wireless/mac80211_hwsim.c
5002 +++ b/drivers/net/wireless/mac80211_hwsim.c
5003 @@ -527,7 +527,7 @@ struct mac80211_hwsim_data {
5004 bool ps_poll_pending;
5005 struct dentry *debugfs;
5006
5007 - uintptr_t pending_cookie;
5008 + atomic_t pending_cookie;
5009 struct sk_buff_head pending; /* packets pending */
5010 /*
5011 * Only radios in the same group can communicate together (the
5012 @@ -1113,8 +1113,7 @@ static void mac80211_hwsim_tx_frame_nl(struct ieee80211_hw *hw,
5013 goto nla_put_failure;
5014
5015 /* We create a cookie to identify this skb */
5016 - data->pending_cookie++;
5017 - cookie = data->pending_cookie;
5018 + cookie = atomic_inc_return(&data->pending_cookie);
5019 info->rate_driver_data[0] = (void *)cookie;
5020 if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD))
5021 goto nla_put_failure;
5022 @@ -3260,6 +3259,7 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
5023 const u8 *src;
5024 unsigned int hwsim_flags;
5025 int i;
5026 + unsigned long flags;
5027 bool found = false;
5028
5029 if (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] ||
5030 @@ -3284,18 +3284,20 @@ static int hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,
5031 goto out;
5032
5033 /* look for the skb matching the cookie passed back from user */
5034 + spin_lock_irqsave(&data2->pending.lock, flags);
5035 skb_queue_walk_safe(&data2->pending, skb, tmp) {
5036 - u64 skb_cookie;
5037 + uintptr_t skb_cookie;
5038
5039 txi = IEEE80211_SKB_CB(skb);
5040 - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0];
5041 + skb_cookie = (uintptr_t)txi->rate_driver_data[0];
5042
5043 if (skb_cookie == ret_skb_cookie) {
5044 - skb_unlink(skb, &data2->pending);
5045 + __skb_unlink(skb, &data2->pending);
5046 found = true;
5047 break;
5048 }
5049 }
5050 + spin_unlock_irqrestore(&data2->pending.lock, flags);
5051
5052 /* not found */
5053 if (!found)
5054 diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c
5055 index 5d6dc1dd050d4..32fdc4150b605 100644
5056 --- a/drivers/net/wireless/marvell/libertas/if_usb.c
5057 +++ b/drivers/net/wireless/marvell/libertas/if_usb.c
5058 @@ -287,6 +287,7 @@ static int if_usb_probe(struct usb_interface *intf,
5059 return 0;
5060
5061 err_get_fw:
5062 + usb_put_dev(udev);
5063 lbs_remove_card(priv);
5064 err_add_card:
5065 if_usb_reset_device(cardp);
5066 diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
5067 index 8bd191347b9fb..179337eb39ba3 100644
5068 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c
5069 +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
5070 @@ -103,6 +103,7 @@ static int mt76_led_init(struct mt76_dev *dev)
5071 if (!of_property_read_u32(np, "led-sources", &led_pin))
5072 dev->led_pin = led_pin;
5073 dev->led_al = of_property_read_bool(np, "led-active-low");
5074 + of_node_put(np);
5075 }
5076
5077 return led_classdev_register(dev->dev, &dev->led_cdev);
5078 diff --git a/drivers/net/wireless/realtek/rtlwifi/debug.c b/drivers/net/wireless/realtek/rtlwifi/debug.c
5079 index 55db71c766fe3..ec0da33da4f89 100644
5080 --- a/drivers/net/wireless/realtek/rtlwifi/debug.c
5081 +++ b/drivers/net/wireless/realtek/rtlwifi/debug.c
5082 @@ -349,8 +349,8 @@ static ssize_t rtl_debugfs_set_write_h2c(struct file *filp,
5083
5084 tmp_len = (count > sizeof(tmp) - 1 ? sizeof(tmp) - 1 : count);
5085
5086 - if (!buffer || copy_from_user(tmp, buffer, tmp_len))
5087 - return count;
5088 + if (copy_from_user(tmp, buffer, tmp_len))
5089 + return -EFAULT;
5090
5091 tmp[tmp_len] = '\0';
5092
5093 @@ -360,8 +360,8 @@ static ssize_t rtl_debugfs_set_write_h2c(struct file *filp,
5094 &h2c_data[4], &h2c_data[5],
5095 &h2c_data[6], &h2c_data[7]);
5096
5097 - if (h2c_len <= 0)
5098 - return count;
5099 + if (h2c_len == 0)
5100 + return -EINVAL;
5101
5102 for (i = 0; i < h2c_len; i++)
5103 h2c_data_packed[i] = (u8)h2c_data[i];
5104 diff --git a/drivers/ntb/test/ntb_tool.c b/drivers/ntb/test/ntb_tool.c
5105 index 311d6ab8d0160..6301aa413c3b8 100644
5106 --- a/drivers/ntb/test/ntb_tool.c
5107 +++ b/drivers/ntb/test/ntb_tool.c
5108 @@ -367,14 +367,16 @@ static ssize_t tool_fn_write(struct tool_ctx *tc,
5109 u64 bits;
5110 int n;
5111
5112 + if (*offp)
5113 + return 0;
5114 +
5115 buf = kmalloc(size + 1, GFP_KERNEL);
5116 if (!buf)
5117 return -ENOMEM;
5118
5119 - ret = simple_write_to_buffer(buf, size, offp, ubuf, size);
5120 - if (ret < 0) {
5121 + if (copy_from_user(buf, ubuf, size)) {
5122 kfree(buf);
5123 - return ret;
5124 + return -EFAULT;
5125 }
5126
5127 buf[size] = 0;
5128 diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c
5129 index 4341c72446628..e9512d077b8a8 100644
5130 --- a/drivers/nvme/target/tcp.c
5131 +++ b/drivers/nvme/target/tcp.c
5132 @@ -1762,7 +1762,8 @@ static int __init nvmet_tcp_init(void)
5133 {
5134 int ret;
5135
5136 - nvmet_tcp_wq = alloc_workqueue("nvmet_tcp_wq", WQ_HIGHPRI, 0);
5137 + nvmet_tcp_wq = alloc_workqueue("nvmet_tcp_wq",
5138 + WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
5139 if (!nvmet_tcp_wq)
5140 return -ENOMEM;
5141
5142 diff --git a/drivers/opp/core.c b/drivers/opp/core.c
5143 index 088c93dc0085c..08f5d1c3d6651 100644
5144 --- a/drivers/opp/core.c
5145 +++ b/drivers/opp/core.c
5146 @@ -1881,8 +1881,8 @@ struct opp_table *dev_pm_opp_attach_genpd(struct device *dev,
5147 }
5148
5149 virt_dev = dev_pm_domain_attach_by_name(dev, *name);
5150 - if (IS_ERR(virt_dev)) {
5151 - ret = PTR_ERR(virt_dev);
5152 + if (IS_ERR_OR_NULL(virt_dev)) {
5153 + ret = PTR_ERR(virt_dev) ? : -ENODEV;
5154 dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret);
5155 goto err;
5156 }
5157 diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
5158 index c06b05ab9f787..120d64c1a27fd 100644
5159 --- a/drivers/pci/controller/dwc/pcie-tegra194.c
5160 +++ b/drivers/pci/controller/dwc/pcie-tegra194.c
5161 @@ -345,15 +345,14 @@ static irqreturn_t tegra_pcie_rp_irq_handler(struct tegra_pcie_dw *pcie)
5162 {
5163 struct dw_pcie *pci = &pcie->pci;
5164 struct pcie_port *pp = &pci->pp;
5165 - u32 val, tmp;
5166 + u32 val, status_l0, status_l1;
5167 u16 val_w;
5168
5169 - val = appl_readl(pcie, APPL_INTR_STATUS_L0);
5170 - if (val & APPL_INTR_STATUS_L0_LINK_STATE_INT) {
5171 - val = appl_readl(pcie, APPL_INTR_STATUS_L1_0_0);
5172 - if (val & APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED) {
5173 - appl_writel(pcie, val, APPL_INTR_STATUS_L1_0_0);
5174 -
5175 + status_l0 = appl_readl(pcie, APPL_INTR_STATUS_L0);
5176 + if (status_l0 & APPL_INTR_STATUS_L0_LINK_STATE_INT) {
5177 + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_0_0);
5178 + appl_writel(pcie, status_l1, APPL_INTR_STATUS_L1_0_0);
5179 + if (status_l1 & APPL_INTR_STATUS_L1_0_0_LINK_REQ_RST_NOT_CHGED) {
5180 /* SBR & Surprise Link Down WAR */
5181 val = appl_readl(pcie, APPL_CAR_RESET_OVRD);
5182 val &= ~APPL_CAR_RESET_OVRD_CYA_OVERRIDE_CORE_RST_N;
5183 @@ -369,15 +368,15 @@ static irqreturn_t tegra_pcie_rp_irq_handler(struct tegra_pcie_dw *pcie)
5184 }
5185 }
5186
5187 - if (val & APPL_INTR_STATUS_L0_INT_INT) {
5188 - val = appl_readl(pcie, APPL_INTR_STATUS_L1_8_0);
5189 - if (val & APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS) {
5190 + if (status_l0 & APPL_INTR_STATUS_L0_INT_INT) {
5191 + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_8_0);
5192 + if (status_l1 & APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS) {
5193 appl_writel(pcie,
5194 APPL_INTR_STATUS_L1_8_0_AUTO_BW_INT_STS,
5195 APPL_INTR_STATUS_L1_8_0);
5196 apply_bad_link_workaround(pp);
5197 }
5198 - if (val & APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS) {
5199 + if (status_l1 & APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS) {
5200 appl_writel(pcie,
5201 APPL_INTR_STATUS_L1_8_0_BW_MGT_INT_STS,
5202 APPL_INTR_STATUS_L1_8_0);
5203 @@ -389,25 +388,24 @@ static irqreturn_t tegra_pcie_rp_irq_handler(struct tegra_pcie_dw *pcie)
5204 }
5205 }
5206
5207 - val = appl_readl(pcie, APPL_INTR_STATUS_L0);
5208 - if (val & APPL_INTR_STATUS_L0_CDM_REG_CHK_INT) {
5209 - val = appl_readl(pcie, APPL_INTR_STATUS_L1_18);
5210 - tmp = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS);
5211 - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT) {
5212 + if (status_l0 & APPL_INTR_STATUS_L0_CDM_REG_CHK_INT) {
5213 + status_l1 = appl_readl(pcie, APPL_INTR_STATUS_L1_18);
5214 + val = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS);
5215 + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMPLT) {
5216 dev_info(pci->dev, "CDM check complete\n");
5217 - tmp |= PCIE_PL_CHK_REG_CHK_REG_COMPLETE;
5218 + val |= PCIE_PL_CHK_REG_CHK_REG_COMPLETE;
5219 }
5220 - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR) {
5221 + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_CMP_ERR) {
5222 dev_err(pci->dev, "CDM comparison mismatch\n");
5223 - tmp |= PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR;
5224 + val |= PCIE_PL_CHK_REG_CHK_REG_COMPARISON_ERROR;
5225 }
5226 - if (val & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR) {
5227 + if (status_l1 & APPL_INTR_STATUS_L1_18_CDM_REG_CHK_LOGIC_ERR) {
5228 dev_err(pci->dev, "CDM Logic error\n");
5229 - tmp |= PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR;
5230 + val |= PCIE_PL_CHK_REG_CHK_REG_LOGIC_ERROR;
5231 }
5232 - dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, tmp);
5233 - tmp = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_ERR_ADDR);
5234 - dev_err(pci->dev, "CDM Error Address Offset = 0x%08X\n", tmp);
5235 + dw_pcie_writel_dbi(pci, PCIE_PL_CHK_REG_CONTROL_STATUS, val);
5236 + val = dw_pcie_readl_dbi(pci, PCIE_PL_CHK_REG_ERR_ADDR);
5237 + dev_err(pci->dev, "CDM Error Address Offset = 0x%08X\n", val);
5238 }
5239
5240 return IRQ_HANDLED;
5241 @@ -856,7 +854,7 @@ static int tegra_pcie_dw_host_init(struct pcie_port *pp)
5242 offset = dw_pcie_find_ext_capability(pci, PCI_EXT_CAP_ID_DLF);
5243 val = dw_pcie_readl_dbi(pci, offset + PCI_DLF_CAP);
5244 val &= ~PCI_DLF_EXCHANGE_ENABLE;
5245 - dw_pcie_writel_dbi(pci, offset, val);
5246 + dw_pcie_writel_dbi(pci, offset + PCI_DLF_CAP, val);
5247
5248 tegra_pcie_prepare_host(pp);
5249
5250 diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
5251 index 2a4bc8df85639..8b98b7f3eb246 100644
5252 --- a/drivers/pci/quirks.c
5253 +++ b/drivers/pci/quirks.c
5254 @@ -4943,6 +4943,9 @@ static const struct pci_dev_acs_enabled {
5255 { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs },
5256 /* Broadcom multi-function device */
5257 { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs },
5258 + { PCI_VENDOR_ID_BROADCOM, 0x1750, pci_quirk_mf_endpoint_acs },
5259 + { PCI_VENDOR_ID_BROADCOM, 0x1751, pci_quirk_mf_endpoint_acs },
5260 + { PCI_VENDOR_ID_BROADCOM, 0x1752, pci_quirk_mf_endpoint_acs },
5261 { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs },
5262 /* Amazon Annapurna Labs */
5263 { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs },
5264 diff --git a/drivers/pinctrl/nomadik/pinctrl-nomadik.c b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
5265 index 9f00adfefba8e..5d7e368a1e7e8 100644
5266 --- a/drivers/pinctrl/nomadik/pinctrl-nomadik.c
5267 +++ b/drivers/pinctrl/nomadik/pinctrl-nomadik.c
5268 @@ -1461,8 +1461,10 @@ static int nmk_pinctrl_dt_subnode_to_map(struct pinctrl_dev *pctldev,
5269
5270 has_config = nmk_pinctrl_dt_get_config(np, &configs);
5271 np_config = of_parse_phandle(np, "ste,config", 0);
5272 - if (np_config)
5273 + if (np_config) {
5274 has_config |= nmk_pinctrl_dt_get_config(np_config, &configs);
5275 + of_node_put(np_config);
5276 + }
5277 if (has_config) {
5278 const char *gpio_name;
5279 const char *pin;
5280 diff --git a/drivers/pinctrl/qcom/pinctrl-msm8916.c b/drivers/pinctrl/qcom/pinctrl-msm8916.c
5281 index 396db12ae9048..bf68913ba8212 100644
5282 --- a/drivers/pinctrl/qcom/pinctrl-msm8916.c
5283 +++ b/drivers/pinctrl/qcom/pinctrl-msm8916.c
5284 @@ -844,8 +844,8 @@ static const struct msm_pingroup msm8916_groups[] = {
5285 PINGROUP(28, pwr_modem_enabled_a, NA, NA, NA, NA, NA, qdss_tracedata_b, NA, atest_combodac),
5286 PINGROUP(29, cci_i2c, NA, NA, NA, NA, NA, qdss_tracedata_b, NA, atest_combodac),
5287 PINGROUP(30, cci_i2c, NA, NA, NA, NA, NA, NA, NA, qdss_tracedata_b),
5288 - PINGROUP(31, cci_timer0, NA, NA, NA, NA, NA, NA, NA, NA),
5289 - PINGROUP(32, cci_timer1, NA, NA, NA, NA, NA, NA, NA, NA),
5290 + PINGROUP(31, cci_timer0, flash_strobe, NA, NA, NA, NA, NA, NA, NA),
5291 + PINGROUP(32, cci_timer1, flash_strobe, NA, NA, NA, NA, NA, NA, NA),
5292 PINGROUP(33, cci_async, NA, NA, NA, NA, NA, NA, NA, qdss_tracedata_b),
5293 PINGROUP(34, pwr_nav_enabled_a, NA, NA, NA, NA, NA, NA, NA, qdss_tracedata_b),
5294 PINGROUP(35, pwr_crypto_enabled_a, NA, NA, NA, NA, NA, NA, NA, qdss_tracedata_b),
5295 diff --git a/drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c b/drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c
5296 index 4557e18d59899..12c40f9c1a247 100644
5297 --- a/drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c
5298 +++ b/drivers/pinctrl/sunxi/pinctrl-sun50i-h6-r.c
5299 @@ -105,6 +105,7 @@ static const struct sunxi_pinctrl_desc sun50i_h6_r_pinctrl_data = {
5300 .npins = ARRAY_SIZE(sun50i_h6_r_pins),
5301 .pin_base = PL_BASE,
5302 .irq_banks = 2,
5303 + .io_bias_cfg_variant = BIAS_VOLTAGE_PIO_POW_MODE_SEL,
5304 };
5305
5306 static int sun50i_h6_r_pinctrl_probe(struct platform_device *pdev)
5307 diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
5308 index c4052eab6bfcc..8c41f8b818b27 100644
5309 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c
5310 +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c
5311 @@ -616,7 +616,7 @@ static int sunxi_pinctrl_set_io_bias_cfg(struct sunxi_pinctrl *pctl,
5312 unsigned pin,
5313 struct regulator *supply)
5314 {
5315 - unsigned short bank = pin / PINS_PER_BANK;
5316 + unsigned short bank;
5317 unsigned long flags;
5318 u32 val, reg;
5319 int uV;
5320 @@ -632,6 +632,9 @@ static int sunxi_pinctrl_set_io_bias_cfg(struct sunxi_pinctrl *pctl,
5321 if (uV == 0)
5322 return 0;
5323
5324 + pin -= pctl->desc->pin_base;
5325 + bank = pin / PINS_PER_BANK;
5326 +
5327 switch (pctl->desc->io_bias_cfg_variant) {
5328 case BIAS_VOLTAGE_GRP_CONFIG:
5329 /*
5330 @@ -649,8 +652,6 @@ static int sunxi_pinctrl_set_io_bias_cfg(struct sunxi_pinctrl *pctl,
5331 else
5332 val = 0xD; /* 3.3V */
5333
5334 - pin -= pctl->desc->pin_base;
5335 -
5336 reg = readl(pctl->membase + sunxi_grp_config_reg(pin));
5337 reg &= ~IO_BIAS_MASK;
5338 writel(reg | val, pctl->membase + sunxi_grp_config_reg(pin));
5339 diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c
5340 index 2db7113383fdc..89d9fca02fe9d 100644
5341 --- a/drivers/platform/olpc/olpc-ec.c
5342 +++ b/drivers/platform/olpc/olpc-ec.c
5343 @@ -265,7 +265,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,
5344 int i, m;
5345 unsigned char ec_cmd[EC_MAX_CMD_ARGS];
5346 unsigned int ec_cmd_int[EC_MAX_CMD_ARGS];
5347 - char cmdbuf[64];
5348 + char cmdbuf[64] = "";
5349 int ec_cmd_bytes;
5350
5351 mutex_lock(&ec_dbgfs_lock);
5352 diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
5353 index 87637eb6bcbcb..7a0a235e44658 100644
5354 --- a/drivers/regulator/of_regulator.c
5355 +++ b/drivers/regulator/of_regulator.c
5356 @@ -206,8 +206,12 @@ static int of_get_regulation_constraints(struct device *dev,
5357 }
5358
5359 suspend_np = of_get_child_by_name(np, regulator_states[i]);
5360 - if (!suspend_np || !suspend_state)
5361 + if (!suspend_np)
5362 continue;
5363 + if (!suspend_state) {
5364 + of_node_put(suspend_np);
5365 + continue;
5366 + }
5367
5368 if (!of_property_read_u32(suspend_np, "regulator-mode",
5369 &pval)) {
5370 diff --git a/drivers/remoteproc/qcom_wcnss.c b/drivers/remoteproc/qcom_wcnss.c
5371 index c72f1b3b60858..18431ac098224 100644
5372 --- a/drivers/remoteproc/qcom_wcnss.c
5373 +++ b/drivers/remoteproc/qcom_wcnss.c
5374 @@ -407,6 +407,7 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss,
5375 irq_handler_t thread_fn)
5376 {
5377 int ret;
5378 + int irq_number;
5379
5380 ret = platform_get_irq_byname(pdev, name);
5381 if (ret < 0 && optional) {
5382 @@ -417,14 +418,19 @@ static int wcnss_request_irq(struct qcom_wcnss *wcnss,
5383 return ret;
5384 }
5385
5386 + irq_number = ret;
5387 +
5388 ret = devm_request_threaded_irq(&pdev->dev, ret,
5389 NULL, thread_fn,
5390 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
5391 "wcnss", wcnss);
5392 - if (ret)
5393 + if (ret) {
5394 dev_err(&pdev->dev, "request %s IRQ failed\n", name);
5395 + return ret;
5396 + }
5397
5398 - return ret;
5399 + /* Return the IRQ number if the IRQ was successfully acquired */
5400 + return irq_number;
5401 }
5402
5403 static int wcnss_alloc_memory_region(struct qcom_wcnss *wcnss)
5404 diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
5405 index a4db9f6100d2f..0b1e853d8c91a 100644
5406 --- a/drivers/rpmsg/qcom_smd.c
5407 +++ b/drivers/rpmsg/qcom_smd.c
5408 @@ -1364,6 +1364,7 @@ static int qcom_smd_parse_edge(struct device *dev,
5409 }
5410
5411 edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
5412 + of_node_put(syscon_np);
5413 if (IS_ERR(edge->ipc_regmap)) {
5414 ret = PTR_ERR(edge->ipc_regmap);
5415 goto put_node;
5416 diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c
5417 index 08f812475f5ed..c9d1725105096 100644
5418 --- a/drivers/s390/char/zcore.c
5419 +++ b/drivers/s390/char/zcore.c
5420 @@ -53,6 +53,7 @@ static struct dentry *zcore_reipl_file;
5421 static struct dentry *zcore_hsa_file;
5422 static struct ipl_parameter_block *zcore_ipl_block;
5423
5424 +static DEFINE_MUTEX(hsa_buf_mutex);
5425 static char hsa_buf[PAGE_SIZE] __aligned(PAGE_SIZE);
5426
5427 /*
5428 @@ -69,19 +70,24 @@ int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count)
5429 if (!hsa_available)
5430 return -ENODATA;
5431
5432 + mutex_lock(&hsa_buf_mutex);
5433 while (count) {
5434 if (sclp_sdias_copy(hsa_buf, src / PAGE_SIZE + 2, 1)) {
5435 TRACE("sclp_sdias_copy() failed\n");
5436 + mutex_unlock(&hsa_buf_mutex);
5437 return -EIO;
5438 }
5439 offset = src % PAGE_SIZE;
5440 bytes = min(PAGE_SIZE - offset, count);
5441 - if (copy_to_user(dest, hsa_buf + offset, bytes))
5442 + if (copy_to_user(dest, hsa_buf + offset, bytes)) {
5443 + mutex_unlock(&hsa_buf_mutex);
5444 return -EFAULT;
5445 + }
5446 src += bytes;
5447 dest += bytes;
5448 count -= bytes;
5449 }
5450 + mutex_unlock(&hsa_buf_mutex);
5451 return 0;
5452 }
5453
5454 @@ -99,9 +105,11 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)
5455 if (!hsa_available)
5456 return -ENODATA;
5457
5458 + mutex_lock(&hsa_buf_mutex);
5459 while (count) {
5460 if (sclp_sdias_copy(hsa_buf, src / PAGE_SIZE + 2, 1)) {
5461 TRACE("sclp_sdias_copy() failed\n");
5462 + mutex_unlock(&hsa_buf_mutex);
5463 return -EIO;
5464 }
5465 offset = src % PAGE_SIZE;
5466 @@ -111,6 +119,7 @@ int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)
5467 dest += bytes;
5468 count -= bytes;
5469 }
5470 + mutex_unlock(&hsa_buf_mutex);
5471 return 0;
5472 }
5473
5474 diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
5475 index fd590d1cffc1f..d42e5a3074375 100644
5476 --- a/drivers/s390/cio/vfio_ccw_drv.c
5477 +++ b/drivers/s390/cio/vfio_ccw_drv.c
5478 @@ -247,19 +247,11 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process)
5479 if (work_pending(&sch->todo_work))
5480 goto out_unlock;
5481
5482 - if (cio_update_schib(sch)) {
5483 - vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
5484 - rc = 0;
5485 - goto out_unlock;
5486 - }
5487 -
5488 - private = dev_get_drvdata(&sch->dev);
5489 - if (private->state == VFIO_CCW_STATE_NOT_OPER) {
5490 - private->state = private->mdev ? VFIO_CCW_STATE_IDLE :
5491 - VFIO_CCW_STATE_STANDBY;
5492 - }
5493 rc = 0;
5494
5495 + if (cio_update_schib(sch))
5496 + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_NOT_OPER);
5497 +
5498 out_unlock:
5499 spin_unlock_irqrestore(sch->lock, flags);
5500
5501 diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
5502 index d4c2c44b863dd..7285e6ca948ff 100644
5503 --- a/drivers/s390/scsi/zfcp_fc.c
5504 +++ b/drivers/s390/scsi/zfcp_fc.c
5505 @@ -145,27 +145,33 @@ void zfcp_fc_enqueue_event(struct zfcp_adapter *adapter,
5506
5507 static int zfcp_fc_wka_port_get(struct zfcp_fc_wka_port *wka_port)
5508 {
5509 + int ret = -EIO;
5510 +
5511 if (mutex_lock_interruptible(&wka_port->mutex))
5512 return -ERESTARTSYS;
5513
5514 if (wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE ||
5515 wka_port->status == ZFCP_FC_WKA_PORT_CLOSING) {
5516 wka_port->status = ZFCP_FC_WKA_PORT_OPENING;
5517 - if (zfcp_fsf_open_wka_port(wka_port))
5518 + if (zfcp_fsf_open_wka_port(wka_port)) {
5519 + /* could not even send request, nothing to wait for */
5520 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
5521 + goto out;
5522 + }
5523 }
5524
5525 - mutex_unlock(&wka_port->mutex);
5526 -
5527 - wait_event(wka_port->completion_wq,
5528 + wait_event(wka_port->opened,
5529 wka_port->status == ZFCP_FC_WKA_PORT_ONLINE ||
5530 wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE);
5531
5532 if (wka_port->status == ZFCP_FC_WKA_PORT_ONLINE) {
5533 atomic_inc(&wka_port->refcount);
5534 - return 0;
5535 + ret = 0;
5536 + goto out;
5537 }
5538 - return -EIO;
5539 +out:
5540 + mutex_unlock(&wka_port->mutex);
5541 + return ret;
5542 }
5543
5544 static void zfcp_fc_wka_port_offline(struct work_struct *work)
5545 @@ -181,9 +187,12 @@ static void zfcp_fc_wka_port_offline(struct work_struct *work)
5546
5547 wka_port->status = ZFCP_FC_WKA_PORT_CLOSING;
5548 if (zfcp_fsf_close_wka_port(wka_port)) {
5549 + /* could not even send request, nothing to wait for */
5550 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
5551 - wake_up(&wka_port->completion_wq);
5552 + goto out;
5553 }
5554 + wait_event(wka_port->closed,
5555 + wka_port->status == ZFCP_FC_WKA_PORT_OFFLINE);
5556 out:
5557 mutex_unlock(&wka_port->mutex);
5558 }
5559 @@ -193,13 +202,15 @@ static void zfcp_fc_wka_port_put(struct zfcp_fc_wka_port *wka_port)
5560 if (atomic_dec_return(&wka_port->refcount) != 0)
5561 return;
5562 /* wait 10 milliseconds, other reqs might pop in */
5563 - schedule_delayed_work(&wka_port->work, HZ / 100);
5564 + queue_delayed_work(wka_port->adapter->work_queue, &wka_port->work,
5565 + msecs_to_jiffies(10));
5566 }
5567
5568 static void zfcp_fc_wka_port_init(struct zfcp_fc_wka_port *wka_port, u32 d_id,
5569 struct zfcp_adapter *adapter)
5570 {
5571 - init_waitqueue_head(&wka_port->completion_wq);
5572 + init_waitqueue_head(&wka_port->opened);
5573 + init_waitqueue_head(&wka_port->closed);
5574
5575 wka_port->adapter = adapter;
5576 wka_port->d_id = d_id;
5577 diff --git a/drivers/s390/scsi/zfcp_fc.h b/drivers/s390/scsi/zfcp_fc.h
5578 index 6902ae1f8e4f0..25bebfaa8cbcd 100644
5579 --- a/drivers/s390/scsi/zfcp_fc.h
5580 +++ b/drivers/s390/scsi/zfcp_fc.h
5581 @@ -185,7 +185,8 @@ enum zfcp_fc_wka_status {
5582 /**
5583 * struct zfcp_fc_wka_port - representation of well-known-address (WKA) FC port
5584 * @adapter: Pointer to adapter structure this WKA port belongs to
5585 - * @completion_wq: Wait for completion of open/close command
5586 + * @opened: Wait for completion of open command
5587 + * @closed: Wait for completion of close command
5588 * @status: Current status of WKA port
5589 * @refcount: Reference count to keep port open as long as it is in use
5590 * @d_id: FC destination id or well-known-address
5591 @@ -195,7 +196,8 @@ enum zfcp_fc_wka_status {
5592 */
5593 struct zfcp_fc_wka_port {
5594 struct zfcp_adapter *adapter;
5595 - wait_queue_head_t completion_wq;
5596 + wait_queue_head_t opened;
5597 + wait_queue_head_t closed;
5598 enum zfcp_fc_wka_status status;
5599 atomic_t refcount;
5600 u32 d_id;
5601 diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
5602 index 5c652deb6fed4..67dac3931634e 100644
5603 --- a/drivers/s390/scsi/zfcp_fsf.c
5604 +++ b/drivers/s390/scsi/zfcp_fsf.c
5605 @@ -1625,7 +1625,7 @@ static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
5606 wka_port->status = ZFCP_FC_WKA_PORT_ONLINE;
5607 }
5608 out:
5609 - wake_up(&wka_port->completion_wq);
5610 + wake_up(&wka_port->opened);
5611 }
5612
5613 /**
5614 @@ -1684,7 +1684,7 @@ static void zfcp_fsf_close_wka_port_handler(struct zfcp_fsf_req *req)
5615 }
5616
5617 wka_port->status = ZFCP_FC_WKA_PORT_OFFLINE;
5618 - wake_up(&wka_port->completion_wq);
5619 + wake_up(&wka_port->closed);
5620 }
5621
5622 /**
5623 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
5624 index e15bb3dfe9956..69551132f304c 100644
5625 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
5626 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
5627 @@ -2402,8 +2402,8 @@ lpfc_debugfs_multixripools_write(struct file *file, const char __user *buf,
5628 struct lpfc_sli4_hdw_queue *qp;
5629 struct lpfc_multixri_pool *multixri_pool;
5630
5631 - if (nbytes > 64)
5632 - nbytes = 64;
5633 + if (nbytes > sizeof(mybuf) - 1)
5634 + nbytes = sizeof(mybuf) - 1;
5635
5636 /* Protect copy from user */
5637 if (!access_ok(buf, nbytes))
5638 @@ -2487,8 +2487,8 @@ lpfc_debugfs_nvmestat_write(struct file *file, const char __user *buf,
5639 if (!phba->targetport)
5640 return -ENXIO;
5641
5642 - if (nbytes > 64)
5643 - nbytes = 64;
5644 + if (nbytes > sizeof(mybuf) - 1)
5645 + nbytes = sizeof(mybuf) - 1;
5646
5647 memset(mybuf, 0, sizeof(mybuf));
5648
5649 @@ -2629,8 +2629,8 @@ lpfc_debugfs_nvmektime_write(struct file *file, const char __user *buf,
5650 char mybuf[64];
5651 char *pbuf;
5652
5653 - if (nbytes > 64)
5654 - nbytes = 64;
5655 + if (nbytes > sizeof(mybuf) - 1)
5656 + nbytes = sizeof(mybuf) - 1;
5657
5658 memset(mybuf, 0, sizeof(mybuf));
5659
5660 @@ -2757,8 +2757,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
5661 char mybuf[64];
5662 char *pbuf;
5663
5664 - if (nbytes > 63)
5665 - nbytes = 63;
5666 + if (nbytes > sizeof(mybuf) - 1)
5667 + nbytes = sizeof(mybuf) - 1;
5668
5669 memset(mybuf, 0, sizeof(mybuf));
5670
5671 @@ -2863,8 +2863,8 @@ lpfc_debugfs_cpucheck_write(struct file *file, const char __user *buf,
5672 char *pbuf;
5673 int i, j;
5674
5675 - if (nbytes > 64)
5676 - nbytes = 64;
5677 + if (nbytes > sizeof(mybuf) - 1)
5678 + nbytes = sizeof(mybuf) - 1;
5679
5680 memset(mybuf, 0, sizeof(mybuf));
5681
5682 diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
5683 index caf28c5281aa5..a8272d4290754 100644
5684 --- a/drivers/scsi/qla2xxx/qla_def.h
5685 +++ b/drivers/scsi/qla2xxx/qla_def.h
5686 @@ -3899,8 +3899,8 @@ struct qla_hw_data {
5687 #define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
5688 #define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
5689 #define IS_CT6_SUPPORTED(ha) ((ha)->device_type & DT_CT6_SUPPORTED)
5690 -#define IS_MQUE_CAPABLE(ha) ((ha)->mqenable || IS_QLA83XX(ha) || \
5691 - IS_QLA27XX(ha) || IS_QLA28XX(ha))
5692 +#define IS_MQUE_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha) || \
5693 + IS_QLA28XX(ha))
5694 #define IS_BIDI_CAPABLE(ha) \
5695 (IS_QLA25XX(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha))
5696 /* Bit 21 of fw_attributes decides the MCTP capabilities */
5697 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
5698 index 1a98e37c9be22..6d78818d52696 100644
5699 --- a/drivers/scsi/qla2xxx/qla_gbl.h
5700 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
5701 @@ -397,7 +397,8 @@ extern int
5702 qla2x00_get_resource_cnts(scsi_qla_host_t *);
5703
5704 extern int
5705 -qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map);
5706 +qla2x00_get_fcal_position_map(scsi_qla_host_t *ha, char *pos_map,
5707 + u8 *num_entries);
5708
5709 extern int
5710 qla2x00_get_link_status(scsi_qla_host_t *, uint16_t, struct link_statistics *,
5711 diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
5712 index a6e24cef89a0b..85f65a0ac1508 100644
5713 --- a/drivers/scsi/qla2xxx/qla_init.c
5714 +++ b/drivers/scsi/qla2xxx/qla_init.c
5715 @@ -5068,6 +5068,22 @@ qla2x00_configure_loop(scsi_qla_host_t *vha)
5716 return (rval);
5717 }
5718
5719 +static void
5720 +qla_reinitialize_link(scsi_qla_host_t *vha)
5721 +{
5722 + int rval;
5723 +
5724 + atomic_set(&vha->loop_state, LOOP_DOWN);
5725 + atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
5726 + rval = qla2x00_full_login_lip(vha);
5727 + if (rval == QLA_SUCCESS) {
5728 + ql_dbg(ql_dbg_disc, vha, 0xd050, "Link reinitialized\n");
5729 + } else {
5730 + ql_dbg(ql_dbg_disc, vha, 0xd051,
5731 + "Link reinitialization failed (%d)\n", rval);
5732 + }
5733 +}
5734 +
5735 /*
5736 * qla2x00_configure_local_loop
5737 * Updates Fibre Channel Device Database with local loop devices.
5738 @@ -5132,6 +5148,19 @@ skip_login:
5739 spin_unlock_irqrestore(&vha->work_lock, flags);
5740
5741 if (vha->scan.scan_retry < MAX_SCAN_RETRIES) {
5742 + u8 loop_map_entries = 0;
5743 + int rc;
5744 +
5745 + rc = qla2x00_get_fcal_position_map(vha, NULL,
5746 + &loop_map_entries);
5747 + if (rc == QLA_SUCCESS && loop_map_entries > 1) {
5748 + /*
5749 + * There are devices that are still not logged
5750 + * in. Reinitialize to give them a chance.
5751 + */
5752 + qla_reinitialize_link(vha);
5753 + return QLA_FUNCTION_FAILED;
5754 + }
5755 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
5756 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
5757 }
5758 @@ -5388,8 +5417,6 @@ qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport)
5759 if (atomic_read(&fcport->state) == FCS_ONLINE)
5760 return;
5761
5762 - qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5763 -
5764 rport_ids.node_name = wwn_to_u64(fcport->node_name);
5765 rport_ids.port_name = wwn_to_u64(fcport->port_name);
5766 rport_ids.port_id = fcport->d_id.b.domain << 16 |
5767 @@ -5485,7 +5512,6 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
5768 qla2x00_reg_remote_port(vha, fcport);
5769 break;
5770 case MODE_TARGET:
5771 - qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5772 if (!vha->vha_tgt.qla_tgt->tgt_stop &&
5773 !vha->vha_tgt.qla_tgt->tgt_stopped)
5774 qlt_fc_port_added(vha, fcport);
5775 @@ -5500,6 +5526,8 @@ qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
5776 break;
5777 }
5778
5779 + qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5780 +
5781 if (IS_IIDMA_CAPABLE(vha->hw) && vha->hw->flags.gpsc_supported) {
5782 if (fcport->id_changed) {
5783 fcport->id_changed = 0;
5784 diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
5785 index d7cf7f9570874..0892eb6bbfa33 100644
5786 --- a/drivers/scsi/qla2xxx/qla_isr.c
5787 +++ b/drivers/scsi/qla2xxx/qla_isr.c
5788 @@ -3568,16 +3568,12 @@ msix_register_fail:
5789 }
5790
5791 /* Enable MSI-X vector for response queue update for queue 0 */
5792 - if (IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) {
5793 - if (ha->msixbase && ha->mqiobase &&
5794 - (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 ||
5795 - ql2xmqsupport))
5796 - ha->mqenable = 1;
5797 - } else
5798 - if (ha->mqiobase &&
5799 - (ha->max_rsp_queues > 1 || ha->max_req_queues > 1 ||
5800 - ql2xmqsupport))
5801 - ha->mqenable = 1;
5802 + if (IS_MQUE_CAPABLE(ha) &&
5803 + (ha->msixbase && ha->mqiobase && ha->max_qpairs))
5804 + ha->mqenable = 1;
5805 + else
5806 + ha->mqenable = 0;
5807 +
5808 ql_dbg(ql_dbg_multiq, vha, 0xc005,
5809 "mqiobase=%p, max_rsp_queues=%d, max_req_queues=%d.\n",
5810 ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues);
5811 diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
5812 index 29f2730fbf66a..77abecf88aa29 100644
5813 --- a/drivers/scsi/qla2xxx/qla_mbx.c
5814 +++ b/drivers/scsi/qla2xxx/qla_mbx.c
5815 @@ -271,6 +271,12 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
5816 atomic_inc(&ha->num_pend_mbx_stage3);
5817 if (!wait_for_completion_timeout(&ha->mbx_intr_comp,
5818 mcp->tov * HZ)) {
5819 + ql_dbg(ql_dbg_mbx, vha, 0x117a,
5820 + "cmd=%x Timeout.\n", command);
5821 + spin_lock_irqsave(&ha->hardware_lock, flags);
5822 + clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
5823 + spin_unlock_irqrestore(&ha->hardware_lock, flags);
5824 +
5825 if (chip_reset != ha->chip_reset) {
5826 spin_lock_irqsave(&ha->hardware_lock, flags);
5827 ha->flags.mbox_busy = 0;
5828 @@ -281,12 +287,6 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
5829 rval = QLA_ABORTED;
5830 goto premature_exit;
5831 }
5832 - ql_dbg(ql_dbg_mbx, vha, 0x117a,
5833 - "cmd=%x Timeout.\n", command);
5834 - spin_lock_irqsave(&ha->hardware_lock, flags);
5835 - clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
5836 - spin_unlock_irqrestore(&ha->hardware_lock, flags);
5837 -
5838 } else if (ha->flags.purge_mbox ||
5839 chip_reset != ha->chip_reset) {
5840 spin_lock_irqsave(&ha->hardware_lock, flags);
5841 @@ -2928,7 +2928,8 @@ qla2x00_get_resource_cnts(scsi_qla_host_t *vha)
5842 * Kernel context.
5843 */
5844 int
5845 -qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
5846 +qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map,
5847 + u8 *num_entries)
5848 {
5849 int rval;
5850 mbx_cmd_t mc;
5851 @@ -2968,6 +2969,8 @@ qla2x00_get_fcal_position_map(scsi_qla_host_t *vha, char *pos_map)
5852
5853 if (pos_map)
5854 memcpy(pos_map, pmap, FCAL_MAP_SIZE);
5855 + if (num_entries)
5856 + *num_entries = pmap[0];
5857 }
5858 dma_pool_free(ha->s_dma_pool, pmap, pmap_dma);
5859
5860 diff --git a/drivers/scsi/qla2xxx/qla_nvme.c b/drivers/scsi/qla2xxx/qla_nvme.c
5861 index a15af048cd820..f0de7089e9aec 100644
5862 --- a/drivers/scsi/qla2xxx/qla_nvme.c
5863 +++ b/drivers/scsi/qla2xxx/qla_nvme.c
5864 @@ -36,11 +36,6 @@ int qla_nvme_register_remote(struct scsi_qla_host *vha, struct fc_port *fcport)
5865 (fcport->nvme_flag & NVME_FLAG_REGISTERED))
5866 return 0;
5867
5868 - if (atomic_read(&fcport->state) == FCS_ONLINE)
5869 - return 0;
5870 -
5871 - qla2x00_set_fcport_state(fcport, FCS_ONLINE);
5872 -
5873 fcport->nvme_flag &= ~NVME_FLAG_RESETTING;
5874
5875 memset(&req, 0, sizeof(struct nvme_fc_port_info));
5876 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
5877 index 9c6bf13daaee3..cc836610e21eb 100644
5878 --- a/drivers/scsi/sg.c
5879 +++ b/drivers/scsi/sg.c
5880 @@ -190,7 +190,7 @@ static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
5881 static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
5882 static Sg_fd *sg_add_sfp(Sg_device * sdp);
5883 static void sg_remove_sfp(struct kref *);
5884 -static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id);
5885 +static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id, bool *busy);
5886 static Sg_request *sg_add_request(Sg_fd * sfp);
5887 static int sg_remove_request(Sg_fd * sfp, Sg_request * srp);
5888 static Sg_device *sg_get_dev(int dev);
5889 @@ -412,6 +412,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
5890 Sg_fd *sfp;
5891 Sg_request *srp;
5892 int req_pack_id = -1;
5893 + bool busy;
5894 sg_io_hdr_t *hp;
5895 struct sg_header *old_hdr = NULL;
5896 int retval = 0;
5897 @@ -459,25 +460,19 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
5898 } else
5899 req_pack_id = old_hdr->pack_id;
5900 }
5901 - srp = sg_get_rq_mark(sfp, req_pack_id);
5902 + srp = sg_get_rq_mark(sfp, req_pack_id, &busy);
5903 if (!srp) { /* now wait on packet to arrive */
5904 - if (atomic_read(&sdp->detaching)) {
5905 - retval = -ENODEV;
5906 - goto free_old_hdr;
5907 - }
5908 if (filp->f_flags & O_NONBLOCK) {
5909 retval = -EAGAIN;
5910 goto free_old_hdr;
5911 }
5912 retval = wait_event_interruptible(sfp->read_wait,
5913 - (atomic_read(&sdp->detaching) ||
5914 - (srp = sg_get_rq_mark(sfp, req_pack_id))));
5915 - if (atomic_read(&sdp->detaching)) {
5916 - retval = -ENODEV;
5917 - goto free_old_hdr;
5918 - }
5919 - if (retval) {
5920 - /* -ERESTARTSYS as signal hit process */
5921 + ((srp = sg_get_rq_mark(sfp, req_pack_id, &busy)) ||
5922 + (!busy && atomic_read(&sdp->detaching))));
5923 + if (!srp) {
5924 + /* signal or detaching */
5925 + if (!retval)
5926 + retval = -ENODEV;
5927 goto free_old_hdr;
5928 }
5929 }
5930 @@ -928,9 +923,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
5931 if (result < 0)
5932 return result;
5933 result = wait_event_interruptible(sfp->read_wait,
5934 - (srp_done(sfp, srp) || atomic_read(&sdp->detaching)));
5935 - if (atomic_read(&sdp->detaching))
5936 - return -ENODEV;
5937 + srp_done(sfp, srp));
5938 write_lock_irq(&sfp->rq_list_lock);
5939 if (srp->done) {
5940 srp->done = 2;
5941 @@ -2074,19 +2067,28 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
5942 }
5943
5944 static Sg_request *
5945 -sg_get_rq_mark(Sg_fd * sfp, int pack_id)
5946 +sg_get_rq_mark(Sg_fd * sfp, int pack_id, bool *busy)
5947 {
5948 Sg_request *resp;
5949 unsigned long iflags;
5950
5951 + *busy = false;
5952 write_lock_irqsave(&sfp->rq_list_lock, iflags);
5953 list_for_each_entry(resp, &sfp->rq_list, entry) {
5954 - /* look for requests that are ready + not SG_IO owned */
5955 - if ((1 == resp->done) && (!resp->sg_io_owned) &&
5956 + /* look for requests that are not SG_IO owned */
5957 + if ((!resp->sg_io_owned) &&
5958 ((-1 == pack_id) || (resp->header.pack_id == pack_id))) {
5959 - resp->done = 2; /* guard against other readers */
5960 - write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
5961 - return resp;
5962 + switch (resp->done) {
5963 + case 0: /* request active */
5964 + *busy = true;
5965 + break;
5966 + case 1: /* request done; response ready to return */
5967 + resp->done = 2; /* guard against other readers */
5968 + write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
5969 + return resp;
5970 + case 2: /* response already being returned */
5971 + break;
5972 + }
5973 }
5974 }
5975 write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
5976 @@ -2140,6 +2142,15 @@ sg_remove_request(Sg_fd * sfp, Sg_request * srp)
5977 res = 1;
5978 }
5979 write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
5980 +
5981 + /*
5982 + * If the device is detaching, wakeup any readers in case we just
5983 + * removed the last response, which would leave nothing for them to
5984 + * return other than -ENODEV.
5985 + */
5986 + if (unlikely(atomic_read(&sfp->parentdp->detaching)))
5987 + wake_up_interruptible_all(&sfp->read_wait);
5988 +
5989 return res;
5990 }
5991
5992 diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
5993 index 80ff00025c03d..540d6eb2cc489 100644
5994 --- a/drivers/scsi/smartpqi/smartpqi_init.c
5995 +++ b/drivers/scsi/smartpqi/smartpqi_init.c
5996 @@ -5018,10 +5018,10 @@ static int pqi_raid_submit_scsi_cmd_with_io_request(
5997 }
5998
5999 switch (scmd->sc_data_direction) {
6000 - case DMA_TO_DEVICE:
6001 + case DMA_FROM_DEVICE:
6002 request->data_direction = SOP_READ_FLAG;
6003 break;
6004 - case DMA_FROM_DEVICE:
6005 + case DMA_TO_DEVICE:
6006 request->data_direction = SOP_WRITE_FLAG;
6007 break;
6008 case DMA_NONE:
6009 diff --git a/drivers/soc/amlogic/meson-mx-socinfo.c b/drivers/soc/amlogic/meson-mx-socinfo.c
6010 index 78f0f1aeca578..92125dd65f338 100644
6011 --- a/drivers/soc/amlogic/meson-mx-socinfo.c
6012 +++ b/drivers/soc/amlogic/meson-mx-socinfo.c
6013 @@ -126,6 +126,7 @@ static int __init meson_mx_socinfo_init(void)
6014 np = of_find_matching_node(NULL, meson_mx_socinfo_analog_top_ids);
6015 if (np) {
6016 analog_top_regmap = syscon_node_to_regmap(np);
6017 + of_node_put(np);
6018 if (IS_ERR(analog_top_regmap))
6019 return PTR_ERR(analog_top_regmap);
6020
6021 diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
6022 index 34810f9bb2ee7..2b7fb7a8805cd 100644
6023 --- a/drivers/soc/fsl/guts.c
6024 +++ b/drivers/soc/fsl/guts.c
6025 @@ -142,7 +142,7 @@ static int fsl_guts_probe(struct platform_device *pdev)
6026 struct device *dev = &pdev->dev;
6027 struct resource *res;
6028 const struct fsl_soc_die_attr *soc_die;
6029 - const char *machine;
6030 + const char *machine = NULL;
6031 u32 svr;
6032
6033 /* Initialize guts */
6034 diff --git a/drivers/soc/qcom/qcom_aoss.c b/drivers/soc/qcom/qcom_aoss.c
6035 index f16d6ec780644..bca98df55bc63 100644
6036 --- a/drivers/soc/qcom/qcom_aoss.c
6037 +++ b/drivers/soc/qcom/qcom_aoss.c
6038 @@ -489,8 +489,10 @@ static int qmp_cooling_devices_register(struct qmp *qmp)
6039 continue;
6040 ret = qmp_cooling_device_add(qmp, &qmp->cooling_devs[count++],
6041 child);
6042 - if (ret)
6043 + if (ret) {
6044 + of_node_put(child);
6045 goto unroll;
6046 + }
6047 }
6048
6049 if (!count)
6050 diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
6051 index 4a465f55039f4..2fe5a51918c8d 100644
6052 --- a/drivers/soundwire/bus_type.c
6053 +++ b/drivers/soundwire/bus_type.c
6054 @@ -155,12 +155,8 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner)
6055
6056 drv->driver.owner = owner;
6057 drv->driver.probe = sdw_drv_probe;
6058 -
6059 - if (drv->remove)
6060 - drv->driver.remove = sdw_drv_remove;
6061 -
6062 - if (drv->shutdown)
6063 - drv->driver.shutdown = sdw_drv_shutdown;
6064 + drv->driver.remove = sdw_drv_remove;
6065 + drv->driver.shutdown = sdw_drv_shutdown;
6066
6067 return driver_register(&drv->driver);
6068 }
6069 diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
6070 index 0524741d73b90..8ae2ac40b4b2e 100644
6071 --- a/drivers/spi/spi-rspi.c
6072 +++ b/drivers/spi/spi-rspi.c
6073 @@ -595,6 +595,10 @@ static int rspi_dma_transfer(struct rspi_data *rspi, struct sg_table *tx,
6074 rspi->dma_callbacked, HZ);
6075 if (ret > 0 && rspi->dma_callbacked) {
6076 ret = 0;
6077 + if (tx)
6078 + dmaengine_synchronize(rspi->ctlr->dma_tx);
6079 + if (rx)
6080 + dmaengine_synchronize(rspi->ctlr->dma_rx);
6081 } else {
6082 if (!ret) {
6083 dev_err(&rspi->ctlr->dev, "DMA timeout\n");
6084 diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c
6085 index 785e7c4451233..1e10af6e10a90 100644
6086 --- a/drivers/spi/spi-synquacer.c
6087 +++ b/drivers/spi/spi-synquacer.c
6088 @@ -784,6 +784,7 @@ static int __maybe_unused synquacer_spi_resume(struct device *dev)
6089
6090 ret = synquacer_spi_enable(master);
6091 if (ret) {
6092 + clk_disable_unprepare(sspi->clk);
6093 dev_err(dev, "failed to enable spi (%d)\n", ret);
6094 return ret;
6095 }
6096 diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h
6097 index ec33fb9122e96..57badc1e91e30 100644
6098 --- a/drivers/staging/rtl8192u/r8192U.h
6099 +++ b/drivers/staging/rtl8192u/r8192U.h
6100 @@ -1013,7 +1013,7 @@ typedef struct r8192_priv {
6101 bool bis_any_nonbepkts;
6102 bool bcurrent_turbo_EDCA;
6103 bool bis_cur_rdlstate;
6104 - struct timer_list fsync_timer;
6105 + struct delayed_work fsync_work;
6106 bool bfsync_processing; /* 500ms Fsync timer is active or not */
6107 u32 rate_record;
6108 u32 rateCountDiffRecord;
6109 diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
6110 index c23e43b095d9b..30b272da36f5e 100644
6111 --- a/drivers/staging/rtl8192u/r8192U_dm.c
6112 +++ b/drivers/staging/rtl8192u/r8192U_dm.c
6113 @@ -2585,19 +2585,20 @@ static void dm_init_fsync(struct net_device *dev)
6114 priv->ieee80211->fsync_seconddiff_ratethreshold = 200;
6115 priv->ieee80211->fsync_state = Default_Fsync;
6116 priv->framesyncMonitor = 1; /* current default 0xc38 monitor on */
6117 - timer_setup(&priv->fsync_timer, dm_fsync_timer_callback, 0);
6118 + INIT_DELAYED_WORK(&priv->fsync_work, dm_fsync_work_callback);
6119 }
6120
6121 static void dm_deInit_fsync(struct net_device *dev)
6122 {
6123 struct r8192_priv *priv = ieee80211_priv(dev);
6124
6125 - del_timer_sync(&priv->fsync_timer);
6126 + cancel_delayed_work_sync(&priv->fsync_work);
6127 }
6128
6129 -void dm_fsync_timer_callback(struct timer_list *t)
6130 +void dm_fsync_work_callback(struct work_struct *work)
6131 {
6132 - struct r8192_priv *priv = from_timer(priv, t, fsync_timer);
6133 + struct r8192_priv *priv =
6134 + container_of(work, struct r8192_priv, fsync_work.work);
6135 struct net_device *dev = priv->ieee80211->dev;
6136 u32 rate_index, rate_count = 0, rate_count_diff = 0;
6137 bool bSwitchFromCountDiff = false;
6138 @@ -2664,17 +2665,16 @@ void dm_fsync_timer_callback(struct timer_list *t)
6139 }
6140 }
6141 if (bDoubleTimeInterval) {
6142 - if (timer_pending(&priv->fsync_timer))
6143 - del_timer_sync(&priv->fsync_timer);
6144 - priv->fsync_timer.expires = jiffies +
6145 - msecs_to_jiffies(priv->ieee80211->fsync_time_interval*priv->ieee80211->fsync_multiple_timeinterval);
6146 - add_timer(&priv->fsync_timer);
6147 + cancel_delayed_work_sync(&priv->fsync_work);
6148 + schedule_delayed_work(&priv->fsync_work,
6149 + msecs_to_jiffies(priv
6150 + ->ieee80211->fsync_time_interval *
6151 + priv->ieee80211->fsync_multiple_timeinterval));
6152 } else {
6153 - if (timer_pending(&priv->fsync_timer))
6154 - del_timer_sync(&priv->fsync_timer);
6155 - priv->fsync_timer.expires = jiffies +
6156 - msecs_to_jiffies(priv->ieee80211->fsync_time_interval);
6157 - add_timer(&priv->fsync_timer);
6158 + cancel_delayed_work_sync(&priv->fsync_work);
6159 + schedule_delayed_work(&priv->fsync_work,
6160 + msecs_to_jiffies(priv
6161 + ->ieee80211->fsync_time_interval));
6162 }
6163 } else {
6164 /* Let Register return to default value; */
6165 @@ -2702,7 +2702,7 @@ static void dm_EndSWFsync(struct net_device *dev)
6166 struct r8192_priv *priv = ieee80211_priv(dev);
6167
6168 RT_TRACE(COMP_HALDM, "%s\n", __func__);
6169 - del_timer_sync(&(priv->fsync_timer));
6170 + cancel_delayed_work_sync(&priv->fsync_work);
6171
6172 /* Let Register return to default value; */
6173 if (priv->bswitch_fsync) {
6174 @@ -2744,11 +2744,9 @@ static void dm_StartSWFsync(struct net_device *dev)
6175 if (priv->ieee80211->fsync_rate_bitmap & rateBitmap)
6176 priv->rate_record += priv->stats.received_rate_histogram[1][rateIndex];
6177 }
6178 - if (timer_pending(&priv->fsync_timer))
6179 - del_timer_sync(&priv->fsync_timer);
6180 - priv->fsync_timer.expires = jiffies +
6181 - msecs_to_jiffies(priv->ieee80211->fsync_time_interval);
6182 - add_timer(&priv->fsync_timer);
6183 + cancel_delayed_work_sync(&priv->fsync_work);
6184 + schedule_delayed_work(&priv->fsync_work,
6185 + msecs_to_jiffies(priv->ieee80211->fsync_time_interval));
6186
6187 write_nic_dword(dev, rOFDM0_RxDetector2, 0x465c12cd);
6188
6189 diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h
6190 index 0b2a1c688597c..2159018b4e38f 100644
6191 --- a/drivers/staging/rtl8192u/r8192U_dm.h
6192 +++ b/drivers/staging/rtl8192u/r8192U_dm.h
6193 @@ -166,7 +166,7 @@ void dm_force_tx_fw_info(struct net_device *dev,
6194 void dm_init_edca_turbo(struct net_device *dev);
6195 void dm_rf_operation_test_callback(unsigned long data);
6196 void dm_rf_pathcheck_workitemcallback(struct work_struct *work);
6197 -void dm_fsync_timer_callback(struct timer_list *t);
6198 +void dm_fsync_work_callback(struct work_struct *work);
6199 void dm_cck_txpower_adjust(struct net_device *dev, bool binch14);
6200 void dm_shadow_init(struct net_device *dev);
6201 void dm_initialize_txpower_tracking(struct net_device *dev);
6202 diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c
6203 index a7ccd4d2bd106..2db144d2d26f3 100644
6204 --- a/drivers/tee/tee_core.c
6205 +++ b/drivers/tee/tee_core.c
6206 @@ -182,6 +182,9 @@ tee_ioctl_shm_register(struct tee_context *ctx,
6207 if (data.flags)
6208 return -EINVAL;
6209
6210 + if (!access_ok((void __user *)(unsigned long)data.addr, data.length))
6211 + return -EFAULT;
6212 +
6213 shm = tee_shm_register(ctx, data.addr, data.length,
6214 TEE_SHM_DMA_BUF | TEE_SHM_USER_MAPPED);
6215 if (IS_ERR(shm))
6216 diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
6217 index 4dce4a8f71ed9..17b2361bc8f21 100644
6218 --- a/drivers/thermal/thermal_sysfs.c
6219 +++ b/drivers/thermal/thermal_sysfs.c
6220 @@ -909,12 +909,13 @@ static const struct attribute_group cooling_device_stats_attr_group = {
6221
6222 static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
6223 {
6224 + const struct attribute_group *stats_attr_group = NULL;
6225 struct cooling_dev_stats *stats;
6226 unsigned long states;
6227 int var;
6228
6229 if (cdev->ops->get_max_state(cdev, &states))
6230 - return;
6231 + goto out;
6232
6233 states++; /* Total number of states is highest state + 1 */
6234
6235 @@ -924,7 +925,7 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
6236
6237 stats = kzalloc(var, GFP_KERNEL);
6238 if (!stats)
6239 - return;
6240 + goto out;
6241
6242 stats->time_in_state = (ktime_t *)(stats + 1);
6243 stats->trans_table = (unsigned int *)(stats->time_in_state + states);
6244 @@ -934,9 +935,12 @@ static void cooling_device_stats_setup(struct thermal_cooling_device *cdev)
6245
6246 spin_lock_init(&stats->lock);
6247
6248 + stats_attr_group = &cooling_device_stats_attr_group;
6249 +
6250 +out:
6251 /* Fill the empty slot left in cooling_device_attr_groups */
6252 var = ARRAY_SIZE(cooling_device_attr_groups) - 2;
6253 - cooling_device_attr_groups[var] = &cooling_device_stats_attr_group;
6254 + cooling_device_attr_groups[var] = stats_attr_group;
6255 }
6256
6257 static void cooling_device_stats_destroy(struct thermal_cooling_device *cdev)
6258 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
6259 index 907a4d0784ac0..22da644530548 100644
6260 --- a/drivers/tty/n_gsm.c
6261 +++ b/drivers/tty/n_gsm.c
6262 @@ -410,6 +410,27 @@ static int gsm_read_ea(unsigned int *val, u8 c)
6263 return c & EA;
6264 }
6265
6266 +/**
6267 + * gsm_read_ea_val - read a value until EA
6268 + * @val: variable holding value
6269 + * @data: buffer of data
6270 + * @dlen: length of data
6271 + *
6272 + * Processes an EA value. Updates the passed variable and
6273 + * returns the processed data length.
6274 + */
6275 +static unsigned int gsm_read_ea_val(unsigned int *val, const u8 *data, int dlen)
6276 +{
6277 + unsigned int len = 0;
6278 +
6279 + for (; dlen > 0; dlen--) {
6280 + len++;
6281 + if (gsm_read_ea(val, *data++))
6282 + break;
6283 + }
6284 + return len;
6285 +}
6286 +
6287 /**
6288 * gsm_encode_modem - encode modem data bits
6289 * @dlci: DLCI to encode from
6290 @@ -657,6 +678,37 @@ static struct gsm_msg *gsm_data_alloc(struct gsm_mux *gsm, u8 addr, int len,
6291 return m;
6292 }
6293
6294 +/**
6295 + * gsm_is_flow_ctrl_msg - checks if flow control message
6296 + * @msg: message to check
6297 + *
6298 + * Returns true if the given message is a flow control command of the
6299 + * control channel. False is returned in any other case.
6300 + */
6301 +static bool gsm_is_flow_ctrl_msg(struct gsm_msg *msg)
6302 +{
6303 + unsigned int cmd;
6304 +
6305 + if (msg->addr > 0)
6306 + return false;
6307 +
6308 + switch (msg->ctrl & ~PF) {
6309 + case UI:
6310 + case UIH:
6311 + cmd = 0;
6312 + if (gsm_read_ea_val(&cmd, msg->data + 2, msg->len - 2) < 1)
6313 + break;
6314 + switch (cmd & ~PF) {
6315 + case CMD_FCOFF:
6316 + case CMD_FCON:
6317 + return true;
6318 + }
6319 + break;
6320 + }
6321 +
6322 + return false;
6323 +}
6324 +
6325 /**
6326 * gsm_data_kick - poke the queue
6327 * @gsm: GSM Mux
6328 @@ -675,7 +727,7 @@ static void gsm_data_kick(struct gsm_mux *gsm, struct gsm_dlci *dlci)
6329 int len;
6330
6331 list_for_each_entry_safe(msg, nmsg, &gsm->tx_list, list) {
6332 - if (gsm->constipated && msg->addr)
6333 + if (gsm->constipated && !gsm_is_flow_ctrl_msg(msg))
6334 continue;
6335 if (gsm->encoding != 0) {
6336 gsm->txframe[0] = GSM1_SOF;
6337 @@ -1330,7 +1382,7 @@ static void gsm_control_retransmit(struct timer_list *t)
6338 spin_lock_irqsave(&gsm->control_lock, flags);
6339 ctrl = gsm->pending_cmd;
6340 if (ctrl) {
6341 - if (gsm->cretries == 0) {
6342 + if (gsm->cretries == 0 || !gsm->dlci[0] || gsm->dlci[0]->dead) {
6343 gsm->pending_cmd = NULL;
6344 ctrl->error = -ETIMEDOUT;
6345 ctrl->done = 1;
6346 @@ -1482,8 +1534,8 @@ static void gsm_dlci_t1(struct timer_list *t)
6347
6348 switch (dlci->state) {
6349 case DLCI_OPENING:
6350 - dlci->retries--;
6351 if (dlci->retries) {
6352 + dlci->retries--;
6353 gsm_command(dlci->gsm, dlci->addr, SABM|PF);
6354 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
6355 } else if (!dlci->addr && gsm->control == (DM | PF)) {
6356 @@ -1498,8 +1550,8 @@ static void gsm_dlci_t1(struct timer_list *t)
6357
6358 break;
6359 case DLCI_CLOSING:
6360 - dlci->retries--;
6361 if (dlci->retries) {
6362 + dlci->retries--;
6363 gsm_command(dlci->gsm, dlci->addr, DISC|PF);
6364 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100);
6365 } else
6366 @@ -1842,7 +1894,7 @@ static void gsm_queue(struct gsm_mux *gsm)
6367 goto invalid;
6368 #endif
6369 if (dlci == NULL || dlci->state != DLCI_OPEN) {
6370 - gsm_command(gsm, address, DM|PF);
6371 + gsm_response(gsm, address, DM|PF);
6372 return;
6373 }
6374 dlci->data(dlci, gsm->buf, gsm->len);
6375 @@ -2599,11 +2651,24 @@ static ssize_t gsmld_read(struct tty_struct *tty, struct file *file,
6376 static ssize_t gsmld_write(struct tty_struct *tty, struct file *file,
6377 const unsigned char *buf, size_t nr)
6378 {
6379 - int space = tty_write_room(tty);
6380 + struct gsm_mux *gsm = tty->disc_data;
6381 + unsigned long flags;
6382 + int space;
6383 + int ret;
6384 +
6385 + if (!gsm)
6386 + return -ENODEV;
6387 +
6388 + ret = -ENOBUFS;
6389 + spin_lock_irqsave(&gsm->tx_lock, flags);
6390 + space = tty_write_room(tty);
6391 if (space >= nr)
6392 - return tty->ops->write(tty, buf, nr);
6393 - set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
6394 - return -ENOBUFS;
6395 + ret = tty->ops->write(tty, buf, nr);
6396 + else
6397 + set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
6398 + spin_unlock_irqrestore(&gsm->tx_lock, flags);
6399 +
6400 + return ret;
6401 }
6402
6403 /**
6404 @@ -2628,12 +2693,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file,
6405
6406 poll_wait(file, &tty->read_wait, wait);
6407 poll_wait(file, &tty->write_wait, wait);
6408 +
6409 + if (gsm->dead)
6410 + mask |= EPOLLHUP;
6411 if (tty_hung_up_p(file))
6412 mask |= EPOLLHUP;
6413 + if (test_bit(TTY_OTHER_CLOSED, &tty->flags))
6414 + mask |= EPOLLHUP;
6415 if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0)
6416 mask |= EPOLLOUT | EPOLLWRNORM;
6417 - if (gsm->dead)
6418 - mask |= EPOLLHUP;
6419 return mask;
6420 }
6421
6422 diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
6423 index 381c5117aec1b..2d5a039229acf 100644
6424 --- a/drivers/tty/serial/8250/8250_dw.c
6425 +++ b/drivers/tty/serial/8250/8250_dw.c
6426 @@ -110,12 +110,15 @@ static void dw8250_check_lcr(struct uart_port *p, int value)
6427 /* Returns once the transmitter is empty or we run out of retries */
6428 static void dw8250_tx_wait_empty(struct uart_port *p)
6429 {
6430 + struct uart_8250_port *up = up_to_u8250p(p);
6431 unsigned int tries = 20000;
6432 unsigned int delay_threshold = tries - 1000;
6433 unsigned int lsr;
6434
6435 while (tries--) {
6436 lsr = readb (p->membase + (UART_LSR << p->regshift));
6437 + up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
6438 +
6439 if (lsr & UART_LSR_TEMT)
6440 break;
6441
6442 diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
6443 index 2ce0d05be3681..bc5f77ac538e2 100644
6444 --- a/drivers/tty/serial/mvebu-uart.c
6445 +++ b/drivers/tty/serial/mvebu-uart.c
6446 @@ -238,6 +238,7 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
6447 struct tty_port *tport = &port->state->port;
6448 unsigned char ch = 0;
6449 char flag = 0;
6450 + int ret;
6451
6452 do {
6453 if (status & STAT_RX_RDY(port)) {
6454 @@ -250,6 +251,16 @@ static void mvebu_uart_rx_chars(struct uart_port *port, unsigned int status)
6455 port->icount.parity++;
6456 }
6457
6458 + /*
6459 + * For UART2, error bits are not cleared on buffer read.
6460 + * This causes interrupt loop and system hang.
6461 + */
6462 + if (IS_EXTENDED(port) && (status & STAT_BRK_ERR)) {
6463 + ret = readl(port->membase + UART_STAT);
6464 + ret |= STAT_BRK_ERR;
6465 + writel(ret, port->membase + UART_STAT);
6466 + }
6467 +
6468 if (status & STAT_BRK_DET) {
6469 port->icount.brk++;
6470 status &= ~(STAT_FRM_ERR | STAT_PAR_ERR);
6471 diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
6472 index a0555ae2b1ef4..181d55e0c60fc 100644
6473 --- a/drivers/tty/serial/ucc_uart.c
6474 +++ b/drivers/tty/serial/ucc_uart.c
6475 @@ -1141,6 +1141,8 @@ static unsigned int soc_info(unsigned int *rev_h, unsigned int *rev_l)
6476 /* No compatible property, so try the name. */
6477 soc_string = np->name;
6478
6479 + of_node_put(np);
6480 +
6481 /* Extract the SOC number from the "PowerPC," string */
6482 if ((sscanf(soc_string, "PowerPC,%u", &soc) != 1) || !soc)
6483 return 0;
6484 diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
6485 index 9d9e056f94ac8..b4f97df8e0000 100644
6486 --- a/drivers/tty/vt/vt.c
6487 +++ b/drivers/tty/vt/vt.c
6488 @@ -351,7 +351,7 @@ static struct uni_screen *vc_uniscr_alloc(unsigned int cols, unsigned int rows)
6489 /* allocate everything in one go */
6490 memsize = cols * rows * sizeof(char32_t);
6491 memsize += rows * sizeof(char32_t *);
6492 - p = vmalloc(memsize);
6493 + p = vzalloc(memsize);
6494 if (!p)
6495 return NULL;
6496
6497 diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c
6498 index 296f2ee1b6803..a9399f2b39308 100644
6499 --- a/drivers/usb/cdns3/gadget.c
6500 +++ b/drivers/usb/cdns3/gadget.c
6501 @@ -549,9 +549,9 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep)
6502 trace_cdns3_wa2(priv_ep, "removes eldest request");
6503
6504 kfree(priv_req->request.buf);
6505 + list_del_init(&priv_req->list);
6506 cdns3_gadget_ep_free_request(&priv_ep->endpoint,
6507 &priv_req->request);
6508 - list_del_init(&priv_req->list);
6509 --priv_ep->wa2_counter;
6510
6511 if (!chain)
6512 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
6513 index fde211519a973..d58098c2af10b 100644
6514 --- a/drivers/usb/core/hcd.c
6515 +++ b/drivers/usb/core/hcd.c
6516 @@ -1688,7 +1688,6 @@ static void usb_giveback_urb_bh(unsigned long param)
6517
6518 spin_lock_irq(&bh->lock);
6519 bh->running = true;
6520 - restart:
6521 list_replace_init(&bh->head, &local_list);
6522 spin_unlock_irq(&bh->lock);
6523
6524 @@ -1702,10 +1701,17 @@ static void usb_giveback_urb_bh(unsigned long param)
6525 bh->completing_ep = NULL;
6526 }
6527
6528 - /* check if there are new URBs to giveback */
6529 + /*
6530 + * giveback new URBs next time to prevent this function
6531 + * from not exiting for a long time.
6532 + */
6533 spin_lock_irq(&bh->lock);
6534 - if (!list_empty(&bh->head))
6535 - goto restart;
6536 + if (!list_empty(&bh->head)) {
6537 + if (bh->high_prio)
6538 + tasklet_hi_schedule(&bh->bh);
6539 + else
6540 + tasklet_schedule(&bh->bh);
6541 + }
6542 bh->running = false;
6543 spin_unlock_irq(&bh->lock);
6544 }
6545 @@ -1730,7 +1736,7 @@ static void usb_giveback_urb_bh(unsigned long param)
6546 void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
6547 {
6548 struct giveback_urb_bh *bh;
6549 - bool running, high_prio_bh;
6550 + bool running;
6551
6552 /* pass status to tasklet via unlinked */
6553 if (likely(!urb->unlinked))
6554 @@ -1741,13 +1747,10 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
6555 return;
6556 }
6557
6558 - if (usb_pipeisoc(urb->pipe) || usb_pipeint(urb->pipe)) {
6559 + if (usb_pipeisoc(urb->pipe) || usb_pipeint(urb->pipe))
6560 bh = &hcd->high_prio_bh;
6561 - high_prio_bh = true;
6562 - } else {
6563 + else
6564 bh = &hcd->low_prio_bh;
6565 - high_prio_bh = false;
6566 - }
6567
6568 spin_lock(&bh->lock);
6569 list_add_tail(&urb->urb_list, &bh->head);
6570 @@ -1756,7 +1759,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
6571
6572 if (running)
6573 ;
6574 - else if (high_prio_bh)
6575 + else if (bh->high_prio)
6576 tasklet_hi_schedule(&bh->bh);
6577 else
6578 tasklet_schedule(&bh->bh);
6579 @@ -2796,6 +2799,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
6580
6581 /* initialize tasklets */
6582 init_giveback_urb_bh(&hcd->high_prio_bh);
6583 + hcd->high_prio_bh.high_prio = true;
6584 init_giveback_urb_bh(&hcd->low_prio_bh);
6585
6586 /* enable irqs just before we start the controller,
6587 diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
6588 index 5c042f3807081..f9fad639a4891 100644
6589 --- a/drivers/usb/gadget/function/uvc_video.c
6590 +++ b/drivers/usb/gadget/function/uvc_video.c
6591 @@ -191,7 +191,7 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req)
6592 goto requeue;
6593
6594 default:
6595 - uvcg_info(&video->uvc->func,
6596 + uvcg_warn(&video->uvc->func,
6597 "VS request completed with status %d.\n",
6598 req->status);
6599 uvcg_queue_cancel(queue, 0);
6600 diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
6601 index 9cd80ad075bd2..97c73d610eeb4 100644
6602 --- a/drivers/usb/gadget/legacy/inode.c
6603 +++ b/drivers/usb/gadget/legacy/inode.c
6604 @@ -362,6 +362,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)
6605 spin_unlock_irq (&epdata->dev->lock);
6606
6607 DBG (epdata->dev, "endpoint gone\n");
6608 + wait_for_completion(&done);
6609 epdata->status = -ENODEV;
6610 }
6611 }
6612 diff --git a/drivers/usb/gadget/udc/Kconfig b/drivers/usb/gadget/udc/Kconfig
6613 index f985bb4a42db2..ccf2c736d4958 100644
6614 --- a/drivers/usb/gadget/udc/Kconfig
6615 +++ b/drivers/usb/gadget/udc/Kconfig
6616 @@ -311,7 +311,7 @@ source "drivers/usb/gadget/udc/bdc/Kconfig"
6617
6618 config USB_AMD5536UDC
6619 tristate "AMD5536 UDC"
6620 - depends on USB_PCI
6621 + depends on USB_PCI && HAS_DMA
6622 select USB_SNP_CORE
6623 help
6624 The AMD5536 UDC is part of the AMD Geode CS5536, an x86 southbridge.
6625 diff --git a/drivers/usb/host/ehci-ppc-of.c b/drivers/usb/host/ehci-ppc-of.c
6626 index 6bbaee74f7e7d..28a19693c19fe 100644
6627 --- a/drivers/usb/host/ehci-ppc-of.c
6628 +++ b/drivers/usb/host/ehci-ppc-of.c
6629 @@ -148,6 +148,7 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
6630 } else {
6631 ehci->has_amcc_usb23 = 1;
6632 }
6633 + of_node_put(np);
6634 }
6635
6636 if (of_get_property(dn, "big-endian", NULL)) {
6637 diff --git a/drivers/usb/host/ohci-nxp.c b/drivers/usb/host/ohci-nxp.c
6638 index c561881d0e793..07cee8c7c25ed 100644
6639 --- a/drivers/usb/host/ohci-nxp.c
6640 +++ b/drivers/usb/host/ohci-nxp.c
6641 @@ -164,6 +164,7 @@ static int ohci_hcd_nxp_probe(struct platform_device *pdev)
6642 }
6643
6644 isp1301_i2c_client = isp1301_get_client(isp1301_node);
6645 + of_node_put(isp1301_node);
6646 if (!isp1301_i2c_client)
6647 return -EPROBE_DEFER;
6648
6649 diff --git a/drivers/usb/host/ohci-ppc-of.c b/drivers/usb/host/ohci-ppc-of.c
6650 index 45f7cceb6df31..98e46725999e9 100644
6651 --- a/drivers/usb/host/ohci-ppc-of.c
6652 +++ b/drivers/usb/host/ohci-ppc-of.c
6653 @@ -169,6 +169,7 @@ static int ohci_hcd_ppc_of_probe(struct platform_device *op)
6654 release_mem_region(res.start, 0x4);
6655 } else
6656 pr_debug("%s: cannot get ehci offset from fdt\n", __FILE__);
6657 + of_node_put(np);
6658 }
6659
6660 irq_dispose_mapping(irq);
6661 diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
6662 index 6087b1fa530f8..d53bdb7d297f8 100644
6663 --- a/drivers/usb/host/xhci-tegra.c
6664 +++ b/drivers/usb/host/xhci-tegra.c
6665 @@ -933,15 +933,15 @@ static int tegra_xusb_powerdomain_init(struct device *dev,
6666 int err;
6667
6668 tegra->genpd_dev_host = dev_pm_domain_attach_by_name(dev, "xusb_host");
6669 - if (IS_ERR(tegra->genpd_dev_host)) {
6670 - err = PTR_ERR(tegra->genpd_dev_host);
6671 + if (IS_ERR_OR_NULL(tegra->genpd_dev_host)) {
6672 + err = PTR_ERR(tegra->genpd_dev_host) ? : -ENODATA;
6673 dev_err(dev, "failed to get host pm-domain: %d\n", err);
6674 return err;
6675 }
6676
6677 tegra->genpd_dev_ss = dev_pm_domain_attach_by_name(dev, "xusb_ss");
6678 - if (IS_ERR(tegra->genpd_dev_ss)) {
6679 - err = PTR_ERR(tegra->genpd_dev_ss);
6680 + if (IS_ERR_OR_NULL(tegra->genpd_dev_ss)) {
6681 + err = PTR_ERR(tegra->genpd_dev_ss) ? : -ENODATA;
6682 dev_err(dev, "failed to get superspeed pm-domain: %d\n", err);
6683 return err;
6684 }
6685 diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
6686 index a9031f4949842..5a6ad776858e3 100644
6687 --- a/drivers/usb/host/xhci.h
6688 +++ b/drivers/usb/host/xhci.h
6689 @@ -2376,7 +2376,7 @@ static inline const char *xhci_decode_trb(char *str, size_t size,
6690 field3 & TRB_CYCLE ? 'C' : 'c');
6691 break;
6692 case TRB_STOP_RING:
6693 - sprintf(str,
6694 + snprintf(str, size,
6695 "%s: slot %d sp %d ep %d flags %c",
6696 xhci_trb_type_string(type),
6697 TRB_TO_SLOT_ID(field3),
6698 diff --git a/drivers/usb/renesas_usbhs/rza.c b/drivers/usb/renesas_usbhs/rza.c
6699 index 24de64edb674b..2d77edefb4b30 100644
6700 --- a/drivers/usb/renesas_usbhs/rza.c
6701 +++ b/drivers/usb/renesas_usbhs/rza.c
6702 @@ -23,6 +23,10 @@ static int usbhs_rza1_hardware_init(struct platform_device *pdev)
6703 extal_clk = of_find_node_by_name(NULL, "extal");
6704 of_property_read_u32(usb_x1_clk, "clock-frequency", &freq_usb);
6705 of_property_read_u32(extal_clk, "clock-frequency", &freq_extal);
6706 +
6707 + of_node_put(usb_x1_clk);
6708 + of_node_put(extal_clk);
6709 +
6710 if (freq_usb == 0) {
6711 if (freq_extal == 12000000) {
6712 /* Select 12MHz XTAL */
6713 diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
6714 index a43263a0edd88..891e52bc5002c 100644
6715 --- a/drivers/usb/serial/sierra.c
6716 +++ b/drivers/usb/serial/sierra.c
6717 @@ -757,7 +757,8 @@ static void sierra_close(struct usb_serial_port *port)
6718
6719 /*
6720 * Need to take susp_lock to make sure port is not already being
6721 - * resumed, but no need to hold it due to initialized
6722 + * resumed, but no need to hold it due to the tty-port initialized
6723 + * flag.
6724 */
6725 spin_lock_irq(&intfdata->susp_lock);
6726 if (--intfdata->open_ports == 0)
6727 diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
6728 index dc7a65b9ec982..2a2469b76cc54 100644
6729 --- a/drivers/usb/serial/usb-serial.c
6730 +++ b/drivers/usb/serial/usb-serial.c
6731 @@ -254,7 +254,7 @@ static int serial_open(struct tty_struct *tty, struct file *filp)
6732 *
6733 * Shut down a USB serial port. Serialized against activate by the
6734 * tport mutex and kept to matching open/close pairs
6735 - * of calls by the initialized flag.
6736 + * of calls by the tty-port initialized flag.
6737 *
6738 * Not called if tty is console.
6739 */
6740 diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
6741 index b2285d5a869de..628a75d1232ae 100644
6742 --- a/drivers/usb/serial/usb_wwan.c
6743 +++ b/drivers/usb/serial/usb_wwan.c
6744 @@ -435,7 +435,8 @@ void usb_wwan_close(struct usb_serial_port *port)
6745
6746 /*
6747 * Need to take susp_lock to make sure port is not already being
6748 - * resumed, but no need to hold it due to initialized
6749 + * resumed, but no need to hold it due to the tty-port initialized
6750 + * flag.
6751 */
6752 spin_lock_irq(&intfdata->susp_lock);
6753 if (--intfdata->open_ports == 0)
6754 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
6755 index 388597930b648..efd3782ead974 100644
6756 --- a/drivers/vfio/vfio.c
6757 +++ b/drivers/vfio/vfio.c
6758 @@ -1802,6 +1802,7 @@ struct vfio_info_cap_header *vfio_info_cap_add(struct vfio_info_cap *caps,
6759 buf = krealloc(caps->buf, caps->size + size, GFP_KERNEL);
6760 if (!buf) {
6761 kfree(caps->buf);
6762 + caps->buf = NULL;
6763 caps->size = 0;
6764 return ERR_PTR(-ENOMEM);
6765 }
6766 diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
6767 index 3b7a7c74bf0a5..09774ada36fb3 100644
6768 --- a/drivers/video/fbdev/amba-clcd.c
6769 +++ b/drivers/video/fbdev/amba-clcd.c
6770 @@ -714,16 +714,18 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
6771 return -ENODEV;
6772
6773 panel = of_graph_get_remote_port_parent(endpoint);
6774 - if (!panel)
6775 - return -ENODEV;
6776 + if (!panel) {
6777 + err = -ENODEV;
6778 + goto out_endpoint_put;
6779 + }
6780
6781 err = clcdfb_of_get_backlight(panel, fb->panel);
6782 if (err)
6783 - return err;
6784 + goto out_panel_put;
6785
6786 err = clcdfb_of_get_mode(&fb->dev->dev, panel, fb->panel);
6787 if (err)
6788 - return err;
6789 + goto out_panel_put;
6790
6791 err = of_property_read_u32(fb->dev->dev.of_node, "max-memory-bandwidth",
6792 &max_bandwidth);
6793 @@ -752,11 +754,21 @@ static int clcdfb_of_init_display(struct clcd_fb *fb)
6794
6795 if (of_property_read_u32_array(endpoint,
6796 "arm,pl11x,tft-r0g0b0-pads",
6797 - tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0)
6798 - return -ENOENT;
6799 + tft_r0b0g0, ARRAY_SIZE(tft_r0b0g0)) != 0) {
6800 + err = -ENOENT;
6801 + goto out_panel_put;
6802 + }
6803 +
6804 + of_node_put(panel);
6805 + of_node_put(endpoint);
6806
6807 return clcdfb_of_init_tft_panel(fb, tft_r0b0g0[0],
6808 tft_r0b0g0[1], tft_r0b0g0[2]);
6809 +out_panel_put:
6810 + of_node_put(panel);
6811 +out_endpoint_put:
6812 + of_node_put(endpoint);
6813 + return err;
6814 }
6815
6816 static int clcdfb_of_vram_setup(struct clcd_fb *fb)
6817 diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
6818 index f940e8b66b858..6b1ad19b8db4c 100644
6819 --- a/drivers/video/fbdev/arkfb.c
6820 +++ b/drivers/video/fbdev/arkfb.c
6821 @@ -778,7 +778,12 @@ static int arkfb_set_par(struct fb_info *info)
6822 return -EINVAL;
6823 }
6824
6825 - ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
6826 + value = (hdiv * info->var.pixclock) / hmul;
6827 + if (!value) {
6828 + fb_dbg(info, "invalid pixclock\n");
6829 + value = 1;
6830 + }
6831 + ark_set_pixclock(info, value);
6832 svga_set_timings(par->state.vgabase, &ark_timing_regs, &(info->var), hmul, hdiv,
6833 (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1,
6834 (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
6835 @@ -789,6 +794,8 @@ static int arkfb_set_par(struct fb_info *info)
6836 value = ((value * hmul / hdiv) / 8) - 5;
6837 vga_wcrt(par->state.vgabase, 0x42, (value + 1) / 2);
6838
6839 + if (screen_size > info->screen_size)
6840 + screen_size = info->screen_size;
6841 memset_io(info->screen_base, 0x00, screen_size);
6842 /* Device and screen back on */
6843 svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);
6844 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
6845 index 8721b75131362..4a544e1e2038c 100644
6846 --- a/drivers/video/fbdev/core/fbcon.c
6847 +++ b/drivers/video/fbdev/core/fbcon.c
6848 @@ -123,8 +123,8 @@ static int logo_lines;
6849 enums. */
6850 static int logo_shown = FBCON_LOGO_CANSHOW;
6851 /* console mappings */
6852 -static int first_fb_vc;
6853 -static int last_fb_vc = MAX_NR_CONSOLES - 1;
6854 +static unsigned int first_fb_vc;
6855 +static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1;
6856 static int fbcon_is_default = 1;
6857 static int primary_device = -1;
6858 static int fbcon_has_console_bind;
6859 @@ -474,10 +474,12 @@ static int __init fb_console_setup(char *this_opt)
6860 options += 3;
6861 if (*options)
6862 first_fb_vc = simple_strtoul(options, &options, 10) - 1;
6863 - if (first_fb_vc < 0)
6864 + if (first_fb_vc >= MAX_NR_CONSOLES)
6865 first_fb_vc = 0;
6866 if (*options++ == '-')
6867 last_fb_vc = simple_strtoul(options, &options, 10) - 1;
6868 + if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES)
6869 + last_fb_vc = MAX_NR_CONSOLES - 1;
6870 fbcon_is_default = 0;
6871 continue;
6872 }
6873 diff --git a/drivers/video/fbdev/i740fb.c b/drivers/video/fbdev/i740fb.c
6874 index 347cf8babc3e3..1434eb0220e78 100644
6875 --- a/drivers/video/fbdev/i740fb.c
6876 +++ b/drivers/video/fbdev/i740fb.c
6877 @@ -400,7 +400,7 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var,
6878 u32 xres, right, hslen, left, xtotal;
6879 u32 yres, lower, vslen, upper, ytotal;
6880 u32 vxres, xoffset, vyres, yoffset;
6881 - u32 bpp, base, dacspeed24, mem;
6882 + u32 bpp, base, dacspeed24, mem, freq;
6883 u8 r7;
6884 int i;
6885
6886 @@ -643,7 +643,12 @@ static int i740fb_decode_var(const struct fb_var_screeninfo *var,
6887 par->atc[VGA_ATC_OVERSCAN] = 0;
6888
6889 /* Calculate VCLK that most closely matches the requested dot clock */
6890 - i740_calc_vclk((((u32)1e9) / var->pixclock) * (u32)(1e3), par);
6891 + freq = (((u32)1e9) / var->pixclock) * (u32)(1e3);
6892 + if (freq < I740_RFREQ_FIX) {
6893 + fb_dbg(info, "invalid pixclock\n");
6894 + freq = I740_RFREQ_FIX;
6895 + }
6896 + i740_calc_vclk(freq, par);
6897
6898 /* Since we program the clocks ourselves, always use VCLK2. */
6899 par->misc |= 0x0C;
6900 diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c
6901 index be16c349c10f8..228e5ee7a5475 100644
6902 --- a/drivers/video/fbdev/s3fb.c
6903 +++ b/drivers/video/fbdev/s3fb.c
6904 @@ -902,6 +902,8 @@ static int s3fb_set_par(struct fb_info *info)
6905 value = clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1);
6906 svga_wcrt_multi(par->state.vgabase, s3_dtpc_regs, value);
6907
6908 + if (screen_size > info->screen_size)
6909 + screen_size = info->screen_size;
6910 memset_io(info->screen_base, 0x00, screen_size);
6911 /* Device and screen back on */
6912 svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);
6913 diff --git a/drivers/video/fbdev/sis/init.c b/drivers/video/fbdev/sis/init.c
6914 index fde27feae5d0c..d6b2ce95a8594 100644
6915 --- a/drivers/video/fbdev/sis/init.c
6916 +++ b/drivers/video/fbdev/sis/init.c
6917 @@ -355,12 +355,12 @@ SiS_GetModeID(int VGAEngine, unsigned int VBFlags, int HDisplay, int VDisplay,
6918 }
6919 break;
6920 case 400:
6921 - if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDwidth >= 600))) {
6922 + if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 800) && (LCDheight >= 600))) {
6923 if(VDisplay == 300) ModeIndex = ModeIndex_400x300[Depth];
6924 }
6925 break;
6926 case 512:
6927 - if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDwidth >= 768))) {
6928 + if((!(VBFlags & CRT1_LCDA)) || ((LCDwidth >= 1024) && (LCDheight >= 768))) {
6929 if(VDisplay == 384) ModeIndex = ModeIndex_512x384[Depth];
6930 }
6931 break;
6932 diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c
6933 index c339a8fbad81f..61e2028924a6b 100644
6934 --- a/drivers/video/fbdev/vt8623fb.c
6935 +++ b/drivers/video/fbdev/vt8623fb.c
6936 @@ -504,6 +504,8 @@ static int vt8623fb_set_par(struct fb_info *info)
6937 (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1,
6938 1, info->node);
6939
6940 + if (screen_size > info->screen_size)
6941 + screen_size = info->screen_size;
6942 memset_io(info->screen_base, 0x00, screen_size);
6943
6944 /* Device and screen back on */
6945 diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
6946 index 32c2c52f7e84e..484c2f09f2ea7 100644
6947 --- a/drivers/virt/vboxguest/vboxguest_linux.c
6948 +++ b/drivers/virt/vboxguest/vboxguest_linux.c
6949 @@ -361,8 +361,8 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
6950 goto err_vbg_core_exit;
6951 }
6952
6953 - ret = devm_request_irq(dev, pci->irq, vbg_core_isr, IRQF_SHARED,
6954 - DEVICE_NAME, gdev);
6955 + ret = request_irq(pci->irq, vbg_core_isr, IRQF_SHARED, DEVICE_NAME,
6956 + gdev);
6957 if (ret) {
6958 vbg_err("vboxguest: Error requesting irq: %d\n", ret);
6959 goto err_vbg_core_exit;
6960 @@ -372,7 +372,7 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
6961 if (ret) {
6962 vbg_err("vboxguest: Error misc_register %s failed: %d\n",
6963 DEVICE_NAME, ret);
6964 - goto err_vbg_core_exit;
6965 + goto err_free_irq;
6966 }
6967
6968 ret = misc_register(&gdev->misc_device_user);
6969 @@ -408,6 +408,8 @@ err_unregister_misc_device_user:
6970 misc_deregister(&gdev->misc_device_user);
6971 err_unregister_misc_device:
6972 misc_deregister(&gdev->misc_device);
6973 +err_free_irq:
6974 + free_irq(pci->irq, gdev);
6975 err_vbg_core_exit:
6976 vbg_core_exit(gdev);
6977 err_disable_pcidev:
6978 @@ -424,6 +426,7 @@ static void vbg_pci_remove(struct pci_dev *pci)
6979 vbg_gdev = NULL;
6980 mutex_unlock(&vbg_gdev_mutex);
6981
6982 + free_irq(pci->irq, gdev);
6983 device_remove_file(gdev->dev, &dev_attr_host_features);
6984 device_remove_file(gdev->dev, &dev_attr_host_version);
6985 misc_deregister(&gdev->misc_device_user);
6986 diff --git a/drivers/watchdog/armada_37xx_wdt.c b/drivers/watchdog/armada_37xx_wdt.c
6987 index e5dcb26d85f0a..dcb3ffda3fad4 100644
6988 --- a/drivers/watchdog/armada_37xx_wdt.c
6989 +++ b/drivers/watchdog/armada_37xx_wdt.c
6990 @@ -274,6 +274,8 @@ static int armada_37xx_wdt_probe(struct platform_device *pdev)
6991 if (!res)
6992 return -ENODEV;
6993 dev->reg = devm_ioremap(&pdev->dev, res->start, resource_size(res));
6994 + if (!dev->reg)
6995 + return -ENOMEM;
6996
6997 /* init clock */
6998 dev->clk = devm_clk_get(&pdev->dev, NULL);
6999 diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
7000 index 597af455a522b..0792fda49a15f 100644
7001 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c
7002 +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
7003 @@ -128,7 +128,7 @@ static ssize_t xenbus_file_read(struct file *filp,
7004 {
7005 struct xenbus_file_priv *u = filp->private_data;
7006 struct read_buffer *rb;
7007 - unsigned i;
7008 + ssize_t i;
7009 int ret;
7010
7011 mutex_lock(&u->reply_mutex);
7012 @@ -148,7 +148,7 @@ again:
7013 rb = list_entry(u->read_buffers.next, struct read_buffer, list);
7014 i = 0;
7015 while (i < len) {
7016 - unsigned sz = min((unsigned)len - i, rb->len - rb->cons);
7017 + size_t sz = min_t(size_t, len - i, rb->len - rb->cons);
7018
7019 ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);
7020
7021 diff --git a/fs/attr.c b/fs/attr.c
7022 index b4bbdbd4c8ca0..848ffe6e3c24b 100644
7023 --- a/fs/attr.c
7024 +++ b/fs/attr.c
7025 @@ -134,6 +134,8 @@ EXPORT_SYMBOL(setattr_prepare);
7026 */
7027 int inode_newsize_ok(const struct inode *inode, loff_t offset)
7028 {
7029 + if (offset < 0)
7030 + return -EINVAL;
7031 if (inode->i_size < offset) {
7032 unsigned long limit;
7033
7034 diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
7035 index bcf19dfb0af35..278933cd3a092 100644
7036 --- a/fs/btrfs/block-group.c
7037 +++ b/fs/btrfs/block-group.c
7038 @@ -2938,6 +2938,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags,
7039 * attempt.
7040 */
7041 wait_for_alloc = true;
7042 + force = CHUNK_ALLOC_NO_FORCE;
7043 spin_unlock(&space_info->lock);
7044 mutex_lock(&fs_info->chunk_mutex);
7045 mutex_unlock(&fs_info->chunk_mutex);
7046 diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
7047 index a4b3e6f6bf021..b94d68035c5d9 100644
7048 --- a/fs/btrfs/disk-io.c
7049 +++ b/fs/btrfs/disk-io.c
7050 @@ -2970,6 +2970,20 @@ int open_ctree(struct super_block *sb,
7051 err = -EINVAL;
7052 goto fail_csum;
7053 }
7054 + /*
7055 + * We have unsupported RO compat features, although RO mounted, we
7056 + * should not cause any metadata write, including log replay.
7057 + * Or we could screw up whatever the new feature requires.
7058 + */
7059 + if (unlikely(features && btrfs_super_log_root(disk_super) &&
7060 + !btrfs_test_opt(fs_info, NOLOGREPLAY))) {
7061 + btrfs_err(fs_info,
7062 +"cannot replay dirty log with unsupported compat_ro features (0x%llx), try rescue=nologreplay",
7063 + features);
7064 + err = -EINVAL;
7065 + goto fail_alloc;
7066 + }
7067 +
7068
7069 ret = btrfs_init_workqueues(fs_info, fs_devices);
7070 if (ret) {
7071 diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
7072 index 7ac679ed2b6c6..226a17a335da3 100644
7073 --- a/fs/btrfs/raid56.c
7074 +++ b/fs/btrfs/raid56.c
7075 @@ -334,6 +334,9 @@ static void merge_rbio(struct btrfs_raid_bio *dest,
7076 {
7077 bio_list_merge(&dest->bio_list, &victim->bio_list);
7078 dest->bio_list_bytes += victim->bio_list_bytes;
7079 + /* Also inherit the bitmaps from @victim. */
7080 + bitmap_or(dest->dbitmap, victim->dbitmap, dest->dbitmap,
7081 + dest->stripe_npages);
7082 dest->generic_bio_cnt += victim->generic_bio_cnt;
7083 bio_list_init(&victim->bio_list);
7084 }
7085 @@ -878,6 +881,12 @@ static void rbio_orig_end_io(struct btrfs_raid_bio *rbio, blk_status_t err)
7086
7087 if (rbio->generic_bio_cnt)
7088 btrfs_bio_counter_sub(rbio->fs_info, rbio->generic_bio_cnt);
7089 + /*
7090 + * Clear the data bitmap, as the rbio may be cached for later usage.
7091 + * do this before before unlock_stripe() so there will be no new bio
7092 + * for this bio.
7093 + */
7094 + bitmap_clear(rbio->dbitmap, 0, rbio->stripe_npages);
7095
7096 /*
7097 * At this moment, rbio->bio_list is empty, however since rbio does not
7098 @@ -1212,6 +1221,9 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
7099 else
7100 BUG();
7101
7102 + /* We should have at least one data sector. */
7103 + ASSERT(bitmap_weight(rbio->dbitmap, rbio->stripe_npages));
7104 +
7105 /* at this point we either have a full stripe,
7106 * or we've read the full stripe from the drive.
7107 * recalculate the parity and write the new results.
7108 @@ -1285,6 +1297,11 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
7109 for (stripe = 0; stripe < rbio->real_stripes; stripe++) {
7110 for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
7111 struct page *page;
7112 +
7113 + /* This vertical stripe has no data, skip it. */
7114 + if (!test_bit(pagenr, rbio->dbitmap))
7115 + continue;
7116 +
7117 if (stripe < rbio->nr_data) {
7118 page = page_in_rbio(rbio, stripe, pagenr, 1);
7119 if (!page)
7120 @@ -1309,6 +1326,11 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
7121
7122 for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
7123 struct page *page;
7124 +
7125 + /* This vertical stripe has no data, skip it. */
7126 + if (!test_bit(pagenr, rbio->dbitmap))
7127 + continue;
7128 +
7129 if (stripe < rbio->nr_data) {
7130 page = page_in_rbio(rbio, stripe, pagenr, 1);
7131 if (!page)
7132 @@ -1748,6 +1770,33 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
7133 run_plug(plug);
7134 }
7135
7136 +/* Add the original bio into rbio->bio_list, and update rbio::dbitmap. */
7137 +static void rbio_add_bio(struct btrfs_raid_bio *rbio, struct bio *orig_bio)
7138 +{
7139 + const struct btrfs_fs_info *fs_info = rbio->fs_info;
7140 + const u64 orig_logical = orig_bio->bi_iter.bi_sector << SECTOR_SHIFT;
7141 + const u64 full_stripe_start = rbio->bbio->raid_map[0];
7142 + const u32 orig_len = orig_bio->bi_iter.bi_size;
7143 + const u32 sectorsize = fs_info->sectorsize;
7144 + u64 cur_logical;
7145 +
7146 + ASSERT(orig_logical >= full_stripe_start &&
7147 + orig_logical + orig_len <= full_stripe_start +
7148 + rbio->nr_data * rbio->stripe_len);
7149 +
7150 + bio_list_add(&rbio->bio_list, orig_bio);
7151 + rbio->bio_list_bytes += orig_bio->bi_iter.bi_size;
7152 +
7153 + /* Update the dbitmap. */
7154 + for (cur_logical = orig_logical; cur_logical < orig_logical + orig_len;
7155 + cur_logical += sectorsize) {
7156 + int bit = ((u32)(cur_logical - full_stripe_start) >>
7157 + PAGE_SHIFT) % rbio->stripe_npages;
7158 +
7159 + set_bit(bit, rbio->dbitmap);
7160 + }
7161 +}
7162 +
7163 /*
7164 * our main entry point for writes from the rest of the FS.
7165 */
7166 @@ -1764,9 +1813,8 @@ int raid56_parity_write(struct btrfs_fs_info *fs_info, struct bio *bio,
7167 btrfs_put_bbio(bbio);
7168 return PTR_ERR(rbio);
7169 }
7170 - bio_list_add(&rbio->bio_list, bio);
7171 - rbio->bio_list_bytes = bio->bi_iter.bi_size;
7172 rbio->operation = BTRFS_RBIO_WRITE;
7173 + rbio_add_bio(rbio, bio);
7174
7175 btrfs_bio_counter_inc_noblocked(fs_info);
7176 rbio->generic_bio_cnt = 1;
7177 @@ -2068,9 +2116,12 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
7178 atomic_set(&rbio->error, 0);
7179
7180 /*
7181 - * read everything that hasn't failed. Thanks to the
7182 - * stripe cache, it is possible that some or all of these
7183 - * pages are going to be uptodate.
7184 + * Read everything that hasn't failed. However this time we will
7185 + * not trust any cached sector.
7186 + * As we may read out some stale data but higher layer is not reading
7187 + * that stale part.
7188 + *
7189 + * So here we always re-read everything in recovery path.
7190 */
7191 for (stripe = 0; stripe < rbio->real_stripes; stripe++) {
7192 if (rbio->faila == stripe || rbio->failb == stripe) {
7193 @@ -2079,16 +2130,6 @@ static int __raid56_parity_recover(struct btrfs_raid_bio *rbio)
7194 }
7195
7196 for (pagenr = 0; pagenr < rbio->stripe_npages; pagenr++) {
7197 - struct page *p;
7198 -
7199 - /*
7200 - * the rmw code may have already read this
7201 - * page in
7202 - */
7203 - p = rbio_stripe_page(rbio, stripe, pagenr);
7204 - if (PageUptodate(p))
7205 - continue;
7206 -
7207 ret = rbio_add_io_page(rbio, &bio_list,
7208 rbio_stripe_page(rbio, stripe, pagenr),
7209 stripe, pagenr, rbio->stripe_len);
7210 @@ -2170,8 +2211,7 @@ int raid56_parity_recover(struct btrfs_fs_info *fs_info, struct bio *bio,
7211 }
7212
7213 rbio->operation = BTRFS_RBIO_READ_REBUILD;
7214 - bio_list_add(&rbio->bio_list, bio);
7215 - rbio->bio_list_bytes = bio->bi_iter.bi_size;
7216 + rbio_add_bio(rbio, bio);
7217
7218 rbio->faila = find_logical_bio_stripe(rbio, bio);
7219 if (rbio->faila == -1) {
7220 diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
7221 index b7bfecfc2ea33..bebd74267bed6 100644
7222 --- a/fs/btrfs/tree-log.c
7223 +++ b/fs/btrfs/tree-log.c
7224 @@ -1100,7 +1100,9 @@ again:
7225 extref = btrfs_lookup_inode_extref(NULL, root, path, name, namelen,
7226 inode_objectid, parent_objectid, 0,
7227 0);
7228 - if (!IS_ERR_OR_NULL(extref)) {
7229 + if (IS_ERR(extref)) {
7230 + return PTR_ERR(extref);
7231 + } else if (extref) {
7232 u32 item_size;
7233 u32 cur_offset = 0;
7234 unsigned long base;
7235 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
7236 index 57164563eec69..6ae281cff0d50 100644
7237 --- a/fs/cifs/smb2ops.c
7238 +++ b/fs/cifs/smb2ops.c
7239 @@ -960,9 +960,7 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
7240 size_t name_len, value_len, user_name_len;
7241
7242 while (src_size > 0) {
7243 - name = &src->ea_data[0];
7244 name_len = (size_t)src->ea_name_length;
7245 - value = &src->ea_data[src->ea_name_length + 1];
7246 value_len = (size_t)le16_to_cpu(src->ea_value_length);
7247
7248 if (name_len == 0)
7249 @@ -974,6 +972,9 @@ move_smb2_ea_to_cifs(char *dst, size_t dst_size,
7250 goto out;
7251 }
7252
7253 + name = &src->ea_data[0];
7254 + value = &src->ea_data[src->ea_name_length + 1];
7255 +
7256 if (ea_name) {
7257 if (ea_name_len == name_len &&
7258 memcmp(ea_name, name, name_len) == 0) {
7259 diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
7260 index 23b74b8e8f96f..38eeec5e30327 100644
7261 --- a/fs/erofs/decompressor.c
7262 +++ b/fs/erofs/decompressor.c
7263 @@ -56,14 +56,18 @@ static int z_erofs_lz4_prepare_destpages(struct z_erofs_decompress_req *rq,
7264
7265 if (page) {
7266 __clear_bit(j, bounced);
7267 - if (kaddr) {
7268 - if (kaddr + PAGE_SIZE == page_address(page))
7269 + if (!PageHighMem(page)) {
7270 + if (!i) {
7271 + kaddr = page_address(page);
7272 + continue;
7273 + }
7274 + if (kaddr &&
7275 + kaddr + PAGE_SIZE == page_address(page)) {
7276 kaddr += PAGE_SIZE;
7277 - else
7278 - kaddr = NULL;
7279 - } else if (!i) {
7280 - kaddr = page_address(page);
7281 + continue;
7282 + }
7283 }
7284 + kaddr = NULL;
7285 continue;
7286 }
7287 kaddr = NULL;
7288 diff --git a/fs/eventpoll.c b/fs/eventpoll.c
7289 index 339453ac834cc..7e11135bc915c 100644
7290 --- a/fs/eventpoll.c
7291 +++ b/fs/eventpoll.c
7292 @@ -1803,6 +1803,21 @@ static inline struct timespec64 ep_set_mstimeout(long ms)
7293 return timespec64_add_safe(now, ts);
7294 }
7295
7296 +/*
7297 + * autoremove_wake_function, but remove even on failure to wake up, because we
7298 + * know that default_wake_function/ttwu will only fail if the thread is already
7299 + * woken, and in that case the ep_poll loop will remove the entry anyways, not
7300 + * try to reuse it.
7301 + */
7302 +static int ep_autoremove_wake_function(struct wait_queue_entry *wq_entry,
7303 + unsigned int mode, int sync, void *key)
7304 +{
7305 + int ret = default_wake_function(wq_entry, mode, sync, key);
7306 +
7307 + list_del_init(&wq_entry->entry);
7308 + return ret;
7309 +}
7310 +
7311 /**
7312 * ep_poll - Retrieves ready events, and delivers them to the caller supplied
7313 * event buffer.
7314 @@ -1880,8 +1895,15 @@ fetch_events:
7315 * normal wakeup path no need to call __remove_wait_queue()
7316 * explicitly, thus ep->lock is not taken, which halts the
7317 * event delivery.
7318 + *
7319 + * In fact, we now use an even more aggressive function that
7320 + * unconditionally removes, because we don't reuse the wait
7321 + * entry between loop iterations. This lets us also avoid the
7322 + * performance issue if a process is killed, causing all of its
7323 + * threads to wake up without being removed normally.
7324 */
7325 init_wait(&wait);
7326 + wait.func = ep_autoremove_wake_function;
7327 write_lock_irq(&ep->lock);
7328 __add_wait_queue_exclusive(&ep->wq, &wait);
7329 write_unlock_irq(&ep->lock);
7330 diff --git a/fs/ext2/super.c b/fs/ext2/super.c
7331 index db403c01d4d5c..644c83c115bc2 100644
7332 --- a/fs/ext2/super.c
7333 +++ b/fs/ext2/super.c
7334 @@ -1077,9 +1077,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
7335 sbi->s_frags_per_group);
7336 goto failed_mount;
7337 }
7338 - if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
7339 + if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
7340 + sbi->s_inodes_per_group > sb->s_blocksize * 8) {
7341 ext2_msg(sb, KERN_ERR,
7342 - "error: #inodes per group too big: %lu",
7343 + "error: invalid #inodes per group: %lu",
7344 sbi->s_inodes_per_group);
7345 goto failed_mount;
7346 }
7347 @@ -1089,6 +1090,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
7348 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
7349 le32_to_cpu(es->s_first_data_block) - 1)
7350 / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
7351 + if ((u64)sbi->s_groups_count * sbi->s_inodes_per_group !=
7352 + le32_to_cpu(es->s_inodes_count)) {
7353 + ext2_msg(sb, KERN_ERR, "error: invalid #inodes: %u vs computed %llu",
7354 + le32_to_cpu(es->s_inodes_count),
7355 + (u64)sbi->s_groups_count * sbi->s_inodes_per_group);
7356 + goto failed_mount;
7357 + }
7358 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
7359 EXT2_DESC_PER_BLOCK(sb);
7360 sbi->s_group_desc = kmalloc_array (db_count,
7361 diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
7362 index 62384ae77a78f..5ef13ede04457 100644
7363 --- a/fs/ext4/inline.c
7364 +++ b/fs/ext4/inline.c
7365 @@ -34,6 +34,9 @@ static int get_max_inline_xattr_value_size(struct inode *inode,
7366 struct ext4_inode *raw_inode;
7367 int free, min_offs;
7368
7369 + if (!EXT4_INODE_HAS_XATTR_SPACE(inode))
7370 + return 0;
7371 +
7372 min_offs = EXT4_SB(inode->i_sb)->s_inode_size -
7373 EXT4_GOOD_OLD_INODE_SIZE -
7374 EXT4_I(inode)->i_extra_isize -
7375 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
7376 index d8fee911d4f4d..22feae1d5f777 100644
7377 --- a/fs/ext4/inode.c
7378 +++ b/fs/ext4/inode.c
7379 @@ -1717,7 +1717,14 @@ static void mpage_release_unused_pages(struct mpage_da_data *mpd,
7380 ext4_lblk_t start, last;
7381 start = index << (PAGE_SHIFT - inode->i_blkbits);
7382 last = end << (PAGE_SHIFT - inode->i_blkbits);
7383 +
7384 + /*
7385 + * avoid racing with extent status tree scans made by
7386 + * ext4_insert_delayed_block()
7387 + */
7388 + down_write(&EXT4_I(inode)->i_data_sem);
7389 ext4_es_remove_extent(inode, start, last - start + 1);
7390 + up_write(&EXT4_I(inode)->i_data_sem);
7391 }
7392
7393 pagevec_init(&pvec);
7394 @@ -4834,8 +4841,7 @@ static inline int ext4_iget_extra_inode(struct inode *inode,
7395 __le32 *magic = (void *)raw_inode +
7396 EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize;
7397
7398 - if (EXT4_GOOD_OLD_INODE_SIZE + ei->i_extra_isize + sizeof(__le32) <=
7399 - EXT4_INODE_SIZE(inode->i_sb) &&
7400 + if (EXT4_INODE_HAS_XATTR_SPACE(inode) &&
7401 *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {
7402 ext4_set_inode_state(inode, EXT4_STATE_XATTR);
7403 return ext4_find_inline_data_nolock(inode);
7404 diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
7405 index c5b2ea1a93729..1faa8e4ffb9df 100644
7406 --- a/fs/ext4/migrate.c
7407 +++ b/fs/ext4/migrate.c
7408 @@ -435,7 +435,7 @@ int ext4_ext_migrate(struct inode *inode)
7409 struct inode *tmp_inode = NULL;
7410 struct migrate_struct lb;
7411 unsigned long max_entries;
7412 - __u32 goal;
7413 + __u32 goal, tmp_csum_seed;
7414 uid_t owner[2];
7415
7416 /*
7417 @@ -483,6 +483,7 @@ int ext4_ext_migrate(struct inode *inode)
7418 * the migration.
7419 */
7420 ei = EXT4_I(inode);
7421 + tmp_csum_seed = EXT4_I(tmp_inode)->i_csum_seed;
7422 EXT4_I(tmp_inode)->i_csum_seed = ei->i_csum_seed;
7423 i_size_write(tmp_inode, i_size_read(inode));
7424 /*
7425 @@ -593,6 +594,7 @@ err_out:
7426 * the inode is not visible to user space.
7427 */
7428 tmp_inode->i_blocks = 0;
7429 + EXT4_I(tmp_inode)->i_csum_seed = tmp_csum_seed;
7430
7431 /* Reset the extent details */
7432 ext4_ext_tree_init(handle, tmp_inode);
7433 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
7434 index d151892db8b0c..aaf1ed8ba87c1 100644
7435 --- a/fs/ext4/namei.c
7436 +++ b/fs/ext4/namei.c
7437 @@ -54,6 +54,7 @@ static struct buffer_head *ext4_append(handle_t *handle,
7438 struct inode *inode,
7439 ext4_lblk_t *block)
7440 {
7441 + struct ext4_map_blocks map;
7442 struct buffer_head *bh;
7443 int err;
7444
7445 @@ -63,6 +64,21 @@ static struct buffer_head *ext4_append(handle_t *handle,
7446 return ERR_PTR(-ENOSPC);
7447
7448 *block = inode->i_size >> inode->i_sb->s_blocksize_bits;
7449 + map.m_lblk = *block;
7450 + map.m_len = 1;
7451 +
7452 + /*
7453 + * We're appending new directory block. Make sure the block is not
7454 + * allocated yet, otherwise we will end up corrupting the
7455 + * directory.
7456 + */
7457 + err = ext4_map_blocks(NULL, inode, &map, 0);
7458 + if (err < 0)
7459 + return ERR_PTR(err);
7460 + if (err) {
7461 + EXT4_ERROR_INODE(inode, "Logical block already allocated");
7462 + return ERR_PTR(-EFSCORRUPTED);
7463 + }
7464
7465 bh = ext4_bread(handle, inode, *block, EXT4_GET_BLOCKS_CREATE);
7466 if (IS_ERR(bh))
7467 @@ -2913,11 +2929,8 @@ bool ext4_empty_dir(struct inode *inode)
7468 de = (struct ext4_dir_entry_2 *) (bh->b_data +
7469 (offset & (sb->s_blocksize - 1)));
7470 if (ext4_check_dir_entry(inode, NULL, de, bh,
7471 - bh->b_data, bh->b_size, offset)) {
7472 - offset = (offset | (sb->s_blocksize - 1)) + 1;
7473 - continue;
7474 - }
7475 - if (le32_to_cpu(de->inode)) {
7476 + bh->b_data, bh->b_size, offset) ||
7477 + le32_to_cpu(de->inode)) {
7478 brelse(bh);
7479 return false;
7480 }
7481 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
7482 index 6410c1e098d36..f0fc7fc579e62 100644
7483 --- a/fs/ext4/resize.c
7484 +++ b/fs/ext4/resize.c
7485 @@ -1483,6 +1483,7 @@ static void ext4_update_super(struct super_block *sb,
7486 * Update the fs overhead information
7487 */
7488 ext4_calculate_overhead(sb);
7489 + es->s_overhead_clusters = cpu_to_le32(sbi->s_overhead);
7490
7491 if (test_opt(sb, DEBUG))
7492 printk(KERN_DEBUG "EXT4-fs: added group %u:"
7493 @@ -1978,6 +1979,16 @@ int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count)
7494 }
7495 brelse(bh);
7496
7497 + /*
7498 + * For bigalloc, trim the requested size to the nearest cluster
7499 + * boundary to avoid creating an unusable filesystem. We do this
7500 + * silently, instead of returning an error, to avoid breaking
7501 + * callers that blindly resize the filesystem to the full size of
7502 + * the underlying block device.
7503 + */
7504 + if (ext4_has_feature_bigalloc(sb))
7505 + n_blocks_count &= ~((1 << EXT4_CLUSTER_BITS(sb)) - 1);
7506 +
7507 retry:
7508 o_blocks_count = ext4_blocks_count(es);
7509
7510 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
7511 index 20e40cac819e4..4b0e2bc71d2cb 100644
7512 --- a/fs/ext4/xattr.c
7513 +++ b/fs/ext4/xattr.c
7514 @@ -2184,8 +2184,9 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
7515 struct ext4_inode *raw_inode;
7516 int error;
7517
7518 - if (EXT4_I(inode)->i_extra_isize == 0)
7519 + if (!EXT4_INODE_HAS_XATTR_SPACE(inode))
7520 return 0;
7521 +
7522 raw_inode = ext4_raw_inode(&is->iloc);
7523 header = IHDR(inode, raw_inode);
7524 is->s.base = is->s.first = IFIRST(header);
7525 @@ -2213,8 +2214,9 @@ int ext4_xattr_ibody_inline_set(handle_t *handle, struct inode *inode,
7526 struct ext4_xattr_search *s = &is->s;
7527 int error;
7528
7529 - if (EXT4_I(inode)->i_extra_isize == 0)
7530 + if (!EXT4_INODE_HAS_XATTR_SPACE(inode))
7531 return -ENOSPC;
7532 +
7533 error = ext4_xattr_set_entry(i, s, handle, inode, false /* is_block */);
7534 if (error)
7535 return error;
7536 diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h
7537 index f39cad2abe2a8..990084e00374f 100644
7538 --- a/fs/ext4/xattr.h
7539 +++ b/fs/ext4/xattr.h
7540 @@ -95,6 +95,19 @@ struct ext4_xattr_entry {
7541
7542 #define EXT4_ZERO_XATTR_VALUE ((void *)-1)
7543
7544 +/*
7545 + * If we want to add an xattr to the inode, we should make sure that
7546 + * i_extra_isize is not 0 and that the inode size is not less than
7547 + * EXT4_GOOD_OLD_INODE_SIZE + extra_isize + pad.
7548 + * EXT4_GOOD_OLD_INODE_SIZE extra_isize header entry pad data
7549 + * |--------------------------|------------|------|---------|---|-------|
7550 + */
7551 +#define EXT4_INODE_HAS_XATTR_SPACE(inode) \
7552 + ((EXT4_I(inode)->i_extra_isize != 0) && \
7553 + (EXT4_GOOD_OLD_INODE_SIZE + EXT4_I(inode)->i_extra_isize + \
7554 + sizeof(struct ext4_xattr_ibody_header) + EXT4_XATTR_PAD <= \
7555 + EXT4_INODE_SIZE((inode)->i_sb)))
7556 +
7557 struct ext4_xattr_info {
7558 const char *name;
7559 const void *value;
7560 diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
7561 index 3dc7cc3d6ac69..b080d5c58f6cb 100644
7562 --- a/fs/f2fs/node.c
7563 +++ b/fs/f2fs/node.c
7564 @@ -1240,7 +1240,11 @@ struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
7565 dec_valid_node_count(sbi, dn->inode, !ofs);
7566 goto fail;
7567 }
7568 - f2fs_bug_on(sbi, new_ni.blk_addr != NULL_ADDR);
7569 + if (unlikely(new_ni.blk_addr != NULL_ADDR)) {
7570 + err = -EFSCORRUPTED;
7571 + set_sbi_flag(sbi, SBI_NEED_FSCK);
7572 + goto fail;
7573 + }
7574 #endif
7575 new_ni.nid = dn->nid;
7576 new_ni.ino = dn->inode->i_ino;
7577 diff --git a/fs/fuse/control.c b/fs/fuse/control.c
7578 index c23f6f243ad42..2742d74cedda8 100644
7579 --- a/fs/fuse/control.c
7580 +++ b/fs/fuse/control.c
7581 @@ -265,7 +265,7 @@ int fuse_ctl_add_conn(struct fuse_conn *fc)
7582 struct dentry *parent;
7583 char name[32];
7584
7585 - if (!fuse_control_sb)
7586 + if (!fuse_control_sb || fc->no_control)
7587 return 0;
7588
7589 parent = fuse_control_sb->s_root;
7590 @@ -303,7 +303,7 @@ void fuse_ctl_remove_conn(struct fuse_conn *fc)
7591 {
7592 int i;
7593
7594 - if (!fuse_control_sb)
7595 + if (!fuse_control_sb || fc->no_control)
7596 return;
7597
7598 for (i = fc->ctl_ndents - 1; i >= 0; i--) {
7599 diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
7600 index aa1d5cf1bc3a4..f3d712decb57c 100644
7601 --- a/fs/fuse/inode.c
7602 +++ b/fs/fuse/inode.c
7603 @@ -162,6 +162,12 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
7604 inode->i_uid = make_kuid(fc->user_ns, attr->uid);
7605 inode->i_gid = make_kgid(fc->user_ns, attr->gid);
7606 inode->i_blocks = attr->blocks;
7607 +
7608 + /* Sanitize nsecs */
7609 + attr->atimensec = min_t(u32, attr->atimensec, NSEC_PER_SEC - 1);
7610 + attr->mtimensec = min_t(u32, attr->mtimensec, NSEC_PER_SEC - 1);
7611 + attr->ctimensec = min_t(u32, attr->ctimensec, NSEC_PER_SEC - 1);
7612 +
7613 inode->i_atime.tv_sec = attr->atime;
7614 inode->i_atime.tv_nsec = attr->atimensec;
7615 /* mtime from server may be stale due to local buffered write */
7616 diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
7617 index d45ceb2e21492..8d5aced7ed0c4 100644
7618 --- a/fs/jbd2/commit.c
7619 +++ b/fs/jbd2/commit.c
7620 @@ -514,13 +514,13 @@ void jbd2_journal_commit_transaction(journal_t *journal)
7621 */
7622 jbd2_journal_switch_revoke_table(journal);
7623
7624 + write_lock(&journal->j_state_lock);
7625 /*
7626 * Reserved credits cannot be claimed anymore, free them
7627 */
7628 atomic_sub(atomic_read(&journal->j_reserved_credits),
7629 &commit_transaction->t_outstanding_credits);
7630
7631 - write_lock(&journal->j_state_lock);
7632 trace_jbd2_commit_flushing(journal, commit_transaction);
7633 stats.run.rs_flushing = jiffies;
7634 stats.run.rs_locked = jbd2_time_diff(stats.run.rs_locked,
7635 diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
7636 index be05fb96757c3..e0bd731404150 100644
7637 --- a/fs/jbd2/transaction.c
7638 +++ b/fs/jbd2/transaction.c
7639 @@ -1375,8 +1375,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
7640 struct journal_head *jh;
7641 int ret = 0;
7642
7643 - if (is_handle_aborted(handle))
7644 - return -EROFS;
7645 if (!buffer_jbd(bh))
7646 return -EUCLEAN;
7647
7648 @@ -1423,6 +1421,18 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
7649 journal = transaction->t_journal;
7650 jbd_lock_bh_state(bh);
7651
7652 + if (is_handle_aborted(handle)) {
7653 + /*
7654 + * Check journal aborting with @jh->b_state_lock locked,
7655 + * since 'jh->b_transaction' could be replaced with
7656 + * 'jh->b_next_transaction' during old transaction
7657 + * committing if journal aborted, which may fail
7658 + * assertion on 'jh->b_frozen_data == NULL'.
7659 + */
7660 + ret = -EROFS;
7661 + goto out_unlock_bh;
7662 + }
7663 +
7664 if (jh->b_modified == 0) {
7665 /*
7666 * This buffer's got modified and becoming part
7667 diff --git a/fs/namei.c b/fs/namei.c
7668 index b952ecbd49c29..22d13732e61d7 100644
7669 --- a/fs/namei.c
7670 +++ b/fs/namei.c
7671 @@ -3443,6 +3443,8 @@ struct dentry *vfs_tmpfile(struct dentry *dentry, umode_t mode, int open_flag)
7672 child = d_alloc(dentry, &slash_name);
7673 if (unlikely(!child))
7674 goto out_err;
7675 + if (!IS_POSIXACL(dir))
7676 + mode &= ~current_umask();
7677 error = dir->i_op->tmpfile(dir, child, mode);
7678 if (error)
7679 goto out_err;
7680 diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
7681 index 1e7296395d71b..4e6dd267ac504 100644
7682 --- a/fs/nfs/nfs4idmap.c
7683 +++ b/fs/nfs/nfs4idmap.c
7684 @@ -560,22 +560,20 @@ nfs_idmap_prepare_pipe_upcall(struct idmap *idmap,
7685 return true;
7686 }
7687
7688 -static void
7689 -nfs_idmap_complete_pipe_upcall_locked(struct idmap *idmap, int ret)
7690 +static void nfs_idmap_complete_pipe_upcall(struct idmap_legacy_upcalldata *data,
7691 + int ret)
7692 {
7693 - struct key *authkey = idmap->idmap_upcall_data->authkey;
7694 -
7695 - kfree(idmap->idmap_upcall_data);
7696 - idmap->idmap_upcall_data = NULL;
7697 - complete_request_key(authkey, ret);
7698 - key_put(authkey);
7699 + complete_request_key(data->authkey, ret);
7700 + key_put(data->authkey);
7701 + kfree(data);
7702 }
7703
7704 -static void
7705 -nfs_idmap_abort_pipe_upcall(struct idmap *idmap, int ret)
7706 +static void nfs_idmap_abort_pipe_upcall(struct idmap *idmap,
7707 + struct idmap_legacy_upcalldata *data,
7708 + int ret)
7709 {
7710 - if (idmap->idmap_upcall_data != NULL)
7711 - nfs_idmap_complete_pipe_upcall_locked(idmap, ret);
7712 + if (cmpxchg(&idmap->idmap_upcall_data, data, NULL) == data)
7713 + nfs_idmap_complete_pipe_upcall(data, ret);
7714 }
7715
7716 static int nfs_idmap_legacy_upcall(struct key *authkey, void *aux)
7717 @@ -612,7 +610,7 @@ static int nfs_idmap_legacy_upcall(struct key *authkey, void *aux)
7718
7719 ret = rpc_queue_upcall(idmap->idmap_pipe, msg);
7720 if (ret < 0)
7721 - nfs_idmap_abort_pipe_upcall(idmap, ret);
7722 + nfs_idmap_abort_pipe_upcall(idmap, data, ret);
7723
7724 return ret;
7725 out2:
7726 @@ -668,6 +666,7 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
7727 struct request_key_auth *rka;
7728 struct rpc_inode *rpci = RPC_I(file_inode(filp));
7729 struct idmap *idmap = (struct idmap *)rpci->private;
7730 + struct idmap_legacy_upcalldata *data;
7731 struct key *authkey;
7732 struct idmap_msg im;
7733 size_t namelen_in;
7734 @@ -677,10 +676,11 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
7735 * will have been woken up and someone else may now have used
7736 * idmap_key_cons - so after this point we may no longer touch it.
7737 */
7738 - if (idmap->idmap_upcall_data == NULL)
7739 + data = xchg(&idmap->idmap_upcall_data, NULL);
7740 + if (data == NULL)
7741 goto out_noupcall;
7742
7743 - authkey = idmap->idmap_upcall_data->authkey;
7744 + authkey = data->authkey;
7745 rka = get_request_key_auth(authkey);
7746
7747 if (mlen != sizeof(im)) {
7748 @@ -702,18 +702,17 @@ idmap_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
7749 if (namelen_in == 0 || namelen_in == IDMAP_NAMESZ) {
7750 ret = -EINVAL;
7751 goto out;
7752 -}
7753 + }
7754
7755 - ret = nfs_idmap_read_and_verify_message(&im,
7756 - &idmap->idmap_upcall_data->idmap_msg,
7757 - rka->target_key, authkey);
7758 + ret = nfs_idmap_read_and_verify_message(&im, &data->idmap_msg,
7759 + rka->target_key, authkey);
7760 if (ret >= 0) {
7761 key_set_timeout(rka->target_key, nfs_idmap_cache_timeout);
7762 ret = mlen;
7763 }
7764
7765 out:
7766 - nfs_idmap_complete_pipe_upcall_locked(idmap, ret);
7767 + nfs_idmap_complete_pipe_upcall(data, ret);
7768 out_noupcall:
7769 return ret;
7770 }
7771 @@ -727,7 +726,7 @@ idmap_pipe_destroy_msg(struct rpc_pipe_msg *msg)
7772 struct idmap *idmap = data->idmap;
7773
7774 if (msg->errno)
7775 - nfs_idmap_abort_pipe_upcall(idmap, msg->errno);
7776 + nfs_idmap_abort_pipe_upcall(idmap, data, msg->errno);
7777 }
7778
7779 static void
7780 @@ -735,8 +734,11 @@ idmap_release_pipe(struct inode *inode)
7781 {
7782 struct rpc_inode *rpci = RPC_I(inode);
7783 struct idmap *idmap = (struct idmap *)rpci->private;
7784 + struct idmap_legacy_upcalldata *data;
7785
7786 - nfs_idmap_abort_pipe_upcall(idmap, -EPIPE);
7787 + data = xchg(&idmap->idmap_upcall_data, NULL);
7788 + if (data)
7789 + nfs_idmap_complete_pipe_upcall(data, -EPIPE);
7790 }
7791
7792 int nfs_map_name_to_uid(const struct nfs_server *server, const char *name, size_t namelen, kuid_t *uid)
7793 diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
7794 index ba4a03a69fbf0..7c5dfed0437f7 100644
7795 --- a/fs/nfs/nfs4proc.c
7796 +++ b/fs/nfs/nfs4proc.c
7797 @@ -779,10 +779,9 @@ static void nfs4_slot_sequence_record_sent(struct nfs4_slot *slot,
7798 if ((s32)(seqnr - slot->seq_nr_highest_sent) > 0)
7799 slot->seq_nr_highest_sent = seqnr;
7800 }
7801 -static void nfs4_slot_sequence_acked(struct nfs4_slot *slot,
7802 - u32 seqnr)
7803 +static void nfs4_slot_sequence_acked(struct nfs4_slot *slot, u32 seqnr)
7804 {
7805 - slot->seq_nr_highest_sent = seqnr;
7806 + nfs4_slot_sequence_record_sent(slot, seqnr);
7807 slot->seq_nr_last_acked = seqnr;
7808 }
7809
7810 @@ -849,7 +848,6 @@ static int nfs41_sequence_process(struct rpc_task *task,
7811 __func__,
7812 slot->slot_nr,
7813 slot->seq_nr);
7814 - nfs4_slot_sequence_acked(slot, slot->seq_nr);
7815 goto out_retry;
7816 case -NFS4ERR_RETRY_UNCACHED_REP:
7817 case -NFS4ERR_SEQ_FALSE_RETRY:
7818 @@ -3041,12 +3039,13 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
7819 }
7820
7821 out:
7822 - if (opendata->lgp) {
7823 - nfs4_lgopen_release(opendata->lgp);
7824 - opendata->lgp = NULL;
7825 - }
7826 - if (!opendata->cancelled)
7827 + if (!opendata->cancelled) {
7828 + if (opendata->lgp) {
7829 + nfs4_lgopen_release(opendata->lgp);
7830 + opendata->lgp = NULL;
7831 + }
7832 nfs4_sequence_free_slot(&opendata->o_res.seq_res);
7833 + }
7834 return ret;
7835 }
7836
7837 @@ -8988,6 +8987,9 @@ static int nfs41_reclaim_complete_handle_errors(struct rpc_task *task, struct nf
7838 rpc_delay(task, NFS4_POLL_RETRY_MAX);
7839 /* fall through */
7840 case -NFS4ERR_RETRY_UNCACHED_REP:
7841 + case -EACCES:
7842 + dprintk("%s: failed to reclaim complete error %d for server %s, retrying\n",
7843 + __func__, task->tk_status, clp->cl_hostname);
7844 return -EAGAIN;
7845 case -NFS4ERR_BADSESSION:
7846 case -NFS4ERR_DEADSESSION:
7847 diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c
7848 index 19574ef174709..984df246962ec 100644
7849 --- a/fs/overlayfs/export.c
7850 +++ b/fs/overlayfs/export.c
7851 @@ -274,7 +274,7 @@ static int ovl_encode_fh(struct inode *inode, u32 *fid, int *max_len,
7852 return FILEID_INVALID;
7853
7854 dentry = d_find_any_alias(inode);
7855 - if (WARN_ON(!dentry))
7856 + if (!dentry)
7857 return FILEID_INVALID;
7858
7859 type = ovl_dentry_to_fh(dentry, fid, max_len);
7860 diff --git a/fs/splice.c b/fs/splice.c
7861 index e509239d7e06a..ae5623244d5e3 100644
7862 --- a/fs/splice.c
7863 +++ b/fs/splice.c
7864 @@ -895,17 +895,15 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
7865 {
7866 struct pipe_inode_info *pipe;
7867 long ret, bytes;
7868 - umode_t i_mode;
7869 size_t len;
7870 int i, flags, more;
7871
7872 /*
7873 - * We require the input being a regular file, as we don't want to
7874 - * randomly drop data for eg socket -> socket splicing. Use the
7875 - * piped splicing for that!
7876 + * We require the input to be seekable, as we don't want to randomly
7877 + * drop data for eg socket -> socket splicing. Use the piped splicing
7878 + * for that!
7879 */
7880 - i_mode = file_inode(in)->i_mode;
7881 - if (unlikely(!S_ISREG(i_mode) && !S_ISBLK(i_mode)))
7882 + if (unlikely(!(in->f_mode & FMODE_LSEEK)))
7883 return -EINVAL;
7884
7885 /*
7886 diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
7887 index a6a9373ab8634..d9417abf4cd08 100644
7888 --- a/include/acpi/cppc_acpi.h
7889 +++ b/include/acpi/cppc_acpi.h
7890 @@ -16,7 +16,7 @@
7891 #include <acpi/pcc.h>
7892 #include <acpi/processor.h>
7893
7894 -/* Support CPPCv2 and CPPCv3 */
7895 +/* CPPCv2 and CPPCv3 support */
7896 #define CPPC_V2_REV 2
7897 #define CPPC_V3_REV 3
7898 #define CPPC_V2_NUM_ENT 21
7899 diff --git a/include/asm-generic/bitops/atomic.h b/include/asm-generic/bitops/atomic.h
7900 index 0e7316a86240b..21aa26e7c9882 100644
7901 --- a/include/asm-generic/bitops/atomic.h
7902 +++ b/include/asm-generic/bitops/atomic.h
7903 @@ -35,9 +35,6 @@ static inline int test_and_set_bit(unsigned int nr, volatile unsigned long *p)
7904 unsigned long mask = BIT_MASK(nr);
7905
7906 p += BIT_WORD(nr);
7907 - if (READ_ONCE(*p) & mask)
7908 - return 1;
7909 -
7910 old = atomic_long_fetch_or(mask, (atomic_long_t *)p);
7911 return !!(old & mask);
7912 }
7913 @@ -48,9 +45,6 @@ static inline int test_and_clear_bit(unsigned int nr, volatile unsigned long *p)
7914 unsigned long mask = BIT_MASK(nr);
7915
7916 p += BIT_WORD(nr);
7917 - if (!(READ_ONCE(*p) & mask))
7918 - return 0;
7919 -
7920 old = atomic_long_fetch_andnot(mask, (atomic_long_t *)p);
7921 return !!(old & mask);
7922 }
7923 diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h
7924 index b56cc825f64d9..8fab480a8e4e4 100644
7925 --- a/include/linux/buffer_head.h
7926 +++ b/include/linux/buffer_head.h
7927 @@ -117,7 +117,6 @@ static __always_inline int test_clear_buffer_##name(struct buffer_head *bh) \
7928 * of the form "mark_buffer_foo()". These are higher-level functions which
7929 * do something in addition to setting a b_state bit.
7930 */
7931 -BUFFER_FNS(Uptodate, uptodate)
7932 BUFFER_FNS(Dirty, dirty)
7933 TAS_BUFFER_FNS(Dirty, dirty)
7934 BUFFER_FNS(Lock, locked)
7935 @@ -135,6 +134,30 @@ BUFFER_FNS(Meta, meta)
7936 BUFFER_FNS(Prio, prio)
7937 BUFFER_FNS(Defer_Completion, defer_completion)
7938
7939 +static __always_inline void set_buffer_uptodate(struct buffer_head *bh)
7940 +{
7941 + /*
7942 + * make it consistent with folio_mark_uptodate
7943 + * pairs with smp_load_acquire in buffer_uptodate
7944 + */
7945 + smp_mb__before_atomic();
7946 + set_bit(BH_Uptodate, &bh->b_state);
7947 +}
7948 +
7949 +static __always_inline void clear_buffer_uptodate(struct buffer_head *bh)
7950 +{
7951 + clear_bit(BH_Uptodate, &bh->b_state);
7952 +}
7953 +
7954 +static __always_inline int buffer_uptodate(const struct buffer_head *bh)
7955 +{
7956 + /*
7957 + * make it consistent with folio_test_uptodate
7958 + * pairs with smp_mb__before_atomic in set_buffer_uptodate
7959 + */
7960 + return (smp_load_acquire(&bh->b_state) & (1UL << BH_Uptodate)) != 0;
7961 +}
7962 +
7963 #define bh_offset(bh) ((unsigned long)(bh)->b_data & ~PAGE_MASK)
7964
7965 /* If we *know* page->private refers to buffer_heads */
7966 diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h
7967 index fc4b0b10210f4..d3e0f9dc2587b 100644
7968 --- a/include/linux/kfifo.h
7969 +++ b/include/linux/kfifo.h
7970 @@ -615,7 +615,7 @@ __kfifo_uint_must_check_helper( \
7971 * writer, you don't need extra locking to use these macro.
7972 */
7973 #define kfifo_to_user(fifo, to, len, copied) \
7974 -__kfifo_uint_must_check_helper( \
7975 +__kfifo_int_must_check_helper( \
7976 ({ \
7977 typeof((fifo) + 1) __tmp = (fifo); \
7978 void __user *__to = (to); \
7979 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
7980 index 19e8344c51a8c..dd4cdad76b18e 100644
7981 --- a/include/linux/kvm_host.h
7982 +++ b/include/linux/kvm_host.h
7983 @@ -146,6 +146,7 @@ static inline bool is_error_page(struct page *page)
7984 #define KVM_REQ_MMU_RELOAD (1 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
7985 #define KVM_REQ_PENDING_TIMER 2
7986 #define KVM_REQ_UNHALT 3
7987 +#define KVM_REQ_VM_BUGGED (4 | KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP)
7988 #define KVM_REQUEST_ARCH_BASE 8
7989
7990 #define KVM_ARCH_REQ_FLAGS(nr, flags) ({ \
7991 @@ -502,6 +503,7 @@ struct kvm {
7992 struct srcu_struct srcu;
7993 struct srcu_struct irq_srcu;
7994 pid_t userspace_pid;
7995 + bool vm_bugged;
7996 };
7997
7998 #define kvm_err(fmt, ...) \
7999 @@ -530,6 +532,31 @@ struct kvm {
8000 #define vcpu_err(vcpu, fmt, ...) \
8001 kvm_err("vcpu%i " fmt, (vcpu)->vcpu_id, ## __VA_ARGS__)
8002
8003 +bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
8004 +static inline void kvm_vm_bugged(struct kvm *kvm)
8005 +{
8006 + kvm->vm_bugged = true;
8007 + kvm_make_all_cpus_request(kvm, KVM_REQ_VM_BUGGED);
8008 +}
8009 +
8010 +#define KVM_BUG(cond, kvm, fmt...) \
8011 +({ \
8012 + int __ret = (cond); \
8013 + \
8014 + if (WARN_ONCE(__ret && !(kvm)->vm_bugged, fmt)) \
8015 + kvm_vm_bugged(kvm); \
8016 + unlikely(__ret); \
8017 +})
8018 +
8019 +#define KVM_BUG_ON(cond, kvm) \
8020 +({ \
8021 + int __ret = (cond); \
8022 + \
8023 + if (WARN_ON_ONCE(__ret && !(kvm)->vm_bugged)) \
8024 + kvm_vm_bugged(kvm); \
8025 + unlikely(__ret); \
8026 +})
8027 +
8028 static inline struct kvm_io_bus *kvm_get_bus(struct kvm *kvm, enum kvm_bus idx)
8029 {
8030 return srcu_dereference_check(kvm->buses[idx], &kvm->srcu,
8031 @@ -790,7 +817,6 @@ void kvm_reload_remote_mmus(struct kvm *kvm);
8032
8033 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
8034 unsigned long *vcpu_bitmap, cpumask_var_t tmp);
8035 -bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
8036
8037 long kvm_arch_dev_ioctl(struct file *filp,
8038 unsigned int ioctl, unsigned long arg);
8039 diff --git a/include/linux/mfd/t7l66xb.h b/include/linux/mfd/t7l66xb.h
8040 index 69632c1b07bd8..ae3e7a5c5219b 100644
8041 --- a/include/linux/mfd/t7l66xb.h
8042 +++ b/include/linux/mfd/t7l66xb.h
8043 @@ -12,7 +12,6 @@
8044
8045 struct t7l66xb_platform_data {
8046 int (*enable)(struct platform_device *dev);
8047 - int (*disable)(struct platform_device *dev);
8048 int (*suspend)(struct platform_device *dev);
8049 int (*resume)(struct platform_device *dev);
8050
8051 diff --git a/include/linux/nmi.h b/include/linux/nmi.h
8052 index 9003e29cde461..e972d1ae1ee63 100644
8053 --- a/include/linux/nmi.h
8054 +++ b/include/linux/nmi.h
8055 @@ -122,6 +122,8 @@ int watchdog_nmi_probe(void);
8056 int watchdog_nmi_enable(unsigned int cpu);
8057 void watchdog_nmi_disable(unsigned int cpu);
8058
8059 +void lockup_detector_reconfigure(void);
8060 +
8061 /**
8062 * touch_nmi_watchdog - restart NMI watchdog timeout.
8063 *
8064 diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
8065 index 42588645478d9..526d423740eb2 100644
8066 --- a/include/linux/pci_ids.h
8067 +++ b/include/linux/pci_ids.h
8068 @@ -59,6 +59,8 @@
8069 #define PCI_CLASS_BRIDGE_EISA 0x0602
8070 #define PCI_CLASS_BRIDGE_MC 0x0603
8071 #define PCI_CLASS_BRIDGE_PCI 0x0604
8072 +#define PCI_CLASS_BRIDGE_PCI_NORMAL 0x060400
8073 +#define PCI_CLASS_BRIDGE_PCI_SUBTRACTIVE 0x060401
8074 #define PCI_CLASS_BRIDGE_PCMCIA 0x0605
8075 #define PCI_CLASS_BRIDGE_NUBUS 0x0606
8076 #define PCI_CLASS_BRIDGE_CARDBUS 0x0607
8077 diff --git a/include/linux/tpm_eventlog.h b/include/linux/tpm_eventlog.h
8078 index f3caeeb7a0d03..def3f6159a0ef 100644
8079 --- a/include/linux/tpm_eventlog.h
8080 +++ b/include/linux/tpm_eventlog.h
8081 @@ -157,7 +157,7 @@ struct tcg_algorithm_info {
8082 * Return: size of the event on success, 0 on failure
8083 */
8084
8085 -static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
8086 +static __always_inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
8087 struct tcg_pcr_event *event_header,
8088 bool do_mapping)
8089 {
8090 diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
8091 index c0eb85b2981e0..a400e86f62181 100644
8092 --- a/include/linux/usb/hcd.h
8093 +++ b/include/linux/usb/hcd.h
8094 @@ -66,6 +66,7 @@
8095
8096 struct giveback_urb_bh {
8097 bool running;
8098 + bool high_prio;
8099 spinlock_t lock;
8100 struct list_head head;
8101 struct tasklet_struct bh;
8102 diff --git a/include/linux/wait.h b/include/linux/wait.h
8103 index 5903b1d17c924..7d04c1b588c73 100644
8104 --- a/include/linux/wait.h
8105 +++ b/include/linux/wait.h
8106 @@ -529,10 +529,11 @@ do { \
8107 \
8108 hrtimer_init_sleeper_on_stack(&__t, CLOCK_MONOTONIC, \
8109 HRTIMER_MODE_REL); \
8110 - if ((timeout) != KTIME_MAX) \
8111 - hrtimer_start_range_ns(&__t.timer, timeout, \
8112 - current->timer_slack_ns, \
8113 - HRTIMER_MODE_REL); \
8114 + if ((timeout) != KTIME_MAX) { \
8115 + hrtimer_set_expires_range_ns(&__t.timer, timeout, \
8116 + current->timer_slack_ns); \
8117 + hrtimer_sleeper_start_expires(&__t, HRTIMER_MODE_REL); \
8118 + } \
8119 \
8120 __ret = ___wait_event(wq_head, condition, state, 0, 0, \
8121 if (!__t.task) { \
8122 diff --git a/include/sound/core.h b/include/sound/core.h
8123 index ee238f100f73f..8a80121811d94 100644
8124 --- a/include/sound/core.h
8125 +++ b/include/sound/core.h
8126 @@ -440,4 +440,12 @@ snd_pci_quirk_lookup_id(u16 vendor, u16 device,
8127 }
8128 #endif
8129
8130 +/* async signal helpers */
8131 +struct snd_fasync;
8132 +
8133 +int snd_fasync_helper(int fd, struct file *file, int on,
8134 + struct snd_fasync **fasyncp);
8135 +void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll);
8136 +void snd_fasync_free(struct snd_fasync *fasync);
8137 +
8138 #endif /* __SOUND_CORE_H */
8139 diff --git a/include/trace/events/spmi.h b/include/trace/events/spmi.h
8140 index 8b60efe18ba68..a6819fd85cdf4 100644
8141 --- a/include/trace/events/spmi.h
8142 +++ b/include/trace/events/spmi.h
8143 @@ -21,15 +21,15 @@ TRACE_EVENT(spmi_write_begin,
8144 __field ( u8, sid )
8145 __field ( u16, addr )
8146 __field ( u8, len )
8147 - __dynamic_array ( u8, buf, len + 1 )
8148 + __dynamic_array ( u8, buf, len )
8149 ),
8150
8151 TP_fast_assign(
8152 __entry->opcode = opcode;
8153 __entry->sid = sid;
8154 __entry->addr = addr;
8155 - __entry->len = len + 1;
8156 - memcpy(__get_dynamic_array(buf), buf, len + 1);
8157 + __entry->len = len;
8158 + memcpy(__get_dynamic_array(buf), buf, len);
8159 ),
8160
8161 TP_printk("opc=%d sid=%02d addr=0x%04x len=%d buf=0x[%*phD]",
8162 @@ -92,7 +92,7 @@ TRACE_EVENT(spmi_read_end,
8163 __field ( u16, addr )
8164 __field ( int, ret )
8165 __field ( u8, len )
8166 - __dynamic_array ( u8, buf, len + 1 )
8167 + __dynamic_array ( u8, buf, len )
8168 ),
8169
8170 TP_fast_assign(
8171 @@ -100,8 +100,8 @@ TRACE_EVENT(spmi_read_end,
8172 __entry->sid = sid;
8173 __entry->addr = addr;
8174 __entry->ret = ret;
8175 - __entry->len = len + 1;
8176 - memcpy(__get_dynamic_array(buf), buf, len + 1);
8177 + __entry->len = len;
8178 + memcpy(__get_dynamic_array(buf), buf, len);
8179 ),
8180
8181 TP_printk("opc=%d sid=%02d addr=0x%04x ret=%d len=%02d buf=0x[%*phD]",
8182 diff --git a/include/uapi/linux/can/error.h b/include/uapi/linux/can/error.h
8183 index 34633283de641..a1000cb630632 100644
8184 --- a/include/uapi/linux/can/error.h
8185 +++ b/include/uapi/linux/can/error.h
8186 @@ -120,6 +120,9 @@
8187 #define CAN_ERR_TRX_CANL_SHORT_TO_GND 0x70 /* 0111 0000 */
8188 #define CAN_ERR_TRX_CANL_SHORT_TO_CANH 0x80 /* 1000 0000 */
8189
8190 -/* controller specific additional information / data[5..7] */
8191 +/* data[5] is reserved (do not use) */
8192 +
8193 +/* TX error counter / data[6] */
8194 +/* RX error counter / data[7] */
8195
8196 #endif /* _UAPI_CAN_ERROR_H */
8197 diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
8198 index 856f0297dc738..521121c2666ce 100644
8199 --- a/kernel/irq/chip.c
8200 +++ b/kernel/irq/chip.c
8201 @@ -1484,7 +1484,8 @@ int irq_chip_request_resources_parent(struct irq_data *data)
8202 if (data->chip->irq_request_resources)
8203 return data->chip->irq_request_resources(data);
8204
8205 - return -ENOSYS;
8206 + /* no error on missing optional irq_chip::irq_request_resources */
8207 + return 0;
8208 }
8209 EXPORT_SYMBOL_GPL(irq_chip_request_resources_parent);
8210
8211 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
8212 index c93340bae3ac2..671b51782182b 100644
8213 --- a/kernel/kprobes.c
8214 +++ b/kernel/kprobes.c
8215 @@ -1594,7 +1594,8 @@ static int check_kprobe_address_safe(struct kprobe *p,
8216 preempt_disable();
8217
8218 /* Ensure it is not in reserved area nor out of text */
8219 - if (!kernel_text_address((unsigned long) p->addr) ||
8220 + if (!(core_kernel_text((unsigned long) p->addr) ||
8221 + is_module_text_address((unsigned long) p->addr)) ||
8222 within_kprobe_blacklist((unsigned long) p->addr) ||
8223 jump_label_text_reserved(p->addr, p->addr) ||
8224 find_bug((unsigned long)p->addr)) {
8225 diff --git a/kernel/power/user.c b/kernel/power/user.c
8226 index 77438954cc2b0..672d4e28fa8a9 100644
8227 --- a/kernel/power/user.c
8228 +++ b/kernel/power/user.c
8229 @@ -26,6 +26,7 @@
8230
8231 #include "power.h"
8232
8233 +static bool need_wait;
8234
8235 #define SNAPSHOT_MINOR 231
8236
8237 @@ -79,7 +80,7 @@ static int snapshot_open(struct inode *inode, struct file *filp)
8238 * Resuming. We may need to wait for the image device to
8239 * appear.
8240 */
8241 - wait_for_device_probe();
8242 + need_wait = true;
8243
8244 data->swap = -1;
8245 data->mode = O_WRONLY;
8246 @@ -171,6 +172,11 @@ static ssize_t snapshot_write(struct file *filp, const char __user *buf,
8247 ssize_t res;
8248 loff_t pg_offp = *offp & ~PAGE_MASK;
8249
8250 + if (need_wait) {
8251 + wait_for_device_probe();
8252 + need_wait = false;
8253 + }
8254 +
8255 lock_system_sleep();
8256
8257 data = filp->private_data;
8258 @@ -206,6 +212,11 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
8259 loff_t size;
8260 sector_t offset;
8261
8262 + if (need_wait) {
8263 + wait_for_device_probe();
8264 + need_wait = false;
8265 + }
8266 +
8267 if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
8268 return -ENOTTY;
8269 if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
8270 diff --git a/kernel/profile.c b/kernel/profile.c
8271 index e97e42aaf2023..b5ce18b6f1b9e 100644
8272 --- a/kernel/profile.c
8273 +++ b/kernel/profile.c
8274 @@ -109,6 +109,13 @@ int __ref profile_init(void)
8275
8276 /* only text is profiled */
8277 prof_len = (_etext - _stext) >> prof_shift;
8278 +
8279 + if (!prof_len) {
8280 + pr_warn("profiling shift: %u too large\n", prof_shift);
8281 + prof_on = 0;
8282 + return -EINVAL;
8283 + }
8284 +
8285 buffer_bytes = prof_len*sizeof(atomic_t);
8286
8287 if (!alloc_cpumask_var(&prof_cpu_mask, GFP_KERNEL))
8288 diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
8289 index 28c82dee13ea9..c11d3d79d4c31 100644
8290 --- a/kernel/sched/rt.c
8291 +++ b/kernel/sched/rt.c
8292 @@ -437,7 +437,7 @@ static inline void rt_queue_push_tasks(struct rq *rq)
8293 #endif /* CONFIG_SMP */
8294
8295 static void enqueue_top_rt_rq(struct rt_rq *rt_rq);
8296 -static void dequeue_top_rt_rq(struct rt_rq *rt_rq);
8297 +static void dequeue_top_rt_rq(struct rt_rq *rt_rq, unsigned int count);
8298
8299 static inline int on_rt_rq(struct sched_rt_entity *rt_se)
8300 {
8301 @@ -519,7 +519,7 @@ static void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
8302 rt_se = rt_rq->tg->rt_se[cpu];
8303
8304 if (!rt_se) {
8305 - dequeue_top_rt_rq(rt_rq);
8306 + dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
8307 /* Kick cpufreq (see the comment in kernel/sched/sched.h). */
8308 cpufreq_update_util(rq_of_rt_rq(rt_rq), 0);
8309 }
8310 @@ -605,7 +605,7 @@ static inline void sched_rt_rq_enqueue(struct rt_rq *rt_rq)
8311
8312 static inline void sched_rt_rq_dequeue(struct rt_rq *rt_rq)
8313 {
8314 - dequeue_top_rt_rq(rt_rq);
8315 + dequeue_top_rt_rq(rt_rq, rt_rq->rt_nr_running);
8316 }
8317
8318 static inline int rt_rq_throttled(struct rt_rq *rt_rq)
8319 @@ -1004,7 +1004,7 @@ static void update_curr_rt(struct rq *rq)
8320 }
8321
8322 static void
8323 -dequeue_top_rt_rq(struct rt_rq *rt_rq)
8324 +dequeue_top_rt_rq(struct rt_rq *rt_rq, unsigned int count)
8325 {
8326 struct rq *rq = rq_of_rt_rq(rt_rq);
8327
8328 @@ -1015,7 +1015,7 @@ dequeue_top_rt_rq(struct rt_rq *rt_rq)
8329
8330 BUG_ON(!rq->nr_running);
8331
8332 - sub_nr_running(rq, rt_rq->rt_nr_running);
8333 + sub_nr_running(rq, count);
8334 rt_rq->rt_queued = 0;
8335
8336 }
8337 @@ -1294,18 +1294,21 @@ static void __dequeue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flag
8338 static void dequeue_rt_stack(struct sched_rt_entity *rt_se, unsigned int flags)
8339 {
8340 struct sched_rt_entity *back = NULL;
8341 + unsigned int rt_nr_running;
8342
8343 for_each_sched_rt_entity(rt_se) {
8344 rt_se->back = back;
8345 back = rt_se;
8346 }
8347
8348 - dequeue_top_rt_rq(rt_rq_of_se(back));
8349 + rt_nr_running = rt_rq_of_se(back)->rt_nr_running;
8350
8351 for (rt_se = back; rt_se; rt_se = rt_se->back) {
8352 if (on_rt_rq(rt_se))
8353 __dequeue_rt_entity(rt_se, flags);
8354 }
8355 +
8356 + dequeue_top_rt_rq(rt_rq_of_se(back), rt_nr_running);
8357 }
8358
8359 static void enqueue_rt_entity(struct sched_rt_entity *rt_se, unsigned int flags)
8360 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
8361 index e23c9e765a5ff..2bc278dd98546 100644
8362 --- a/kernel/time/timekeeping.c
8363 +++ b/kernel/time/timekeeping.c
8364 @@ -23,6 +23,7 @@
8365 #include <linux/pvclock_gtod.h>
8366 #include <linux/compiler.h>
8367 #include <linux/audit.h>
8368 +#include <linux/random.h>
8369
8370 #include "tick-internal.h"
8371 #include "ntp_internal.h"
8372 @@ -1256,8 +1257,10 @@ out:
8373 /* signal hrtimers about time change */
8374 clock_was_set();
8375
8376 - if (!ret)
8377 + if (!ret) {
8378 audit_tk_injoffset(ts_delta);
8379 + add_device_randomness(ts, sizeof(*ts));
8380 + }
8381
8382 return ret;
8383 }
8384 @@ -2336,6 +2339,7 @@ int do_adjtimex(struct __kernel_timex *txc)
8385 ret = timekeeping_validate_timex(txc);
8386 if (ret)
8387 return ret;
8388 + add_device_randomness(txc, sizeof(*txc));
8389
8390 if (txc->modes & ADJ_SETOFFSET) {
8391 struct timespec64 delta;
8392 @@ -2353,6 +2357,7 @@ int do_adjtimex(struct __kernel_timex *txc)
8393 audit_ntp_init(&ad);
8394
8395 ktime_get_real_ts64(&ts);
8396 + add_device_randomness(&ts, sizeof(ts));
8397
8398 raw_spin_lock_irqsave(&timekeeper_lock, flags);
8399 write_seqcount_begin(&tk_core.seq);
8400 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
8401 index 4acc77e049e5f..047a89b815a32 100644
8402 --- a/kernel/trace/trace_events.c
8403 +++ b/kernel/trace/trace_events.c
8404 @@ -166,6 +166,7 @@ static int trace_define_generic_fields(void)
8405
8406 __generic_field(int, CPU, FILTER_CPU);
8407 __generic_field(int, cpu, FILTER_CPU);
8408 + __generic_field(int, common_cpu, FILTER_CPU);
8409 __generic_field(char *, COMM, FILTER_COMM);
8410 __generic_field(char *, comm, FILTER_COMM);
8411
8412 diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c
8413 index 23e85cb151346..476a685c6b6cf 100644
8414 --- a/kernel/trace/trace_probe.c
8415 +++ b/kernel/trace/trace_probe.c
8416 @@ -300,7 +300,7 @@ static int parse_probe_vars(char *arg, const struct fetch_type *t,
8417 }
8418 } else
8419 goto inval_var;
8420 - } else if (strcmp(arg, "comm") == 0) {
8421 + } else if (strcmp(arg, "comm") == 0 || strcmp(arg, "COMM") == 0) {
8422 code->op = FETCH_OP_COMM;
8423 #ifdef CONFIG_HAVE_FUNCTION_ARG_ACCESS_API
8424 } else if (((flags & TPARG_FL_MASK) ==
8425 @@ -595,7 +595,8 @@ static int traceprobe_parse_probe_arg_body(char *arg, ssize_t *size,
8426 * Since $comm and immediate string can not be dereferred,
8427 * we can find those by strcmp.
8428 */
8429 - if (strcmp(arg, "$comm") == 0 || strncmp(arg, "\\\"", 2) == 0) {
8430 + if (strcmp(arg, "$comm") == 0 || strcmp(arg, "$COMM") == 0 ||
8431 + strncmp(arg, "\\\"", 2) == 0) {
8432 /* The type of $comm must be "string", and not an array. */
8433 if (parg->count || (t && strcmp(t, "string")))
8434 return -EINVAL;
8435 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
8436 index cbd3cf503c904..a3d0e928305c3 100644
8437 --- a/kernel/watchdog.c
8438 +++ b/kernel/watchdog.c
8439 @@ -568,7 +568,7 @@ int lockup_detector_offline_cpu(unsigned int cpu)
8440 return 0;
8441 }
8442
8443 -static void lockup_detector_reconfigure(void)
8444 +static void __lockup_detector_reconfigure(void)
8445 {
8446 cpus_read_lock();
8447 watchdog_nmi_stop();
8448 @@ -588,6 +588,13 @@ static void lockup_detector_reconfigure(void)
8449 __lockup_detector_cleanup();
8450 }
8451
8452 +void lockup_detector_reconfigure(void)
8453 +{
8454 + mutex_lock(&watchdog_mutex);
8455 + __lockup_detector_reconfigure();
8456 + mutex_unlock(&watchdog_mutex);
8457 +}
8458 +
8459 /*
8460 * Create the watchdog thread infrastructure and configure the detector(s).
8461 *
8462 @@ -608,13 +615,13 @@ static __init void lockup_detector_setup(void)
8463 return;
8464
8465 mutex_lock(&watchdog_mutex);
8466 - lockup_detector_reconfigure();
8467 + __lockup_detector_reconfigure();
8468 softlockup_initialized = true;
8469 mutex_unlock(&watchdog_mutex);
8470 }
8471
8472 #else /* CONFIG_SOFTLOCKUP_DETECTOR */
8473 -static void lockup_detector_reconfigure(void)
8474 +static void __lockup_detector_reconfigure(void)
8475 {
8476 cpus_read_lock();
8477 watchdog_nmi_stop();
8478 @@ -622,9 +629,13 @@ static void lockup_detector_reconfigure(void)
8479 watchdog_nmi_start();
8480 cpus_read_unlock();
8481 }
8482 +void lockup_detector_reconfigure(void)
8483 +{
8484 + __lockup_detector_reconfigure();
8485 +}
8486 static inline void lockup_detector_setup(void)
8487 {
8488 - lockup_detector_reconfigure();
8489 + __lockup_detector_reconfigure();
8490 }
8491 #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */
8492
8493 @@ -664,7 +675,7 @@ static void proc_watchdog_update(void)
8494 {
8495 /* Remove impossible cpus to keep sysctl output clean. */
8496 cpumask_and(&watchdog_cpumask, &watchdog_cpumask, cpu_possible_mask);
8497 - lockup_detector_reconfigure();
8498 + __lockup_detector_reconfigure();
8499 }
8500
8501 /*
8502 diff --git a/lib/list_debug.c b/lib/list_debug.c
8503 index 5d5424b51b746..413daa72a3d83 100644
8504 --- a/lib/list_debug.c
8505 +++ b/lib/list_debug.c
8506 @@ -20,7 +20,11 @@
8507 bool __list_add_valid(struct list_head *new, struct list_head *prev,
8508 struct list_head *next)
8509 {
8510 - if (CHECK_DATA_CORRUPTION(next->prev != prev,
8511 + if (CHECK_DATA_CORRUPTION(prev == NULL,
8512 + "list_add corruption. prev is NULL.\n") ||
8513 + CHECK_DATA_CORRUPTION(next == NULL,
8514 + "list_add corruption. next is NULL.\n") ||
8515 + CHECK_DATA_CORRUPTION(next->prev != prev,
8516 "list_add corruption. next->prev should be prev (%px), but was %px. (next=%px).\n",
8517 prev, next->prev, next) ||
8518 CHECK_DATA_CORRUPTION(prev->next != next,
8519 @@ -42,7 +46,11 @@ bool __list_del_entry_valid(struct list_head *entry)
8520 prev = entry->prev;
8521 next = entry->next;
8522
8523 - if (CHECK_DATA_CORRUPTION(next == LIST_POISON1,
8524 + if (CHECK_DATA_CORRUPTION(next == NULL,
8525 + "list_del corruption, %px->next is NULL\n", entry) ||
8526 + CHECK_DATA_CORRUPTION(prev == NULL,
8527 + "list_del corruption, %px->prev is NULL\n", entry) ||
8528 + CHECK_DATA_CORRUPTION(next == LIST_POISON1,
8529 "list_del corruption, %px->next is LIST_POISON1 (%px)\n",
8530 entry, LIST_POISON1) ||
8531 CHECK_DATA_CORRUPTION(prev == LIST_POISON2,
8532 diff --git a/mm/mmap.c b/mm/mmap.c
8533 index 88e6863677768..8873ef114d280 100644
8534 --- a/mm/mmap.c
8535 +++ b/mm/mmap.c
8536 @@ -1860,7 +1860,6 @@ unmap_and_free_vma:
8537
8538 /* Undo any partial mapping done by a device driver. */
8539 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
8540 - charged = 0;
8541 if (vm_flags & VM_SHARED)
8542 mapping_unmap_writable(file->f_mapping);
8543 allow_write_and_free_vma:
8544 diff --git a/mm/mremap.c b/mm/mremap.c
8545 index 8ce1b7632fbb8..f6b8c009dd05e 100644
8546 --- a/mm/mremap.c
8547 +++ b/mm/mremap.c
8548 @@ -293,12 +293,10 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
8549 */
8550 bool moved;
8551
8552 - if (need_rmap_locks)
8553 - take_rmap_locks(vma);
8554 + take_rmap_locks(vma);
8555 moved = move_normal_pmd(vma, old_addr, new_addr,
8556 old_end, old_pmd, new_pmd);
8557 - if (need_rmap_locks)
8558 - drop_rmap_locks(vma);
8559 + drop_rmap_locks(vma);
8560 if (moved)
8561 continue;
8562 #endif
8563 diff --git a/net/9p/client.c b/net/9p/client.c
8564 index b03fce66eb8de..9368a1c0196d1 100644
8565 --- a/net/9p/client.c
8566 +++ b/net/9p/client.c
8567 @@ -893,16 +893,13 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt)
8568 struct p9_fid *fid;
8569
8570 p9_debug(P9_DEBUG_FID, "clnt %p\n", clnt);
8571 - fid = kmalloc(sizeof(struct p9_fid), GFP_KERNEL);
8572 + fid = kzalloc(sizeof(struct p9_fid), GFP_KERNEL);
8573 if (!fid)
8574 return NULL;
8575
8576 - memset(&fid->qid, 0, sizeof(struct p9_qid));
8577 fid->mode = -1;
8578 fid->uid = current_fsuid();
8579 fid->clnt = clnt;
8580 - fid->rdir = NULL;
8581 - fid->fid = 0;
8582
8583 idr_preload(GFP_KERNEL);
8584 spin_lock_irq(&clnt->lock);
8585 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
8586 index 286fca6a9ab2a..7aa64f300422e 100644
8587 --- a/net/bluetooth/l2cap_core.c
8588 +++ b/net/bluetooth/l2cap_core.c
8589 @@ -1813,11 +1813,11 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
8590 bdaddr_t *dst,
8591 u8 link_type)
8592 {
8593 - struct l2cap_chan *c, *c1 = NULL;
8594 + struct l2cap_chan *c, *tmp, *c1 = NULL;
8595
8596 read_lock(&chan_list_lock);
8597
8598 - list_for_each_entry(c, &chan_list, global_l) {
8599 + list_for_each_entry_safe(c, tmp, &chan_list, global_l) {
8600 if (state && c->state != state)
8601 continue;
8602
8603 @@ -1836,11 +1836,10 @@ static struct l2cap_chan *l2cap_global_chan_by_psm(int state, __le16 psm,
8604 dst_match = !bacmp(&c->dst, dst);
8605 if (src_match && dst_match) {
8606 c = l2cap_chan_hold_unless_zero(c);
8607 - if (!c)
8608 - continue;
8609 -
8610 - read_unlock(&chan_list_lock);
8611 - return c;
8612 + if (c) {
8613 + read_unlock(&chan_list_lock);
8614 + return c;
8615 + }
8616 }
8617
8618 /* Closest match */
8619 diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c
8620 index 51bfb220fad85..8817a258e73b9 100644
8621 --- a/net/can/j1939/socket.c
8622 +++ b/net/can/j1939/socket.c
8623 @@ -178,7 +178,10 @@ activate_next:
8624 if (!first)
8625 return;
8626
8627 - if (WARN_ON_ONCE(j1939_session_activate(first))) {
8628 + if (j1939_session_activate(first)) {
8629 + netdev_warn_once(first->priv->ndev,
8630 + "%s: 0x%p: Identical session is already activated.\n",
8631 + __func__, first);
8632 first->err = -EBUSY;
8633 goto activate_next;
8634 } else {
8635 diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c
8636 index 22f4b798d385b..6d31555e536e0 100644
8637 --- a/net/can/j1939/transport.c
8638 +++ b/net/can/j1939/transport.c
8639 @@ -260,6 +260,8 @@ static void __j1939_session_drop(struct j1939_session *session)
8640
8641 static void j1939_session_destroy(struct j1939_session *session)
8642 {
8643 + struct sk_buff *skb;
8644 +
8645 if (session->err)
8646 j1939_sk_errqueue(session, J1939_ERRQUEUE_ABORT);
8647 else
8648 @@ -270,7 +272,11 @@ static void j1939_session_destroy(struct j1939_session *session)
8649 WARN_ON_ONCE(!list_empty(&session->sk_session_queue_entry));
8650 WARN_ON_ONCE(!list_empty(&session->active_session_list_entry));
8651
8652 - skb_queue_purge(&session->skb_queue);
8653 + while ((skb = skb_dequeue(&session->skb_queue)) != NULL) {
8654 + /* drop ref taken in j1939_session_skb_queue() */
8655 + skb_unref(skb);
8656 + kfree_skb(skb);
8657 + }
8658 __j1939_session_drop(session);
8659 j1939_priv_put(session->priv);
8660 kfree(session);
8661 diff --git a/net/core/devlink.c b/net/core/devlink.c
8662 index 0ac02cab3087b..2dd354d869cd7 100644
8663 --- a/net/core/devlink.c
8664 +++ b/net/core/devlink.c
8665 @@ -2953,7 +2953,7 @@ static int devlink_param_get(struct devlink *devlink,
8666 const struct devlink_param *param,
8667 struct devlink_param_gset_ctx *ctx)
8668 {
8669 - if (!param->get)
8670 + if (!param->get || devlink->reload_failed)
8671 return -EOPNOTSUPP;
8672 return param->get(devlink, param->id, ctx);
8673 }
8674 @@ -2962,7 +2962,7 @@ static int devlink_param_set(struct devlink *devlink,
8675 const struct devlink_param *param,
8676 struct devlink_param_gset_ctx *ctx)
8677 {
8678 - if (!param->set)
8679 + if (!param->set || devlink->reload_failed)
8680 return -EOPNOTSUPP;
8681 return param->set(devlink, param->id, ctx);
8682 }
8683 diff --git a/net/dccp/proto.c b/net/dccp/proto.c
8684 index cb61a9d281f66..951cbdf05ffe9 100644
8685 --- a/net/dccp/proto.c
8686 +++ b/net/dccp/proto.c
8687 @@ -765,11 +765,6 @@ int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
8688
8689 lock_sock(sk);
8690
8691 - if (dccp_qpolicy_full(sk)) {
8692 - rc = -EAGAIN;
8693 - goto out_release;
8694 - }
8695 -
8696 timeo = sock_sndtimeo(sk, noblock);
8697
8698 /*
8699 @@ -788,6 +783,11 @@ int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
8700 if (skb == NULL)
8701 goto out_release;
8702
8703 + if (dccp_qpolicy_full(sk)) {
8704 + rc = -EAGAIN;
8705 + goto out_discard;
8706 + }
8707 +
8708 if (sk->sk_state == DCCP_CLOSED) {
8709 rc = -ENOTCONN;
8710 goto out_discard;
8711 diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
8712 index ef749a47768a5..c37028af0db04 100644
8713 --- a/net/ipv4/tcp_output.c
8714 +++ b/net/ipv4/tcp_output.c
8715 @@ -2911,7 +2911,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
8716 struct tcp_sock *tp = tcp_sk(sk);
8717 unsigned int cur_mss;
8718 int diff, len, err;
8719 -
8720 + int avail_wnd;
8721
8722 /* Inconclusive MTU probe */
8723 if (icsk->icsk_mtup.probe_size)
8724 @@ -2941,17 +2941,25 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
8725 return -EHOSTUNREACH; /* Routing failure or similar. */
8726
8727 cur_mss = tcp_current_mss(sk);
8728 + avail_wnd = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq;
8729
8730 /* If receiver has shrunk his window, and skb is out of
8731 * new window, do not retransmit it. The exception is the
8732 * case, when window is shrunk to zero. In this case
8733 - * our retransmit serves as a zero window probe.
8734 + * our retransmit of one segment serves as a zero window probe.
8735 */
8736 - if (!before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp)) &&
8737 - TCP_SKB_CB(skb)->seq != tp->snd_una)
8738 - return -EAGAIN;
8739 + if (avail_wnd <= 0) {
8740 + if (TCP_SKB_CB(skb)->seq != tp->snd_una)
8741 + return -EAGAIN;
8742 + avail_wnd = cur_mss;
8743 + }
8744
8745 len = cur_mss * segs;
8746 + if (len > avail_wnd) {
8747 + len = rounddown(avail_wnd, cur_mss);
8748 + if (!len)
8749 + len = avail_wnd;
8750 + }
8751 if (skb->len > len) {
8752 if (tcp_fragment(sk, TCP_FRAG_IN_RTX_QUEUE, skb, len,
8753 cur_mss, GFP_ATOMIC))
8754 @@ -2965,8 +2973,9 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
8755 diff -= tcp_skb_pcount(skb);
8756 if (diff)
8757 tcp_adjust_pcount(sk, skb, diff);
8758 - if (skb->len < cur_mss)
8759 - tcp_retrans_try_collapse(sk, skb, cur_mss);
8760 + avail_wnd = min_t(int, avail_wnd, cur_mss);
8761 + if (skb->len < avail_wnd)
8762 + tcp_retrans_try_collapse(sk, skb, avail_wnd);
8763 }
8764
8765 /* RFC3168, section 6.1.1.1. ECN fallback */
8766 @@ -3134,11 +3143,12 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
8767 */
8768 void sk_forced_mem_schedule(struct sock *sk, int size)
8769 {
8770 - int amt;
8771 + int delta, amt;
8772
8773 - if (size <= sk->sk_forward_alloc)
8774 + delta = size - sk->sk_forward_alloc;
8775 + if (delta <= 0)
8776 return;
8777 - amt = sk_mem_pages(size);
8778 + amt = sk_mem_pages(delta);
8779 sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
8780 sk_memory_allocated_add(sk, amt);
8781
8782 diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
8783 index 58a7d89719b1d..f9cecd30f1bad 100644
8784 --- a/net/netfilter/nf_tables_api.c
8785 +++ b/net/netfilter/nf_tables_api.c
8786 @@ -113,6 +113,7 @@ static struct nft_trans *nft_trans_alloc_gfp(const struct nft_ctx *ctx,
8787 if (trans == NULL)
8788 return NULL;
8789
8790 + INIT_LIST_HEAD(&trans->list);
8791 trans->msg_type = msg_type;
8792 trans->ctx = *ctx;
8793
8794 @@ -2713,6 +2714,7 @@ static int nft_table_validate(struct net *net, const struct nft_table *table)
8795 }
8796
8797 static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
8798 + const struct nft_chain *chain,
8799 const struct nlattr *nla);
8800
8801 #define NFT_RULE_MAXEXPRS 128
8802 @@ -2786,7 +2788,7 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
8803 return PTR_ERR(old_rule);
8804 }
8805 } else if (nla[NFTA_RULE_POSITION_ID]) {
8806 - old_rule = nft_rule_lookup_byid(net, nla[NFTA_RULE_POSITION_ID]);
8807 + old_rule = nft_rule_lookup_byid(net, chain, nla[NFTA_RULE_POSITION_ID]);
8808 if (IS_ERR(old_rule)) {
8809 NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_POSITION_ID]);
8810 return PTR_ERR(old_rule);
8811 @@ -2921,6 +2923,7 @@ err1:
8812 }
8813
8814 static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
8815 + const struct nft_chain *chain,
8816 const struct nlattr *nla)
8817 {
8818 u32 id = ntohl(nla_get_be32(nla));
8819 @@ -2930,6 +2933,7 @@ static struct nft_rule *nft_rule_lookup_byid(const struct net *net,
8820 struct nft_rule *rule = nft_trans_rule(trans);
8821
8822 if (trans->msg_type == NFT_MSG_NEWRULE &&
8823 + trans->ctx.chain == chain &&
8824 id == nft_trans_rule_id(trans))
8825 return rule;
8826 }
8827 @@ -2976,7 +2980,7 @@ static int nf_tables_delrule(struct net *net, struct sock *nlsk,
8828
8829 err = nft_delrule(&ctx, rule);
8830 } else if (nla[NFTA_RULE_ID]) {
8831 - rule = nft_rule_lookup_byid(net, nla[NFTA_RULE_ID]);
8832 + rule = nft_rule_lookup_byid(net, chain, nla[NFTA_RULE_ID]);
8833 if (IS_ERR(rule)) {
8834 NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_ID]);
8835 return PTR_ERR(rule);
8836 @@ -3191,6 +3195,7 @@ static struct nft_set *nft_set_lookup_byhandle(const struct nft_table *table,
8837 }
8838
8839 static struct nft_set *nft_set_lookup_byid(const struct net *net,
8840 + const struct nft_table *table,
8841 const struct nlattr *nla, u8 genmask)
8842 {
8843 struct nft_trans *trans;
8844 @@ -3201,6 +3206,7 @@ static struct nft_set *nft_set_lookup_byid(const struct net *net,
8845 struct nft_set *set = nft_trans_set(trans);
8846
8847 if (id == nft_trans_set_id(trans) &&
8848 + set->table == table &&
8849 nft_active_genmask(set, genmask))
8850 return set;
8851 }
8852 @@ -3221,7 +3227,7 @@ struct nft_set *nft_set_lookup_global(const struct net *net,
8853 if (!nla_set_id)
8854 return set;
8855
8856 - set = nft_set_lookup_byid(net, nla_set_id, genmask);
8857 + set = nft_set_lookup_byid(net, table, nla_set_id, genmask);
8858 }
8859 return set;
8860 }
8861 @@ -3247,7 +3253,7 @@ cont:
8862 list_for_each_entry(i, &ctx->table->sets, list) {
8863 int tmp;
8864
8865 - if (!nft_is_active_next(ctx->net, set))
8866 + if (!nft_is_active_next(ctx->net, i))
8867 continue;
8868 if (!sscanf(i->name, name, &tmp))
8869 continue;
8870 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
8871 index a0f99bbf362ca..6dd3f45df9ca6 100644
8872 --- a/net/rds/ib_recv.c
8873 +++ b/net/rds/ib_recv.c
8874 @@ -363,6 +363,7 @@ static int acquire_refill(struct rds_connection *conn)
8875 static void release_refill(struct rds_connection *conn)
8876 {
8877 clear_bit(RDS_RECV_REFILL, &conn->c_flags);
8878 + smp_mb__after_atomic();
8879
8880 /* We don't use wait_on_bit()/wake_up_bit() because our waking is in a
8881 * hot path and finding waiters is very rare. We don't want to walk
8882 diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
8883 index 6a0df7c8a939e..95dda29058a0e 100644
8884 --- a/net/rose/af_rose.c
8885 +++ b/net/rose/af_rose.c
8886 @@ -169,6 +169,7 @@ static void rose_kill_by_device(struct net_device *dev)
8887 rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
8888 if (rose->neighbour)
8889 rose->neighbour->use--;
8890 + dev_put(rose->device);
8891 rose->device = NULL;
8892 }
8893 }
8894 @@ -569,6 +570,8 @@ static struct sock *rose_make_new(struct sock *osk)
8895 rose->idle = orose->idle;
8896 rose->defer = orose->defer;
8897 rose->device = orose->device;
8898 + if (rose->device)
8899 + dev_hold(rose->device);
8900 rose->qbitincl = orose->qbitincl;
8901
8902 return sk;
8903 @@ -622,6 +625,7 @@ static int rose_release(struct socket *sock)
8904 break;
8905 }
8906
8907 + dev_put(rose->device);
8908 sock->sk = NULL;
8909 release_sock(sk);
8910 sock_put(sk);
8911 @@ -698,7 +702,6 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
8912 struct rose_sock *rose = rose_sk(sk);
8913 struct sockaddr_rose *addr = (struct sockaddr_rose *)uaddr;
8914 unsigned char cause, diagnostic;
8915 - struct net_device *dev;
8916 ax25_uid_assoc *user;
8917 int n, err = 0;
8918
8919 @@ -755,9 +758,12 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
8920 }
8921
8922 if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */
8923 + struct net_device *dev;
8924 +
8925 sock_reset_flag(sk, SOCK_ZAPPED);
8926
8927 - if ((dev = rose_dev_first()) == NULL) {
8928 + dev = rose_dev_first();
8929 + if (!dev) {
8930 err = -ENETUNREACH;
8931 goto out_release;
8932 }
8933 @@ -765,6 +771,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le
8934 user = ax25_findbyuid(current_euid());
8935 if (!user) {
8936 err = -EINVAL;
8937 + dev_put(dev);
8938 goto out_release;
8939 }
8940
8941 diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
8942 index 5f32113c9bbda..64d441d3b6533 100644
8943 --- a/net/rose/rose_route.c
8944 +++ b/net/rose/rose_route.c
8945 @@ -613,6 +613,8 @@ struct net_device *rose_dev_first(void)
8946 if (first == NULL || strncmp(dev->name, first->name, 3) < 0)
8947 first = dev;
8948 }
8949 + if (first)
8950 + dev_hold(first);
8951 rcu_read_unlock();
8952
8953 return first;
8954 diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
8955 index 5efa3e7ace152..b775e681cb56e 100644
8956 --- a/net/sched/cls_route.c
8957 +++ b/net/sched/cls_route.c
8958 @@ -424,6 +424,11 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
8959 return -EINVAL;
8960 }
8961
8962 + if (!nhandle) {
8963 + NL_SET_ERR_MSG(extack, "Replacing with handle of 0 is invalid");
8964 + return -EINVAL;
8965 + }
8966 +
8967 h1 = to_hash(nhandle);
8968 b = rtnl_dereference(head->table[h1]);
8969 if (!b) {
8970 @@ -477,6 +482,11 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
8971 int err;
8972 bool new = true;
8973
8974 + if (!handle) {
8975 + NL_SET_ERR_MSG(extack, "Creating with handle of 0 is invalid");
8976 + return -EINVAL;
8977 + }
8978 +
8979 if (opt == NULL)
8980 return handle ? -EINVAL : 0;
8981
8982 @@ -526,7 +536,7 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
8983 rcu_assign_pointer(f->next, f1);
8984 rcu_assign_pointer(*fp, f);
8985
8986 - if (fold && fold->handle && f->handle != fold->handle) {
8987 + if (fold) {
8988 th = to_hash(fold->handle);
8989 h = from_hash(fold->handle >> 16);
8990 b = rtnl_dereference(head->table[th]);
8991 diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
8992 index cdb05b48de449..e8fa21ad06a07 100644
8993 --- a/net/sunrpc/auth.c
8994 +++ b/net/sunrpc/auth.c
8995 @@ -494,7 +494,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
8996 * Enforce a 60 second garbage collection moratorium
8997 * Note that the cred_unused list must be time-ordered.
8998 */
8999 - if (!time_in_range(cred->cr_expire, expired, jiffies))
9000 + if (time_in_range(cred->cr_expire, expired, jiffies))
9001 continue;
9002 if (!rpcauth_unhash_cred(cred))
9003 continue;
9004 diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
9005 index 195b40c5dae4b..266f3e5f55dec 100644
9006 --- a/net/sunrpc/backchannel_rqst.c
9007 +++ b/net/sunrpc/backchannel_rqst.c
9008 @@ -64,6 +64,17 @@ static void xprt_free_allocation(struct rpc_rqst *req)
9009 kfree(req);
9010 }
9011
9012 +static void xprt_bc_reinit_xdr_buf(struct xdr_buf *buf)
9013 +{
9014 + buf->head[0].iov_len = PAGE_SIZE;
9015 + buf->tail[0].iov_len = 0;
9016 + buf->pages = NULL;
9017 + buf->page_len = 0;
9018 + buf->flags = 0;
9019 + buf->len = 0;
9020 + buf->buflen = PAGE_SIZE;
9021 +}
9022 +
9023 static int xprt_alloc_xdr_buf(struct xdr_buf *buf, gfp_t gfp_flags)
9024 {
9025 struct page *page;
9026 @@ -292,6 +303,9 @@ void xprt_free_bc_rqst(struct rpc_rqst *req)
9027 */
9028 spin_lock_bh(&xprt->bc_pa_lock);
9029 if (xprt_need_to_requeue(xprt)) {
9030 + xprt_bc_reinit_xdr_buf(&req->rq_snd_buf);
9031 + xprt_bc_reinit_xdr_buf(&req->rq_rcv_buf);
9032 + req->rq_rcv_buf.len = PAGE_SIZE;
9033 list_add_tail(&req->rq_bc_pa_list, &xprt->bc_pa_list);
9034 xprt->bc_alloc_count++;
9035 atomic_inc(&xprt->bc_slot_count);
9036 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
9037 index d60d7caacbf5d..28f6188458c42 100644
9038 --- a/net/vmw_vsock/af_vsock.c
9039 +++ b/net/vmw_vsock/af_vsock.c
9040 @@ -1110,6 +1110,7 @@ static void vsock_connect_timeout(struct work_struct *work)
9041 if (sk->sk_state == TCP_SYN_SENT &&
9042 (sk->sk_shutdown != SHUTDOWN_MASK)) {
9043 sk->sk_state = TCP_CLOSE;
9044 + sk->sk_socket->state = SS_UNCONNECTED;
9045 sk->sk_err = ETIMEDOUT;
9046 sk->sk_error_report(sk);
9047 vsock_transport_cancel_pkt(vsk);
9048 @@ -1207,7 +1208,14 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
9049 * timeout fires.
9050 */
9051 sock_hold(sk);
9052 - schedule_delayed_work(&vsk->connect_work, timeout);
9053 +
9054 + /* If the timeout function is already scheduled,
9055 + * reschedule it, then ungrab the socket refcount to
9056 + * keep it balanced.
9057 + */
9058 + if (mod_delayed_work(system_wq, &vsk->connect_work,
9059 + timeout))
9060 + sock_put(sk);
9061
9062 /* Skip ahead to preserve error code set above. */
9063 goto out_wait;
9064 diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
9065 index 63d21489216b0..ba4e271702c6f 100644
9066 --- a/scripts/Makefile.gcc-plugins
9067 +++ b/scripts/Makefile.gcc-plugins
9068 @@ -6,7 +6,7 @@ gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so
9069 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \
9070 += -DLATENT_ENTROPY_PLUGIN
9071 ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
9072 - DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
9073 + DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable -ULATENT_ENTROPY_PLUGIN
9074 endif
9075 export DISABLE_LATENT_ENTROPY_PLUGIN
9076
9077 diff --git a/scripts/faddr2line b/scripts/faddr2line
9078 index 94ed98dd899f3..57099687e5e1d 100755
9079 --- a/scripts/faddr2line
9080 +++ b/scripts/faddr2line
9081 @@ -112,7 +112,9 @@ __faddr2line() {
9082 # section offsets.
9083 local file_type=$(${READELF} --file-header $objfile |
9084 ${AWK} '$1 == "Type:" { print $2; exit }')
9085 - [[ $file_type = "EXEC" ]] && is_vmlinux=1
9086 + if [[ $file_type = "EXEC" ]] || [[ $file_type == "DYN" ]]; then
9087 + is_vmlinux=1
9088 + fi
9089
9090 # Go through each of the object's symbols which match the func name.
9091 # In rare cases there might be duplicates, in which case we print all
9092 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
9093 index 7a8813677950f..84daab8ae0621 100644
9094 --- a/security/apparmor/apparmorfs.c
9095 +++ b/security/apparmor/apparmorfs.c
9096 @@ -403,7 +403,7 @@ static struct aa_loaddata *aa_simple_write_to_buffer(const char __user *userbuf,
9097
9098 data->size = copy_size;
9099 if (copy_from_user(data->data, userbuf, copy_size)) {
9100 - kvfree(data);
9101 + aa_put_loaddata(data);
9102 return ERR_PTR(-EFAULT);
9103 }
9104
9105 diff --git a/security/apparmor/audit.c b/security/apparmor/audit.c
9106 index 5977325038157..68e06d87908ec 100644
9107 --- a/security/apparmor/audit.c
9108 +++ b/security/apparmor/audit.c
9109 @@ -139,7 +139,7 @@ int aa_audit(int type, struct aa_profile *profile, struct common_audit_data *sa,
9110 }
9111 if (AUDIT_MODE(profile) == AUDIT_QUIET ||
9112 (type == AUDIT_APPARMOR_DENIED &&
9113 - AUDIT_MODE(profile) == AUDIT_QUIET))
9114 + AUDIT_MODE(profile) == AUDIT_QUIET_DENIED))
9115 return aad(sa)->error;
9116
9117 if (KILL_MODE(profile) && type == AUDIT_APPARMOR_DENIED)
9118 diff --git a/security/apparmor/domain.c b/security/apparmor/domain.c
9119 index 1a33f490e6670..2f61b4cc2fc0d 100644
9120 --- a/security/apparmor/domain.c
9121 +++ b/security/apparmor/domain.c
9122 @@ -460,7 +460,7 @@ restart:
9123 * xattrs, or a longer match
9124 */
9125 candidate = profile;
9126 - candidate_len = profile->xmatch_len;
9127 + candidate_len = max(count, profile->xmatch_len);
9128 candidate_xattrs = ret;
9129 conflict = false;
9130 }
9131 diff --git a/security/apparmor/include/lib.h b/security/apparmor/include/lib.h
9132 index 7d27db740bc2f..ac5054899f6f4 100644
9133 --- a/security/apparmor/include/lib.h
9134 +++ b/security/apparmor/include/lib.h
9135 @@ -22,6 +22,11 @@
9136 */
9137
9138 #define DEBUG_ON (aa_g_debug)
9139 +/*
9140 + * split individual debug cases out in preparation for finer grained
9141 + * debug controls in the future.
9142 + */
9143 +#define AA_DEBUG_LABEL DEBUG_ON
9144 #define dbg_printk(__fmt, __args...) pr_debug(__fmt, ##__args)
9145 #define AA_DEBUG(fmt, args...) \
9146 do { \
9147 diff --git a/security/apparmor/include/policy.h b/security/apparmor/include/policy.h
9148 index b5b4b8190e654..b5aa4231af682 100644
9149 --- a/security/apparmor/include/policy.h
9150 +++ b/security/apparmor/include/policy.h
9151 @@ -135,7 +135,7 @@ struct aa_profile {
9152
9153 const char *attach;
9154 struct aa_dfa *xmatch;
9155 - int xmatch_len;
9156 + unsigned int xmatch_len;
9157 enum audit_mode audit;
9158 long mode;
9159 u32 path_flags;
9160 diff --git a/security/apparmor/label.c b/security/apparmor/label.c
9161 index 747a734a08246..e2674e425ca7d 100644
9162 --- a/security/apparmor/label.c
9163 +++ b/security/apparmor/label.c
9164 @@ -1637,9 +1637,9 @@ int aa_label_snxprint(char *str, size_t size, struct aa_ns *ns,
9165 AA_BUG(!str && size != 0);
9166 AA_BUG(!label);
9167
9168 - if (flags & FLAG_ABS_ROOT) {
9169 + if (AA_DEBUG_LABEL && (flags & FLAG_ABS_ROOT)) {
9170 ns = root_ns;
9171 - len = snprintf(str, size, "=");
9172 + len = snprintf(str, size, "_");
9173 update_for_len(total, len, size, str);
9174 } else if (!ns) {
9175 ns = labels_ns(label);
9176 @@ -1750,7 +1750,7 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
9177 if (!use_label_hname(ns, label, flags) ||
9178 display_mode(ns, label, flags)) {
9179 len = aa_label_asxprint(&name, ns, label, flags, gfp);
9180 - if (len == -1) {
9181 + if (len < 0) {
9182 AA_DEBUG("label print error");
9183 return;
9184 }
9185 @@ -1778,7 +1778,7 @@ void aa_label_seq_xprint(struct seq_file *f, struct aa_ns *ns,
9186 int len;
9187
9188 len = aa_label_asxprint(&str, ns, label, flags, gfp);
9189 - if (len == -1) {
9190 + if (len < 0) {
9191 AA_DEBUG("label print error");
9192 return;
9193 }
9194 @@ -1801,7 +1801,7 @@ void aa_label_xprintk(struct aa_ns *ns, struct aa_label *label, int flags,
9195 int len;
9196
9197 len = aa_label_asxprint(&str, ns, label, flags, gfp);
9198 - if (len == -1) {
9199 + if (len < 0) {
9200 AA_DEBUG("label print error");
9201 return;
9202 }
9203 @@ -1901,7 +1901,8 @@ struct aa_label *aa_label_strn_parse(struct aa_label *base, const char *str,
9204 AA_BUG(!str);
9205
9206 str = skipn_spaces(str, n);
9207 - if (str == NULL || (*str == '=' && base != &root_ns->unconfined->label))
9208 + if (str == NULL || (AA_DEBUG_LABEL && *str == '_' &&
9209 + base != &root_ns->unconfined->label))
9210 return ERR_PTR(-EINVAL);
9211
9212 len = label_count_strn_entries(str, end - str);
9213 diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c
9214 index 17081c8dbefac..4b433cf1526fc 100644
9215 --- a/security/apparmor/mount.c
9216 +++ b/security/apparmor/mount.c
9217 @@ -229,7 +229,8 @@ static const char * const mnt_info_table[] = {
9218 "failed srcname match",
9219 "failed type match",
9220 "failed flags match",
9221 - "failed data match"
9222 + "failed data match",
9223 + "failed perms check"
9224 };
9225
9226 /*
9227 @@ -284,8 +285,8 @@ static int do_match_mnt(struct aa_dfa *dfa, unsigned int start,
9228 return 0;
9229 }
9230
9231 - /* failed at end of flags match */
9232 - return 4;
9233 + /* failed at perms check, don't confuse with flags match */
9234 + return 6;
9235 }
9236
9237
9238 @@ -682,6 +683,7 @@ int aa_pivotroot(struct aa_label *label, const struct path *old_path,
9239 aa_put_label(target);
9240 goto out;
9241 }
9242 + aa_put_label(target);
9243 } else
9244 /* already audited error */
9245 error = PTR_ERR(target);
9246 diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h
9247 index 162d0e79b85b3..b18bc405f8203 100644
9248 --- a/security/selinux/ss/policydb.h
9249 +++ b/security/selinux/ss/policydb.h
9250 @@ -356,6 +356,8 @@ static inline int put_entry(const void *buf, size_t bytes, int num, struct polic
9251 {
9252 size_t len = bytes * num;
9253
9254 + if (len > fp->len)
9255 + return -EINVAL;
9256 memcpy(fp->data, buf, len);
9257 fp->data += len;
9258 fp->len -= len;
9259 diff --git a/sound/core/info.c b/sound/core/info.c
9260 index f18f4ef6661e9..d670bd5dd7a97 100644
9261 --- a/sound/core/info.c
9262 +++ b/sound/core/info.c
9263 @@ -112,9 +112,9 @@ static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
9264 entry = data->entry;
9265 mutex_lock(&entry->access);
9266 if (entry->c.ops->llseek) {
9267 - offset = entry->c.ops->llseek(entry,
9268 - data->file_private_data,
9269 - file, offset, orig);
9270 + ret = entry->c.ops->llseek(entry,
9271 + data->file_private_data,
9272 + file, offset, orig);
9273 goto out;
9274 }
9275
9276 diff --git a/sound/core/misc.c b/sound/core/misc.c
9277 index 3579dd7a161f7..c3f3d94b51970 100644
9278 --- a/sound/core/misc.c
9279 +++ b/sound/core/misc.c
9280 @@ -10,6 +10,7 @@
9281 #include <linux/time.h>
9282 #include <linux/slab.h>
9283 #include <linux/ioport.h>
9284 +#include <linux/fs.h>
9285 #include <sound/core.h>
9286
9287 #ifdef CONFIG_SND_DEBUG
9288 @@ -145,3 +146,96 @@ snd_pci_quirk_lookup(struct pci_dev *pci, const struct snd_pci_quirk *list)
9289 }
9290 EXPORT_SYMBOL(snd_pci_quirk_lookup);
9291 #endif
9292 +
9293 +/*
9294 + * Deferred async signal helpers
9295 + *
9296 + * Below are a few helper functions to wrap the async signal handling
9297 + * in the deferred work. The main purpose is to avoid the messy deadlock
9298 + * around tasklist_lock and co at the kill_fasync() invocation.
9299 + * fasync_helper() and kill_fasync() are replaced with snd_fasync_helper()
9300 + * and snd_kill_fasync(), respectively. In addition, snd_fasync_free() has
9301 + * to be called at releasing the relevant file object.
9302 + */
9303 +struct snd_fasync {
9304 + struct fasync_struct *fasync;
9305 + int signal;
9306 + int poll;
9307 + int on;
9308 + struct list_head list;
9309 +};
9310 +
9311 +static DEFINE_SPINLOCK(snd_fasync_lock);
9312 +static LIST_HEAD(snd_fasync_list);
9313 +
9314 +static void snd_fasync_work_fn(struct work_struct *work)
9315 +{
9316 + struct snd_fasync *fasync;
9317 +
9318 + spin_lock_irq(&snd_fasync_lock);
9319 + while (!list_empty(&snd_fasync_list)) {
9320 + fasync = list_first_entry(&snd_fasync_list, struct snd_fasync, list);
9321 + list_del_init(&fasync->list);
9322 + spin_unlock_irq(&snd_fasync_lock);
9323 + if (fasync->on)
9324 + kill_fasync(&fasync->fasync, fasync->signal, fasync->poll);
9325 + spin_lock_irq(&snd_fasync_lock);
9326 + }
9327 + spin_unlock_irq(&snd_fasync_lock);
9328 +}
9329 +
9330 +static DECLARE_WORK(snd_fasync_work, snd_fasync_work_fn);
9331 +
9332 +int snd_fasync_helper(int fd, struct file *file, int on,
9333 + struct snd_fasync **fasyncp)
9334 +{
9335 + struct snd_fasync *fasync = NULL;
9336 +
9337 + if (on) {
9338 + fasync = kzalloc(sizeof(*fasync), GFP_KERNEL);
9339 + if (!fasync)
9340 + return -ENOMEM;
9341 + INIT_LIST_HEAD(&fasync->list);
9342 + }
9343 +
9344 + spin_lock_irq(&snd_fasync_lock);
9345 + if (*fasyncp) {
9346 + kfree(fasync);
9347 + fasync = *fasyncp;
9348 + } else {
9349 + if (!fasync) {
9350 + spin_unlock_irq(&snd_fasync_lock);
9351 + return 0;
9352 + }
9353 + *fasyncp = fasync;
9354 + }
9355 + fasync->on = on;
9356 + spin_unlock_irq(&snd_fasync_lock);
9357 + return fasync_helper(fd, file, on, &fasync->fasync);
9358 +}
9359 +EXPORT_SYMBOL_GPL(snd_fasync_helper);
9360 +
9361 +void snd_kill_fasync(struct snd_fasync *fasync, int signal, int poll)
9362 +{
9363 + unsigned long flags;
9364 +
9365 + if (!fasync || !fasync->on)
9366 + return;
9367 + spin_lock_irqsave(&snd_fasync_lock, flags);
9368 + fasync->signal = signal;
9369 + fasync->poll = poll;
9370 + list_move(&fasync->list, &snd_fasync_list);
9371 + schedule_work(&snd_fasync_work);
9372 + spin_unlock_irqrestore(&snd_fasync_lock, flags);
9373 +}
9374 +EXPORT_SYMBOL_GPL(snd_kill_fasync);
9375 +
9376 +void snd_fasync_free(struct snd_fasync *fasync)
9377 +{
9378 + if (!fasync)
9379 + return;
9380 + fasync->on = 0;
9381 + flush_work(&snd_fasync_work);
9382 + kfree(fasync);
9383 +}
9384 +EXPORT_SYMBOL_GPL(snd_fasync_free);
9385 diff --git a/sound/core/timer.c b/sound/core/timer.c
9386 index d684aa4150aad..420cc07a7f882 100644
9387 --- a/sound/core/timer.c
9388 +++ b/sound/core/timer.c
9389 @@ -61,7 +61,7 @@ struct snd_timer_user {
9390 unsigned int filter;
9391 struct timespec tstamp; /* trigger tstamp */
9392 wait_queue_head_t qchange_sleep;
9393 - struct fasync_struct *fasync;
9394 + struct snd_fasync *fasync;
9395 struct mutex ioctl_lock;
9396 };
9397
9398 @@ -1317,7 +1317,7 @@ static void snd_timer_user_interrupt(struct snd_timer_instance *timeri,
9399 }
9400 __wake:
9401 spin_unlock(&tu->qlock);
9402 - kill_fasync(&tu->fasync, SIGIO, POLL_IN);
9403 + snd_kill_fasync(tu->fasync, SIGIO, POLL_IN);
9404 wake_up(&tu->qchange_sleep);
9405 }
9406
9407 @@ -1354,7 +1354,7 @@ static void snd_timer_user_ccallback(struct snd_timer_instance *timeri,
9408 spin_lock_irqsave(&tu->qlock, flags);
9409 snd_timer_user_append_to_tqueue(tu, &r1);
9410 spin_unlock_irqrestore(&tu->qlock, flags);
9411 - kill_fasync(&tu->fasync, SIGIO, POLL_IN);
9412 + snd_kill_fasync(tu->fasync, SIGIO, POLL_IN);
9413 wake_up(&tu->qchange_sleep);
9414 }
9415
9416 @@ -1421,7 +1421,7 @@ static void snd_timer_user_tinterrupt(struct snd_timer_instance *timeri,
9417 spin_unlock(&tu->qlock);
9418 if (append == 0)
9419 return;
9420 - kill_fasync(&tu->fasync, SIGIO, POLL_IN);
9421 + snd_kill_fasync(tu->fasync, SIGIO, POLL_IN);
9422 wake_up(&tu->qchange_sleep);
9423 }
9424
9425 @@ -1487,6 +1487,7 @@ static int snd_timer_user_release(struct inode *inode, struct file *file)
9426 if (tu->timeri)
9427 snd_timer_close(tu->timeri);
9428 mutex_unlock(&tu->ioctl_lock);
9429 + snd_fasync_free(tu->fasync);
9430 kfree(tu->queue);
9431 kfree(tu->tqueue);
9432 kfree(tu);
9433 @@ -2050,7 +2051,7 @@ static int snd_timer_user_fasync(int fd, struct file * file, int on)
9434 struct snd_timer_user *tu;
9435
9436 tu = file->private_data;
9437 - return fasync_helper(fd, file, on, &tu->fasync);
9438 + return snd_fasync_helper(fd, file, on, &tu->fasync);
9439 }
9440
9441 static ssize_t snd_timer_user_read(struct file *file, char __user *buffer,
9442 diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
9443 index f46204ab0b903..c10a264e9567d 100644
9444 --- a/sound/pci/hda/patch_cirrus.c
9445 +++ b/sound/pci/hda/patch_cirrus.c
9446 @@ -396,6 +396,7 @@ static const struct snd_pci_quirk cs420x_fixup_tbl[] = {
9447
9448 /* codec SSID */
9449 SND_PCI_QUIRK(0x106b, 0x0600, "iMac 14,1", CS420X_IMAC27_122),
9450 + SND_PCI_QUIRK(0x106b, 0x0900, "iMac 12,1", CS420X_IMAC27_122),
9451 SND_PCI_QUIRK(0x106b, 0x1c00, "MacBookPro 8,1", CS420X_MBP81),
9452 SND_PCI_QUIRK(0x106b, 0x2000, "iMac 12,2", CS420X_IMAC27_122),
9453 SND_PCI_QUIRK(0x106b, 0x2800, "MacBookPro 10,1", CS420X_MBP101),
9454 diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c
9455 index d4bfb11493270..d181dc31cd8d6 100644
9456 --- a/sound/pci/hda/patch_conexant.c
9457 +++ b/sound/pci/hda/patch_conexant.c
9458 @@ -197,6 +197,7 @@ enum {
9459 CXT_PINCFG_LEMOTE_A1205,
9460 CXT_PINCFG_COMPAQ_CQ60,
9461 CXT_FIXUP_STEREO_DMIC,
9462 + CXT_PINCFG_LENOVO_NOTEBOOK,
9463 CXT_FIXUP_INC_MIC_BOOST,
9464 CXT_FIXUP_HEADPHONE_MIC_PIN,
9465 CXT_FIXUP_HEADPHONE_MIC,
9466 @@ -737,6 +738,14 @@ static const struct hda_fixup cxt_fixups[] = {
9467 .type = HDA_FIXUP_FUNC,
9468 .v.func = cxt_fixup_stereo_dmic,
9469 },
9470 + [CXT_PINCFG_LENOVO_NOTEBOOK] = {
9471 + .type = HDA_FIXUP_PINS,
9472 + .v.pins = (const struct hda_pintbl[]) {
9473 + { 0x1a, 0x05d71030 },
9474 + { }
9475 + },
9476 + .chain_id = CXT_FIXUP_STEREO_DMIC,
9477 + },
9478 [CXT_FIXUP_INC_MIC_BOOST] = {
9479 .type = HDA_FIXUP_FUNC,
9480 .v.func = cxt5066_increase_mic_boost,
9481 @@ -930,7 +939,7 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
9482 SND_PCI_QUIRK(0x17aa, 0x3905, "Lenovo G50-30", CXT_FIXUP_STEREO_DMIC),
9483 SND_PCI_QUIRK(0x17aa, 0x390b, "Lenovo G50-80", CXT_FIXUP_STEREO_DMIC),
9484 SND_PCI_QUIRK(0x17aa, 0x3975, "Lenovo U300s", CXT_FIXUP_STEREO_DMIC),
9485 - SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_FIXUP_STEREO_DMIC),
9486 + SND_PCI_QUIRK(0x17aa, 0x3977, "Lenovo IdeaPad U310", CXT_PINCFG_LENOVO_NOTEBOOK),
9487 SND_PCI_QUIRK(0x17aa, 0x3978, "Lenovo G50-70", CXT_FIXUP_STEREO_DMIC),
9488 SND_PCI_QUIRK(0x17aa, 0x397b, "Lenovo S205", CXT_FIXUP_STEREO_DMIC),
9489 SND_PCI_QUIRK_VENDOR(0x17aa, "Thinkpad", CXT_FIXUP_THINKPAD_ACPI),
9490 diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
9491 index 145e494f776a3..d925ae7f1b027 100644
9492 --- a/sound/pci/hda/patch_realtek.c
9493 +++ b/sound/pci/hda/patch_realtek.c
9494 @@ -6370,6 +6370,7 @@ enum {
9495 ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
9496 ALC269VB_FIXUP_ASUS_ZENBOOK,
9497 ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A,
9498 + ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE,
9499 ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
9500 ALC269VB_FIXUP_ORDISSIMO_EVE2,
9501 ALC283_FIXUP_CHROME_BOOK,
9502 @@ -6901,6 +6902,15 @@ static const struct hda_fixup alc269_fixups[] = {
9503 .chained = true,
9504 .chain_id = ALC269VB_FIXUP_ASUS_ZENBOOK,
9505 },
9506 + [ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE] = {
9507 + .type = HDA_FIXUP_PINS,
9508 + .v.pins = (const struct hda_pintbl[]) {
9509 + { 0x18, 0x01a110f0 }, /* use as headset mic */
9510 + { }
9511 + },
9512 + .chained = true,
9513 + .chain_id = ALC269_FIXUP_HEADSET_MIC
9514 + },
9515 [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
9516 .type = HDA_FIXUP_FUNC,
9517 .v.func = alc269_fixup_limit_int_mic_boost,
9518 @@ -8215,6 +8225,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
9519 SND_PCI_QUIRK(0x1043, 0x12a0, "ASUS X441UV", ALC233_FIXUP_EAPD_COEF_AND_MIC_NO_PRESENCE),
9520 SND_PCI_QUIRK(0x1043, 0x12e0, "ASUS X541SA", ALC256_FIXUP_ASUS_MIC),
9521 SND_PCI_QUIRK(0x1043, 0x12f0, "ASUS X541UV", ALC256_FIXUP_ASUS_MIC),
9522 + SND_PCI_QUIRK(0x1043, 0x1313, "Asus K42JZ", ALC269VB_FIXUP_ASUS_MIC_NO_PRESENCE),
9523 SND_PCI_QUIRK(0x1043, 0x13b0, "ASUS Z550SA", ALC256_FIXUP_ASUS_MIC),
9524 SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_ASUS_ZENBOOK),
9525 SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_ASUS_ZENBOOK_UX31A),
9526 diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c
9527 index e172913d04a4a..efc5049c0796e 100644
9528 --- a/sound/soc/codecs/da7210.c
9529 +++ b/sound/soc/codecs/da7210.c
9530 @@ -1333,6 +1333,8 @@ static int __init da7210_modinit(void)
9531 int ret = 0;
9532 #if IS_ENABLED(CONFIG_I2C)
9533 ret = i2c_add_driver(&da7210_i2c_driver);
9534 + if (ret)
9535 + return ret;
9536 #endif
9537 #if defined(CONFIG_SPI_MASTER)
9538 ret = spi_register_driver(&da7210_spi_driver);
9539 diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c
9540 index e4cde214b7b2d..6e5bce4f5eb2f 100644
9541 --- a/sound/soc/codecs/msm8916-wcd-digital.c
9542 +++ b/sound/soc/codecs/msm8916-wcd-digital.c
9543 @@ -328,8 +328,8 @@ static const struct snd_kcontrol_new rx1_mix2_inp1_mux = SOC_DAPM_ENUM(
9544 static const struct snd_kcontrol_new rx2_mix2_inp1_mux = SOC_DAPM_ENUM(
9545 "RX2 MIX2 INP1 Mux", rx2_mix2_inp1_chain_enum);
9546
9547 -/* Digital Gain control -38.4 dB to +38.4 dB in 0.3 dB steps */
9548 -static const DECLARE_TLV_DB_SCALE(digital_gain, -3840, 30, 0);
9549 +/* Digital Gain control -84 dB to +40 dB in 1 dB steps */
9550 +static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
9551
9552 /* Cutoff Freq for High Pass Filter at -3dB */
9553 static const char * const hpf_cutoff_text[] = {
9554 @@ -510,15 +510,15 @@ static int wcd_iir_filter_info(struct snd_kcontrol *kcontrol,
9555
9556 static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {
9557 SOC_SINGLE_S8_TLV("RX1 Digital Volume", LPASS_CDC_RX1_VOL_CTL_B2_CTL,
9558 - -128, 127, digital_gain),
9559 + -84, 40, digital_gain),
9560 SOC_SINGLE_S8_TLV("RX2 Digital Volume", LPASS_CDC_RX2_VOL_CTL_B2_CTL,
9561 - -128, 127, digital_gain),
9562 + -84, 40, digital_gain),
9563 SOC_SINGLE_S8_TLV("RX3 Digital Volume", LPASS_CDC_RX3_VOL_CTL_B2_CTL,
9564 - -128, 127, digital_gain),
9565 + -84, 40, digital_gain),
9566 SOC_SINGLE_S8_TLV("TX1 Digital Volume", LPASS_CDC_TX1_VOL_CTL_GAIN,
9567 - -128, 127, digital_gain),
9568 + -84, 40, digital_gain),
9569 SOC_SINGLE_S8_TLV("TX2 Digital Volume", LPASS_CDC_TX2_VOL_CTL_GAIN,
9570 - -128, 127, digital_gain),
9571 + -84, 40, digital_gain),
9572 SOC_ENUM("TX1 HPF Cutoff", tx1_hpf_cutoff_enum),
9573 SOC_ENUM("TX2 HPF Cutoff", tx2_hpf_cutoff_enum),
9574 SOC_SINGLE("TX1 HPF Switch", LPASS_CDC_TX1_MUX_CTL, 3, 1, 0),
9575 @@ -553,22 +553,22 @@ static const struct snd_kcontrol_new msm8916_wcd_digital_snd_controls[] = {
9576 WCD_IIR_FILTER_CTL("IIR2 Band3", IIR2, BAND3),
9577 WCD_IIR_FILTER_CTL("IIR2 Band4", IIR2, BAND4),
9578 WCD_IIR_FILTER_CTL("IIR2 Band5", IIR2, BAND5),
9579 - SOC_SINGLE_SX_TLV("IIR1 INP1 Volume", LPASS_CDC_IIR1_GAIN_B1_CTL,
9580 - 0, -84, 40, digital_gain),
9581 - SOC_SINGLE_SX_TLV("IIR1 INP2 Volume", LPASS_CDC_IIR1_GAIN_B2_CTL,
9582 - 0, -84, 40, digital_gain),
9583 - SOC_SINGLE_SX_TLV("IIR1 INP3 Volume", LPASS_CDC_IIR1_GAIN_B3_CTL,
9584 - 0, -84, 40, digital_gain),
9585 - SOC_SINGLE_SX_TLV("IIR1 INP4 Volume", LPASS_CDC_IIR1_GAIN_B4_CTL,
9586 - 0, -84, 40, digital_gain),
9587 - SOC_SINGLE_SX_TLV("IIR2 INP1 Volume", LPASS_CDC_IIR2_GAIN_B1_CTL,
9588 - 0, -84, 40, digital_gain),
9589 - SOC_SINGLE_SX_TLV("IIR2 INP2 Volume", LPASS_CDC_IIR2_GAIN_B2_CTL,
9590 - 0, -84, 40, digital_gain),
9591 - SOC_SINGLE_SX_TLV("IIR2 INP3 Volume", LPASS_CDC_IIR2_GAIN_B3_CTL,
9592 - 0, -84, 40, digital_gain),
9593 - SOC_SINGLE_SX_TLV("IIR2 INP4 Volume", LPASS_CDC_IIR2_GAIN_B4_CTL,
9594 - 0, -84, 40, digital_gain),
9595 + SOC_SINGLE_S8_TLV("IIR1 INP1 Volume", LPASS_CDC_IIR1_GAIN_B1_CTL,
9596 + -84, 40, digital_gain),
9597 + SOC_SINGLE_S8_TLV("IIR1 INP2 Volume", LPASS_CDC_IIR1_GAIN_B2_CTL,
9598 + -84, 40, digital_gain),
9599 + SOC_SINGLE_S8_TLV("IIR1 INP3 Volume", LPASS_CDC_IIR1_GAIN_B3_CTL,
9600 + -84, 40, digital_gain),
9601 + SOC_SINGLE_S8_TLV("IIR1 INP4 Volume", LPASS_CDC_IIR1_GAIN_B4_CTL,
9602 + -84, 40, digital_gain),
9603 + SOC_SINGLE_S8_TLV("IIR2 INP1 Volume", LPASS_CDC_IIR2_GAIN_B1_CTL,
9604 + -84, 40, digital_gain),
9605 + SOC_SINGLE_S8_TLV("IIR2 INP2 Volume", LPASS_CDC_IIR2_GAIN_B2_CTL,
9606 + -84, 40, digital_gain),
9607 + SOC_SINGLE_S8_TLV("IIR2 INP3 Volume", LPASS_CDC_IIR2_GAIN_B3_CTL,
9608 + -84, 40, digital_gain),
9609 + SOC_SINGLE_S8_TLV("IIR2 INP4 Volume", LPASS_CDC_IIR2_GAIN_B4_CTL,
9610 + -84, 40, digital_gain),
9611
9612 };
9613
9614 diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
9615 index 016aff97e2fb2..c01c69613f63d 100644
9616 --- a/sound/soc/codecs/wcd9335.c
9617 +++ b/sound/soc/codecs/wcd9335.c
9618 @@ -2252,51 +2252,42 @@ static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc,
9619
9620 static const struct snd_kcontrol_new wcd9335_snd_controls[] = {
9621 /* -84dB min - 40dB max */
9622 - SOC_SINGLE_SX_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
9623 - 0, -84, 40, digital_gain),
9624 - SOC_SINGLE_SX_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
9625 - 0, -84, 40, digital_gain),
9626 - SOC_SINGLE_SX_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
9627 - 0, -84, 40, digital_gain),
9628 - SOC_SINGLE_SX_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
9629 - 0, -84, 40, digital_gain),
9630 - SOC_SINGLE_SX_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
9631 - 0, -84, 40, digital_gain),
9632 - SOC_SINGLE_SX_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
9633 - 0, -84, 40, digital_gain),
9634 - SOC_SINGLE_SX_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
9635 - 0, -84, 40, digital_gain),
9636 - SOC_SINGLE_SX_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
9637 - 0, -84, 40, digital_gain),
9638 - SOC_SINGLE_SX_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
9639 - 0, -84, 40, digital_gain),
9640 - SOC_SINGLE_SX_TLV("RX0 Mix Digital Volume",
9641 - WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
9642 - 0, -84, 40, digital_gain),
9643 - SOC_SINGLE_SX_TLV("RX1 Mix Digital Volume",
9644 - WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
9645 - 0, -84, 40, digital_gain),
9646 - SOC_SINGLE_SX_TLV("RX2 Mix Digital Volume",
9647 - WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
9648 - 0, -84, 40, digital_gain),
9649 - SOC_SINGLE_SX_TLV("RX3 Mix Digital Volume",
9650 - WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
9651 - 0, -84, 40, digital_gain),
9652 - SOC_SINGLE_SX_TLV("RX4 Mix Digital Volume",
9653 - WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
9654 - 0, -84, 40, digital_gain),
9655 - SOC_SINGLE_SX_TLV("RX5 Mix Digital Volume",
9656 - WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
9657 - 0, -84, 40, digital_gain),
9658 - SOC_SINGLE_SX_TLV("RX6 Mix Digital Volume",
9659 - WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
9660 - 0, -84, 40, digital_gain),
9661 - SOC_SINGLE_SX_TLV("RX7 Mix Digital Volume",
9662 - WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
9663 - 0, -84, 40, digital_gain),
9664 - SOC_SINGLE_SX_TLV("RX8 Mix Digital Volume",
9665 - WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
9666 - 0, -84, 40, digital_gain),
9667 + SOC_SINGLE_S8_TLV("RX0 Digital Volume", WCD9335_CDC_RX0_RX_VOL_CTL,
9668 + -84, 40, digital_gain),
9669 + SOC_SINGLE_S8_TLV("RX1 Digital Volume", WCD9335_CDC_RX1_RX_VOL_CTL,
9670 + -84, 40, digital_gain),
9671 + SOC_SINGLE_S8_TLV("RX2 Digital Volume", WCD9335_CDC_RX2_RX_VOL_CTL,
9672 + -84, 40, digital_gain),
9673 + SOC_SINGLE_S8_TLV("RX3 Digital Volume", WCD9335_CDC_RX3_RX_VOL_CTL,
9674 + -84, 40, digital_gain),
9675 + SOC_SINGLE_S8_TLV("RX4 Digital Volume", WCD9335_CDC_RX4_RX_VOL_CTL,
9676 + -84, 40, digital_gain),
9677 + SOC_SINGLE_S8_TLV("RX5 Digital Volume", WCD9335_CDC_RX5_RX_VOL_CTL,
9678 + -84, 40, digital_gain),
9679 + SOC_SINGLE_S8_TLV("RX6 Digital Volume", WCD9335_CDC_RX6_RX_VOL_CTL,
9680 + -84, 40, digital_gain),
9681 + SOC_SINGLE_S8_TLV("RX7 Digital Volume", WCD9335_CDC_RX7_RX_VOL_CTL,
9682 + -84, 40, digital_gain),
9683 + SOC_SINGLE_S8_TLV("RX8 Digital Volume", WCD9335_CDC_RX8_RX_VOL_CTL,
9684 + -84, 40, digital_gain),
9685 + SOC_SINGLE_S8_TLV("RX0 Mix Digital Volume", WCD9335_CDC_RX0_RX_VOL_MIX_CTL,
9686 + -84, 40, digital_gain),
9687 + SOC_SINGLE_S8_TLV("RX1 Mix Digital Volume", WCD9335_CDC_RX1_RX_VOL_MIX_CTL,
9688 + -84, 40, digital_gain),
9689 + SOC_SINGLE_S8_TLV("RX2 Mix Digital Volume", WCD9335_CDC_RX2_RX_VOL_MIX_CTL,
9690 + -84, 40, digital_gain),
9691 + SOC_SINGLE_S8_TLV("RX3 Mix Digital Volume", WCD9335_CDC_RX3_RX_VOL_MIX_CTL,
9692 + -84, 40, digital_gain),
9693 + SOC_SINGLE_S8_TLV("RX4 Mix Digital Volume", WCD9335_CDC_RX4_RX_VOL_MIX_CTL,
9694 + -84, 40, digital_gain),
9695 + SOC_SINGLE_S8_TLV("RX5 Mix Digital Volume", WCD9335_CDC_RX5_RX_VOL_MIX_CTL,
9696 + -84, 40, digital_gain),
9697 + SOC_SINGLE_S8_TLV("RX6 Mix Digital Volume", WCD9335_CDC_RX6_RX_VOL_MIX_CTL,
9698 + -84, 40, digital_gain),
9699 + SOC_SINGLE_S8_TLV("RX7 Mix Digital Volume", WCD9335_CDC_RX7_RX_VOL_MIX_CTL,
9700 + -84, 40, digital_gain),
9701 + SOC_SINGLE_S8_TLV("RX8 Mix Digital Volume", WCD9335_CDC_RX8_RX_VOL_MIX_CTL,
9702 + -84, 40, digital_gain),
9703 SOC_ENUM("RX INT0_1 HPF cut off", cf_int0_1_enum),
9704 SOC_ENUM("RX INT0_2 HPF cut off", cf_int0_2_enum),
9705 SOC_ENUM("RX INT1_1 HPF cut off", cf_int1_1_enum),
9706 diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
9707 index 1bc4981246899..96aa2c015572f 100644
9708 --- a/sound/soc/generic/audio-graph-card.c
9709 +++ b/sound/soc/generic/audio-graph-card.c
9710 @@ -149,8 +149,10 @@ static int asoc_simple_parse_dai(struct device_node *ep,
9711 * if he unbinded CPU or Codec.
9712 */
9713 ret = snd_soc_get_dai_name(&args, &dlc->dai_name);
9714 - if (ret < 0)
9715 + if (ret < 0) {
9716 + of_node_put(node);
9717 return ret;
9718 + }
9719
9720 dlc->of_node = node;
9721
9722 diff --git a/sound/soc/mediatek/mt6797/mt6797-mt6351.c b/sound/soc/mediatek/mt6797/mt6797-mt6351.c
9723 index 496f32bcfb5e3..d2f6213a6bfcc 100644
9724 --- a/sound/soc/mediatek/mt6797/mt6797-mt6351.c
9725 +++ b/sound/soc/mediatek/mt6797/mt6797-mt6351.c
9726 @@ -217,7 +217,8 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)
9727 if (!codec_node) {
9728 dev_err(&pdev->dev,
9729 "Property 'audio-codec' missing or invalid\n");
9730 - return -EINVAL;
9731 + ret = -EINVAL;
9732 + goto put_platform_node;
9733 }
9734 for_each_card_prelinks(card, i, dai_link) {
9735 if (dai_link->codecs->name)
9736 @@ -230,6 +231,9 @@ static int mt6797_mt6351_dev_probe(struct platform_device *pdev)
9737 dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
9738 __func__, ret);
9739
9740 + of_node_put(codec_node);
9741 +put_platform_node:
9742 + of_node_put(platform_node);
9743 return ret;
9744 }
9745
9746 diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
9747 index 727ff0f7f20b1..8e1e60a9b45c4 100644
9748 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
9749 +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c
9750 @@ -256,14 +256,16 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
9751 if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node) {
9752 dev_err(&pdev->dev,
9753 "Property 'audio-codec' missing or invalid\n");
9754 - return -EINVAL;
9755 + ret = -EINVAL;
9756 + goto put_node;
9757 }
9758 mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node =
9759 of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 1);
9760 if (!mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node) {
9761 dev_err(&pdev->dev,
9762 "Property 'audio-codec' missing or invalid\n");
9763 - return -EINVAL;
9764 + ret = -EINVAL;
9765 + goto put_node;
9766 }
9767 mt8173_rt5650_rt5676_codec_conf[0].of_node =
9768 mt8173_rt5650_rt5676_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node;
9769 @@ -276,7 +278,8 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
9770 if (!mt8173_rt5650_rt5676_dais[DAI_LINK_HDMI_I2S].codecs->of_node) {
9771 dev_err(&pdev->dev,
9772 "Property 'audio-codec' missing or invalid\n");
9773 - return -EINVAL;
9774 + ret = -EINVAL;
9775 + goto put_node;
9776 }
9777
9778 card->dev = &pdev->dev;
9779 @@ -286,6 +289,7 @@ static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
9780 dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
9781 __func__, ret);
9782
9783 +put_node:
9784 of_node_put(platform_node);
9785 return ret;
9786 }
9787 diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
9788 index 21e7d4d3ded5a..cdfc697ad94e2 100644
9789 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c
9790 +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c
9791 @@ -266,7 +266,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
9792 if (!mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node) {
9793 dev_err(&pdev->dev,
9794 "Property 'audio-codec' missing or invalid\n");
9795 - return -EINVAL;
9796 + ret = -EINVAL;
9797 + goto put_platform_node;
9798 }
9799 mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[1].of_node =
9800 mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[0].of_node;
9801 @@ -279,7 +280,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
9802 dev_err(&pdev->dev,
9803 "%s codec_capture_dai name fail %d\n",
9804 __func__, ret);
9805 - return ret;
9806 + goto put_platform_node;
9807 }
9808 mt8173_rt5650_dais[DAI_LINK_CODEC_I2S].codecs[1].dai_name =
9809 codec_capture_dai;
9810 @@ -301,7 +302,8 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
9811 if (!mt8173_rt5650_dais[DAI_LINK_HDMI_I2S].codecs->of_node) {
9812 dev_err(&pdev->dev,
9813 "Property 'audio-codec' missing or invalid\n");
9814 - return -EINVAL;
9815 + ret = -EINVAL;
9816 + goto put_platform_node;
9817 }
9818 card->dev = &pdev->dev;
9819
9820 @@ -310,6 +312,7 @@ static int mt8173_rt5650_dev_probe(struct platform_device *pdev)
9821 dev_err(&pdev->dev, "%s snd_soc_register_card fail %d\n",
9822 __func__, ret);
9823
9824 +put_platform_node:
9825 of_node_put(platform_node);
9826 return ret;
9827 }
9828 diff --git a/sound/soc/qcom/qdsp6/q6adm.c b/sound/soc/qcom/qdsp6/q6adm.c
9829 index da242515e1467..8e3539941fad1 100644
9830 --- a/sound/soc/qcom/qdsp6/q6adm.c
9831 +++ b/sound/soc/qcom/qdsp6/q6adm.c
9832 @@ -217,7 +217,7 @@ static struct q6copp *q6adm_alloc_copp(struct q6adm *adm, int port_idx)
9833 idx = find_first_zero_bit(&adm->copp_bitmap[port_idx],
9834 MAX_COPPS_PER_PORT);
9835
9836 - if (idx > MAX_COPPS_PER_PORT)
9837 + if (idx >= MAX_COPPS_PER_PORT)
9838 return ERR_PTR(-EBUSY);
9839
9840 c = kzalloc(sizeof(*c), GFP_ATOMIC);
9841 diff --git a/sound/usb/bcd2000/bcd2000.c b/sound/usb/bcd2000/bcd2000.c
9842 index 6e3175826faf7..97afb37809703 100644
9843 --- a/sound/usb/bcd2000/bcd2000.c
9844 +++ b/sound/usb/bcd2000/bcd2000.c
9845 @@ -348,7 +348,8 @@ static int bcd2000_init_midi(struct bcd2000 *bcd2k)
9846 static void bcd2000_free_usb_related_resources(struct bcd2000 *bcd2k,
9847 struct usb_interface *interface)
9848 {
9849 - /* usb_kill_urb not necessary, urb is aborted automatically */
9850 + usb_kill_urb(bcd2k->midi_out_urb);
9851 + usb_kill_urb(bcd2k->midi_in_urb);
9852
9853 usb_free_urb(bcd2k->midi_out_urb);
9854 usb_free_urb(bcd2k->midi_in_urb);
9855 diff --git a/tools/build/feature/test-libcrypto.c b/tools/build/feature/test-libcrypto.c
9856 index a98174e0569c8..bc34a5bbb5049 100644
9857 --- a/tools/build/feature/test-libcrypto.c
9858 +++ b/tools/build/feature/test-libcrypto.c
9859 @@ -1,16 +1,23 @@
9860 // SPDX-License-Identifier: GPL-2.0
9861 +#include <openssl/evp.h>
9862 #include <openssl/sha.h>
9863 #include <openssl/md5.h>
9864
9865 int main(void)
9866 {
9867 - MD5_CTX context;
9868 + EVP_MD_CTX *mdctx;
9869 unsigned char md[MD5_DIGEST_LENGTH + SHA_DIGEST_LENGTH];
9870 unsigned char dat[] = "12345";
9871 + unsigned int digest_len;
9872
9873 - MD5_Init(&context);
9874 - MD5_Update(&context, &dat[0], sizeof(dat));
9875 - MD5_Final(&md[0], &context);
9876 + mdctx = EVP_MD_CTX_new();
9877 + if (!mdctx)
9878 + return 0;
9879 +
9880 + EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
9881 + EVP_DigestUpdate(mdctx, &dat[0], sizeof(dat));
9882 + EVP_DigestFinal_ex(mdctx, &md[0], &digest_len);
9883 + EVP_MD_CTX_free(mdctx);
9884
9885 SHA1(&dat[0], sizeof(dat), &md[0]);
9886
9887 diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
9888 index 2a1dbf52fc9a5..b8849812449c3 100644
9889 --- a/tools/lib/bpf/libbpf.c
9890 +++ b/tools/lib/bpf/libbpf.c
9891 @@ -1884,7 +1884,7 @@ static int bpf_map_find_btf_info(struct bpf_object *obj, struct bpf_map *map)
9892 int bpf_map__reuse_fd(struct bpf_map *map, int fd)
9893 {
9894 struct bpf_map_info info = {};
9895 - __u32 len = sizeof(info);
9896 + __u32 len = sizeof(info), name_len;
9897 int new_fd, err;
9898 char *new_name;
9899
9900 @@ -1892,7 +1892,12 @@ int bpf_map__reuse_fd(struct bpf_map *map, int fd)
9901 if (err)
9902 return err;
9903
9904 - new_name = strdup(info.name);
9905 + name_len = strlen(info.name);
9906 + if (name_len == BPF_OBJ_NAME_LEN - 1 && strncmp(map->name, info.name, name_len) == 0)
9907 + new_name = strdup(map->name);
9908 + else
9909 + new_name = strdup(info.name);
9910 +
9911 if (!new_name)
9912 return -errno;
9913
9914 diff --git a/tools/perf/util/genelf.c b/tools/perf/util/genelf.c
9915 index f9f18b8b1df9a..17b74aba8b9a2 100644
9916 --- a/tools/perf/util/genelf.c
9917 +++ b/tools/perf/util/genelf.c
9918 @@ -35,7 +35,11 @@
9919
9920 #define BUILD_ID_URANDOM /* different uuid for each run */
9921
9922 -#ifdef HAVE_LIBCRYPTO
9923 +// FIXME, remove this and fix the deprecation warnings before its removed and
9924 +// We'll break for good here...
9925 +#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9926 +
9927 +#ifdef HAVE_LIBCRYPTO_SUPPORT
9928
9929 #define BUILD_ID_MD5
9930 #undef BUILD_ID_SHA /* does not seem to work well when linked with Java */
9931 diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
9932 index 0b185b1090ff3..a04a7dfb8ec09 100644
9933 --- a/tools/perf/util/symbol-elf.c
9934 +++ b/tools/perf/util/symbol-elf.c
9935 @@ -1159,16 +1159,29 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss,
9936
9937 if (elf_read_program_header(syms_ss->elf,
9938 (u64)sym.st_value, &phdr)) {
9939 - pr_warning("%s: failed to find program header for "
9940 + pr_debug4("%s: failed to find program header for "
9941 "symbol: %s st_value: %#" PRIx64 "\n",
9942 __func__, elf_name, (u64)sym.st_value);
9943 - continue;
9944 + pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " "
9945 + "sh_addr: %#" PRIx64 " sh_offset: %#" PRIx64 "\n",
9946 + __func__, (u64)sym.st_value, (u64)shdr.sh_addr,
9947 + (u64)shdr.sh_offset);
9948 + /*
9949 + * Fail to find program header, let's rollback
9950 + * to use shdr.sh_addr and shdr.sh_offset to
9951 + * calibrate symbol's file address, though this
9952 + * is not necessary for normal C ELF file, we
9953 + * still need to handle java JIT symbols in this
9954 + * case.
9955 + */
9956 + sym.st_value -= shdr.sh_addr - shdr.sh_offset;
9957 + } else {
9958 + pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " "
9959 + "p_vaddr: %#" PRIx64 " p_offset: %#" PRIx64 "\n",
9960 + __func__, (u64)sym.st_value, (u64)phdr.p_vaddr,
9961 + (u64)phdr.p_offset);
9962 + sym.st_value -= phdr.p_vaddr - phdr.p_offset;
9963 }
9964 - pr_debug4("%s: adjusting symbol: st_value: %#" PRIx64 " "
9965 - "p_vaddr: %#" PRIx64 " p_offset: %#" PRIx64 "\n",
9966 - __func__, (u64)sym.st_value, (u64)phdr.p_vaddr,
9967 - (u64)phdr.p_offset);
9968 - sym.st_value -= phdr.p_vaddr - phdr.p_offset;
9969 }
9970
9971 demangled = demangle_sym(dso, kmodule, elf_name);
9972 diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
9973 index 3d617e8060548..996eca57bc977 100644
9974 --- a/tools/testing/selftests/bpf/test_btf.c
9975 +++ b/tools/testing/selftests/bpf/test_btf.c
9976 @@ -4808,7 +4808,7 @@ static int do_test_pprint(int test_num)
9977 ret = snprintf(pin_path, sizeof(pin_path), "%s/%s",
9978 "/sys/fs/bpf", test->map_name);
9979
9980 - if (CHECK(ret == sizeof(pin_path), "pin_path %s/%s is too long",
9981 + if (CHECK(ret >= sizeof(pin_path), "pin_path %s/%s is too long",
9982 "/sys/fs/bpf", test->map_name)) {
9983 err = -1;
9984 goto done;
9985 diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
9986 index ef1e9bafb0984..728c2762ee581 100644
9987 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
9988 +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_syntax_errors.tc
9989 @@ -24,7 +24,6 @@ check_error 'p:^/bar vfs_read' # NO_GROUP_NAME
9990 check_error 'p:^12345678901234567890123456789012345678901234567890123456789012345/bar vfs_read' # GROUP_TOO_LONG
9991
9992 check_error 'p:^foo.1/bar vfs_read' # BAD_GROUP_NAME
9993 -check_error 'p:foo/^ vfs_read' # NO_EVENT_NAME
9994 check_error 'p:foo/^12345678901234567890123456789012345678901234567890123456789012345 vfs_read' # EVENT_TOO_LONG
9995 check_error 'p:foo/^bar.1 vfs_read' # BAD_EVENT_NAME
9996
9997 diff --git a/tools/testing/selftests/timers/clocksource-switch.c b/tools/testing/selftests/timers/clocksource-switch.c
9998 index bfc974b4572d5..c18313a5f357b 100644
9999 --- a/tools/testing/selftests/timers/clocksource-switch.c
10000 +++ b/tools/testing/selftests/timers/clocksource-switch.c
10001 @@ -110,10 +110,10 @@ int run_tests(int secs)
10002
10003 sprintf(buf, "./inconsistency-check -t %i", secs);
10004 ret = system(buf);
10005 - if (ret)
10006 - return ret;
10007 + if (WIFEXITED(ret) && WEXITSTATUS(ret))
10008 + return WEXITSTATUS(ret);
10009 ret = system("./nanosleep");
10010 - return ret;
10011 + return WIFEXITED(ret) ? WEXITSTATUS(ret) : 0;
10012 }
10013
10014
10015 diff --git a/tools/testing/selftests/timers/valid-adjtimex.c b/tools/testing/selftests/timers/valid-adjtimex.c
10016 index 5397de708d3c2..48b9a803235a8 100644
10017 --- a/tools/testing/selftests/timers/valid-adjtimex.c
10018 +++ b/tools/testing/selftests/timers/valid-adjtimex.c
10019 @@ -40,7 +40,7 @@
10020 #define ADJ_SETOFFSET 0x0100
10021
10022 #include <sys/syscall.h>
10023 -static int clock_adjtime(clockid_t id, struct timex *tx)
10024 +int clock_adjtime(clockid_t id, struct timex *tx)
10025 {
10026 return syscall(__NR_clock_adjtime, id, tx);
10027 }
10028 diff --git a/tools/thermal/tmon/sysfs.c b/tools/thermal/tmon/sysfs.c
10029 index b00b1bfd9d8e7..cb1108bc92498 100644
10030 --- a/tools/thermal/tmon/sysfs.c
10031 +++ b/tools/thermal/tmon/sysfs.c
10032 @@ -13,6 +13,7 @@
10033 #include <stdint.h>
10034 #include <dirent.h>
10035 #include <libintl.h>
10036 +#include <limits.h>
10037 #include <ctype.h>
10038 #include <time.h>
10039 #include <syslog.h>
10040 @@ -33,9 +34,9 @@ int sysfs_set_ulong(char *path, char *filename, unsigned long val)
10041 {
10042 FILE *fd;
10043 int ret = -1;
10044 - char filepath[256];
10045 + char filepath[PATH_MAX + 2]; /* NUL and '/' */
10046
10047 - snprintf(filepath, 256, "%s/%s", path, filename);
10048 + snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
10049
10050 fd = fopen(filepath, "w");
10051 if (!fd) {
10052 @@ -57,9 +58,9 @@ static int sysfs_get_ulong(char *path, char *filename, unsigned long *p_ulong)
10053 {
10054 FILE *fd;
10055 int ret = -1;
10056 - char filepath[256];
10057 + char filepath[PATH_MAX + 2]; /* NUL and '/' */
10058
10059 - snprintf(filepath, 256, "%s/%s", path, filename);
10060 + snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
10061
10062 fd = fopen(filepath, "r");
10063 if (!fd) {
10064 @@ -76,9 +77,9 @@ static int sysfs_get_string(char *path, char *filename, char *str)
10065 {
10066 FILE *fd;
10067 int ret = -1;
10068 - char filepath[256];
10069 + char filepath[PATH_MAX + 2]; /* NUL and '/' */
10070
10071 - snprintf(filepath, 256, "%s/%s", path, filename);
10072 + snprintf(filepath, sizeof(filepath), "%s/%s", path, filename);
10073
10074 fd = fopen(filepath, "r");
10075 if (!fd) {
10076 @@ -199,8 +200,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
10077 {
10078 unsigned long trip_instance = 0;
10079 char cdev_name_linked[256];
10080 - char cdev_name[256];
10081 - char cdev_trip_name[256];
10082 + char cdev_name[PATH_MAX];
10083 + char cdev_trip_name[PATH_MAX];
10084 int cdev_id;
10085
10086 if (nl->d_type == DT_LNK) {
10087 @@ -213,7 +214,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
10088 return -EINVAL;
10089 }
10090 /* find the link to real cooling device record binding */
10091 - snprintf(cdev_name, 256, "%s/%s", tz_name, nl->d_name);
10092 + snprintf(cdev_name, sizeof(cdev_name) - 2, "%s/%s",
10093 + tz_name, nl->d_name);
10094 memset(cdev_name_linked, 0, sizeof(cdev_name_linked));
10095 if (readlink(cdev_name, cdev_name_linked,
10096 sizeof(cdev_name_linked) - 1) != -1) {
10097 @@ -226,8 +228,8 @@ static int find_tzone_cdev(struct dirent *nl, char *tz_name,
10098 /* find the trip point in which the cdev is binded to
10099 * in this tzone
10100 */
10101 - snprintf(cdev_trip_name, 256, "%s%s", nl->d_name,
10102 - "_trip_point");
10103 + snprintf(cdev_trip_name, sizeof(cdev_trip_name) - 1,
10104 + "%s%s", nl->d_name, "_trip_point");
10105 sysfs_get_ulong(tz_name, cdev_trip_name,
10106 &trip_instance);
10107 /* validate trip point range, e.g. trip could return -1
10108 diff --git a/tools/thermal/tmon/tmon.h b/tools/thermal/tmon/tmon.h
10109 index c9066ec104ddd..44d16d778f044 100644
10110 --- a/tools/thermal/tmon/tmon.h
10111 +++ b/tools/thermal/tmon/tmon.h
10112 @@ -27,6 +27,9 @@
10113 #define NR_LINES_TZDATA 1
10114 #define TMON_LOG_FILE "/var/tmp/tmon.log"
10115
10116 +#include <sys/time.h>
10117 +#include <pthread.h>
10118 +
10119 extern unsigned long ticktime;
10120 extern double time_elapsed;
10121 extern unsigned long target_temp_user;
10122 diff --git a/tools/vm/slabinfo.c b/tools/vm/slabinfo.c
10123 index 68092d15e12b5..dda035c358c20 100644
10124 --- a/tools/vm/slabinfo.c
10125 +++ b/tools/vm/slabinfo.c
10126 @@ -125,7 +125,7 @@ static void usage(void)
10127 "-n|--numa Show NUMA information\n"
10128 "-N|--lines=K Show the first K slabs\n"
10129 "-o|--ops Show kmem_cache_ops\n"
10130 - "-P|--partial Sort by number of partial slabs\n"
10131 + "-P|--partial Sort by number of partial slabs\n"
10132 "-r|--report Detailed report on single slabs\n"
10133 "-s|--shrink Shrink slabs\n"
10134 "-S|--Size Sort by size\n"
10135 @@ -1045,15 +1045,27 @@ static void sort_slabs(void)
10136 for (s2 = s1 + 1; s2 < slabinfo + slabs; s2++) {
10137 int result;
10138
10139 - if (sort_size)
10140 - result = slab_size(s1) < slab_size(s2);
10141 - else if (sort_active)
10142 - result = slab_activity(s1) < slab_activity(s2);
10143 - else if (sort_loss)
10144 - result = slab_waste(s1) < slab_waste(s2);
10145 - else if (sort_partial)
10146 - result = s1->partial < s2->partial;
10147 - else
10148 + if (sort_size) {
10149 + if (slab_size(s1) == slab_size(s2))
10150 + result = strcasecmp(s1->name, s2->name);
10151 + else
10152 + result = slab_size(s1) < slab_size(s2);
10153 + } else if (sort_active) {
10154 + if (slab_activity(s1) == slab_activity(s2))
10155 + result = strcasecmp(s1->name, s2->name);
10156 + else
10157 + result = slab_activity(s1) < slab_activity(s2);
10158 + } else if (sort_loss) {
10159 + if (slab_waste(s1) == slab_waste(s2))
10160 + result = strcasecmp(s1->name, s2->name);
10161 + else
10162 + result = slab_waste(s1) < slab_waste(s2);
10163 + } else if (sort_partial) {
10164 + if (s1->partial == s2->partial)
10165 + result = strcasecmp(s1->name, s2->name);
10166 + else
10167 + result = s1->partial < s2->partial;
10168 + } else
10169 result = strcasecmp(s1->name, s2->name);
10170
10171 if (show_inverted)
10172 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
10173 index 4b445dddb7985..0008fc49528a4 100644
10174 --- a/virt/kvm/kvm_main.c
10175 +++ b/virt/kvm/kvm_main.c
10176 @@ -2937,7 +2937,7 @@ static long kvm_vcpu_ioctl(struct file *filp,
10177 struct kvm_fpu *fpu = NULL;
10178 struct kvm_sregs *kvm_sregs = NULL;
10179
10180 - if (vcpu->kvm->mm != current->mm)
10181 + if (vcpu->kvm->mm != current->mm || vcpu->kvm->vm_bugged)
10182 return -EIO;
10183
10184 if (unlikely(_IOC_TYPE(ioctl) != KVMIO))
10185 @@ -3144,7 +3144,7 @@ static long kvm_vcpu_compat_ioctl(struct file *filp,
10186 void __user *argp = compat_ptr(arg);
10187 int r;
10188
10189 - if (vcpu->kvm->mm != current->mm)
10190 + if (vcpu->kvm->mm != current->mm || vcpu->kvm->vm_bugged)
10191 return -EIO;
10192
10193 switch (ioctl) {
10194 @@ -3209,7 +3209,7 @@ static long kvm_device_ioctl(struct file *filp, unsigned int ioctl,
10195 {
10196 struct kvm_device *dev = filp->private_data;
10197
10198 - if (dev->kvm->mm != current->mm)
10199 + if (dev->kvm->mm != current->mm || dev->kvm->vm_bugged)
10200 return -EIO;
10201
10202 switch (ioctl) {
10203 @@ -3413,7 +3413,7 @@ static long kvm_vm_ioctl(struct file *filp,
10204 void __user *argp = (void __user *)arg;
10205 int r;
10206
10207 - if (kvm->mm != current->mm)
10208 + if (kvm->mm != current->mm || kvm->vm_bugged)
10209 return -EIO;
10210 switch (ioctl) {
10211 case KVM_CREATE_VCPU:
10212 @@ -3621,7 +3621,7 @@ static long kvm_vm_compat_ioctl(struct file *filp,
10213 struct kvm *kvm = filp->private_data;
10214 int r;
10215
10216 - if (kvm->mm != current->mm)
10217 + if (kvm->mm != current->mm || kvm->vm_bugged)
10218 return -EIO;
10219 switch (ioctl) {
10220 #ifdef CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT