Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0269-5.4.170-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (show annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (18 months ago) by niro
File size: 47199 byte(s)
-add missing
1 diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
2 index e7f71df9daf1c..165abcb656c5b 100644
3 --- a/Documentation/admin-guide/kernel-parameters.txt
4 +++ b/Documentation/admin-guide/kernel-parameters.txt
5 @@ -1487,6 +1487,8 @@
6 architectures force reset to be always executed
7 i8042.unlock [HW] Unlock (ignore) the keylock
8 i8042.kbdreset [HW] Reset device connected to KBD port
9 + i8042.probe_defer
10 + [HW] Allow deferred probing upon i8042 probe errors
11
12 i810= [HW,DRM]
13
14 diff --git a/Makefile b/Makefile
15 index 151fd24540125..7380354e49513 100644
16 --- a/Makefile
17 +++ b/Makefile
18 @@ -1,7 +1,7 @@
19 # SPDX-License-Identifier: GPL-2.0
20 VERSION = 5
21 PATCHLEVEL = 4
22 -SUBLEVEL = 169
23 +SUBLEVEL = 170
24 EXTRAVERSION =
25 NAME = Kleptomaniac Octopus
26
27 diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
28 index 3526bb1488e5e..b5022a7f6bae1 100644
29 --- a/drivers/android/binder_alloc.c
30 +++ b/drivers/android/binder_alloc.c
31 @@ -613,7 +613,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,
32 BUG_ON(buffer->user_data > alloc->buffer + alloc->buffer_size);
33
34 if (buffer->async_transaction) {
35 - alloc->free_async_space += size + sizeof(struct binder_buffer);
36 + alloc->free_async_space += buffer_size + sizeof(struct binder_buffer);
37
38 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC_ASYNC,
39 "%d: binder_free_buf size %zd async free %zd\n",
40 diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
41 index 0cfcfb116a03d..5169a38ee47a9 100644
42 --- a/drivers/hid/Kconfig
43 +++ b/drivers/hid/Kconfig
44 @@ -149,6 +149,7 @@ config HID_APPLEIR
45
46 config HID_ASUS
47 tristate "Asus"
48 + depends on USB_HID
49 depends on LEDS_CLASS
50 depends on ASUS_WMI || ASUS_WMI=n
51 select POWER_SUPPLY
52 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
53 index c9ae1895cd48a..7da6ca26a5f56 100644
54 --- a/drivers/i2c/i2c-dev.c
55 +++ b/drivers/i2c/i2c-dev.c
56 @@ -536,6 +536,9 @@ static long compat_i2cdev_ioctl(struct file *file, unsigned int cmd, unsigned lo
57 sizeof(rdwr_arg)))
58 return -EFAULT;
59
60 + if (!rdwr_arg.msgs || rdwr_arg.nmsgs == 0)
61 + return -EINVAL;
62 +
63 if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
64 return -EINVAL;
65
66 diff --git a/drivers/input/joystick/spaceball.c b/drivers/input/joystick/spaceball.c
67 index cf7cbcd0c29df..6971412990695 100644
68 --- a/drivers/input/joystick/spaceball.c
69 +++ b/drivers/input/joystick/spaceball.c
70 @@ -19,6 +19,7 @@
71 #include <linux/module.h>
72 #include <linux/input.h>
73 #include <linux/serio.h>
74 +#include <asm/unaligned.h>
75
76 #define DRIVER_DESC "SpaceTec SpaceBall 2003/3003/4000 FLX driver"
77
78 @@ -75,9 +76,15 @@ static void spaceball_process_packet(struct spaceball* spaceball)
79
80 case 'D': /* Ball data */
81 if (spaceball->idx != 15) return;
82 - for (i = 0; i < 6; i++)
83 + /*
84 + * Skip first three bytes; read six axes worth of data.
85 + * Axis values are signed 16-bit big-endian.
86 + */
87 + data += 3;
88 + for (i = 0; i < ARRAY_SIZE(spaceball_axes); i++) {
89 input_report_abs(dev, spaceball_axes[i],
90 - (__s16)((data[2 * i + 3] << 8) | data[2 * i + 2]));
91 + (__s16)get_unaligned_be16(&data[i * 2]));
92 + }
93 break;
94
95 case 'K': /* Button data */
96 diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
97 index 3f06e8a495d80..ff94388416645 100644
98 --- a/drivers/input/mouse/appletouch.c
99 +++ b/drivers/input/mouse/appletouch.c
100 @@ -916,6 +916,8 @@ static int atp_probe(struct usb_interface *iface,
101 set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit);
102 set_bit(BTN_LEFT, input_dev->keybit);
103
104 + INIT_WORK(&dev->work, atp_reinit);
105 +
106 error = input_register_device(dev->input);
107 if (error)
108 goto err_free_buffer;
109 @@ -923,8 +925,6 @@ static int atp_probe(struct usb_interface *iface,
110 /* save our data pointer in this interface device */
111 usb_set_intfdata(iface, dev);
112
113 - INIT_WORK(&dev->work, atp_reinit);
114 -
115 return 0;
116
117 err_free_buffer:
118 diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
119 index 202e43a6ffae2..0282c4c55e9da 100644
120 --- a/drivers/input/serio/i8042-x86ia64io.h
121 +++ b/drivers/input/serio/i8042-x86ia64io.h
122 @@ -995,6 +995,24 @@ static const struct dmi_system_id __initconst i8042_dmi_kbdreset_table[] = {
123 { }
124 };
125
126 +static const struct dmi_system_id i8042_dmi_probe_defer_table[] __initconst = {
127 + {
128 + /* ASUS ZenBook UX425UA */
129 + .matches = {
130 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
131 + DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX425UA"),
132 + },
133 + },
134 + {
135 + /* ASUS ZenBook UM325UA */
136 + .matches = {
137 + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
138 + DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325UA_UM325UA"),
139 + },
140 + },
141 + { }
142 +};
143 +
144 #endif /* CONFIG_X86 */
145
146 #ifdef CONFIG_PNP
147 @@ -1314,6 +1332,9 @@ static int __init i8042_platform_init(void)
148 if (dmi_check_system(i8042_dmi_kbdreset_table))
149 i8042_kbdreset = true;
150
151 + if (dmi_check_system(i8042_dmi_probe_defer_table))
152 + i8042_probe_defer = true;
153 +
154 /*
155 * A20 was already enabled during early kernel init. But some buggy
156 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
157 diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
158 index 6ff6b5710dd4e..bb76ff2f6b1d8 100644
159 --- a/drivers/input/serio/i8042.c
160 +++ b/drivers/input/serio/i8042.c
161 @@ -44,6 +44,10 @@ static bool i8042_unlock;
162 module_param_named(unlock, i8042_unlock, bool, 0);
163 MODULE_PARM_DESC(unlock, "Ignore keyboard lock.");
164
165 +static bool i8042_probe_defer;
166 +module_param_named(probe_defer, i8042_probe_defer, bool, 0);
167 +MODULE_PARM_DESC(probe_defer, "Allow deferred probing.");
168 +
169 enum i8042_controller_reset_mode {
170 I8042_RESET_NEVER,
171 I8042_RESET_ALWAYS,
172 @@ -709,7 +713,7 @@ static int i8042_set_mux_mode(bool multiplex, unsigned char *mux_version)
173 * LCS/Telegraphics.
174 */
175
176 -static int __init i8042_check_mux(void)
177 +static int i8042_check_mux(void)
178 {
179 unsigned char mux_version;
180
181 @@ -738,10 +742,10 @@ static int __init i8042_check_mux(void)
182 /*
183 * The following is used to test AUX IRQ delivery.
184 */
185 -static struct completion i8042_aux_irq_delivered __initdata;
186 -static bool i8042_irq_being_tested __initdata;
187 +static struct completion i8042_aux_irq_delivered;
188 +static bool i8042_irq_being_tested;
189
190 -static irqreturn_t __init i8042_aux_test_irq(int irq, void *dev_id)
191 +static irqreturn_t i8042_aux_test_irq(int irq, void *dev_id)
192 {
193 unsigned long flags;
194 unsigned char str, data;
195 @@ -768,7 +772,7 @@ static irqreturn_t __init i8042_aux_test_irq(int irq, void *dev_id)
196 * verifies success by readinng CTR. Used when testing for presence of AUX
197 * port.
198 */
199 -static int __init i8042_toggle_aux(bool on)
200 +static int i8042_toggle_aux(bool on)
201 {
202 unsigned char param;
203 int i;
204 @@ -796,7 +800,7 @@ static int __init i8042_toggle_aux(bool on)
205 * the presence of an AUX interface.
206 */
207
208 -static int __init i8042_check_aux(void)
209 +static int i8042_check_aux(void)
210 {
211 int retval = -1;
212 bool irq_registered = false;
213 @@ -1003,7 +1007,7 @@ static int i8042_controller_init(void)
214
215 if (i8042_command(&ctr[n++ % 2], I8042_CMD_CTL_RCTR)) {
216 pr_err("Can't read CTR while initializing i8042\n");
217 - return -EIO;
218 + return i8042_probe_defer ? -EPROBE_DEFER : -EIO;
219 }
220
221 } while (n < 2 || ctr[0] != ctr[1]);
222 @@ -1318,7 +1322,7 @@ static void i8042_shutdown(struct platform_device *dev)
223 i8042_controller_reset(false);
224 }
225
226 -static int __init i8042_create_kbd_port(void)
227 +static int i8042_create_kbd_port(void)
228 {
229 struct serio *serio;
230 struct i8042_port *port = &i8042_ports[I8042_KBD_PORT_NO];
231 @@ -1346,7 +1350,7 @@ static int __init i8042_create_kbd_port(void)
232 return 0;
233 }
234
235 -static int __init i8042_create_aux_port(int idx)
236 +static int i8042_create_aux_port(int idx)
237 {
238 struct serio *serio;
239 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx;
240 @@ -1383,13 +1387,13 @@ static int __init i8042_create_aux_port(int idx)
241 return 0;
242 }
243
244 -static void __init i8042_free_kbd_port(void)
245 +static void i8042_free_kbd_port(void)
246 {
247 kfree(i8042_ports[I8042_KBD_PORT_NO].serio);
248 i8042_ports[I8042_KBD_PORT_NO].serio = NULL;
249 }
250
251 -static void __init i8042_free_aux_ports(void)
252 +static void i8042_free_aux_ports(void)
253 {
254 int i;
255
256 @@ -1399,7 +1403,7 @@ static void __init i8042_free_aux_ports(void)
257 }
258 }
259
260 -static void __init i8042_register_ports(void)
261 +static void i8042_register_ports(void)
262 {
263 int i;
264
265 @@ -1440,7 +1444,7 @@ static void i8042_free_irqs(void)
266 i8042_aux_irq_registered = i8042_kbd_irq_registered = false;
267 }
268
269 -static int __init i8042_setup_aux(void)
270 +static int i8042_setup_aux(void)
271 {
272 int (*aux_enable)(void);
273 int error;
274 @@ -1482,7 +1486,7 @@ static int __init i8042_setup_aux(void)
275 return error;
276 }
277
278 -static int __init i8042_setup_kbd(void)
279 +static int i8042_setup_kbd(void)
280 {
281 int error;
282
283 @@ -1532,7 +1536,7 @@ static int i8042_kbd_bind_notifier(struct notifier_block *nb,
284 return 0;
285 }
286
287 -static int __init i8042_probe(struct platform_device *dev)
288 +static int i8042_probe(struct platform_device *dev)
289 {
290 int error;
291
292 @@ -1597,6 +1601,7 @@ static struct platform_driver i8042_driver = {
293 .pm = &i8042_pm_ops,
294 #endif
295 },
296 + .probe = i8042_probe,
297 .remove = i8042_remove,
298 .shutdown = i8042_shutdown,
299 };
300 @@ -1607,7 +1612,6 @@ static struct notifier_block i8042_kbd_bind_notifier_block = {
301
302 static int __init i8042_init(void)
303 {
304 - struct platform_device *pdev;
305 int err;
306
307 dbg_init();
308 @@ -1623,17 +1627,29 @@ static int __init i8042_init(void)
309 /* Set this before creating the dev to allow i8042_command to work right away */
310 i8042_present = true;
311
312 - pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
313 - if (IS_ERR(pdev)) {
314 - err = PTR_ERR(pdev);
315 + err = platform_driver_register(&i8042_driver);
316 + if (err)
317 goto err_platform_exit;
318 +
319 + i8042_platform_device = platform_device_alloc("i8042", -1);
320 + if (!i8042_platform_device) {
321 + err = -ENOMEM;
322 + goto err_unregister_driver;
323 }
324
325 + err = platform_device_add(i8042_platform_device);
326 + if (err)
327 + goto err_free_device;
328 +
329 bus_register_notifier(&serio_bus, &i8042_kbd_bind_notifier_block);
330 panic_blink = i8042_panic_blink;
331
332 return 0;
333
334 +err_free_device:
335 + platform_device_put(i8042_platform_device);
336 +err_unregister_driver:
337 + platform_driver_unregister(&i8042_driver);
338 err_platform_exit:
339 i8042_platform_exit();
340 return err;
341 diff --git a/drivers/net/ethernet/freescale/fman/fman_port.c b/drivers/net/ethernet/freescale/fman/fman_port.c
342 index 47f6fee1f3964..1812434cda847 100644
343 --- a/drivers/net/ethernet/freescale/fman/fman_port.c
344 +++ b/drivers/net/ethernet/freescale/fman/fman_port.c
345 @@ -1791,7 +1791,7 @@ static int fman_port_probe(struct platform_device *of_dev)
346 fman = dev_get_drvdata(&fm_pdev->dev);
347 if (!fman) {
348 err = -EINVAL;
349 - goto return_err;
350 + goto put_device;
351 }
352
353 err = of_property_read_u32(port_node, "cell-index", &val);
354 @@ -1799,7 +1799,7 @@ static int fman_port_probe(struct platform_device *of_dev)
355 dev_err(port->dev, "%s: reading cell-index for %pOF failed\n",
356 __func__, port_node);
357 err = -EINVAL;
358 - goto return_err;
359 + goto put_device;
360 }
361 port_id = (u8)val;
362 port->dts_params.id = port_id;
363 @@ -1833,7 +1833,7 @@ static int fman_port_probe(struct platform_device *of_dev)
364 } else {
365 dev_err(port->dev, "%s: Illegal port type\n", __func__);
366 err = -EINVAL;
367 - goto return_err;
368 + goto put_device;
369 }
370
371 port->dts_params.type = port_type;
372 @@ -1847,7 +1847,7 @@ static int fman_port_probe(struct platform_device *of_dev)
373 dev_err(port->dev, "%s: incorrect qman-channel-id\n",
374 __func__);
375 err = -EINVAL;
376 - goto return_err;
377 + goto put_device;
378 }
379 port->dts_params.qman_channel_id = qman_channel_id;
380 }
381 @@ -1857,7 +1857,7 @@ static int fman_port_probe(struct platform_device *of_dev)
382 dev_err(port->dev, "%s: of_address_to_resource() failed\n",
383 __func__);
384 err = -ENOMEM;
385 - goto return_err;
386 + goto put_device;
387 }
388
389 port->dts_params.fman = fman;
390 @@ -1882,6 +1882,8 @@ static int fman_port_probe(struct platform_device *of_dev)
391
392 return 0;
393
394 +put_device:
395 + put_device(&fm_pdev->dev);
396 return_err:
397 of_node_put(port_node);
398 free_port:
399 diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
400 index 6e504854571cf..94541bf889a23 100644
401 --- a/drivers/net/ethernet/lantiq_xrx200.c
402 +++ b/drivers/net/ethernet/lantiq_xrx200.c
403 @@ -209,7 +209,7 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
404 skb->protocol = eth_type_trans(skb, net_dev);
405 netif_receive_skb(skb);
406 net_dev->stats.rx_packets++;
407 - net_dev->stats.rx_bytes += len - ETH_FCS_LEN;
408 + net_dev->stats.rx_bytes += len;
409
410 return 0;
411 }
412 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
413 index 5f4f0f61c83c8..dea884c94568c 100644
414 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
415 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
416 @@ -3907,12 +3907,11 @@ static int set_feature_arfs(struct net_device *netdev, bool enable)
417
418 static int mlx5e_handle_feature(struct net_device *netdev,
419 netdev_features_t *features,
420 - netdev_features_t wanted_features,
421 netdev_features_t feature,
422 mlx5e_feature_handler feature_handler)
423 {
424 - netdev_features_t changes = wanted_features ^ netdev->features;
425 - bool enable = !!(wanted_features & feature);
426 + netdev_features_t changes = *features ^ netdev->features;
427 + bool enable = !!(*features & feature);
428 int err;
429
430 if (!(changes & feature))
431 @@ -3920,22 +3919,22 @@ static int mlx5e_handle_feature(struct net_device *netdev,
432
433 err = feature_handler(netdev, enable);
434 if (err) {
435 + MLX5E_SET_FEATURE(features, feature, !enable);
436 netdev_err(netdev, "%s feature %pNF failed, err %d\n",
437 enable ? "Enable" : "Disable", &feature, err);
438 return err;
439 }
440
441 - MLX5E_SET_FEATURE(features, feature, enable);
442 return 0;
443 }
444
445 int mlx5e_set_features(struct net_device *netdev, netdev_features_t features)
446 {
447 - netdev_features_t oper_features = netdev->features;
448 + netdev_features_t oper_features = features;
449 int err = 0;
450
451 #define MLX5E_HANDLE_FEATURE(feature, handler) \
452 - mlx5e_handle_feature(netdev, &oper_features, features, feature, handler)
453 + mlx5e_handle_feature(netdev, &oper_features, feature, handler)
454
455 err |= MLX5E_HANDLE_FEATURE(NETIF_F_LRO, set_feature_lro);
456 err |= MLX5E_HANDLE_FEATURE(NETIF_F_HW_VLAN_CTAG_FILTER,
457 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
458 index 56bf900eb753f..dbdb6a9592f09 100644
459 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
460 +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c
461 @@ -2,6 +2,7 @@
462 /* Copyright (c) 2019 Mellanox Technologies. */
463
464 #include <linux/mlx5/eswitch.h>
465 +#include <linux/err.h>
466 #include "dr_types.h"
467
468 static int dr_domain_init_cache(struct mlx5dr_domain *dmn)
469 @@ -64,9 +65,9 @@ static int dr_domain_init_resources(struct mlx5dr_domain *dmn)
470 }
471
472 dmn->uar = mlx5_get_uars_page(dmn->mdev);
473 - if (!dmn->uar) {
474 + if (IS_ERR(dmn->uar)) {
475 mlx5dr_err(dmn, "Couldn't allocate UAR\n");
476 - ret = -ENOMEM;
477 + ret = PTR_ERR(dmn->uar);
478 goto clean_pd;
479 }
480
481 diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
482 index 99ba3551458fc..f9c303d76658a 100644
483 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
484 +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
485 @@ -1995,7 +1995,7 @@ static int ionic_lif_init(struct ionic_lif *lif)
486 return -EINVAL;
487 }
488
489 - lif->dbid_inuse = bitmap_alloc(lif->dbid_count, GFP_KERNEL);
490 + lif->dbid_inuse = bitmap_zalloc(lif->dbid_count, GFP_KERNEL);
491 if (!lif->dbid_inuse) {
492 dev_err(dev, "Failed alloc doorbell id bitmap, aborting\n");
493 return -ENOMEM;
494 diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c
495 index b744c09346a7c..dda051c94fb4d 100644
496 --- a/drivers/net/usb/pegasus.c
497 +++ b/drivers/net/usb/pegasus.c
498 @@ -495,11 +495,11 @@ static void read_bulk_callback(struct urb *urb)
499 goto goon;
500
501 rx_status = buf[count - 2];
502 - if (rx_status & 0x1e) {
503 + if (rx_status & 0x1c) {
504 netif_dbg(pegasus, rx_err, net,
505 "RX packet error %x\n", rx_status);
506 net->stats.rx_errors++;
507 - if (rx_status & 0x06) /* long or runt */
508 + if (rx_status & 0x04) /* runt */
509 net->stats.rx_length_errors++;
510 if (rx_status & 0x08)
511 net->stats.rx_crc_errors++;
512 diff --git a/drivers/nfc/st21nfca/i2c.c b/drivers/nfc/st21nfca/i2c.c
513 index 23ed11f91213d..6ea59426ab0bf 100644
514 --- a/drivers/nfc/st21nfca/i2c.c
515 +++ b/drivers/nfc/st21nfca/i2c.c
516 @@ -533,7 +533,8 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
517 phy->gpiod_ena = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW);
518 if (IS_ERR(phy->gpiod_ena)) {
519 nfc_err(dev, "Unable to get ENABLE GPIO\n");
520 - return PTR_ERR(phy->gpiod_ena);
521 + r = PTR_ERR(phy->gpiod_ena);
522 + goto out_free;
523 }
524
525 phy->se_status.is_ese_present =
526 @@ -544,7 +545,7 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
527 r = st21nfca_hci_platform_init(phy);
528 if (r < 0) {
529 nfc_err(&client->dev, "Unable to reboot st21nfca\n");
530 - return r;
531 + goto out_free;
532 }
533
534 r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
535 @@ -553,15 +554,23 @@ static int st21nfca_hci_i2c_probe(struct i2c_client *client,
536 ST21NFCA_HCI_DRIVER_NAME, phy);
537 if (r < 0) {
538 nfc_err(&client->dev, "Unable to register IRQ handler\n");
539 - return r;
540 + goto out_free;
541 }
542
543 - return st21nfca_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
544 - ST21NFCA_FRAME_HEADROOM,
545 - ST21NFCA_FRAME_TAILROOM,
546 - ST21NFCA_HCI_LLC_MAX_PAYLOAD,
547 - &phy->hdev,
548 - &phy->se_status);
549 + r = st21nfca_hci_probe(phy, &i2c_phy_ops, LLC_SHDLC_NAME,
550 + ST21NFCA_FRAME_HEADROOM,
551 + ST21NFCA_FRAME_TAILROOM,
552 + ST21NFCA_HCI_LLC_MAX_PAYLOAD,
553 + &phy->hdev,
554 + &phy->se_status);
555 + if (r)
556 + goto out_free;
557 +
558 + return 0;
559 +
560 +out_free:
561 + kfree_skb(phy->pending_skb);
562 + return r;
563 }
564
565 static int st21nfca_hci_i2c_remove(struct i2c_client *client)
566 @@ -574,6 +583,8 @@ static int st21nfca_hci_i2c_remove(struct i2c_client *client)
567
568 if (phy->powered)
569 st21nfca_hci_i2c_disable(phy);
570 + if (phy->pending_skb)
571 + kfree_skb(phy->pending_skb);
572
573 return 0;
574 }
575 diff --git a/drivers/platform/x86/apple-gmux.c b/drivers/platform/x86/apple-gmux.c
576 index 7e3083deb1c5d..1b86005c0f5f4 100644
577 --- a/drivers/platform/x86/apple-gmux.c
578 +++ b/drivers/platform/x86/apple-gmux.c
579 @@ -625,7 +625,7 @@ static int gmux_probe(struct pnp_dev *pnp, const struct pnp_device_id *id)
580 }
581
582 gmux_data->iostart = res->start;
583 - gmux_data->iolen = res->end - res->start;
584 + gmux_data->iolen = resource_size(res);
585
586 if (gmux_data->iolen < GMUX_MIN_IO_LEN) {
587 pr_err("gmux I/O region too small (%lu < %u)\n",
588 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
589 index 3c9248d2435e1..e15bb3dfe9956 100644
590 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
591 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
592 @@ -2757,8 +2757,8 @@ lpfc_debugfs_nvmeio_trc_write(struct file *file, const char __user *buf,
593 char mybuf[64];
594 char *pbuf;
595
596 - if (nbytes > 64)
597 - nbytes = 64;
598 + if (nbytes > 63)
599 + nbytes = 63;
600
601 memset(mybuf, 0, sizeof(mybuf));
602
603 diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
604 index 0ac342b1deb95..0370ff6dd2efd 100644
605 --- a/drivers/scsi/vmw_pvscsi.c
606 +++ b/drivers/scsi/vmw_pvscsi.c
607 @@ -578,9 +578,12 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
608 * Commands like INQUIRY may transfer less data than
609 * requested by the initiator via bufflen. Set residual
610 * count to make upper layer aware of the actual amount
611 - * of data returned.
612 + * of data returned. There are cases when controller
613 + * returns zero dataLen with non zero data - do not set
614 + * residual count in that case.
615 */
616 - scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
617 + if (e->dataLen && (e->dataLen < scsi_bufflen(cmd)))
618 + scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
619 cmd->result = (DID_OK << 16);
620 break;
621
622 diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
623 index d6491e973fa4c..0d5ae80530498 100644
624 --- a/drivers/tee/tee_shm.c
625 +++ b/drivers/tee/tee_shm.c
626 @@ -1,26 +1,18 @@
627 // SPDX-License-Identifier: GPL-2.0-only
628 /*
629 - * Copyright (c) 2015-2016, Linaro Limited
630 + * Copyright (c) 2015-2017, 2019-2021 Linaro Limited
631 */
632 +#include <linux/anon_inodes.h>
633 #include <linux/device.h>
634 -#include <linux/dma-buf.h>
635 -#include <linux/fdtable.h>
636 #include <linux/idr.h>
637 +#include <linux/mm.h>
638 #include <linux/sched.h>
639 #include <linux/slab.h>
640 #include <linux/tee_drv.h>
641 #include "tee_private.h"
642
643 -static void tee_shm_release(struct tee_shm *shm)
644 +static void tee_shm_release(struct tee_device *teedev, struct tee_shm *shm)
645 {
646 - struct tee_device *teedev = shm->teedev;
647 -
648 - mutex_lock(&teedev->mutex);
649 - idr_remove(&teedev->idr, shm->id);
650 - if (shm->ctx)
651 - list_del(&shm->link);
652 - mutex_unlock(&teedev->mutex);
653 -
654 if (shm->flags & TEE_SHM_POOL) {
655 struct tee_shm_pool_mgr *poolm;
656
657 @@ -52,51 +44,6 @@ static void tee_shm_release(struct tee_shm *shm)
658 tee_device_put(teedev);
659 }
660
661 -static struct sg_table *tee_shm_op_map_dma_buf(struct dma_buf_attachment
662 - *attach, enum dma_data_direction dir)
663 -{
664 - return NULL;
665 -}
666 -
667 -static void tee_shm_op_unmap_dma_buf(struct dma_buf_attachment *attach,
668 - struct sg_table *table,
669 - enum dma_data_direction dir)
670 -{
671 -}
672 -
673 -static void tee_shm_op_release(struct dma_buf *dmabuf)
674 -{
675 - struct tee_shm *shm = dmabuf->priv;
676 -
677 - tee_shm_release(shm);
678 -}
679 -
680 -static void *tee_shm_op_map(struct dma_buf *dmabuf, unsigned long pgnum)
681 -{
682 - return NULL;
683 -}
684 -
685 -static int tee_shm_op_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma)
686 -{
687 - struct tee_shm *shm = dmabuf->priv;
688 - size_t size = vma->vm_end - vma->vm_start;
689 -
690 - /* Refuse sharing shared memory provided by application */
691 - if (shm->flags & TEE_SHM_REGISTER)
692 - return -EINVAL;
693 -
694 - return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT,
695 - size, vma->vm_page_prot);
696 -}
697 -
698 -static const struct dma_buf_ops tee_shm_dma_buf_ops = {
699 - .map_dma_buf = tee_shm_op_map_dma_buf,
700 - .unmap_dma_buf = tee_shm_op_unmap_dma_buf,
701 - .release = tee_shm_op_release,
702 - .map = tee_shm_op_map,
703 - .mmap = tee_shm_op_mmap,
704 -};
705 -
706 static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx,
707 struct tee_device *teedev,
708 size_t size, u32 flags)
709 @@ -137,6 +84,7 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx,
710 goto err_dev_put;
711 }
712
713 + refcount_set(&shm->refcount, 1);
714 shm->flags = flags | TEE_SHM_POOL;
715 shm->teedev = teedev;
716 shm->ctx = ctx;
717 @@ -159,21 +107,6 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx,
718 goto err_pool_free;
719 }
720
721 - if (flags & TEE_SHM_DMA_BUF) {
722 - DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
723 -
724 - exp_info.ops = &tee_shm_dma_buf_ops;
725 - exp_info.size = shm->size;
726 - exp_info.flags = O_RDWR;
727 - exp_info.priv = shm;
728 -
729 - shm->dmabuf = dma_buf_export(&exp_info);
730 - if (IS_ERR(shm->dmabuf)) {
731 - ret = ERR_CAST(shm->dmabuf);
732 - goto err_rem;
733 - }
734 - }
735 -
736 if (ctx) {
737 teedev_ctx_get(ctx);
738 mutex_lock(&teedev->mutex);
739 @@ -182,10 +115,6 @@ static struct tee_shm *__tee_shm_alloc(struct tee_context *ctx,
740 }
741
742 return shm;
743 -err_rem:
744 - mutex_lock(&teedev->mutex);
745 - idr_remove(&teedev->idr, shm->id);
746 - mutex_unlock(&teedev->mutex);
747 err_pool_free:
748 poolm->ops->free(poolm, shm);
749 err_kfree:
750 @@ -268,6 +197,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
751 goto err;
752 }
753
754 + refcount_set(&shm->refcount, 1);
755 shm->flags = flags | TEE_SHM_REGISTER;
756 shm->teedev = teedev;
757 shm->ctx = ctx;
758 @@ -309,22 +239,6 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
759 goto err;
760 }
761
762 - if (flags & TEE_SHM_DMA_BUF) {
763 - DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
764 -
765 - exp_info.ops = &tee_shm_dma_buf_ops;
766 - exp_info.size = shm->size;
767 - exp_info.flags = O_RDWR;
768 - exp_info.priv = shm;
769 -
770 - shm->dmabuf = dma_buf_export(&exp_info);
771 - if (IS_ERR(shm->dmabuf)) {
772 - ret = ERR_CAST(shm->dmabuf);
773 - teedev->desc->ops->shm_unregister(ctx, shm);
774 - goto err;
775 - }
776 - }
777 -
778 mutex_lock(&teedev->mutex);
779 list_add_tail(&shm->link, &ctx->list_shm);
780 mutex_unlock(&teedev->mutex);
781 @@ -352,6 +266,35 @@ err:
782 }
783 EXPORT_SYMBOL_GPL(tee_shm_register);
784
785 +static int tee_shm_fop_release(struct inode *inode, struct file *filp)
786 +{
787 + tee_shm_put(filp->private_data);
788 + return 0;
789 +}
790 +
791 +static int tee_shm_fop_mmap(struct file *filp, struct vm_area_struct *vma)
792 +{
793 + struct tee_shm *shm = filp->private_data;
794 + size_t size = vma->vm_end - vma->vm_start;
795 +
796 + /* Refuse sharing shared memory provided by application */
797 + if (shm->flags & TEE_SHM_USER_MAPPED)
798 + return -EINVAL;
799 +
800 + /* check for overflowing the buffer's size */
801 + if (vma->vm_pgoff + vma_pages(vma) > shm->size >> PAGE_SHIFT)
802 + return -EINVAL;
803 +
804 + return remap_pfn_range(vma, vma->vm_start, shm->paddr >> PAGE_SHIFT,
805 + size, vma->vm_page_prot);
806 +}
807 +
808 +static const struct file_operations tee_shm_fops = {
809 + .owner = THIS_MODULE,
810 + .release = tee_shm_fop_release,
811 + .mmap = tee_shm_fop_mmap,
812 +};
813 +
814 /**
815 * tee_shm_get_fd() - Increase reference count and return file descriptor
816 * @shm: Shared memory handle
817 @@ -364,10 +307,11 @@ int tee_shm_get_fd(struct tee_shm *shm)
818 if (!(shm->flags & TEE_SHM_DMA_BUF))
819 return -EINVAL;
820
821 - get_dma_buf(shm->dmabuf);
822 - fd = dma_buf_fd(shm->dmabuf, O_CLOEXEC);
823 + /* matched by tee_shm_put() in tee_shm_op_release() */
824 + refcount_inc(&shm->refcount);
825 + fd = anon_inode_getfd("tee_shm", &tee_shm_fops, shm, O_RDWR);
826 if (fd < 0)
827 - dma_buf_put(shm->dmabuf);
828 + tee_shm_put(shm);
829 return fd;
830 }
831
832 @@ -377,17 +321,7 @@ int tee_shm_get_fd(struct tee_shm *shm)
833 */
834 void tee_shm_free(struct tee_shm *shm)
835 {
836 - /*
837 - * dma_buf_put() decreases the dmabuf reference counter and will
838 - * call tee_shm_release() when the last reference is gone.
839 - *
840 - * In the case of driver private memory we call tee_shm_release
841 - * directly instead as it doesn't have a reference counter.
842 - */
843 - if (shm->flags & TEE_SHM_DMA_BUF)
844 - dma_buf_put(shm->dmabuf);
845 - else
846 - tee_shm_release(shm);
847 + tee_shm_put(shm);
848 }
849 EXPORT_SYMBOL_GPL(tee_shm_free);
850
851 @@ -494,10 +428,15 @@ struct tee_shm *tee_shm_get_from_id(struct tee_context *ctx, int id)
852 teedev = ctx->teedev;
853 mutex_lock(&teedev->mutex);
854 shm = idr_find(&teedev->idr, id);
855 + /*
856 + * If the tee_shm was found in the IDR it must have a refcount
857 + * larger than 0 due to the guarantee in tee_shm_put() below. So
858 + * it's safe to use refcount_inc().
859 + */
860 if (!shm || shm->ctx != ctx)
861 shm = ERR_PTR(-EINVAL);
862 - else if (shm->flags & TEE_SHM_DMA_BUF)
863 - get_dma_buf(shm->dmabuf);
864 + else
865 + refcount_inc(&shm->refcount);
866 mutex_unlock(&teedev->mutex);
867 return shm;
868 }
869 @@ -509,7 +448,25 @@ EXPORT_SYMBOL_GPL(tee_shm_get_from_id);
870 */
871 void tee_shm_put(struct tee_shm *shm)
872 {
873 - if (shm->flags & TEE_SHM_DMA_BUF)
874 - dma_buf_put(shm->dmabuf);
875 + struct tee_device *teedev = shm->teedev;
876 + bool do_release = false;
877 +
878 + mutex_lock(&teedev->mutex);
879 + if (refcount_dec_and_test(&shm->refcount)) {
880 + /*
881 + * refcount has reached 0, we must now remove it from the
882 + * IDR before releasing the mutex. This will guarantee that
883 + * the refcount_inc() in tee_shm_get_from_id() never starts
884 + * from 0.
885 + */
886 + idr_remove(&teedev->idr, shm->id);
887 + if (shm->ctx)
888 + list_del(&shm->link);
889 + do_release = true;
890 + }
891 + mutex_unlock(&teedev->mutex);
892 +
893 + if (do_release)
894 + tee_shm_release(teedev, shm);
895 }
896 EXPORT_SYMBOL_GPL(tee_shm_put);
897 diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
898 index 94ccf43368dfc..3f5c21f7f9905 100644
899 --- a/drivers/usb/gadget/function/f_fs.c
900 +++ b/drivers/usb/gadget/function/f_fs.c
901 @@ -1791,11 +1791,15 @@ static void ffs_data_clear(struct ffs_data *ffs)
902
903 BUG_ON(ffs->gadget);
904
905 - if (ffs->epfiles)
906 + if (ffs->epfiles) {
907 ffs_epfiles_destroy(ffs->epfiles, ffs->eps_count);
908 + ffs->epfiles = NULL;
909 + }
910
911 - if (ffs->ffs_eventfd)
912 + if (ffs->ffs_eventfd) {
913 eventfd_ctx_put(ffs->ffs_eventfd);
914 + ffs->ffs_eventfd = NULL;
915 + }
916
917 kfree(ffs->raw_descs_data);
918 kfree(ffs->raw_strings);
919 @@ -1808,7 +1812,6 @@ static void ffs_data_reset(struct ffs_data *ffs)
920
921 ffs_data_clear(ffs);
922
923 - ffs->epfiles = NULL;
924 ffs->raw_descs_data = NULL;
925 ffs->raw_descs = NULL;
926 ffs->raw_strings = NULL;
927 diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
928 index ded05c39e4d1c..e7533787db411 100644
929 --- a/drivers/usb/host/xhci-pci.c
930 +++ b/drivers/usb/host/xhci-pci.c
931 @@ -108,7 +108,6 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
932 /* Look for vendor-specific quirks */
933 if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
934 (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK ||
935 - pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1100 ||
936 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1400)) {
937 if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK &&
938 pdev->revision == 0x0) {
939 @@ -143,6 +142,10 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci)
940 pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1009)
941 xhci->quirks |= XHCI_BROKEN_STREAMS;
942
943 + if (pdev->vendor == PCI_VENDOR_ID_FRESCO_LOGIC &&
944 + pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_FL1100)
945 + xhci->quirks |= XHCI_TRUST_TX_LENGTH;
946 +
947 if (pdev->vendor == PCI_VENDOR_ID_NEC)
948 xhci->quirks |= XHCI_NEC_HOST;
949
950 diff --git a/drivers/usb/mtu3/mtu3_gadget.c b/drivers/usb/mtu3/mtu3_gadget.c
951 index 619c4598e64ea..253c8b71d3c49 100644
952 --- a/drivers/usb/mtu3/mtu3_gadget.c
953 +++ b/drivers/usb/mtu3/mtu3_gadget.c
954 @@ -100,6 +100,13 @@ static int mtu3_ep_enable(struct mtu3_ep *mep)
955 interval = clamp_val(interval, 1, 16) - 1;
956 mult = usb_endpoint_maxp_mult(desc) - 1;
957 }
958 + break;
959 + case USB_SPEED_FULL:
960 + if (usb_endpoint_xfer_isoc(desc))
961 + interval = clamp_val(desc->bInterval, 1, 16);
962 + else if (usb_endpoint_xfer_int(desc))
963 + interval = clamp_val(desc->bInterval, 1, 255);
964 +
965 break;
966 default:
967 break; /*others are ignored */
968 @@ -245,6 +252,7 @@ struct usb_request *mtu3_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
969 mreq->request.dma = DMA_ADDR_INVALID;
970 mreq->epnum = mep->epnum;
971 mreq->mep = mep;
972 + INIT_LIST_HEAD(&mreq->list);
973 trace_mtu3_alloc_request(mreq);
974
975 return &mreq->request;
976 diff --git a/drivers/usb/mtu3/mtu3_qmu.c b/drivers/usb/mtu3/mtu3_qmu.c
977 index 3f414f91b5899..2ea3157ddb6e2 100644
978 --- a/drivers/usb/mtu3/mtu3_qmu.c
979 +++ b/drivers/usb/mtu3/mtu3_qmu.c
980 @@ -273,6 +273,8 @@ static int mtu3_prepare_tx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
981 gpd->dw3_info |= cpu_to_le32(GPD_EXT_FLAG_ZLP);
982 }
983
984 + /* prevent reorder, make sure GPD's HWO is set last */
985 + mb();
986 gpd->dw0_info |= cpu_to_le32(GPD_FLAGS_IOC | GPD_FLAGS_HWO);
987
988 mreq->gpd = gpd;
989 @@ -306,6 +308,8 @@ static int mtu3_prepare_rx_gpd(struct mtu3_ep *mep, struct mtu3_request *mreq)
990 gpd->next_gpd = cpu_to_le32(lower_32_bits(enq_dma));
991 ext_addr |= GPD_EXT_NGP(mtu, upper_32_bits(enq_dma));
992 gpd->dw3_info = cpu_to_le32(ext_addr);
993 + /* prevent reorder, make sure GPD's HWO is set last */
994 + mb();
995 gpd->dw0_info |= cpu_to_le32(GPD_FLAGS_IOC | GPD_FLAGS_HWO);
996
997 mreq->gpd = gpd;
998 @@ -445,7 +449,8 @@ static void qmu_tx_zlp_error_handler(struct mtu3 *mtu, u8 epnum)
999 return;
1000 }
1001 mtu3_setbits(mbase, MU3D_EP_TXCR0(mep->epnum), TX_TXPKTRDY);
1002 -
1003 + /* prevent reorder, make sure GPD's HWO is set last */
1004 + mb();
1005 /* by pass the current GDP */
1006 gpd_current->dw0_info |= cpu_to_le32(GPD_FLAGS_BPS | GPD_FLAGS_HWO);
1007
1008 diff --git a/include/linux/memblock.h b/include/linux/memblock.h
1009 index f491690d54c6c..64b971b2542d6 100644
1010 --- a/include/linux/memblock.h
1011 +++ b/include/linux/memblock.h
1012 @@ -351,8 +351,8 @@ phys_addr_t memblock_phys_alloc_range(phys_addr_t size, phys_addr_t align,
1013 phys_addr_t start, phys_addr_t end);
1014 phys_addr_t memblock_phys_alloc_try_nid(phys_addr_t size, phys_addr_t align, int nid);
1015
1016 -static inline phys_addr_t memblock_phys_alloc(phys_addr_t size,
1017 - phys_addr_t align)
1018 +static __always_inline phys_addr_t memblock_phys_alloc(phys_addr_t size,
1019 + phys_addr_t align)
1020 {
1021 return memblock_phys_alloc_range(size, align, 0,
1022 MEMBLOCK_ALLOC_ACCESSIBLE);
1023 diff --git a/include/linux/tee_drv.h b/include/linux/tee_drv.h
1024 index cd15c1b7fae06..e08ace76eba6a 100644
1025 --- a/include/linux/tee_drv.h
1026 +++ b/include/linux/tee_drv.h
1027 @@ -178,7 +178,7 @@ void tee_device_unregister(struct tee_device *teedev);
1028 * @offset: offset of buffer in user space
1029 * @pages: locked pages from userspace
1030 * @num_pages: number of locked pages
1031 - * @dmabuf: dmabuf used to for exporting to user space
1032 + * @refcount: reference counter
1033 * @flags: defined by TEE_SHM_* in tee_drv.h
1034 * @id: unique id of a shared memory object on this device
1035 *
1036 @@ -195,7 +195,7 @@ struct tee_shm {
1037 unsigned int offset;
1038 struct page **pages;
1039 size_t num_pages;
1040 - struct dma_buf *dmabuf;
1041 + refcount_t refcount;
1042 u32 flags;
1043 int id;
1044 };
1045 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
1046 index 3ab5c6bbb90bd..35c108a6b8720 100644
1047 --- a/include/net/sctp/sctp.h
1048 +++ b/include/net/sctp/sctp.h
1049 @@ -103,6 +103,7 @@ extern struct percpu_counter sctp_sockets_allocated;
1050 int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *);
1051 struct sk_buff *sctp_skb_recv_datagram(struct sock *, int, int, int *);
1052
1053 +typedef int (*sctp_callback_t)(struct sctp_endpoint *, struct sctp_transport *, void *);
1054 void sctp_transport_walk_start(struct rhashtable_iter *iter);
1055 void sctp_transport_walk_stop(struct rhashtable_iter *iter);
1056 struct sctp_transport *sctp_transport_get_next(struct net *net,
1057 @@ -113,9 +114,8 @@ int sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *),
1058 struct net *net,
1059 const union sctp_addr *laddr,
1060 const union sctp_addr *paddr, void *p);
1061 -int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
1062 - int (*cb_done)(struct sctp_transport *, void *),
1063 - struct net *net, int *pos, void *p);
1064 +int sctp_transport_traverse_process(sctp_callback_t cb, sctp_callback_t cb_done,
1065 + struct net *net, int *pos, void *p);
1066 int sctp_for_each_endpoint(int (*cb)(struct sctp_endpoint *, void *), void *p);
1067 int sctp_get_sctp_info(struct sock *sk, struct sctp_association *asoc,
1068 struct sctp_info *info);
1069 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
1070 index fd7c3f76040c3..cb05e503c9cd1 100644
1071 --- a/include/net/sctp/structs.h
1072 +++ b/include/net/sctp/structs.h
1073 @@ -1345,6 +1345,7 @@ struct sctp_endpoint {
1074
1075 u32 secid;
1076 u32 peer_secid;
1077 + struct rcu_head rcu;
1078 };
1079
1080 /* Recover the outter endpoint structure. */
1081 @@ -1360,7 +1361,7 @@ static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base)
1082 struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t);
1083 void sctp_endpoint_free(struct sctp_endpoint *);
1084 void sctp_endpoint_put(struct sctp_endpoint *);
1085 -void sctp_endpoint_hold(struct sctp_endpoint *);
1086 +int sctp_endpoint_hold(struct sctp_endpoint *ep);
1087 void sctp_endpoint_add_asoc(struct sctp_endpoint *, struct sctp_association *);
1088 struct sctp_association *sctp_endpoint_lookup_assoc(
1089 const struct sctp_endpoint *ep,
1090 diff --git a/include/uapi/linux/nfc.h b/include/uapi/linux/nfc.h
1091 index f6e3c8c9c7449..4fa4e979e948a 100644
1092 --- a/include/uapi/linux/nfc.h
1093 +++ b/include/uapi/linux/nfc.h
1094 @@ -263,7 +263,7 @@ enum nfc_sdp_attr {
1095 #define NFC_SE_ENABLED 0x1
1096
1097 struct sockaddr_nfc {
1098 - sa_family_t sa_family;
1099 + __kernel_sa_family_t sa_family;
1100 __u32 dev_idx;
1101 __u32 target_idx;
1102 __u32 nfc_protocol;
1103 @@ -271,14 +271,14 @@ struct sockaddr_nfc {
1104
1105 #define NFC_LLCP_MAX_SERVICE_NAME 63
1106 struct sockaddr_nfc_llcp {
1107 - sa_family_t sa_family;
1108 + __kernel_sa_family_t sa_family;
1109 __u32 dev_idx;
1110 __u32 target_idx;
1111 __u32 nfc_protocol;
1112 __u8 dsap; /* Destination SAP, if known */
1113 __u8 ssap; /* Source SAP to be bound to */
1114 char service_name[NFC_LLCP_MAX_SERVICE_NAME]; /* Service name URI */;
1115 - size_t service_name_len;
1116 + __kernel_size_t service_name_len;
1117 };
1118
1119 /* NFC socket protocols */
1120 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
1121 index 70f92aaca4110..c800220c404d5 100644
1122 --- a/net/ipv4/af_inet.c
1123 +++ b/net/ipv4/af_inet.c
1124 @@ -1974,6 +1974,10 @@ static int __init inet_init(void)
1125
1126 ip_init();
1127
1128 + /* Initialise per-cpu ipv4 mibs */
1129 + if (init_ipv4_mibs())
1130 + panic("%s: Cannot init ipv4 mibs\n", __func__);
1131 +
1132 /* Setup TCP slab cache for open requests. */
1133 tcp_init();
1134
1135 @@ -2004,12 +2008,6 @@ static int __init inet_init(void)
1136
1137 if (init_inet_pernet_ops())
1138 pr_crit("%s: Cannot init ipv4 inet pernet ops\n", __func__);
1139 - /*
1140 - * Initialise per-cpu ipv4 mibs
1141 - */
1142 -
1143 - if (init_ipv4_mibs())
1144 - pr_crit("%s: Cannot init ipv4 mibs\n", __func__);
1145
1146 ipv4_proc_init();
1147
1148 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
1149 index 818fc99756256..a71bfa5b02770 100644
1150 --- a/net/ipv6/udp.c
1151 +++ b/net/ipv6/udp.c
1152 @@ -1132,7 +1132,7 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
1153 kfree_skb(skb);
1154 return -EINVAL;
1155 }
1156 - if (skb->len > cork->gso_size * UDP_MAX_SEGMENTS) {
1157 + if (datalen > cork->gso_size * UDP_MAX_SEGMENTS) {
1158 kfree_skb(skb);
1159 return -EINVAL;
1160 }
1161 diff --git a/net/ncsi/ncsi-netlink.c b/net/ncsi/ncsi-netlink.c
1162 index a33ea45dec054..27700887c3217 100644
1163 --- a/net/ncsi/ncsi-netlink.c
1164 +++ b/net/ncsi/ncsi-netlink.c
1165 @@ -112,7 +112,11 @@ static int ncsi_write_package_info(struct sk_buff *skb,
1166 pnest = nla_nest_start_noflag(skb, NCSI_PKG_ATTR);
1167 if (!pnest)
1168 return -ENOMEM;
1169 - nla_put_u32(skb, NCSI_PKG_ATTR_ID, np->id);
1170 + rc = nla_put_u32(skb, NCSI_PKG_ATTR_ID, np->id);
1171 + if (rc) {
1172 + nla_nest_cancel(skb, pnest);
1173 + return rc;
1174 + }
1175 if ((0x1 << np->id) == ndp->package_whitelist)
1176 nla_put_flag(skb, NCSI_PKG_ATTR_FORCED);
1177 cnest = nla_nest_start_noflag(skb, NCSI_PKG_ATTR_CHANNEL_LIST);
1178 diff --git a/net/sctp/diag.c b/net/sctp/diag.c
1179 index ba9f64fdfd238..7921e77fa55a3 100644
1180 --- a/net/sctp/diag.c
1181 +++ b/net/sctp/diag.c
1182 @@ -292,9 +292,8 @@ out:
1183 return err;
1184 }
1185
1186 -static int sctp_sock_dump(struct sctp_transport *tsp, void *p)
1187 +static int sctp_sock_dump(struct sctp_endpoint *ep, struct sctp_transport *tsp, void *p)
1188 {
1189 - struct sctp_endpoint *ep = tsp->asoc->ep;
1190 struct sctp_comm_param *commp = p;
1191 struct sock *sk = ep->base.sk;
1192 struct sk_buff *skb = commp->skb;
1193 @@ -304,6 +303,8 @@ static int sctp_sock_dump(struct sctp_transport *tsp, void *p)
1194 int err = 0;
1195
1196 lock_sock(sk);
1197 + if (ep != tsp->asoc->ep)
1198 + goto release;
1199 list_for_each_entry(assoc, &ep->asocs, asocs) {
1200 if (cb->args[4] < cb->args[1])
1201 goto next;
1202 @@ -346,9 +347,8 @@ release:
1203 return err;
1204 }
1205
1206 -static int sctp_sock_filter(struct sctp_transport *tsp, void *p)
1207 +static int sctp_sock_filter(struct sctp_endpoint *ep, struct sctp_transport *tsp, void *p)
1208 {
1209 - struct sctp_endpoint *ep = tsp->asoc->ep;
1210 struct sctp_comm_param *commp = p;
1211 struct sock *sk = ep->base.sk;
1212 const struct inet_diag_req_v2 *r = commp->r;
1213 @@ -506,8 +506,8 @@ skip:
1214 if (!(idiag_states & ~(TCPF_LISTEN | TCPF_CLOSE)))
1215 goto done;
1216
1217 - sctp_for_each_transport(sctp_sock_filter, sctp_sock_dump,
1218 - net, &pos, &commp);
1219 + sctp_transport_traverse_process(sctp_sock_filter, sctp_sock_dump,
1220 + net, &pos, &commp);
1221 cb->args[2] = pos;
1222
1223 done:
1224 diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c
1225 index 3067deb0fbec1..665a22d5c725b 100644
1226 --- a/net/sctp/endpointola.c
1227 +++ b/net/sctp/endpointola.c
1228 @@ -184,6 +184,18 @@ void sctp_endpoint_free(struct sctp_endpoint *ep)
1229 }
1230
1231 /* Final destructor for endpoint. */
1232 +static void sctp_endpoint_destroy_rcu(struct rcu_head *head)
1233 +{
1234 + struct sctp_endpoint *ep = container_of(head, struct sctp_endpoint, rcu);
1235 + struct sock *sk = ep->base.sk;
1236 +
1237 + sctp_sk(sk)->ep = NULL;
1238 + sock_put(sk);
1239 +
1240 + kfree(ep);
1241 + SCTP_DBG_OBJCNT_DEC(ep);
1242 +}
1243 +
1244 static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
1245 {
1246 struct sock *sk;
1247 @@ -213,18 +225,13 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
1248 if (sctp_sk(sk)->bind_hash)
1249 sctp_put_port(sk);
1250
1251 - sctp_sk(sk)->ep = NULL;
1252 - /* Give up our hold on the sock */
1253 - sock_put(sk);
1254 -
1255 - kfree(ep);
1256 - SCTP_DBG_OBJCNT_DEC(ep);
1257 + call_rcu(&ep->rcu, sctp_endpoint_destroy_rcu);
1258 }
1259
1260 /* Hold a reference to an endpoint. */
1261 -void sctp_endpoint_hold(struct sctp_endpoint *ep)
1262 +int sctp_endpoint_hold(struct sctp_endpoint *ep)
1263 {
1264 - refcount_inc(&ep->base.refcnt);
1265 + return refcount_inc_not_zero(&ep->base.refcnt);
1266 }
1267
1268 /* Release a reference to an endpoint and clean up if there are
1269 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
1270 index 2146372adff43..565aa77fe5cbe 100644
1271 --- a/net/sctp/socket.c
1272 +++ b/net/sctp/socket.c
1273 @@ -5395,11 +5395,12 @@ int sctp_transport_lookup_process(int (*cb)(struct sctp_transport *, void *),
1274 }
1275 EXPORT_SYMBOL_GPL(sctp_transport_lookup_process);
1276
1277 -int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
1278 - int (*cb_done)(struct sctp_transport *, void *),
1279 - struct net *net, int *pos, void *p) {
1280 +int sctp_transport_traverse_process(sctp_callback_t cb, sctp_callback_t cb_done,
1281 + struct net *net, int *pos, void *p)
1282 +{
1283 struct rhashtable_iter hti;
1284 struct sctp_transport *tsp;
1285 + struct sctp_endpoint *ep;
1286 int ret;
1287
1288 again:
1289 @@ -5408,26 +5409,32 @@ again:
1290
1291 tsp = sctp_transport_get_idx(net, &hti, *pos + 1);
1292 for (; !IS_ERR_OR_NULL(tsp); tsp = sctp_transport_get_next(net, &hti)) {
1293 - ret = cb(tsp, p);
1294 - if (ret)
1295 - break;
1296 + ep = tsp->asoc->ep;
1297 + if (sctp_endpoint_hold(ep)) { /* asoc can be peeled off */
1298 + ret = cb(ep, tsp, p);
1299 + if (ret)
1300 + break;
1301 + sctp_endpoint_put(ep);
1302 + }
1303 (*pos)++;
1304 sctp_transport_put(tsp);
1305 }
1306 sctp_transport_walk_stop(&hti);
1307
1308 if (ret) {
1309 - if (cb_done && !cb_done(tsp, p)) {
1310 + if (cb_done && !cb_done(ep, tsp, p)) {
1311 (*pos)++;
1312 + sctp_endpoint_put(ep);
1313 sctp_transport_put(tsp);
1314 goto again;
1315 }
1316 + sctp_endpoint_put(ep);
1317 sctp_transport_put(tsp);
1318 }
1319
1320 return ret;
1321 }
1322 -EXPORT_SYMBOL_GPL(sctp_for_each_transport);
1323 +EXPORT_SYMBOL_GPL(sctp_transport_traverse_process);
1324
1325 /* 7.2.1 Association Status (SCTP_STATUS)
1326
1327 diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
1328 index a4ca050815aba..dc1d3696af6b8 100755
1329 --- a/scripts/recordmcount.pl
1330 +++ b/scripts/recordmcount.pl
1331 @@ -252,7 +252,7 @@ if ($arch eq "x86_64") {
1332
1333 } elsif ($arch eq "s390" && $bits == 64) {
1334 if ($cc =~ /-DCC_USING_HOTPATCH/) {
1335 - $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*c0 04 00 00 00 00\\s*(bcrl\\s*0,|jgnop\\s*)[0-9a-f]+ <([^\+]*)>\$";
1336 + $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*c0 04 00 00 00 00\\s*(brcl\\s*0,|jgnop\\s*)[0-9a-f]+ <([^\+]*)>\$";
1337 $mcount_adjust = 0;
1338 } else {
1339 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_390_(PC|PLT)32DBL\\s+_mcount\\+0x2\$";
1340 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
1341 index 8b9cbe1e8ee22..91f2ba0b225b7 100644
1342 --- a/security/selinux/hooks.c
1343 +++ b/security/selinux/hooks.c
1344 @@ -5734,7 +5734,7 @@ static unsigned int selinux_ip_postroute_compat(struct sk_buff *skb,
1345 struct common_audit_data ad;
1346 struct lsm_network_audit net = {0,};
1347 char *addrp;
1348 - u8 proto;
1349 + u8 proto = 0;
1350
1351 if (sk == NULL)
1352 return NF_ACCEPT;
1353 diff --git a/security/tomoyo/util.c b/security/tomoyo/util.c
1354 index eba0b3395851e..861fc6f4ebfb7 100644
1355 --- a/security/tomoyo/util.c
1356 +++ b/security/tomoyo/util.c
1357 @@ -1029,6 +1029,8 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
1358 return false;
1359 if (!domain)
1360 return true;
1361 + if (READ_ONCE(domain->flags[TOMOYO_DIF_QUOTA_WARNED]))
1362 + return false;
1363 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list,
1364 srcu_read_lock_held(&tomoyo_ss)) {
1365 u16 perm;
1366 @@ -1074,14 +1076,12 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
1367 if (count < tomoyo_profile(domain->ns, domain->profile)->
1368 pref[TOMOYO_PREF_MAX_LEARNING_ENTRY])
1369 return true;
1370 - if (!domain->flags[TOMOYO_DIF_QUOTA_WARNED]) {
1371 - domain->flags[TOMOYO_DIF_QUOTA_WARNED] = true;
1372 - /* r->granted = false; */
1373 - tomoyo_write_log(r, "%s", tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED]);
1374 + WRITE_ONCE(domain->flags[TOMOYO_DIF_QUOTA_WARNED], true);
1375 + /* r->granted = false; */
1376 + tomoyo_write_log(r, "%s", tomoyo_dif[TOMOYO_DIF_QUOTA_WARNED]);
1377 #ifndef CONFIG_SECURITY_TOMOYO_INSECURE_BUILTIN_SETTING
1378 - pr_warn("WARNING: Domain '%s' has too many ACLs to hold. Stopped learning mode.\n",
1379 - domain->domainname->name);
1380 + pr_warn("WARNING: Domain '%s' has too many ACLs to hold. Stopped learning mode.\n",
1381 + domain->domainname->name);
1382 #endif
1383 - }
1384 return false;
1385 }
1386 diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
1387 index 3a169a026635d..bbf1f2d3387e3 100644
1388 --- a/tools/perf/builtin-script.c
1389 +++ b/tools/perf/builtin-script.c
1390 @@ -2308,7 +2308,7 @@ static int process_switch_event(struct perf_tool *tool,
1391 if (perf_event__process_switch(tool, event, sample, machine) < 0)
1392 return -1;
1393
1394 - if (scripting_ops && scripting_ops->process_switch)
1395 + if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample))
1396 scripting_ops->process_switch(event, sample, machine);
1397
1398 if (!script->show_switch_events)
1399 diff --git a/tools/testing/selftests/net/udpgso.c b/tools/testing/selftests/net/udpgso.c
1400 index c66da6ffd6d8d..7badaf215de28 100644
1401 --- a/tools/testing/selftests/net/udpgso.c
1402 +++ b/tools/testing/selftests/net/udpgso.c
1403 @@ -156,13 +156,13 @@ struct testcase testcases_v4[] = {
1404 },
1405 {
1406 /* send max number of min sized segments */
1407 - .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4,
1408 + .tlen = UDP_MAX_SEGMENTS,
1409 .gso_len = 1,
1410 - .r_num_mss = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4,
1411 + .r_num_mss = UDP_MAX_SEGMENTS,
1412 },
1413 {
1414 /* send max number + 1 of min sized segments: fail */
1415 - .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V4 + 1,
1416 + .tlen = UDP_MAX_SEGMENTS + 1,
1417 .gso_len = 1,
1418 .tfail = true,
1419 },
1420 @@ -259,13 +259,13 @@ struct testcase testcases_v6[] = {
1421 },
1422 {
1423 /* send max number of min sized segments */
1424 - .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6,
1425 + .tlen = UDP_MAX_SEGMENTS,
1426 .gso_len = 1,
1427 - .r_num_mss = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6,
1428 + .r_num_mss = UDP_MAX_SEGMENTS,
1429 },
1430 {
1431 /* send max number + 1 of min sized segments: fail */
1432 - .tlen = UDP_MAX_SEGMENTS - CONST_HDRLEN_V6 + 1,
1433 + .tlen = UDP_MAX_SEGMENTS + 1,
1434 .gso_len = 1,
1435 .tfail = true,
1436 },
1437 diff --git a/tools/testing/selftests/net/udpgso_bench_tx.c b/tools/testing/selftests/net/udpgso_bench_tx.c
1438 index 17512a43885e7..f1fdaa2702913 100644
1439 --- a/tools/testing/selftests/net/udpgso_bench_tx.c
1440 +++ b/tools/testing/selftests/net/udpgso_bench_tx.c
1441 @@ -419,6 +419,7 @@ static void usage(const char *filepath)
1442
1443 static void parse_opts(int argc, char **argv)
1444 {
1445 + const char *bind_addr = NULL;
1446 int max_len, hdrlen;
1447 int c;
1448
1449 @@ -446,7 +447,7 @@ static void parse_opts(int argc, char **argv)
1450 cfg_cpu = strtol(optarg, NULL, 0);
1451 break;
1452 case 'D':
1453 - setup_sockaddr(cfg_family, optarg, &cfg_dst_addr);
1454 + bind_addr = optarg;
1455 break;
1456 case 'l':
1457 cfg_runtime_ms = strtoul(optarg, NULL, 10) * 1000;
1458 @@ -492,6 +493,11 @@ static void parse_opts(int argc, char **argv)
1459 }
1460 }
1461
1462 + if (!bind_addr)
1463 + bind_addr = cfg_family == PF_INET6 ? "::" : "0.0.0.0";
1464 +
1465 + setup_sockaddr(cfg_family, bind_addr, &cfg_dst_addr);
1466 +
1467 if (optind != argc)
1468 usage(argv[0]);
1469