Magellan Linux

Annotation of /trunk/kernel-alx/patches-5.4/0223-5.4.124-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (hide annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (18 months, 3 weeks ago) by niro
File size: 189575 byte(s)
-add missing
1 niro 3637 diff --git a/Documentation/userspace-api/seccomp_filter.rst b/Documentation/userspace-api/seccomp_filter.rst
2     index bd9165241b6c8..6efb41cc80725 100644
3     --- a/Documentation/userspace-api/seccomp_filter.rst
4     +++ b/Documentation/userspace-api/seccomp_filter.rst
5     @@ -250,14 +250,14 @@ Users can read via ``ioctl(SECCOMP_IOCTL_NOTIF_RECV)`` (or ``poll()``) on a
6     seccomp notification fd to receive a ``struct seccomp_notif``, which contains
7     five members: the input length of the structure, a unique-per-filter ``id``,
8     the ``pid`` of the task which triggered this request (which may be 0 if the
9     -task is in a pid ns not visible from the listener's pid namespace), a ``flags``
10     -member which for now only has ``SECCOMP_NOTIF_FLAG_SIGNALED``, representing
11     -whether or not the notification is a result of a non-fatal signal, and the
12     -``data`` passed to seccomp. Userspace can then make a decision based on this
13     -information about what to do, and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a
14     -response, indicating what should be returned to userspace. The ``id`` member of
15     -``struct seccomp_notif_resp`` should be the same ``id`` as in ``struct
16     -seccomp_notif``.
17     +task is in a pid ns not visible from the listener's pid namespace). The
18     +notification also contains the ``data`` passed to seccomp, and a filters flag.
19     +The structure should be zeroed out prior to calling the ioctl.
20     +
21     +Userspace can then make a decision based on this information about what to do,
22     +and ``ioctl(SECCOMP_IOCTL_NOTIF_SEND)`` a response, indicating what should be
23     +returned to userspace. The ``id`` member of ``struct seccomp_notif_resp`` should
24     +be the same ``id`` as in ``struct seccomp_notif``.
25    
26     It is worth noting that ``struct seccomp_data`` contains the values of register
27     arguments to the syscall, but does not contain pointers to memory. The task's
28     diff --git a/Makefile b/Makefile
29     index d3f7a032f080b..22668742d3d04 100644
30     --- a/Makefile
31     +++ b/Makefile
32     @@ -1,7 +1,7 @@
33     # SPDX-License-Identifier: GPL-2.0
34     VERSION = 5
35     PATCHLEVEL = 4
36     -SUBLEVEL = 123
37     +SUBLEVEL = 124
38     EXTRAVERSION =
39     NAME = Kleptomaniac Octopus
40    
41     diff --git a/arch/mips/alchemy/board-xxs1500.c b/arch/mips/alchemy/board-xxs1500.c
42     index c67dfe1f49971..ec35aedc7727d 100644
43     --- a/arch/mips/alchemy/board-xxs1500.c
44     +++ b/arch/mips/alchemy/board-xxs1500.c
45     @@ -18,6 +18,7 @@
46     #include <asm/reboot.h>
47     #include <asm/setup.h>
48     #include <asm/mach-au1x00/au1000.h>
49     +#include <asm/mach-au1x00/gpio-au1000.h>
50     #include <prom.h>
51    
52     const char *get_system_type(void)
53     diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c
54     index 59b23095bfbb4..4e38a905ab386 100644
55     --- a/arch/mips/ralink/of.c
56     +++ b/arch/mips/ralink/of.c
57     @@ -8,6 +8,7 @@
58    
59     #include <linux/io.h>
60     #include <linux/clk.h>
61     +#include <linux/export.h>
62     #include <linux/init.h>
63     #include <linux/sizes.h>
64     #include <linux/of_fdt.h>
65     @@ -25,6 +26,7 @@
66    
67     __iomem void *rt_sysc_membase;
68     __iomem void *rt_memc_membase;
69     +EXPORT_SYMBOL_GPL(rt_sysc_membase);
70    
71     __iomem void *plat_of_remap_node(const char *node)
72     {
73     diff --git a/arch/openrisc/include/asm/barrier.h b/arch/openrisc/include/asm/barrier.h
74     new file mode 100644
75     index 0000000000000..7538294721bed
76     --- /dev/null
77     +++ b/arch/openrisc/include/asm/barrier.h
78     @@ -0,0 +1,9 @@
79     +/* SPDX-License-Identifier: GPL-2.0 */
80     +#ifndef __ASM_BARRIER_H
81     +#define __ASM_BARRIER_H
82     +
83     +#define mb() asm volatile ("l.msync" ::: "memory")
84     +
85     +#include <asm-generic/barrier.h>
86     +
87     +#endif /* __ASM_BARRIER_H */
88     diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
89     index f69609b47fef8..d390ab5e51d3f 100644
90     --- a/drivers/char/hpet.c
91     +++ b/drivers/char/hpet.c
92     @@ -984,6 +984,8 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
93     hdp->hd_phys_address = fixmem32->address;
94     hdp->hd_address = ioremap(fixmem32->address,
95     HPET_RANGE_SIZE);
96     + if (!hdp->hd_address)
97     + return AE_ERROR;
98    
99     if (hpet_is_known(hdp)) {
100     iounmap(hdp->hd_address);
101     diff --git a/drivers/dma/qcom/hidma_mgmt.c b/drivers/dma/qcom/hidma_mgmt.c
102     index 806ca02c52d71..62026607f3f8b 100644
103     --- a/drivers/dma/qcom/hidma_mgmt.c
104     +++ b/drivers/dma/qcom/hidma_mgmt.c
105     @@ -418,8 +418,23 @@ static int __init hidma_mgmt_init(void)
106     hidma_mgmt_of_populate_channels(child);
107     }
108     #endif
109     - return platform_driver_register(&hidma_mgmt_driver);
110     + /*
111     + * We do not check for return value here, as it is assumed that
112     + * platform_driver_register must not fail. The reason for this is that
113     + * the (potential) hidma_mgmt_of_populate_channels calls above are not
114     + * cleaned up if it does fail, and to do this work is quite
115     + * complicated. In particular, various calls of of_address_to_resource,
116     + * of_irq_to_resource, platform_device_register_full, of_dma_configure,
117     + * and of_msi_configure which then call other functions and so on, must
118     + * be cleaned up - this is not a trivial exercise.
119     + *
120     + * Currently, this module is not intended to be unloaded, and there is
121     + * no module_exit function defined which does the needed cleanup. For
122     + * this reason, we have to assume success here.
123     + */
124     + platform_driver_register(&hidma_mgmt_driver);
125    
126     + return 0;
127     }
128     module_init(hidma_mgmt_init);
129     MODULE_LICENSE("GPL v2");
130     diff --git a/drivers/gpio/gpio-cadence.c b/drivers/gpio/gpio-cadence.c
131     index a4d3239d25944..4ab3fcd9b9ba6 100644
132     --- a/drivers/gpio/gpio-cadence.c
133     +++ b/drivers/gpio/gpio-cadence.c
134     @@ -278,6 +278,7 @@ static const struct of_device_id cdns_of_ids[] = {
135     { .compatible = "cdns,gpio-r1p02" },
136     { /* sentinel */ },
137     };
138     +MODULE_DEVICE_TABLE(of, cdns_of_ids);
139    
140     static struct platform_driver cdns_gpio_driver = {
141     .driver = {
142     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
143     index 3b3fc9a426e91..765f9a6c46401 100644
144     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
145     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
146     @@ -3704,7 +3704,6 @@ out:
147     r = amdgpu_ib_ring_tests(tmp_adev);
148     if (r) {
149     dev_err(tmp_adev->dev, "ib ring test failed (%d).\n", r);
150     - r = amdgpu_device_ip_suspend(tmp_adev);
151     need_full_reset = true;
152     r = -EAGAIN;
153     goto end;
154     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
155     index fd94a17fb2c6d..46522804c7d84 100644
156     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
157     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
158     @@ -289,10 +289,13 @@ out:
159     static int amdgpu_fbdev_destroy(struct drm_device *dev, struct amdgpu_fbdev *rfbdev)
160     {
161     struct amdgpu_framebuffer *rfb = &rfbdev->rfb;
162     + int i;
163    
164     drm_fb_helper_unregister_fbi(&rfbdev->helper);
165    
166     if (rfb->base.obj[0]) {
167     + for (i = 0; i < rfb->base.format->num_planes; i++)
168     + drm_gem_object_put(rfb->base.obj[0]);
169     amdgpufb_destroy_pinned_object(rfb->base.obj[0]);
170     rfb->base.obj[0] = NULL;
171     drm_framebuffer_unregister_private(&rfb->base);
172     diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
173     index 91e3a87b1de83..58e14d3040f03 100644
174     --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
175     +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
176     @@ -1300,6 +1300,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)
177     if (gtt && gtt->userptr) {
178     amdgpu_ttm_tt_set_user_pages(ttm, NULL);
179     kfree(ttm->sg);
180     + ttm->sg = NULL;
181     ttm->page_flags &= ~TTM_PAGE_FLAG_SG;
182     return;
183     }
184     diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
185     index 4f0f0de832937..1bb0f3c0978a8 100644
186     --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
187     +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
188     @@ -233,9 +233,13 @@ static int vcn_v1_0_hw_fini(void *handle)
189     struct amdgpu_device *adev = (struct amdgpu_device *)handle;
190     struct amdgpu_ring *ring = &adev->vcn.inst->ring_dec;
191    
192     + cancel_delayed_work_sync(&adev->vcn.idle_work);
193     +
194     if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
195     - RREG32_SOC15(VCN, 0, mmUVD_STATUS))
196     + (adev->vcn.cur_state != AMD_PG_STATE_GATE &&
197     + RREG32_SOC15(VCN, 0, mmUVD_STATUS))) {
198     vcn_v1_0_set_powergating_state(adev, AMD_PG_STATE_GATE);
199     + }
200    
201     ring->sched.ready = false;
202    
203     diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
204     index cd2cbe760e883..82327ee96f953 100644
205     --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
206     +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
207     @@ -293,6 +293,8 @@ static int vcn_v2_0_hw_fini(void *handle)
208     struct amdgpu_ring *ring = &adev->vcn.inst->ring_dec;
209     int i;
210    
211     + cancel_delayed_work_sync(&adev->vcn.idle_work);
212     +
213     if ((adev->pg_flags & AMD_PG_SUPPORT_VCN_DPG) ||
214     (adev->vcn.cur_state != AMD_PG_STATE_GATE &&
215     RREG32_SOC15(VCN, 0, mmUVD_STATUS)))
216     diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
217     index 9d778a0b2c5e2..4c9a1633b02a7 100644
218     --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
219     +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
220     @@ -302,6 +302,8 @@ static int vcn_v2_5_hw_fini(void *handle)
221     struct amdgpu_ring *ring;
222     int i;
223    
224     + cancel_delayed_work_sync(&adev->vcn.idle_work);
225     +
226     for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
227     if (adev->vcn.harvest_config & (1 << i))
228     continue;
229     diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
230     index 40041c61a100e..6b03267021eac 100644
231     --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
232     +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
233     @@ -936,6 +936,24 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)
234     dc_is_dvi_signal(link->connector_signal)) {
235     if (prev_sink != NULL)
236     dc_sink_release(prev_sink);
237     + link_disconnect_sink(link);
238     +
239     + return false;
240     + }
241     + /*
242     + * Abort detection for DP connectors if we have
243     + * no EDID and connector is active converter
244     + * as there are no display downstream
245     + *
246     + */
247     + if (dc_is_dp_sst_signal(link->connector_signal) &&
248     + (link->dpcd_caps.dongle_type ==
249     + DISPLAY_DONGLE_DP_VGA_CONVERTER ||
250     + link->dpcd_caps.dongle_type ==
251     + DISPLAY_DONGLE_DP_DVI_CONVERTER)) {
252     + if (prev_sink)
253     + dc_sink_release(prev_sink);
254     + link_disconnect_sink(link);
255    
256     return false;
257     }
258     diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
259     index c2fccf97f7a42..abc8c42b8b0c1 100644
260     --- a/drivers/gpu/drm/i915/display/intel_dp.c
261     +++ b/drivers/gpu/drm/i915/display/intel_dp.c
262     @@ -3634,7 +3634,7 @@ static void chv_dp_post_pll_disable(struct intel_encoder *encoder,
263     * link status information
264     */
265     bool
266     -intel_dp_get_link_status(struct intel_dp *intel_dp, u8 link_status[DP_LINK_STATUS_SIZE])
267     +intel_dp_get_link_status(struct intel_dp *intel_dp, u8 *link_status)
268     {
269     return drm_dp_dpcd_read(&intel_dp->aux, DP_LANE0_1_STATUS, link_status,
270     DP_LINK_STATUS_SIZE) == DP_LINK_STATUS_SIZE;
271     @@ -4706,7 +4706,18 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)
272     bool bret;
273    
274     if (intel_dp->is_mst) {
275     - u8 esi[DP_DPRX_ESI_LEN] = { 0 };
276     + /*
277     + * The +2 is because DP_DPRX_ESI_LEN is 14, but we then
278     + * pass in "esi+10" to drm_dp_channel_eq_ok(), which
279     + * takes a 6-byte array. So we actually need 16 bytes
280     + * here.
281     + *
282     + * Somebody who knows what the limits actually are
283     + * should check this, but for now this is at least
284     + * harmless and avoids a valid compiler warning about
285     + * using more of the array than we have allocated.
286     + */
287     + u8 esi[DP_DPRX_ESI_LEN+2] = {};
288     int ret = 0;
289     int retry;
290     bool handled;
291     diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c
292     index 86d0961112773..61a6536e7e61a 100644
293     --- a/drivers/gpu/drm/meson/meson_drv.c
294     +++ b/drivers/gpu/drm/meson/meson_drv.c
295     @@ -423,11 +423,12 @@ static int meson_probe_remote(struct platform_device *pdev,
296     static void meson_drv_shutdown(struct platform_device *pdev)
297     {
298     struct meson_drm *priv = dev_get_drvdata(&pdev->dev);
299     - struct drm_device *drm = priv->drm;
300    
301     - DRM_DEBUG_DRIVER("\n");
302     - drm_kms_helper_poll_fini(drm);
303     - drm_atomic_helper_shutdown(drm);
304     + if (!priv)
305     + return;
306     +
307     + drm_kms_helper_poll_fini(priv->drm);
308     + drm_atomic_helper_shutdown(priv->drm);
309     }
310    
311     static int meson_drv_probe(struct platform_device *pdev)
312     diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
313     index 2b6a4c1f188f4..a959062ded4f8 100644
314     --- a/drivers/i2c/busses/i2c-i801.c
315     +++ b/drivers/i2c/busses/i2c-i801.c
316     @@ -379,11 +379,9 @@ static int i801_check_post(struct i801_priv *priv, int status)
317     dev_err(&priv->pci_dev->dev, "Transaction timeout\n");
318     /* try to stop the current command */
319     dev_dbg(&priv->pci_dev->dev, "Terminating the current operation\n");
320     - outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL,
321     - SMBHSTCNT(priv));
322     + outb_p(SMBHSTCNT_KILL, SMBHSTCNT(priv));
323     usleep_range(1000, 2000);
324     - outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL),
325     - SMBHSTCNT(priv));
326     + outb_p(0, SMBHSTCNT(priv));
327    
328     /* Check if it worked */
329     status = inb_p(SMBHSTSTS(priv));
330     diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
331     index c98ef4c4a0c9e..d6322698b2458 100644
332     --- a/drivers/i2c/busses/i2c-s3c2410.c
333     +++ b/drivers/i2c/busses/i2c-s3c2410.c
334     @@ -484,7 +484,10 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
335     * forces us to send a new START
336     * when we change direction
337     */
338     + dev_dbg(i2c->dev,
339     + "missing START before write->read\n");
340     s3c24xx_i2c_stop(i2c, -EINVAL);
341     + break;
342     }
343    
344     goto retry_write;
345     diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
346     index d5dd58c27ce5f..0dc2494f1a37b 100644
347     --- a/drivers/i2c/busses/i2c-sh_mobile.c
348     +++ b/drivers/i2c/busses/i2c-sh_mobile.c
349     @@ -813,7 +813,7 @@ static const struct sh_mobile_dt_config r8a7740_dt_config = {
350     static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
351     { .compatible = "renesas,iic-r8a73a4", .data = &fast_clock_dt_config },
352     { .compatible = "renesas,iic-r8a7740", .data = &r8a7740_dt_config },
353     - { .compatible = "renesas,iic-r8a774c0", .data = &fast_clock_dt_config },
354     + { .compatible = "renesas,iic-r8a774c0", .data = &v2_freq_calc_dt_config },
355     { .compatible = "renesas,iic-r8a7790", .data = &v2_freq_calc_dt_config },
356     { .compatible = "renesas,iic-r8a7791", .data = &v2_freq_calc_dt_config },
357     { .compatible = "renesas,iic-r8a7792", .data = &v2_freq_calc_dt_config },
358     diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c
359     index 306bf15023a78..fa808f9c0d9af 100644
360     --- a/drivers/iio/adc/ad7124.c
361     +++ b/drivers/iio/adc/ad7124.c
362     @@ -473,6 +473,13 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
363     if (ret)
364     goto err;
365    
366     + if (channel >= indio_dev->num_channels) {
367     + dev_err(indio_dev->dev.parent,
368     + "Channel index >= number of channels\n");
369     + ret = -EINVAL;
370     + goto err;
371     + }
372     +
373     ret = of_property_read_u32_array(child, "diff-channels",
374     ain, 2);
375     if (ret)
376     @@ -564,6 +571,11 @@ static int ad7124_setup(struct ad7124_state *st)
377     return ret;
378     }
379    
380     +static void ad7124_reg_disable(void *r)
381     +{
382     + regulator_disable(r);
383     +}
384     +
385     static int ad7124_probe(struct spi_device *spi)
386     {
387     const struct spi_device_id *id;
388     @@ -607,17 +619,20 @@ static int ad7124_probe(struct spi_device *spi)
389     ret = regulator_enable(st->vref[i]);
390     if (ret)
391     return ret;
392     +
393     + ret = devm_add_action_or_reset(&spi->dev, ad7124_reg_disable,
394     + st->vref[i]);
395     + if (ret)
396     + return ret;
397     }
398    
399     st->mclk = devm_clk_get(&spi->dev, "mclk");
400     - if (IS_ERR(st->mclk)) {
401     - ret = PTR_ERR(st->mclk);
402     - goto error_regulator_disable;
403     - }
404     + if (IS_ERR(st->mclk))
405     + return PTR_ERR(st->mclk);
406    
407     ret = clk_prepare_enable(st->mclk);
408     if (ret < 0)
409     - goto error_regulator_disable;
410     + return ret;
411    
412     ret = ad7124_soft_reset(st);
413     if (ret < 0)
414     @@ -643,11 +658,6 @@ error_remove_trigger:
415     ad_sd_cleanup_buffer_and_trigger(indio_dev);
416     error_clk_disable_unprepare:
417     clk_disable_unprepare(st->mclk);
418     -error_regulator_disable:
419     - for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
420     - if (!IS_ERR_OR_NULL(st->vref[i]))
421     - regulator_disable(st->vref[i]);
422     - }
423    
424     return ret;
425     }
426     @@ -656,17 +666,11 @@ static int ad7124_remove(struct spi_device *spi)
427     {
428     struct iio_dev *indio_dev = spi_get_drvdata(spi);
429     struct ad7124_state *st = iio_priv(indio_dev);
430     - int i;
431    
432     iio_device_unregister(indio_dev);
433     ad_sd_cleanup_buffer_and_trigger(indio_dev);
434     clk_disable_unprepare(st->mclk);
435    
436     - for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) {
437     - if (!IS_ERR_OR_NULL(st->vref[i]))
438     - regulator_disable(st->vref[i]);
439     - }
440     -
441     return 0;
442     }
443    
444     diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c
445     index 0d132708c4295..0f6c1be1cda2c 100644
446     --- a/drivers/iio/adc/ad7768-1.c
447     +++ b/drivers/iio/adc/ad7768-1.c
448     @@ -166,6 +166,10 @@ struct ad7768_state {
449     * transfer buffers to live in their own cache lines.
450     */
451     union {
452     + struct {
453     + __be32 chan;
454     + s64 timestamp;
455     + } scan;
456     __be32 d32;
457     u8 d8[2];
458     } data ____cacheline_aligned;
459     @@ -459,11 +463,11 @@ static irqreturn_t ad7768_trigger_handler(int irq, void *p)
460    
461     mutex_lock(&st->lock);
462    
463     - ret = spi_read(st->spi, &st->data.d32, 3);
464     + ret = spi_read(st->spi, &st->data.scan.chan, 3);
465     if (ret < 0)
466     goto err_unlock;
467    
468     - iio_push_to_buffers_with_timestamp(indio_dev, &st->data.d32,
469     + iio_push_to_buffers_with_timestamp(indio_dev, &st->data.scan,
470     iio_get_time_ns(indio_dev));
471    
472     iio_trigger_notify_done(indio_dev->trig);
473     diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c
474     index 6ed6d14102016..947d6c7772344 100644
475     --- a/drivers/iio/adc/ad7793.c
476     +++ b/drivers/iio/adc/ad7793.c
477     @@ -278,6 +278,7 @@ static int ad7793_setup(struct iio_dev *indio_dev,
478     id &= AD7793_ID_MASK;
479    
480     if (id != st->chip_info->id) {
481     + ret = -ENODEV;
482     dev_err(&st->sd.spi->dev, "device ID query failed\n");
483     goto out;
484     }
485     diff --git a/drivers/iio/gyro/fxas21002c_core.c b/drivers/iio/gyro/fxas21002c_core.c
486     index 89d2bb2282eac..958cf8b6002ca 100644
487     --- a/drivers/iio/gyro/fxas21002c_core.c
488     +++ b/drivers/iio/gyro/fxas21002c_core.c
489     @@ -333,6 +333,7 @@ static int fxas21002c_temp_get(struct fxas21002c_data *data, int *val)
490     ret = regmap_field_read(data->regmap_fields[F_TEMP], &temp);
491     if (ret < 0) {
492     dev_err(dev, "failed to read temp: %d\n", ret);
493     + fxas21002c_pm_put(data);
494     goto data_unlock;
495     }
496    
497     @@ -366,6 +367,7 @@ static int fxas21002c_axis_get(struct fxas21002c_data *data,
498     &axis_be, sizeof(axis_be));
499     if (ret < 0) {
500     dev_err(dev, "failed to read axis: %d: %d\n", index, ret);
501     + fxas21002c_pm_put(data);
502     goto data_unlock;
503     }
504    
505     diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
506     index 1b9795743276d..24616525c90dc 100644
507     --- a/drivers/iommu/dmar.c
508     +++ b/drivers/iommu/dmar.c
509     @@ -1110,7 +1110,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
510    
511     err = iommu_device_register(&iommu->iommu);
512     if (err)
513     - goto err_unmap;
514     + goto err_sysfs;
515     }
516    
517     drhd->iommu = iommu;
518     @@ -1118,6 +1118,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
519    
520     return 0;
521    
522     +err_sysfs:
523     + iommu_device_sysfs_remove(&iommu->iommu);
524     err_unmap:
525     unmap_iommu(iommu);
526     error_free_seq_id:
527     diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
528     index 008a74a1ed444..1f89378b56231 100644
529     --- a/drivers/isdn/hardware/mISDN/hfcsusb.c
530     +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
531     @@ -46,7 +46,7 @@ static void hfcsusb_start_endpoint(struct hfcsusb *hw, int channel);
532     static void hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel);
533     static int hfcsusb_setup_bch(struct bchannel *bch, int protocol);
534     static void deactivate_bchannel(struct bchannel *bch);
535     -static void hfcsusb_ph_info(struct hfcsusb *hw);
536     +static int hfcsusb_ph_info(struct hfcsusb *hw);
537    
538     /* start next background transfer for control channel */
539     static void
540     @@ -241,7 +241,7 @@ hfcusb_l2l1B(struct mISDNchannel *ch, struct sk_buff *skb)
541     * send full D/B channel status information
542     * as MPH_INFORMATION_IND
543     */
544     -static void
545     +static int
546     hfcsusb_ph_info(struct hfcsusb *hw)
547     {
548     struct ph_info *phi;
549     @@ -250,7 +250,7 @@ hfcsusb_ph_info(struct hfcsusb *hw)
550    
551     phi = kzalloc(struct_size(phi, bch, dch->dev.nrbchan), GFP_ATOMIC);
552     if (!phi)
553     - return;
554     + return -ENOMEM;
555    
556     phi->dch.ch.protocol = hw->protocol;
557     phi->dch.ch.Flags = dch->Flags;
558     @@ -264,6 +264,8 @@ hfcsusb_ph_info(struct hfcsusb *hw)
559     sizeof(struct ph_info_dch) + dch->dev.nrbchan *
560     sizeof(struct ph_info_ch), phi, GFP_ATOMIC);
561     kfree(phi);
562     +
563     + return 0;
564     }
565    
566     /*
567     @@ -348,8 +350,7 @@ hfcusb_l2l1D(struct mISDNchannel *ch, struct sk_buff *skb)
568     ret = l1_event(dch->l1, hh->prim);
569     break;
570     case MPH_INFORMATION_REQ:
571     - hfcsusb_ph_info(hw);
572     - ret = 0;
573     + ret = hfcsusb_ph_info(hw);
574     break;
575     }
576    
577     @@ -404,8 +405,7 @@ hfc_l1callback(struct dchannel *dch, u_int cmd)
578     hw->name, __func__, cmd);
579     return -1;
580     }
581     - hfcsusb_ph_info(hw);
582     - return 0;
583     + return hfcsusb_ph_info(hw);
584     }
585    
586     static int
587     @@ -747,8 +747,7 @@ hfcsusb_setup_bch(struct bchannel *bch, int protocol)
588     handle_led(hw, (bch->nr == 1) ? LED_B1_OFF :
589     LED_B2_OFF);
590     }
591     - hfcsusb_ph_info(hw);
592     - return 0;
593     + return hfcsusb_ph_info(hw);
594     }
595    
596     static void
597     diff --git a/drivers/isdn/hardware/mISDN/mISDNinfineon.c b/drivers/isdn/hardware/mISDN/mISDNinfineon.c
598     index f4cb297668884..3cf0c6f5a1dca 100644
599     --- a/drivers/isdn/hardware/mISDN/mISDNinfineon.c
600     +++ b/drivers/isdn/hardware/mISDN/mISDNinfineon.c
601     @@ -630,17 +630,19 @@ static void
602     release_io(struct inf_hw *hw)
603     {
604     if (hw->cfg.mode) {
605     - if (hw->cfg.p) {
606     + if (hw->cfg.mode == AM_MEMIO) {
607     release_mem_region(hw->cfg.start, hw->cfg.size);
608     - iounmap(hw->cfg.p);
609     + if (hw->cfg.p)
610     + iounmap(hw->cfg.p);
611     } else
612     release_region(hw->cfg.start, hw->cfg.size);
613     hw->cfg.mode = AM_NONE;
614     }
615     if (hw->addr.mode) {
616     - if (hw->addr.p) {
617     + if (hw->addr.mode == AM_MEMIO) {
618     release_mem_region(hw->addr.start, hw->addr.size);
619     - iounmap(hw->addr.p);
620     + if (hw->addr.p)
621     + iounmap(hw->addr.p);
622     } else
623     release_region(hw->addr.start, hw->addr.size);
624     hw->addr.mode = AM_NONE;
625     @@ -670,9 +672,12 @@ setup_io(struct inf_hw *hw)
626     (ulong)hw->cfg.start, (ulong)hw->cfg.size);
627     return err;
628     }
629     - if (hw->ci->cfg_mode == AM_MEMIO)
630     - hw->cfg.p = ioremap(hw->cfg.start, hw->cfg.size);
631     hw->cfg.mode = hw->ci->cfg_mode;
632     + if (hw->ci->cfg_mode == AM_MEMIO) {
633     + hw->cfg.p = ioremap(hw->cfg.start, hw->cfg.size);
634     + if (!hw->cfg.p)
635     + return -ENOMEM;
636     + }
637     if (debug & DEBUG_HW)
638     pr_notice("%s: IO cfg %lx (%lu bytes) mode%d\n",
639     hw->name, (ulong)hw->cfg.start,
640     @@ -697,12 +702,12 @@ setup_io(struct inf_hw *hw)
641     (ulong)hw->addr.start, (ulong)hw->addr.size);
642     return err;
643     }
644     + hw->addr.mode = hw->ci->addr_mode;
645     if (hw->ci->addr_mode == AM_MEMIO) {
646     hw->addr.p = ioremap(hw->addr.start, hw->addr.size);
647     - if (unlikely(!hw->addr.p))
648     + if (!hw->addr.p)
649     return -ENOMEM;
650     }
651     - hw->addr.mode = hw->ci->addr_mode;
652     if (debug & DEBUG_HW)
653     pr_notice("%s: IO addr %lx (%lu bytes) mode%d\n",
654     hw->name, (ulong)hw->addr.start,
655     diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
656     index add7d4ce41802..e902aae685af9 100644
657     --- a/drivers/md/dm-snap.c
658     +++ b/drivers/md/dm-snap.c
659     @@ -854,7 +854,7 @@ static int dm_add_exception(void *context, chunk_t old, chunk_t new)
660     static uint32_t __minimum_chunk_size(struct origin *o)
661     {
662     struct dm_snapshot *snap;
663     - unsigned chunk_size = 0;
664     + unsigned chunk_size = rounddown_pow_of_two(UINT_MAX);
665    
666     if (o)
667     list_for_each_entry(snap, &o->snapshots, list)
668     diff --git a/drivers/media/dvb-frontends/sp8870.c b/drivers/media/dvb-frontends/sp8870.c
669     index 655db8272268d..9767159aeb9b2 100644
670     --- a/drivers/media/dvb-frontends/sp8870.c
671     +++ b/drivers/media/dvb-frontends/sp8870.c
672     @@ -281,7 +281,7 @@ static int sp8870_set_frontend_parameters(struct dvb_frontend *fe)
673    
674     // read status reg in order to clear pending irqs
675     err = sp8870_readreg(state, 0x200);
676     - if (err)
677     + if (err < 0)
678     return err;
679    
680     // system controller start
681     diff --git a/drivers/media/usb/gspca/cpia1.c b/drivers/media/usb/gspca/cpia1.c
682     index a4f7431486f31..d93d384286c16 100644
683     --- a/drivers/media/usb/gspca/cpia1.c
684     +++ b/drivers/media/usb/gspca/cpia1.c
685     @@ -1424,7 +1424,6 @@ static int sd_config(struct gspca_dev *gspca_dev,
686     {
687     struct sd *sd = (struct sd *) gspca_dev;
688     struct cam *cam;
689     - int ret;
690    
691     sd->mainsFreq = FREQ_DEF == V4L2_CID_POWER_LINE_FREQUENCY_60HZ;
692     reset_camera_params(gspca_dev);
693     @@ -1436,10 +1435,7 @@ static int sd_config(struct gspca_dev *gspca_dev,
694     cam->cam_mode = mode;
695     cam->nmodes = ARRAY_SIZE(mode);
696    
697     - ret = goto_low_power(gspca_dev);
698     - if (ret)
699     - gspca_err(gspca_dev, "Cannot go to low power mode: %d\n",
700     - ret);
701     + goto_low_power(gspca_dev);
702     /* Check the firmware version. */
703     sd->params.version.firmwareVersion = 0;
704     get_version_information(gspca_dev);
705     diff --git a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
706     index bfa3b381d8a26..bf1af6ed9131e 100644
707     --- a/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
708     +++ b/drivers/media/usb/gspca/m5602/m5602_mt9m111.c
709     @@ -195,7 +195,7 @@ static const struct v4l2_ctrl_config mt9m111_greenbal_cfg = {
710     int mt9m111_probe(struct sd *sd)
711     {
712     u8 data[2] = {0x00, 0x00};
713     - int i, rc = 0;
714     + int i, err;
715     struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
716    
717     if (force_sensor) {
718     @@ -213,18 +213,18 @@ int mt9m111_probe(struct sd *sd)
719     /* Do the preinit */
720     for (i = 0; i < ARRAY_SIZE(preinit_mt9m111); i++) {
721     if (preinit_mt9m111[i][0] == BRIDGE) {
722     - rc |= m5602_write_bridge(sd,
723     - preinit_mt9m111[i][1],
724     - preinit_mt9m111[i][2]);
725     + err = m5602_write_bridge(sd,
726     + preinit_mt9m111[i][1],
727     + preinit_mt9m111[i][2]);
728     } else {
729     data[0] = preinit_mt9m111[i][2];
730     data[1] = preinit_mt9m111[i][3];
731     - rc |= m5602_write_sensor(sd,
732     - preinit_mt9m111[i][1], data, 2);
733     + err = m5602_write_sensor(sd,
734     + preinit_mt9m111[i][1], data, 2);
735     }
736     + if (err < 0)
737     + return err;
738     }
739     - if (rc < 0)
740     - return rc;
741    
742     if (m5602_read_sensor(sd, MT9M111_SC_CHIPVER, data, 2))
743     return -ENODEV;
744     diff --git a/drivers/media/usb/gspca/m5602/m5602_po1030.c b/drivers/media/usb/gspca/m5602/m5602_po1030.c
745     index d680b777f097f..8fd99ceee4b67 100644
746     --- a/drivers/media/usb/gspca/m5602/m5602_po1030.c
747     +++ b/drivers/media/usb/gspca/m5602/m5602_po1030.c
748     @@ -154,8 +154,8 @@ static const struct v4l2_ctrl_config po1030_greenbal_cfg = {
749    
750     int po1030_probe(struct sd *sd)
751     {
752     - int rc = 0;
753     u8 dev_id_h = 0, i;
754     + int err;
755     struct gspca_dev *gspca_dev = (struct gspca_dev *)sd;
756    
757     if (force_sensor) {
758     @@ -174,14 +174,14 @@ int po1030_probe(struct sd *sd)
759     for (i = 0; i < ARRAY_SIZE(preinit_po1030); i++) {
760     u8 data = preinit_po1030[i][2];
761     if (preinit_po1030[i][0] == SENSOR)
762     - rc |= m5602_write_sensor(sd,
763     - preinit_po1030[i][1], &data, 1);
764     + err = m5602_write_sensor(sd, preinit_po1030[i][1],
765     + &data, 1);
766     else
767     - rc |= m5602_write_bridge(sd, preinit_po1030[i][1],
768     - data);
769     + err = m5602_write_bridge(sd, preinit_po1030[i][1],
770     + data);
771     + if (err < 0)
772     + return err;
773     }
774     - if (rc < 0)
775     - return rc;
776    
777     if (m5602_read_sensor(sd, PO1030_DEVID_H, &dev_id_h, 1))
778     return -ENODEV;
779     diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
780     index 5c183c02dfd92..8d18f19c99c4b 100644
781     --- a/drivers/misc/kgdbts.c
782     +++ b/drivers/misc/kgdbts.c
783     @@ -100,8 +100,9 @@
784     printk(KERN_INFO a); \
785     } while (0)
786     #define v2printk(a...) do { \
787     - if (verbose > 1) \
788     + if (verbose > 1) { \
789     printk(KERN_INFO a); \
790     + } \
791     touch_nmi_watchdog(); \
792     } while (0)
793     #define eprintk(a...) do { \
794     diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
795     index 1b0c99883c57b..c008eecfdfe8d 100644
796     --- a/drivers/misc/lis3lv02d/lis3lv02d.h
797     +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
798     @@ -271,6 +271,7 @@ struct lis3lv02d {
799     int regs_size;
800     u8 *reg_cache;
801     bool regs_stored;
802     + bool init_required;
803     u8 odr_mask; /* ODR bit mask */
804     u8 whoami; /* indicates measurement precision */
805     s16 (*read_data) (struct lis3lv02d *lis3, int reg);
806     diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
807     index c70a8c74cc57a..a70d989032c19 100644
808     --- a/drivers/misc/mei/interrupt.c
809     +++ b/drivers/misc/mei/interrupt.c
810     @@ -222,6 +222,9 @@ static int mei_cl_irq_read(struct mei_cl *cl, struct mei_cl_cb *cb,
811     return ret;
812     }
813    
814     + pm_runtime_mark_last_busy(dev->dev);
815     + pm_request_autosuspend(dev->dev);
816     +
817     list_move_tail(&cb->list, &cl->rd_pending);
818    
819     return 0;
820     diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
821     index 40b079162804f..0f2bee59a82b0 100644
822     --- a/drivers/net/caif/caif_serial.c
823     +++ b/drivers/net/caif/caif_serial.c
824     @@ -270,7 +270,6 @@ static int caif_xmit(struct sk_buff *skb, struct net_device *dev)
825     {
826     struct ser_device *ser;
827    
828     - BUG_ON(dev == NULL);
829     ser = netdev_priv(dev);
830    
831     /* Send flow off once, on high water mark */
832     diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
833     index 00d680cb44418..071e5015bf91d 100644
834     --- a/drivers/net/dsa/mt7530.c
835     +++ b/drivers/net/dsa/mt7530.c
836     @@ -809,14 +809,6 @@ mt7530_port_set_vlan_aware(struct dsa_switch *ds, int port)
837     {
838     struct mt7530_priv *priv = ds->priv;
839    
840     - /* The real fabric path would be decided on the membership in the
841     - * entry of VLAN table. PCR_MATRIX set up here with ALL_MEMBERS
842     - * means potential VLAN can be consisting of certain subset of all
843     - * ports.
844     - */
845     - mt7530_rmw(priv, MT7530_PCR_P(port),
846     - PCR_MATRIX_MASK, PCR_MATRIX(MT7530_ALL_MEMBERS));
847     -
848     /* Trapped into security mode allows packet forwarding through VLAN
849     * table lookup. CPU port is set to fallback mode to let untagged
850     * frames pass through.
851     diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
852     index 3b51e87a3714a..034f1b50ab287 100644
853     --- a/drivers/net/dsa/sja1105/sja1105_main.c
854     +++ b/drivers/net/dsa/sja1105/sja1105_main.c
855     @@ -178,6 +178,7 @@ static int sja1105_init_mii_settings(struct sja1105_private *priv,
856     default:
857     dev_err(dev, "Unsupported PHY mode %s!\n",
858     phy_modes(ports[i].phy_mode));
859     + return -EINVAL;
860     }
861    
862     mii->phy_mac[i] = ports[i].role;
863     diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
864     index fbc196b480b63..c3f67d8e10933 100644
865     --- a/drivers/net/ethernet/broadcom/bnx2.c
866     +++ b/drivers/net/ethernet/broadcom/bnx2.c
867     @@ -8249,9 +8249,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
868     BNX2_WR(bp, PCI_COMMAND, reg);
869     } else if ((BNX2_CHIP_ID(bp) == BNX2_CHIP_ID_5706_A1) &&
870     !(bp->flags & BNX2_FLAG_PCIX)) {
871     -
872     dev_err(&pdev->dev,
873     "5706 A1 can only be used in a PCIX bus, aborting\n");
874     + rc = -EPERM;
875     goto err_out_unmap;
876     }
877    
878     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
879     index 106f2b2ce17f0..0dba28bb309a2 100644
880     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
881     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
882     @@ -280,7 +280,8 @@ static bool bnxt_vf_pciid(enum board_idx idx)
883     {
884     return (idx == NETXTREME_C_VF || idx == NETXTREME_E_VF ||
885     idx == NETXTREME_S_VF || idx == NETXTREME_C_VF_HV ||
886     - idx == NETXTREME_E_VF_HV || idx == NETXTREME_E_P5_VF);
887     + idx == NETXTREME_E_VF_HV || idx == NETXTREME_E_P5_VF ||
888     + idx == NETXTREME_E_P5_VF_HV);
889     }
890    
891     #define DB_CP_REARM_FLAGS (DB_KEY_CP | DB_IDX_VALID)
892     diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
893     index e338272931d14..94e87e7f277bb 100644
894     --- a/drivers/net/ethernet/brocade/bna/bnad.c
895     +++ b/drivers/net/ethernet/brocade/bna/bnad.c
896     @@ -3282,7 +3282,7 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
897     {
898     int err, mtu;
899     struct bnad *bnad = netdev_priv(netdev);
900     - u32 rx_count = 0, frame, new_frame;
901     + u32 frame, new_frame;
902    
903     mutex_lock(&bnad->conf_mutex);
904    
905     @@ -3298,12 +3298,9 @@ bnad_change_mtu(struct net_device *netdev, int new_mtu)
906     /* only when transition is over 4K */
907     if ((frame <= 4096 && new_frame > 4096) ||
908     (frame > 4096 && new_frame <= 4096))
909     - rx_count = bnad_reinit_rx(bnad);
910     + bnad_reinit_rx(bnad);
911     }
912    
913     - /* rx_count > 0 - new rx created
914     - * - Linux set err = 0 and return
915     - */
916     err = bnad_mtu_set(bnad, new_frame);
917     if (err)
918     err = -EBUSY;
919     diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c b/drivers/net/ethernet/cavium/liquidio/lio_main.c
920     index 7f3b2e3b0868e..d0c77ff9dbb11 100644
921     --- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
922     +++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
923     @@ -1179,7 +1179,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
924     * @param lio per-network private data
925     * @param start_stop whether to start or stop
926     */
927     -static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
928     +static int send_rx_ctrl_cmd(struct lio *lio, int start_stop)
929     {
930     struct octeon_soft_command *sc;
931     union octnet_cmd *ncmd;
932     @@ -1187,15 +1187,15 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
933     int retval;
934    
935     if (oct->props[lio->ifidx].rx_on == start_stop)
936     - return;
937     + return 0;
938    
939     sc = (struct octeon_soft_command *)
940     octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
941     16, 0);
942     if (!sc) {
943     netif_info(lio, rx_err, lio->netdev,
944     - "Failed to allocate octeon_soft_command\n");
945     - return;
946     + "Failed to allocate octeon_soft_command struct\n");
947     + return -ENOMEM;
948     }
949    
950     ncmd = (union octnet_cmd *)sc->virtdptr;
951     @@ -1218,18 +1218,19 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
952     if (retval == IQ_SEND_FAILED) {
953     netif_info(lio, rx_err, lio->netdev, "Failed to send RX Control message\n");
954     octeon_free_soft_command(oct, sc);
955     - return;
956     } else {
957     /* Sleep on a wait queue till the cond flag indicates that the
958     * response arrived or timed-out.
959     */
960     retval = wait_for_sc_completion_timeout(oct, sc, 0);
961     if (retval)
962     - return;
963     + return retval;
964    
965     oct->props[lio->ifidx].rx_on = start_stop;
966     WRITE_ONCE(sc->caller_is_done, true);
967     }
968     +
969     + return retval;
970     }
971    
972     /**
973     @@ -1816,6 +1817,7 @@ static int liquidio_open(struct net_device *netdev)
974     struct octeon_device_priv *oct_priv =
975     (struct octeon_device_priv *)oct->priv;
976     struct napi_struct *napi, *n;
977     + int ret = 0;
978    
979     if (oct->props[lio->ifidx].napi_enabled == 0) {
980     tasklet_disable(&oct_priv->droq_tasklet);
981     @@ -1851,7 +1853,9 @@ static int liquidio_open(struct net_device *netdev)
982     netif_info(lio, ifup, lio->netdev, "Interface Open, ready for traffic\n");
983    
984     /* tell Octeon to start forwarding packets to host */
985     - send_rx_ctrl_cmd(lio, 1);
986     + ret = send_rx_ctrl_cmd(lio, 1);
987     + if (ret)
988     + return ret;
989    
990     /* start periodical statistics fetch */
991     INIT_DELAYED_WORK(&lio->stats_wk.work, lio_fetch_stats);
992     @@ -1862,7 +1866,7 @@ static int liquidio_open(struct net_device *netdev)
993     dev_info(&oct->pci_dev->dev, "%s interface is opened\n",
994     netdev->name);
995    
996     - return 0;
997     + return ret;
998     }
999    
1000     /**
1001     @@ -1876,6 +1880,7 @@ static int liquidio_stop(struct net_device *netdev)
1002     struct octeon_device_priv *oct_priv =
1003     (struct octeon_device_priv *)oct->priv;
1004     struct napi_struct *napi, *n;
1005     + int ret = 0;
1006    
1007     ifstate_reset(lio, LIO_IFSTATE_RUNNING);
1008    
1009     @@ -1892,7 +1897,9 @@ static int liquidio_stop(struct net_device *netdev)
1010     lio->link_changes++;
1011    
1012     /* Tell Octeon that nic interface is down. */
1013     - send_rx_ctrl_cmd(lio, 0);
1014     + ret = send_rx_ctrl_cmd(lio, 0);
1015     + if (ret)
1016     + return ret;
1017    
1018     if (OCTEON_CN23XX_PF(oct)) {
1019     if (!oct->msix_on)
1020     @@ -1927,7 +1934,7 @@ static int liquidio_stop(struct net_device *netdev)
1021    
1022     dev_info(&oct->pci_dev->dev, "%s interface is stopped\n", netdev->name);
1023    
1024     - return 0;
1025     + return ret;
1026     }
1027    
1028     /**
1029     diff --git a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
1030     index 370d76822ee07..929da9e9fe9af 100644
1031     --- a/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
1032     +++ b/drivers/net/ethernet/cavium/liquidio/lio_vf_main.c
1033     @@ -598,7 +598,7 @@ static void octeon_destroy_resources(struct octeon_device *oct)
1034     * @param lio per-network private data
1035     * @param start_stop whether to start or stop
1036     */
1037     -static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
1038     +static int send_rx_ctrl_cmd(struct lio *lio, int start_stop)
1039     {
1040     struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;
1041     struct octeon_soft_command *sc;
1042     @@ -606,11 +606,16 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
1043     int retval;
1044    
1045     if (oct->props[lio->ifidx].rx_on == start_stop)
1046     - return;
1047     + return 0;
1048    
1049     sc = (struct octeon_soft_command *)
1050     octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
1051     16, 0);
1052     + if (!sc) {
1053     + netif_info(lio, rx_err, lio->netdev,
1054     + "Failed to allocate octeon_soft_command struct\n");
1055     + return -ENOMEM;
1056     + }
1057    
1058     ncmd = (union octnet_cmd *)sc->virtdptr;
1059    
1060     @@ -638,11 +643,13 @@ static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
1061     */
1062     retval = wait_for_sc_completion_timeout(oct, sc, 0);
1063     if (retval)
1064     - return;
1065     + return retval;
1066    
1067     oct->props[lio->ifidx].rx_on = start_stop;
1068     WRITE_ONCE(sc->caller_is_done, true);
1069     }
1070     +
1071     + return retval;
1072     }
1073    
1074     /**
1075     @@ -909,6 +916,7 @@ static int liquidio_open(struct net_device *netdev)
1076     struct octeon_device_priv *oct_priv =
1077     (struct octeon_device_priv *)oct->priv;
1078     struct napi_struct *napi, *n;
1079     + int ret = 0;
1080    
1081     if (!oct->props[lio->ifidx].napi_enabled) {
1082     tasklet_disable(&oct_priv->droq_tasklet);
1083     @@ -935,11 +943,13 @@ static int liquidio_open(struct net_device *netdev)
1084     (LIQUIDIO_NDEV_STATS_POLL_TIME_MS));
1085    
1086     /* tell Octeon to start forwarding packets to host */
1087     - send_rx_ctrl_cmd(lio, 1);
1088     + ret = send_rx_ctrl_cmd(lio, 1);
1089     + if (ret)
1090     + return ret;
1091    
1092     dev_info(&oct->pci_dev->dev, "%s interface is opened\n", netdev->name);
1093    
1094     - return 0;
1095     + return ret;
1096     }
1097    
1098     /**
1099     @@ -953,9 +963,12 @@ static int liquidio_stop(struct net_device *netdev)
1100     struct octeon_device_priv *oct_priv =
1101     (struct octeon_device_priv *)oct->priv;
1102     struct napi_struct *napi, *n;
1103     + int ret = 0;
1104    
1105     /* tell Octeon to stop forwarding packets to host */
1106     - send_rx_ctrl_cmd(lio, 0);
1107     + ret = send_rx_ctrl_cmd(lio, 0);
1108     + if (ret)
1109     + return ret;
1110    
1111     netif_info(lio, ifdown, lio->netdev, "Stopping interface!\n");
1112     /* Inform that netif carrier is down */
1113     @@ -989,7 +1002,7 @@ static int liquidio_stop(struct net_device *netdev)
1114    
1115     dev_info(&oct->pci_dev->dev, "%s interface is stopped\n", netdev->name);
1116    
1117     - return 0;
1118     + return ret;
1119     }
1120    
1121     /**
1122     diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
1123     index 64a2453e06ba1..ccb28182f745b 100644
1124     --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
1125     +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
1126     @@ -778,7 +778,7 @@ void clear_all_filters(struct adapter *adapter)
1127     cxgb4_del_filter(dev, i, &f->fs);
1128     }
1129    
1130     - sb = t4_read_reg(adapter, LE_DB_SRVR_START_INDEX_A);
1131     + sb = adapter->tids.stid_base;
1132     for (i = 0; i < sb; i++) {
1133     f = (struct filter_entry *)adapter->tids.tid_tab[i];
1134    
1135     diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
1136     index f16853c3c851a..c813e6f2b371e 100644
1137     --- a/drivers/net/ethernet/dec/tulip/de4x5.c
1138     +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
1139     @@ -4927,11 +4927,11 @@ mii_get_oui(u_char phyaddr, u_long ioaddr)
1140     u_char breg[2];
1141     } a;
1142     int i, r2, r3, ret=0;*/
1143     - int r2, r3;
1144     + int r2;
1145    
1146     /* Read r2 and r3 */
1147     r2 = mii_rd(MII_ID0, phyaddr, ioaddr);
1148     - r3 = mii_rd(MII_ID1, phyaddr, ioaddr);
1149     + mii_rd(MII_ID1, phyaddr, ioaddr);
1150     /* SEEQ and Cypress way * /
1151     / * Shuffle r2 and r3 * /
1152     a.reg=0;
1153     diff --git a/drivers/net/ethernet/dec/tulip/media.c b/drivers/net/ethernet/dec/tulip/media.c
1154     index dcf21a36a9cf4..011604787b8ed 100644
1155     --- a/drivers/net/ethernet/dec/tulip/media.c
1156     +++ b/drivers/net/ethernet/dec/tulip/media.c
1157     @@ -319,13 +319,8 @@ void tulip_select_media(struct net_device *dev, int startup)
1158     break;
1159     }
1160     case 5: case 6: {
1161     - u16 setup[5];
1162     -
1163     new_csr6 = 0; /* FIXME */
1164    
1165     - for (i = 0; i < 5; i++)
1166     - setup[i] = get_u16(&p[i*2 + 1]);
1167     -
1168     if (startup && mtable->has_reset) {
1169     struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
1170     unsigned char *rst = rleaf->leafdata;
1171     diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
1172     index fd7fc6f20c9da..b1856552ab813 100644
1173     --- a/drivers/net/ethernet/freescale/fec_main.c
1174     +++ b/drivers/net/ethernet/freescale/fec_main.c
1175     @@ -3274,7 +3274,9 @@ static int fec_enet_init(struct net_device *ndev)
1176     return ret;
1177     }
1178    
1179     - fec_enet_alloc_queue(ndev);
1180     + ret = fec_enet_alloc_queue(ndev);
1181     + if (ret)
1182     + return ret;
1183    
1184     bd_size = (fep->total_tx_ring_size + fep->total_rx_ring_size) * dsize;
1185    
1186     @@ -3282,7 +3284,8 @@ static int fec_enet_init(struct net_device *ndev)
1187     cbd_base = dmam_alloc_coherent(&fep->pdev->dev, bd_size, &bd_dma,
1188     GFP_KERNEL);
1189     if (!cbd_base) {
1190     - return -ENOMEM;
1191     + ret = -ENOMEM;
1192     + goto free_queue_mem;
1193     }
1194    
1195     /* Get the Ethernet address */
1196     @@ -3360,6 +3363,10 @@ static int fec_enet_init(struct net_device *ndev)
1197     fec_enet_update_ethtool_stats(ndev);
1198    
1199     return 0;
1200     +
1201     +free_queue_mem:
1202     + fec_enet_free_queue(ndev);
1203     + return ret;
1204     }
1205    
1206     #ifdef CONFIG_OF
1207     diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
1208     index 1eca0fdb99334..b8fc9bbeca2c7 100644
1209     --- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
1210     +++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
1211     @@ -548,8 +548,8 @@ static int fmvj18x_get_hwinfo(struct pcmcia_device *link, u_char *node_id)
1212    
1213     base = ioremap(link->resource[2]->start, resource_size(link->resource[2]));
1214     if (!base) {
1215     - pcmcia_release_window(link, link->resource[2]);
1216     - return -ENOMEM;
1217     + pcmcia_release_window(link, link->resource[2]);
1218     + return -1;
1219     }
1220    
1221     pcmcia_map_mem_page(link, link->resource[2], 0);
1222     diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
1223     index 9b7a8db9860fc..6ea0975d74a1f 100644
1224     --- a/drivers/net/ethernet/google/gve/gve_main.c
1225     +++ b/drivers/net/ethernet/google/gve/gve_main.c
1226     @@ -121,7 +121,7 @@ static int gve_napi_poll(struct napi_struct *napi, int budget)
1227     /* Double check we have no extra work.
1228     * Ensure unmask synchronizes with checking for work.
1229     */
1230     - dma_rmb();
1231     + mb();
1232     if (block->tx)
1233     reschedule |= gve_tx_poll(block, -1);
1234     if (block->rx)
1235     @@ -161,6 +161,7 @@ static int gve_alloc_notify_blocks(struct gve_priv *priv)
1236     int vecs_left = new_num_ntfy_blks % 2;
1237    
1238     priv->num_ntfy_blks = new_num_ntfy_blks;
1239     + priv->mgmt_msix_idx = priv->num_ntfy_blks;
1240     priv->tx_cfg.max_queues = min_t(int, priv->tx_cfg.max_queues,
1241     vecs_per_type);
1242     priv->rx_cfg.max_queues = min_t(int, priv->rx_cfg.max_queues,
1243     @@ -241,20 +242,22 @@ static void gve_free_notify_blocks(struct gve_priv *priv)
1244     {
1245     int i;
1246    
1247     - /* Free the irqs */
1248     - for (i = 0; i < priv->num_ntfy_blks; i++) {
1249     - struct gve_notify_block *block = &priv->ntfy_blocks[i];
1250     - int msix_idx = i;
1251     + if (priv->msix_vectors) {
1252     + /* Free the irqs */
1253     + for (i = 0; i < priv->num_ntfy_blks; i++) {
1254     + struct gve_notify_block *block = &priv->ntfy_blocks[i];
1255     + int msix_idx = i;
1256    
1257     - irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector,
1258     - NULL);
1259     - free_irq(priv->msix_vectors[msix_idx].vector, block);
1260     + irq_set_affinity_hint(priv->msix_vectors[msix_idx].vector,
1261     + NULL);
1262     + free_irq(priv->msix_vectors[msix_idx].vector, block);
1263     + }
1264     + free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
1265     }
1266     dma_free_coherent(&priv->pdev->dev,
1267     priv->num_ntfy_blks * sizeof(*priv->ntfy_blocks),
1268     priv->ntfy_blocks, priv->ntfy_block_bus);
1269     priv->ntfy_blocks = NULL;
1270     - free_irq(priv->msix_vectors[priv->mgmt_msix_idx].vector, priv);
1271     pci_disable_msix(priv->pdev);
1272     kvfree(priv->msix_vectors);
1273     priv->msix_vectors = NULL;
1274     diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c
1275     index d0244feb03011..b653197b34d10 100644
1276     --- a/drivers/net/ethernet/google/gve/gve_tx.c
1277     +++ b/drivers/net/ethernet/google/gve/gve_tx.c
1278     @@ -207,10 +207,12 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx)
1279     goto abort_with_info;
1280    
1281     tx->tx_fifo.qpl = gve_assign_tx_qpl(priv);
1282     + if (!tx->tx_fifo.qpl)
1283     + goto abort_with_desc;
1284    
1285     /* map Tx FIFO */
1286     if (gve_tx_fifo_init(priv, &tx->tx_fifo))
1287     - goto abort_with_desc;
1288     + goto abort_with_qpl;
1289    
1290     tx->q_resources =
1291     dma_alloc_coherent(hdev,
1292     @@ -229,6 +231,8 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx)
1293    
1294     abort_with_fifo:
1295     gve_tx_fifo_release(priv, &tx->tx_fifo);
1296     +abort_with_qpl:
1297     + gve_unassign_qpl(priv, tx->tx_fifo.qpl->id);
1298     abort_with_desc:
1299     dma_free_coherent(hdev, bytes, tx->desc, tx->bus);
1300     tx->desc = NULL;
1301     @@ -478,7 +482,7 @@ netdev_tx_t gve_tx(struct sk_buff *skb, struct net_device *dev)
1302     struct gve_tx_ring *tx;
1303     int nsegs;
1304    
1305     - WARN(skb_get_queue_mapping(skb) > priv->tx_cfg.num_queues,
1306     + WARN(skb_get_queue_mapping(skb) >= priv->tx_cfg.num_queues,
1307     "skb queue index out of range");
1308     tx = &priv->tx[skb_get_queue_mapping(skb)];
1309     if (unlikely(gve_maybe_stop_tx(tx, skb))) {
1310     diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
1311     index 5f2948bafff21..e64e175162068 100644
1312     --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
1313     +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
1314     @@ -810,8 +810,6 @@ static bool hns3_tunnel_csum_bug(struct sk_buff *skb)
1315     l4.udp->dest == htons(4790))))
1316     return false;
1317    
1318     - skb_checksum_help(skb);
1319     -
1320     return true;
1321     }
1322    
1323     @@ -889,8 +887,7 @@ static int hns3_set_l2l3l4(struct sk_buff *skb, u8 ol4_proto,
1324     /* the stack computes the IP header already,
1325     * driver calculate l4 checksum when not TSO.
1326     */
1327     - skb_checksum_help(skb);
1328     - return 0;
1329     + return skb_checksum_help(skb);
1330     }
1331    
1332     hns3_set_outer_l2l3l4(skb, ol4_proto, ol_type_vlan_len_msec);
1333     @@ -935,7 +932,7 @@ static int hns3_set_l2l3l4(struct sk_buff *skb, u8 ol4_proto,
1334     break;
1335     case IPPROTO_UDP:
1336     if (hns3_tunnel_csum_bug(skb))
1337     - break;
1338     + return skb_checksum_help(skb);
1339    
1340     hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4CS_B, 1);
1341     hns3_set_field(*type_cs_vlan_tso, HNS3_TXD_L4T_S,
1342     @@ -960,8 +957,7 @@ static int hns3_set_l2l3l4(struct sk_buff *skb, u8 ol4_proto,
1343     /* the stack computes the IP header already,
1344     * driver calculate l4 checksum when not TSO.
1345     */
1346     - skb_checksum_help(skb);
1347     - return 0;
1348     + return skb_checksum_help(skb);
1349     }
1350    
1351     return 0;
1352     diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
1353     index 537dfff585e0d..47a920128760e 100644
1354     --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
1355     +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
1356     @@ -467,12 +467,16 @@ static int ixgbe_set_vf_vlan(struct ixgbe_adapter *adapter, int add, int vid,
1357     return err;
1358     }
1359    
1360     -static s32 ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
1361     +static int ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 max_frame, u32 vf)
1362     {
1363     struct ixgbe_hw *hw = &adapter->hw;
1364     - int max_frame = msgbuf[1];
1365     u32 max_frs;
1366    
1367     + if (max_frame < ETH_MIN_MTU || max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE) {
1368     + e_err(drv, "VF max_frame %d out of range\n", max_frame);
1369     + return -EINVAL;
1370     + }
1371     +
1372     /*
1373     * For 82599EB we have to keep all PFs and VFs operating with
1374     * the same max_frame value in order to avoid sending an oversize
1375     @@ -533,12 +537,6 @@ static s32 ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf)
1376     }
1377     }
1378    
1379     - /* MTU < 68 is an error and causes problems on some kernels */
1380     - if (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE) {
1381     - e_err(drv, "VF max_frame %d out of range\n", max_frame);
1382     - return -EINVAL;
1383     - }
1384     -
1385     /* pull current max frame size from hardware */
1386     max_frs = IXGBE_READ_REG(hw, IXGBE_MAXFRS);
1387     max_frs &= IXGBE_MHADD_MFS_MASK;
1388     @@ -1249,7 +1247,7 @@ static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
1389     retval = ixgbe_set_vf_vlan_msg(adapter, msgbuf, vf);
1390     break;
1391     case IXGBE_VF_SET_LPE:
1392     - retval = ixgbe_set_vf_lpe(adapter, msgbuf, vf);
1393     + retval = ixgbe_set_vf_lpe(adapter, msgbuf[1], vf);
1394     break;
1395     case IXGBE_VF_SET_MACVLAN:
1396     retval = ixgbe_set_vf_macvlan_msg(adapter, msgbuf, vf);
1397     diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c
1398     index 4e44a39267eb3..6ece99e6b6dde 100644
1399     --- a/drivers/net/ethernet/lantiq_xrx200.c
1400     +++ b/drivers/net/ethernet/lantiq_xrx200.c
1401     @@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev)
1402    
1403     static int xrx200_alloc_skb(struct xrx200_chan *ch)
1404     {
1405     + dma_addr_t mapping;
1406     int ret = 0;
1407    
1408     ch->skb[ch->dma.desc] = netdev_alloc_skb_ip_align(ch->priv->net_dev,
1409     @@ -163,16 +164,17 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch)
1410     goto skip;
1411     }
1412    
1413     - ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(ch->priv->dev,
1414     - ch->skb[ch->dma.desc]->data, XRX200_DMA_DATA_LEN,
1415     - DMA_FROM_DEVICE);
1416     - if (unlikely(dma_mapping_error(ch->priv->dev,
1417     - ch->dma.desc_base[ch->dma.desc].addr))) {
1418     + mapping = dma_map_single(ch->priv->dev, ch->skb[ch->dma.desc]->data,
1419     + XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE);
1420     + if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) {
1421     dev_kfree_skb_any(ch->skb[ch->dma.desc]);
1422     ret = -ENOMEM;
1423     goto skip;
1424     }
1425    
1426     + ch->dma.desc_base[ch->dma.desc].addr = mapping;
1427     + /* Make sure the address is written before we give it to HW */
1428     + wmb();
1429     skip:
1430     ch->dma.desc_base[ch->dma.desc].ctl =
1431     LTQ_DMA_OWN | LTQ_DMA_RX_OFFSET(NET_IP_ALIGN) |
1432     @@ -196,6 +198,8 @@ static int xrx200_hw_receive(struct xrx200_chan *ch)
1433     ch->dma.desc %= LTQ_DESC_NUM;
1434    
1435     if (ret) {
1436     + ch->skb[ch->dma.desc] = skb;
1437     + net_dev->stats.rx_dropped++;
1438     netdev_err(net_dev, "failed to allocate new rx buffer\n");
1439     return ret;
1440     }
1441     diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1442     index 7e3806fd70b21..48b395b9c15ad 100644
1443     --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1444     +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
1445     @@ -675,32 +675,53 @@ static int mtk_set_mac_address(struct net_device *dev, void *p)
1446     void mtk_stats_update_mac(struct mtk_mac *mac)
1447     {
1448     struct mtk_hw_stats *hw_stats = mac->hw_stats;
1449     - unsigned int base = MTK_GDM1_TX_GBCNT;
1450     - u64 stats;
1451     -
1452     - base += hw_stats->reg_offset;
1453     + struct mtk_eth *eth = mac->hw;
1454    
1455     u64_stats_update_begin(&hw_stats->syncp);
1456    
1457     - hw_stats->rx_bytes += mtk_r32(mac->hw, base);
1458     - stats = mtk_r32(mac->hw, base + 0x04);
1459     - if (stats)
1460     - hw_stats->rx_bytes += (stats << 32);
1461     - hw_stats->rx_packets += mtk_r32(mac->hw, base + 0x08);
1462     - hw_stats->rx_overflow += mtk_r32(mac->hw, base + 0x10);
1463     - hw_stats->rx_fcs_errors += mtk_r32(mac->hw, base + 0x14);
1464     - hw_stats->rx_short_errors += mtk_r32(mac->hw, base + 0x18);
1465     - hw_stats->rx_long_errors += mtk_r32(mac->hw, base + 0x1c);
1466     - hw_stats->rx_checksum_errors += mtk_r32(mac->hw, base + 0x20);
1467     - hw_stats->rx_flow_control_packets +=
1468     - mtk_r32(mac->hw, base + 0x24);
1469     - hw_stats->tx_skip += mtk_r32(mac->hw, base + 0x28);
1470     - hw_stats->tx_collisions += mtk_r32(mac->hw, base + 0x2c);
1471     - hw_stats->tx_bytes += mtk_r32(mac->hw, base + 0x30);
1472     - stats = mtk_r32(mac->hw, base + 0x34);
1473     - if (stats)
1474     - hw_stats->tx_bytes += (stats << 32);
1475     - hw_stats->tx_packets += mtk_r32(mac->hw, base + 0x38);
1476     + if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) {
1477     + hw_stats->tx_packets += mtk_r32(mac->hw, MT7628_SDM_TPCNT);
1478     + hw_stats->tx_bytes += mtk_r32(mac->hw, MT7628_SDM_TBCNT);
1479     + hw_stats->rx_packets += mtk_r32(mac->hw, MT7628_SDM_RPCNT);
1480     + hw_stats->rx_bytes += mtk_r32(mac->hw, MT7628_SDM_RBCNT);
1481     + hw_stats->rx_checksum_errors +=
1482     + mtk_r32(mac->hw, MT7628_SDM_CS_ERR);
1483     + } else {
1484     + unsigned int offs = hw_stats->reg_offset;
1485     + u64 stats;
1486     +
1487     + hw_stats->rx_bytes += mtk_r32(mac->hw,
1488     + MTK_GDM1_RX_GBCNT_L + offs);
1489     + stats = mtk_r32(mac->hw, MTK_GDM1_RX_GBCNT_H + offs);
1490     + if (stats)
1491     + hw_stats->rx_bytes += (stats << 32);
1492     + hw_stats->rx_packets +=
1493     + mtk_r32(mac->hw, MTK_GDM1_RX_GPCNT + offs);
1494     + hw_stats->rx_overflow +=
1495     + mtk_r32(mac->hw, MTK_GDM1_RX_OERCNT + offs);
1496     + hw_stats->rx_fcs_errors +=
1497     + mtk_r32(mac->hw, MTK_GDM1_RX_FERCNT + offs);
1498     + hw_stats->rx_short_errors +=
1499     + mtk_r32(mac->hw, MTK_GDM1_RX_SERCNT + offs);
1500     + hw_stats->rx_long_errors +=
1501     + mtk_r32(mac->hw, MTK_GDM1_RX_LENCNT + offs);
1502     + hw_stats->rx_checksum_errors +=
1503     + mtk_r32(mac->hw, MTK_GDM1_RX_CERCNT + offs);
1504     + hw_stats->rx_flow_control_packets +=
1505     + mtk_r32(mac->hw, MTK_GDM1_RX_FCCNT + offs);
1506     + hw_stats->tx_skip +=
1507     + mtk_r32(mac->hw, MTK_GDM1_TX_SKIPCNT + offs);
1508     + hw_stats->tx_collisions +=
1509     + mtk_r32(mac->hw, MTK_GDM1_TX_COLCNT + offs);
1510     + hw_stats->tx_bytes +=
1511     + mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_L + offs);
1512     + stats = mtk_r32(mac->hw, MTK_GDM1_TX_GBCNT_H + offs);
1513     + if (stats)
1514     + hw_stats->tx_bytes += (stats << 32);
1515     + hw_stats->tx_packets +=
1516     + mtk_r32(mac->hw, MTK_GDM1_TX_GPCNT + offs);
1517     + }
1518     +
1519     u64_stats_update_end(&hw_stats->syncp);
1520     }
1521    
1522     diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
1523     index 1e9202b34d352..c0b2768b480f8 100644
1524     --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
1525     +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
1526     @@ -264,8 +264,21 @@
1527     /* QDMA FQ Free Page Buffer Length Register */
1528     #define MTK_QDMA_FQ_BLEN 0x1B2C
1529    
1530     -/* GMA1 Received Good Byte Count Register */
1531     -#define MTK_GDM1_TX_GBCNT 0x2400
1532     +/* GMA1 counter / statics register */
1533     +#define MTK_GDM1_RX_GBCNT_L 0x2400
1534     +#define MTK_GDM1_RX_GBCNT_H 0x2404
1535     +#define MTK_GDM1_RX_GPCNT 0x2408
1536     +#define MTK_GDM1_RX_OERCNT 0x2410
1537     +#define MTK_GDM1_RX_FERCNT 0x2414
1538     +#define MTK_GDM1_RX_SERCNT 0x2418
1539     +#define MTK_GDM1_RX_LENCNT 0x241c
1540     +#define MTK_GDM1_RX_CERCNT 0x2420
1541     +#define MTK_GDM1_RX_FCCNT 0x2424
1542     +#define MTK_GDM1_TX_SKIPCNT 0x2428
1543     +#define MTK_GDM1_TX_COLCNT 0x242c
1544     +#define MTK_GDM1_TX_GBCNT_L 0x2430
1545     +#define MTK_GDM1_TX_GBCNT_H 0x2434
1546     +#define MTK_GDM1_TX_GPCNT 0x2438
1547     #define MTK_STAT_OFFSET 0x40
1548    
1549     /* QDMA descriptor txd4 */
1550     @@ -476,6 +489,13 @@
1551     #define MT7628_SDM_MAC_ADRL (MT7628_SDM_OFFSET + 0x0c)
1552     #define MT7628_SDM_MAC_ADRH (MT7628_SDM_OFFSET + 0x10)
1553    
1554     +/* Counter / stat register */
1555     +#define MT7628_SDM_TPCNT (MT7628_SDM_OFFSET + 0x100)
1556     +#define MT7628_SDM_TBCNT (MT7628_SDM_OFFSET + 0x104)
1557     +#define MT7628_SDM_RPCNT (MT7628_SDM_OFFSET + 0x108)
1558     +#define MT7628_SDM_RBCNT (MT7628_SDM_OFFSET + 0x10c)
1559     +#define MT7628_SDM_CS_ERR (MT7628_SDM_OFFSET + 0x110)
1560     +
1561     struct mtk_rx_dma {
1562     unsigned int rxd1;
1563     unsigned int rxd2;
1564     diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1565     index 5582fba2f5823..426786a349c3c 100644
1566     --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1567     +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
1568     @@ -2011,8 +2011,6 @@ static int mlx4_en_set_tunable(struct net_device *dev,
1569     return ret;
1570     }
1571    
1572     -#define MLX4_EEPROM_PAGE_LEN 256
1573     -
1574     static int mlx4_en_get_module_info(struct net_device *dev,
1575     struct ethtool_modinfo *modinfo)
1576     {
1577     @@ -2047,7 +2045,7 @@ static int mlx4_en_get_module_info(struct net_device *dev,
1578     break;
1579     case MLX4_MODULE_ID_SFP:
1580     modinfo->type = ETH_MODULE_SFF_8472;
1581     - modinfo->eeprom_len = MLX4_EEPROM_PAGE_LEN;
1582     + modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN;
1583     break;
1584     default:
1585     return -EINVAL;
1586     diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1587     index 605c079d48417..b0837ad94da65 100644
1588     --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1589     +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
1590     @@ -868,6 +868,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
1591     struct mlx4_en_tx_desc *tx_desc;
1592     struct mlx4_wqe_data_seg *data;
1593     struct mlx4_en_tx_info *tx_info;
1594     + u32 __maybe_unused ring_cons;
1595     int tx_ind;
1596     int nr_txbb;
1597     int desc_size;
1598     @@ -881,7 +882,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
1599     bool stop_queue;
1600     bool inline_ok;
1601     u8 data_offset;
1602     - u32 ring_cons;
1603     bool bf_ok;
1604    
1605     tx_ind = skb_get_queue_mapping(skb);
1606     diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c
1607     index ba6ac31a339dc..256a06b3c096b 100644
1608     --- a/drivers/net/ethernet/mellanox/mlx4/port.c
1609     +++ b/drivers/net/ethernet/mellanox/mlx4/port.c
1610     @@ -1973,6 +1973,7 @@ EXPORT_SYMBOL(mlx4_get_roce_gid_from_slave);
1611     #define I2C_ADDR_LOW 0x50
1612     #define I2C_ADDR_HIGH 0x51
1613     #define I2C_PAGE_SIZE 256
1614     +#define I2C_HIGH_PAGE_SIZE 128
1615    
1616     /* Module Info Data */
1617     struct mlx4_cable_info {
1618     @@ -2026,6 +2027,88 @@ static inline const char *cable_info_mad_err_str(u16 mad_status)
1619     return "Unknown Error";
1620     }
1621    
1622     +static int mlx4_get_module_id(struct mlx4_dev *dev, u8 port, u8 *module_id)
1623     +{
1624     + struct mlx4_cmd_mailbox *inbox, *outbox;
1625     + struct mlx4_mad_ifc *inmad, *outmad;
1626     + struct mlx4_cable_info *cable_info;
1627     + int ret;
1628     +
1629     + inbox = mlx4_alloc_cmd_mailbox(dev);
1630     + if (IS_ERR(inbox))
1631     + return PTR_ERR(inbox);
1632     +
1633     + outbox = mlx4_alloc_cmd_mailbox(dev);
1634     + if (IS_ERR(outbox)) {
1635     + mlx4_free_cmd_mailbox(dev, inbox);
1636     + return PTR_ERR(outbox);
1637     + }
1638     +
1639     + inmad = (struct mlx4_mad_ifc *)(inbox->buf);
1640     + outmad = (struct mlx4_mad_ifc *)(outbox->buf);
1641     +
1642     + inmad->method = 0x1; /* Get */
1643     + inmad->class_version = 0x1;
1644     + inmad->mgmt_class = 0x1;
1645     + inmad->base_version = 0x1;
1646     + inmad->attr_id = cpu_to_be16(0xFF60); /* Module Info */
1647     +
1648     + cable_info = (struct mlx4_cable_info *)inmad->data;
1649     + cable_info->dev_mem_address = 0;
1650     + cable_info->page_num = 0;
1651     + cable_info->i2c_addr = I2C_ADDR_LOW;
1652     + cable_info->size = cpu_to_be16(1);
1653     +
1654     + ret = mlx4_cmd_box(dev, inbox->dma, outbox->dma, port, 3,
1655     + MLX4_CMD_MAD_IFC, MLX4_CMD_TIME_CLASS_C,
1656     + MLX4_CMD_NATIVE);
1657     + if (ret)
1658     + goto out;
1659     +
1660     + if (be16_to_cpu(outmad->status)) {
1661     + /* Mad returned with bad status */
1662     + ret = be16_to_cpu(outmad->status);
1663     + mlx4_warn(dev,
1664     + "MLX4_CMD_MAD_IFC Get Module ID attr(%x) port(%d) i2c_addr(%x) offset(%d) size(%d): Response Mad Status(%x) - %s\n",
1665     + 0xFF60, port, I2C_ADDR_LOW, 0, 1, ret,
1666     + cable_info_mad_err_str(ret));
1667     + ret = -ret;
1668     + goto out;
1669     + }
1670     + cable_info = (struct mlx4_cable_info *)outmad->data;
1671     + *module_id = cable_info->data[0];
1672     +out:
1673     + mlx4_free_cmd_mailbox(dev, inbox);
1674     + mlx4_free_cmd_mailbox(dev, outbox);
1675     + return ret;
1676     +}
1677     +
1678     +static void mlx4_sfp_eeprom_params_set(u8 *i2c_addr, u8 *page_num, u16 *offset)
1679     +{
1680     + *i2c_addr = I2C_ADDR_LOW;
1681     + *page_num = 0;
1682     +
1683     + if (*offset < I2C_PAGE_SIZE)
1684     + return;
1685     +
1686     + *i2c_addr = I2C_ADDR_HIGH;
1687     + *offset -= I2C_PAGE_SIZE;
1688     +}
1689     +
1690     +static void mlx4_qsfp_eeprom_params_set(u8 *i2c_addr, u8 *page_num, u16 *offset)
1691     +{
1692     + /* Offsets 0-255 belong to page 0.
1693     + * Offsets 256-639 belong to pages 01, 02, 03.
1694     + * For example, offset 400 is page 02: 1 + (400 - 256) / 128 = 2
1695     + */
1696     + if (*offset < I2C_PAGE_SIZE)
1697     + *page_num = 0;
1698     + else
1699     + *page_num = 1 + (*offset - I2C_PAGE_SIZE) / I2C_HIGH_PAGE_SIZE;
1700     + *i2c_addr = I2C_ADDR_LOW;
1701     + *offset -= *page_num * I2C_HIGH_PAGE_SIZE;
1702     +}
1703     +
1704     /**
1705     * mlx4_get_module_info - Read cable module eeprom data
1706     * @dev: mlx4_dev.
1707     @@ -2045,12 +2128,30 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port,
1708     struct mlx4_cmd_mailbox *inbox, *outbox;
1709     struct mlx4_mad_ifc *inmad, *outmad;
1710     struct mlx4_cable_info *cable_info;
1711     - u16 i2c_addr;
1712     + u8 module_id, i2c_addr, page_num;
1713     int ret;
1714    
1715     if (size > MODULE_INFO_MAX_READ)
1716     size = MODULE_INFO_MAX_READ;
1717    
1718     + ret = mlx4_get_module_id(dev, port, &module_id);
1719     + if (ret)
1720     + return ret;
1721     +
1722     + switch (module_id) {
1723     + case MLX4_MODULE_ID_SFP:
1724     + mlx4_sfp_eeprom_params_set(&i2c_addr, &page_num, &offset);
1725     + break;
1726     + case MLX4_MODULE_ID_QSFP:
1727     + case MLX4_MODULE_ID_QSFP_PLUS:
1728     + case MLX4_MODULE_ID_QSFP28:
1729     + mlx4_qsfp_eeprom_params_set(&i2c_addr, &page_num, &offset);
1730     + break;
1731     + default:
1732     + mlx4_err(dev, "Module ID not recognized: %#x\n", module_id);
1733     + return -EINVAL;
1734     + }
1735     +
1736     inbox = mlx4_alloc_cmd_mailbox(dev);
1737     if (IS_ERR(inbox))
1738     return PTR_ERR(inbox);
1739     @@ -2076,11 +2177,9 @@ int mlx4_get_module_info(struct mlx4_dev *dev, u8 port,
1740     */
1741     size -= offset + size - I2C_PAGE_SIZE;
1742    
1743     - i2c_addr = I2C_ADDR_LOW;
1744     -
1745     cable_info = (struct mlx4_cable_info *)inmad->data;
1746     cable_info->dev_mem_address = cpu_to_be16(offset);
1747     - cable_info->page_num = 0;
1748     + cable_info->page_num = page_num;
1749     cable_info->i2c_addr = i2c_addr;
1750     cable_info->size = cpu_to_be16(size);
1751    
1752     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1753     index 6495c26d95969..fe7342e8a043b 100644
1754     --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1755     +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1756     @@ -3170,8 +3170,12 @@ static int add_vlan_push_action(struct mlx5e_priv *priv,
1757     if (err)
1758     return err;
1759    
1760     - *out_dev = dev_get_by_index_rcu(dev_net(vlan_dev),
1761     - dev_get_iflink(vlan_dev));
1762     + rcu_read_lock();
1763     + *out_dev = dev_get_by_index_rcu(dev_net(vlan_dev), dev_get_iflink(vlan_dev));
1764     + rcu_read_unlock();
1765     + if (!*out_dev)
1766     + return -ENODEV;
1767     +
1768     if (is_vlan_dev(*out_dev))
1769     err = add_vlan_push_action(priv, attr, out_dev, action);
1770    
1771     diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c b/drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c
1772     index 5d20d615663e7..bdc7f915d80e3 100644
1773     --- a/drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c
1774     +++ b/drivers/net/ethernet/mellanox/mlx5/core/lag_mp.c
1775     @@ -307,6 +307,11 @@ int mlx5_lag_mp_init(struct mlx5_lag *ldev)
1776     struct lag_mp *mp = &ldev->lag_mp;
1777     int err;
1778    
1779     + /* always clear mfi, as it might become stale when a route delete event
1780     + * has been missed
1781     + */
1782     + mp->mfi = NULL;
1783     +
1784     if (mp->fib_nb.notifier_call)
1785     return 0;
1786    
1787     @@ -328,4 +333,5 @@ void mlx5_lag_mp_cleanup(struct mlx5_lag *ldev)
1788    
1789     unregister_fib_notifier(&mp->fib_nb);
1790     mp->fib_nb.notifier_call = NULL;
1791     + mp->mfi = NULL;
1792     }
1793     diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
1794     index e102e1560ac79..7dc451fdaf35e 100644
1795     --- a/drivers/net/ethernet/micrel/ksz884x.c
1796     +++ b/drivers/net/ethernet/micrel/ksz884x.c
1797     @@ -1649,8 +1649,7 @@ static inline void set_tx_len(struct ksz_desc *desc, u32 len)
1798    
1799     #define HW_DELAY(hw, reg) \
1800     do { \
1801     - u16 dummy; \
1802     - dummy = readw(hw->io + reg); \
1803     + readw(hw->io + reg); \
1804     } while (0)
1805    
1806     /**
1807     diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
1808     index 4bbdc53eaf3f3..dfa0ded169ee9 100644
1809     --- a/drivers/net/ethernet/microchip/lan743x_main.c
1810     +++ b/drivers/net/ethernet/microchip/lan743x_main.c
1811     @@ -156,9 +156,8 @@ static void lan743x_tx_isr(void *context, u32 int_sts, u32 flags)
1812     struct lan743x_tx *tx = context;
1813     struct lan743x_adapter *adapter = tx->adapter;
1814     bool enable_flag = true;
1815     - u32 int_en = 0;
1816    
1817     - int_en = lan743x_csr_read(adapter, INT_EN_SET);
1818     + lan743x_csr_read(adapter, INT_EN_SET);
1819     if (flags & LAN743X_VECTOR_FLAG_SOURCE_ENABLE_CLEAR) {
1820     lan743x_csr_write(adapter, INT_EN_CLR,
1821     INT_BIT_DMA_TX_(tx->channel_number));
1822     @@ -1631,10 +1630,9 @@ static int lan743x_tx_napi_poll(struct napi_struct *napi, int weight)
1823     bool start_transmitter = false;
1824     unsigned long irq_flags = 0;
1825     u32 ioc_bit = 0;
1826     - u32 int_sts = 0;
1827    
1828     ioc_bit = DMAC_INT_BIT_TX_IOC_(tx->channel_number);
1829     - int_sts = lan743x_csr_read(adapter, DMAC_INT_STS);
1830     + lan743x_csr_read(adapter, DMAC_INT_STS);
1831     if (tx->vector_flags & LAN743X_VECTOR_FLAG_SOURCE_STATUS_W2C)
1832     lan743x_csr_write(adapter, DMAC_INT_STS, ioc_bit);
1833     spin_lock_irqsave(&tx->ring_lock, irq_flags);
1834     diff --git a/drivers/net/ethernet/neterion/vxge/vxge-traffic.c b/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
1835     index 709d20d9938fb..bd525e8eda10c 100644
1836     --- a/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
1837     +++ b/drivers/net/ethernet/neterion/vxge/vxge-traffic.c
1838     @@ -30,8 +30,6 @@
1839     */
1840     enum vxge_hw_status vxge_hw_vpath_intr_enable(struct __vxge_hw_vpath_handle *vp)
1841     {
1842     - u64 val64;
1843     -
1844     struct __vxge_hw_virtualpath *vpath;
1845     struct vxge_hw_vpath_reg __iomem *vp_reg;
1846     enum vxge_hw_status status = VXGE_HW_OK;
1847     @@ -84,7 +82,7 @@ enum vxge_hw_status vxge_hw_vpath_intr_enable(struct __vxge_hw_vpath_handle *vp)
1848     __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
1849     &vp_reg->xgmac_vp_int_status);
1850    
1851     - val64 = readq(&vp_reg->vpath_general_int_status);
1852     + readq(&vp_reg->vpath_general_int_status);
1853    
1854     /* Mask unwanted interrupts */
1855    
1856     @@ -157,8 +155,6 @@ exit:
1857     enum vxge_hw_status vxge_hw_vpath_intr_disable(
1858     struct __vxge_hw_vpath_handle *vp)
1859     {
1860     - u64 val64;
1861     -
1862     struct __vxge_hw_virtualpath *vpath;
1863     enum vxge_hw_status status = VXGE_HW_OK;
1864     struct vxge_hw_vpath_reg __iomem *vp_reg;
1865     @@ -179,8 +175,6 @@ enum vxge_hw_status vxge_hw_vpath_intr_disable(
1866     (u32)VXGE_HW_INTR_MASK_ALL,
1867     &vp_reg->vpath_general_int_mask);
1868    
1869     - val64 = VXGE_HW_TIM_CLR_INT_EN_VP(1 << (16 - vpath->vp_id));
1870     -
1871     writeq(VXGE_HW_INTR_MASK_ALL, &vp_reg->kdfcctl_errors_mask);
1872    
1873     __vxge_hw_pio_mem_write32_upper((u32)VXGE_HW_INTR_MASK_ALL,
1874     @@ -487,9 +481,7 @@ void vxge_hw_device_unmask_all(struct __vxge_hw_device *hldev)
1875     */
1876     void vxge_hw_device_flush_io(struct __vxge_hw_device *hldev)
1877     {
1878     - u32 val32;
1879     -
1880     - val32 = readl(&hldev->common_reg->titan_general_int_status);
1881     + readl(&hldev->common_reg->titan_general_int_status);
1882     }
1883    
1884     /**
1885     @@ -1716,8 +1708,8 @@ void vxge_hw_fifo_txdl_free(struct __vxge_hw_fifo *fifo, void *txdlh)
1886     enum vxge_hw_status
1887     vxge_hw_vpath_mac_addr_add(
1888     struct __vxge_hw_vpath_handle *vp,
1889     - u8 (macaddr)[ETH_ALEN],
1890     - u8 (macaddr_mask)[ETH_ALEN],
1891     + u8 *macaddr,
1892     + u8 *macaddr_mask,
1893     enum vxge_hw_vpath_mac_addr_add_mode duplicate_mode)
1894     {
1895     u32 i;
1896     @@ -1779,8 +1771,8 @@ exit:
1897     enum vxge_hw_status
1898     vxge_hw_vpath_mac_addr_get(
1899     struct __vxge_hw_vpath_handle *vp,
1900     - u8 (macaddr)[ETH_ALEN],
1901     - u8 (macaddr_mask)[ETH_ALEN])
1902     + u8 *macaddr,
1903     + u8 *macaddr_mask)
1904     {
1905     u32 i;
1906     u64 data1 = 0ULL;
1907     @@ -1831,8 +1823,8 @@ exit:
1908     enum vxge_hw_status
1909     vxge_hw_vpath_mac_addr_get_next(
1910     struct __vxge_hw_vpath_handle *vp,
1911     - u8 (macaddr)[ETH_ALEN],
1912     - u8 (macaddr_mask)[ETH_ALEN])
1913     + u8 *macaddr,
1914     + u8 *macaddr_mask)
1915     {
1916     u32 i;
1917     u64 data1 = 0ULL;
1918     @@ -1884,8 +1876,8 @@ exit:
1919     enum vxge_hw_status
1920     vxge_hw_vpath_mac_addr_delete(
1921     struct __vxge_hw_vpath_handle *vp,
1922     - u8 (macaddr)[ETH_ALEN],
1923     - u8 (macaddr_mask)[ETH_ALEN])
1924     + u8 *macaddr,
1925     + u8 *macaddr_mask)
1926     {
1927     u32 i;
1928     u64 data1 = 0ULL;
1929     @@ -2375,7 +2367,6 @@ enum vxge_hw_status vxge_hw_vpath_poll_rx(struct __vxge_hw_ring *ring)
1930     u8 t_code;
1931     enum vxge_hw_status status = VXGE_HW_OK;
1932     void *first_rxdh;
1933     - u64 val64 = 0;
1934     int new_count = 0;
1935    
1936     ring->cmpl_cnt = 0;
1937     @@ -2403,8 +2394,7 @@ enum vxge_hw_status vxge_hw_vpath_poll_rx(struct __vxge_hw_ring *ring)
1938     }
1939     writeq(VXGE_HW_PRC_RXD_DOORBELL_NEW_QW_CNT(new_count),
1940     &ring->vp_reg->prc_rxd_doorbell);
1941     - val64 =
1942     - readl(&ring->common_reg->titan_general_int_status);
1943     + readl(&ring->common_reg->titan_general_int_status);
1944     ring->doorbell_cnt = 0;
1945     }
1946     }
1947     diff --git a/drivers/net/ethernet/sfc/falcon/farch.c b/drivers/net/ethernet/sfc/falcon/farch.c
1948     index 332183280a459..612a43233b18b 100644
1949     --- a/drivers/net/ethernet/sfc/falcon/farch.c
1950     +++ b/drivers/net/ethernet/sfc/falcon/farch.c
1951     @@ -870,17 +870,12 @@ static u16 ef4_farch_handle_rx_not_ok(struct ef4_rx_queue *rx_queue,
1952     {
1953     struct ef4_channel *channel = ef4_rx_queue_channel(rx_queue);
1954     struct ef4_nic *efx = rx_queue->efx;
1955     - bool rx_ev_buf_owner_id_err, rx_ev_ip_hdr_chksum_err;
1956     + bool __maybe_unused rx_ev_buf_owner_id_err, rx_ev_ip_hdr_chksum_err;
1957     bool rx_ev_tcp_udp_chksum_err, rx_ev_eth_crc_err;
1958     bool rx_ev_frm_trunc, rx_ev_drib_nib, rx_ev_tobe_disc;
1959     - bool rx_ev_other_err, rx_ev_pause_frm;
1960     - bool rx_ev_hdr_type, rx_ev_mcast_pkt;
1961     - unsigned rx_ev_pkt_type;
1962     + bool rx_ev_pause_frm;
1963    
1964     - rx_ev_hdr_type = EF4_QWORD_FIELD(*event, FSF_AZ_RX_EV_HDR_TYPE);
1965     - rx_ev_mcast_pkt = EF4_QWORD_FIELD(*event, FSF_AZ_RX_EV_MCAST_PKT);
1966     rx_ev_tobe_disc = EF4_QWORD_FIELD(*event, FSF_AZ_RX_EV_TOBE_DISC);
1967     - rx_ev_pkt_type = EF4_QWORD_FIELD(*event, FSF_AZ_RX_EV_PKT_TYPE);
1968     rx_ev_buf_owner_id_err = EF4_QWORD_FIELD(*event,
1969     FSF_AZ_RX_EV_BUF_OWNER_ID_ERR);
1970     rx_ev_ip_hdr_chksum_err = EF4_QWORD_FIELD(*event,
1971     @@ -893,10 +888,6 @@ static u16 ef4_farch_handle_rx_not_ok(struct ef4_rx_queue *rx_queue,
1972     0 : EF4_QWORD_FIELD(*event, FSF_AA_RX_EV_DRIB_NIB));
1973     rx_ev_pause_frm = EF4_QWORD_FIELD(*event, FSF_AZ_RX_EV_PAUSE_FRM_ERR);
1974    
1975     - /* Every error apart from tobe_disc and pause_frm */
1976     - rx_ev_other_err = (rx_ev_drib_nib | rx_ev_tcp_udp_chksum_err |
1977     - rx_ev_buf_owner_id_err | rx_ev_eth_crc_err |
1978     - rx_ev_frm_trunc | rx_ev_ip_hdr_chksum_err);
1979    
1980     /* Count errors that are not in MAC stats. Ignore expected
1981     * checksum errors during self-test. */
1982     @@ -916,6 +907,13 @@ static u16 ef4_farch_handle_rx_not_ok(struct ef4_rx_queue *rx_queue,
1983     * to a FIFO overflow.
1984     */
1985     #ifdef DEBUG
1986     + {
1987     + /* Every error apart from tobe_disc and pause_frm */
1988     +
1989     + bool rx_ev_other_err = (rx_ev_drib_nib | rx_ev_tcp_udp_chksum_err |
1990     + rx_ev_buf_owner_id_err | rx_ev_eth_crc_err |
1991     + rx_ev_frm_trunc | rx_ev_ip_hdr_chksum_err);
1992     +
1993     if (rx_ev_other_err && net_ratelimit()) {
1994     netif_dbg(efx, rx_err, efx->net_dev,
1995     " RX queue %d unexpected RX event "
1996     @@ -932,6 +930,7 @@ static u16 ef4_farch_handle_rx_not_ok(struct ef4_rx_queue *rx_queue,
1997     rx_ev_tobe_disc ? " [TOBE_DISC]" : "",
1998     rx_ev_pause_frm ? " [PAUSE]" : "");
1999     }
2000     + }
2001     #endif
2002    
2003     /* The frame must be discarded if any of these are true. */
2004     @@ -1643,15 +1642,11 @@ void ef4_farch_rx_push_indir_table(struct ef4_nic *efx)
2005     */
2006     void ef4_farch_dimension_resources(struct ef4_nic *efx, unsigned sram_lim_qw)
2007     {
2008     - unsigned vi_count, buftbl_min;
2009     + unsigned vi_count;
2010    
2011     /* Account for the buffer table entries backing the datapath channels
2012     * and the descriptor caches for those channels.
2013     */
2014     - buftbl_min = ((efx->n_rx_channels * EF4_MAX_DMAQ_SIZE +
2015     - efx->n_tx_channels * EF4_TXQ_TYPES * EF4_MAX_DMAQ_SIZE +
2016     - efx->n_channels * EF4_MAX_EVQ_SIZE)
2017     - * sizeof(ef4_qword_t) / EF4_BUF_SIZE);
2018     vi_count = max(efx->n_channels, efx->n_tx_channels * EF4_TXQ_TYPES);
2019    
2020     efx->tx_dc_base = sram_lim_qw - vi_count * TX_DC_ENTRIES;
2021     @@ -2532,7 +2527,6 @@ int ef4_farch_filter_remove_safe(struct ef4_nic *efx,
2022     enum ef4_farch_filter_table_id table_id;
2023     struct ef4_farch_filter_table *table;
2024     unsigned int filter_idx;
2025     - struct ef4_farch_filter_spec *spec;
2026     int rc;
2027    
2028     table_id = ef4_farch_filter_id_table_id(filter_id);
2029     @@ -2543,7 +2537,6 @@ int ef4_farch_filter_remove_safe(struct ef4_nic *efx,
2030     filter_idx = ef4_farch_filter_id_index(filter_id);
2031     if (filter_idx >= table->size)
2032     return -ENOENT;
2033     - spec = &table->spec[filter_idx];
2034    
2035     spin_lock_bh(&efx->filter_lock);
2036     rc = ef4_farch_filter_remove(efx, table, filter_idx, priority);
2037     diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
2038     index 85eaccbbbac1c..44fe2adf0ee0c 100644
2039     --- a/drivers/net/ethernet/sis/sis900.c
2040     +++ b/drivers/net/ethernet/sis/sis900.c
2041     @@ -787,10 +787,9 @@ static u16 sis900_default_phy(struct net_device * net_dev)
2042     static void sis900_set_capability(struct net_device *net_dev, struct mii_phy *phy)
2043     {
2044     u16 cap;
2045     - u16 status;
2046    
2047     - status = mdio_read(net_dev, phy->phy_addr, MII_STATUS);
2048     - status = mdio_read(net_dev, phy->phy_addr, MII_STATUS);
2049     + mdio_read(net_dev, phy->phy_addr, MII_STATUS);
2050     + mdio_read(net_dev, phy->phy_addr, MII_STATUS);
2051    
2052     cap = MII_NWAY_CSMA_CD |
2053     ((phy->status & MII_STAT_CAN_TX_FDX)? MII_NWAY_TX_FDX:0) |
2054     diff --git a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
2055     index eb1c6b03c329a..df26cea459048 100644
2056     --- a/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
2057     +++ b/drivers/net/ethernet/synopsys/dwc-xlgmac-common.c
2058     @@ -513,7 +513,7 @@ void xlgmac_get_all_hw_features(struct xlgmac_pdata *pdata)
2059    
2060     void xlgmac_print_all_hw_features(struct xlgmac_pdata *pdata)
2061     {
2062     - char *str = NULL;
2063     + char __maybe_unused *str = NULL;
2064    
2065     XLGMAC_PR("\n");
2066     XLGMAC_PR("=====================================================\n");
2067     diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
2068     index 7cc09a6f9f9ae..6869c5c74b9f7 100644
2069     --- a/drivers/net/ethernet/ti/davinci_emac.c
2070     +++ b/drivers/net/ethernet/ti/davinci_emac.c
2071     @@ -1226,7 +1226,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
2072     struct net_device *ndev = priv->ndev;
2073     struct device *emac_dev = &ndev->dev;
2074     u32 status = 0;
2075     - u32 num_tx_pkts = 0, num_rx_pkts = 0;
2076     + u32 num_rx_pkts = 0;
2077    
2078     /* Check interrupt vectors and call packet processing */
2079     status = emac_read(EMAC_MACINVECTOR);
2080     @@ -1237,8 +1237,7 @@ static int emac_poll(struct napi_struct *napi, int budget)
2081     mask = EMAC_DM646X_MAC_IN_VECTOR_TX_INT_VEC;
2082    
2083     if (status & mask) {
2084     - num_tx_pkts = cpdma_chan_process(priv->txchan,
2085     - EMAC_DEF_TX_MAX_SERVICE);
2086     + cpdma_chan_process(priv->txchan, EMAC_DEF_TX_MAX_SERVICE);
2087     } /* TX processing */
2088    
2089     mask = EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC;
2090     diff --git a/drivers/net/ethernet/ti/netcp_core.c b/drivers/net/ethernet/ti/netcp_core.c
2091     index 1b2702f744552..4154c48d1ddf6 100644
2092     --- a/drivers/net/ethernet/ti/netcp_core.c
2093     +++ b/drivers/net/ethernet/ti/netcp_core.c
2094     @@ -1350,9 +1350,9 @@ int netcp_txpipe_open(struct netcp_tx_pipe *tx_pipe)
2095     tx_pipe->dma_queue = knav_queue_open(name, tx_pipe->dma_queue_id,
2096     KNAV_QUEUE_SHARED);
2097     if (IS_ERR(tx_pipe->dma_queue)) {
2098     + ret = PTR_ERR(tx_pipe->dma_queue);
2099     dev_err(dev, "Could not open DMA queue for channel \"%s\": %d\n",
2100     name, ret);
2101     - ret = PTR_ERR(tx_pipe->dma_queue);
2102     goto err;
2103     }
2104    
2105     diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
2106     index 78f0f2d59e227..a3691bc94b101 100644
2107     --- a/drivers/net/ethernet/ti/tlan.c
2108     +++ b/drivers/net/ethernet/ti/tlan.c
2109     @@ -673,7 +673,6 @@ module_exit(tlan_exit);
2110     static void __init tlan_eisa_probe(void)
2111     {
2112     long ioaddr;
2113     - int rc = -ENODEV;
2114     int irq;
2115     u16 device_id;
2116    
2117     @@ -738,8 +737,7 @@ static void __init tlan_eisa_probe(void)
2118    
2119    
2120     /* Setup the newly found eisa adapter */
2121     - rc = tlan_probe1(NULL, ioaddr, irq,
2122     - 12, NULL);
2123     + tlan_probe1(NULL, ioaddr, irq, 12, NULL);
2124     continue;
2125    
2126     out:
2127     diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
2128     index 346e44115c4e0..24a82d51fe60d 100644
2129     --- a/drivers/net/ethernet/via/via-velocity.c
2130     +++ b/drivers/net/ethernet/via/via-velocity.c
2131     @@ -865,26 +865,13 @@ static u32 check_connection_type(struct mac_regs __iomem *regs)
2132     */
2133     static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
2134     {
2135     - u32 curr_status;
2136     struct mac_regs __iomem *regs = vptr->mac_regs;
2137    
2138     vptr->mii_status = mii_check_media_mode(vptr->mac_regs);
2139     - curr_status = vptr->mii_status & (~VELOCITY_LINK_FAIL);
2140    
2141     /* Set mii link status */
2142     set_mii_flow_control(vptr);
2143    
2144     - /*
2145     - Check if new status is consistent with current status
2146     - if (((mii_status & curr_status) & VELOCITY_AUTONEG_ENABLE) ||
2147     - (mii_status==curr_status)) {
2148     - vptr->mii_status=mii_check_media_mode(vptr->mac_regs);
2149     - vptr->mii_status=check_connection_type(vptr->mac_regs);
2150     - VELOCITY_PRT(MSG_LEVEL_INFO, "Velocity link no change\n");
2151     - return 0;
2152     - }
2153     - */
2154     -
2155     if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201)
2156     MII_REG_BITS_ON(AUXCR_MDPPS, MII_NCONFIG, vptr->mac_regs);
2157    
2158     diff --git a/drivers/net/phy/mdio-octeon.c b/drivers/net/phy/mdio-octeon.c
2159     index 8327382aa5689..088c737316526 100644
2160     --- a/drivers/net/phy/mdio-octeon.c
2161     +++ b/drivers/net/phy/mdio-octeon.c
2162     @@ -72,7 +72,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
2163    
2164     return 0;
2165     fail_register:
2166     - mdiobus_free(bus->mii_bus);
2167     smi_en.u64 = 0;
2168     oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
2169     return err;
2170     @@ -86,7 +85,6 @@ static int octeon_mdiobus_remove(struct platform_device *pdev)
2171     bus = platform_get_drvdata(pdev);
2172    
2173     mdiobus_unregister(bus->mii_bus);
2174     - mdiobus_free(bus->mii_bus);
2175     smi_en.u64 = 0;
2176     oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
2177     return 0;
2178     diff --git a/drivers/net/phy/mdio-thunder.c b/drivers/net/phy/mdio-thunder.c
2179     index b6128ae7f14f3..1e2f57ed1ef75 100644
2180     --- a/drivers/net/phy/mdio-thunder.c
2181     +++ b/drivers/net/phy/mdio-thunder.c
2182     @@ -126,7 +126,6 @@ static void thunder_mdiobus_pci_remove(struct pci_dev *pdev)
2183     continue;
2184    
2185     mdiobus_unregister(bus->mii_bus);
2186     - mdiobus_free(bus->mii_bus);
2187     oct_mdio_writeq(0, bus->register_base + SMI_EN);
2188     }
2189     pci_set_drvdata(pdev, NULL);
2190     diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
2191     index 02de9480d3f06..22450c4a92251 100644
2192     --- a/drivers/net/usb/hso.c
2193     +++ b/drivers/net/usb/hso.c
2194     @@ -1689,7 +1689,7 @@ static int hso_serial_tiocmset(struct tty_struct *tty,
2195     spin_unlock_irqrestore(&serial->serial_lock, flags);
2196    
2197     return usb_control_msg(serial->parent->usb,
2198     - usb_rcvctrlpipe(serial->parent->usb, 0), 0x22,
2199     + usb_sndctrlpipe(serial->parent->usb, 0), 0x22,
2200     0x21, val, if_num, NULL, 0,
2201     USB_CTRL_SET_TIMEOUT);
2202     }
2203     @@ -2436,7 +2436,7 @@ static int hso_rfkill_set_block(void *data, bool blocked)
2204     if (hso_dev->usb_gone)
2205     rv = 0;
2206     else
2207     - rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0),
2208     + rv = usb_control_msg(hso_dev->usb, usb_sndctrlpipe(hso_dev->usb, 0),
2209     enabled ? 0x82 : 0x81, 0x40, 0, 0, NULL, 0,
2210     USB_CTRL_SET_TIMEOUT);
2211     mutex_unlock(&hso_dev->mutex);
2212     @@ -2619,32 +2619,31 @@ static struct hso_device *hso_create_bulk_serial_device(
2213     num_urbs = 2;
2214     serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
2215     GFP_KERNEL);
2216     + if (!serial->tiocmget)
2217     + goto exit;
2218     serial->tiocmget->serial_state_notification
2219     = kzalloc(sizeof(struct hso_serial_state_notification),
2220     GFP_KERNEL);
2221     - /* it isn't going to break our heart if serial->tiocmget
2222     - * allocation fails don't bother checking this.
2223     - */
2224     - if (serial->tiocmget && serial->tiocmget->serial_state_notification) {
2225     - tiocmget = serial->tiocmget;
2226     - tiocmget->endp = hso_get_ep(interface,
2227     - USB_ENDPOINT_XFER_INT,
2228     - USB_DIR_IN);
2229     - if (!tiocmget->endp) {
2230     - dev_err(&interface->dev, "Failed to find INT IN ep\n");
2231     - goto exit;
2232     - }
2233     -
2234     - tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
2235     - if (tiocmget->urb) {
2236     - mutex_init(&tiocmget->mutex);
2237     - init_waitqueue_head(&tiocmget->waitq);
2238     - } else
2239     - hso_free_tiomget(serial);
2240     + if (!serial->tiocmget->serial_state_notification)
2241     + goto exit;
2242     + tiocmget = serial->tiocmget;
2243     + tiocmget->endp = hso_get_ep(interface,
2244     + USB_ENDPOINT_XFER_INT,
2245     + USB_DIR_IN);
2246     + if (!tiocmget->endp) {
2247     + dev_err(&interface->dev, "Failed to find INT IN ep\n");
2248     + goto exit;
2249     }
2250     - }
2251     - else
2252     +
2253     + tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
2254     + if (!tiocmget->urb)
2255     + goto exit;
2256     +
2257     + mutex_init(&tiocmget->mutex);
2258     + init_waitqueue_head(&tiocmget->waitq);
2259     + } else {
2260     num_urbs = 1;
2261     + }
2262    
2263     if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE,
2264     BULK_URB_TX_SIZE))
2265     diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c
2266     index 9556d431885f5..d0ae0df34e132 100644
2267     --- a/drivers/net/usb/smsc75xx.c
2268     +++ b/drivers/net/usb/smsc75xx.c
2269     @@ -1482,7 +1482,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
2270     ret = smsc75xx_wait_ready(dev, 0);
2271     if (ret < 0) {
2272     netdev_warn(dev->net, "device not ready in smsc75xx_bind\n");
2273     - return ret;
2274     + goto err;
2275     }
2276    
2277     smsc75xx_init_mac_address(dev);
2278     @@ -1491,7 +1491,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
2279     ret = smsc75xx_reset(dev);
2280     if (ret < 0) {
2281     netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret);
2282     - return ret;
2283     + goto err;
2284     }
2285    
2286     dev->net->netdev_ops = &smsc75xx_netdev_ops;
2287     @@ -1501,6 +1501,10 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf)
2288     dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
2289     dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE;
2290     return 0;
2291     +
2292     +err:
2293     + kfree(pdata);
2294     + return ret;
2295     }
2296    
2297     static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)
2298     diff --git a/drivers/net/wireless/ath/ath10k/htt.h b/drivers/net/wireless/ath/ath10k/htt.h
2299     index bd5fa4dbab9c0..2637e188954d7 100644
2300     --- a/drivers/net/wireless/ath/ath10k/htt.h
2301     +++ b/drivers/net/wireless/ath/ath10k/htt.h
2302     @@ -835,6 +835,7 @@ enum htt_security_types {
2303    
2304     #define ATH10K_HTT_TXRX_PEER_SECURITY_MAX 2
2305     #define ATH10K_TXRX_NUM_EXT_TIDS 19
2306     +#define ATH10K_TXRX_NON_QOS_TID 16
2307    
2308     enum htt_security_flags {
2309     #define HTT_SECURITY_TYPE_MASK 0x7F
2310     diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c
2311     index 04095f91d3014..760d24a28f392 100644
2312     --- a/drivers/net/wireless/ath/ath10k/htt_rx.c
2313     +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c
2314     @@ -1739,16 +1739,97 @@ static void ath10k_htt_rx_h_csum_offload(struct sk_buff *msdu)
2315     msdu->ip_summed = ath10k_htt_rx_get_csum_state(msdu);
2316     }
2317    
2318     +static u64 ath10k_htt_rx_h_get_pn(struct ath10k *ar, struct sk_buff *skb,
2319     + u16 offset,
2320     + enum htt_rx_mpdu_encrypt_type enctype)
2321     +{
2322     + struct ieee80211_hdr *hdr;
2323     + u64 pn = 0;
2324     + u8 *ehdr;
2325     +
2326     + hdr = (struct ieee80211_hdr *)(skb->data + offset);
2327     + ehdr = skb->data + offset + ieee80211_hdrlen(hdr->frame_control);
2328     +
2329     + if (enctype == HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2) {
2330     + pn = ehdr[0];
2331     + pn |= (u64)ehdr[1] << 8;
2332     + pn |= (u64)ehdr[4] << 16;
2333     + pn |= (u64)ehdr[5] << 24;
2334     + pn |= (u64)ehdr[6] << 32;
2335     + pn |= (u64)ehdr[7] << 40;
2336     + }
2337     + return pn;
2338     +}
2339     +
2340     +static bool ath10k_htt_rx_h_frag_multicast_check(struct ath10k *ar,
2341     + struct sk_buff *skb,
2342     + u16 offset)
2343     +{
2344     + struct ieee80211_hdr *hdr;
2345     +
2346     + hdr = (struct ieee80211_hdr *)(skb->data + offset);
2347     + return !is_multicast_ether_addr(hdr->addr1);
2348     +}
2349     +
2350     +static bool ath10k_htt_rx_h_frag_pn_check(struct ath10k *ar,
2351     + struct sk_buff *skb,
2352     + u16 peer_id,
2353     + u16 offset,
2354     + enum htt_rx_mpdu_encrypt_type enctype)
2355     +{
2356     + struct ath10k_peer *peer;
2357     + union htt_rx_pn_t *last_pn, new_pn = {0};
2358     + struct ieee80211_hdr *hdr;
2359     + bool more_frags;
2360     + u8 tid, frag_number;
2361     + u32 seq;
2362     +
2363     + peer = ath10k_peer_find_by_id(ar, peer_id);
2364     + if (!peer) {
2365     + ath10k_dbg(ar, ATH10K_DBG_HTT, "invalid peer for frag pn check\n");
2366     + return false;
2367     + }
2368     +
2369     + hdr = (struct ieee80211_hdr *)(skb->data + offset);
2370     + if (ieee80211_is_data_qos(hdr->frame_control))
2371     + tid = ieee80211_get_tid(hdr);
2372     + else
2373     + tid = ATH10K_TXRX_NON_QOS_TID;
2374     +
2375     + last_pn = &peer->frag_tids_last_pn[tid];
2376     + new_pn.pn48 = ath10k_htt_rx_h_get_pn(ar, skb, offset, enctype);
2377     + more_frags = ieee80211_has_morefrags(hdr->frame_control);
2378     + frag_number = le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_FRAG;
2379     + seq = (__le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4;
2380     +
2381     + if (frag_number == 0) {
2382     + last_pn->pn48 = new_pn.pn48;
2383     + peer->frag_tids_seq[tid] = seq;
2384     + } else {
2385     + if (seq != peer->frag_tids_seq[tid])
2386     + return false;
2387     +
2388     + if (new_pn.pn48 != last_pn->pn48 + 1)
2389     + return false;
2390     +
2391     + last_pn->pn48 = new_pn.pn48;
2392     + }
2393     +
2394     + return true;
2395     +}
2396     +
2397     static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
2398     struct sk_buff_head *amsdu,
2399     struct ieee80211_rx_status *status,
2400     bool fill_crypt_header,
2401     u8 *rx_hdr,
2402     - enum ath10k_pkt_rx_err *err)
2403     + enum ath10k_pkt_rx_err *err,
2404     + u16 peer_id,
2405     + bool frag)
2406     {
2407     struct sk_buff *first;
2408     struct sk_buff *last;
2409     - struct sk_buff *msdu;
2410     + struct sk_buff *msdu, *temp;
2411     struct htt_rx_desc *rxd;
2412     struct ieee80211_hdr *hdr;
2413     enum htt_rx_mpdu_encrypt_type enctype;
2414     @@ -1761,6 +1842,7 @@ static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
2415     bool is_decrypted;
2416     bool is_mgmt;
2417     u32 attention;
2418     + bool frag_pn_check = true, multicast_check = true;
2419    
2420     if (skb_queue_empty(amsdu))
2421     return;
2422     @@ -1859,7 +1941,37 @@ static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
2423     }
2424    
2425     skb_queue_walk(amsdu, msdu) {
2426     + if (frag && !fill_crypt_header && is_decrypted &&
2427     + enctype == HTT_RX_MPDU_ENCRYPT_AES_CCM_WPA2)
2428     + frag_pn_check = ath10k_htt_rx_h_frag_pn_check(ar,
2429     + msdu,
2430     + peer_id,
2431     + 0,
2432     + enctype);
2433     +
2434     + if (frag)
2435     + multicast_check = ath10k_htt_rx_h_frag_multicast_check(ar,
2436     + msdu,
2437     + 0);
2438     +
2439     + if (!frag_pn_check || !multicast_check) {
2440     + /* Discard the fragment with invalid PN or multicast DA
2441     + */
2442     + temp = msdu->prev;
2443     + __skb_unlink(msdu, amsdu);
2444     + dev_kfree_skb_any(msdu);
2445     + msdu = temp;
2446     + frag_pn_check = true;
2447     + multicast_check = true;
2448     + continue;
2449     + }
2450     +
2451     ath10k_htt_rx_h_csum_offload(msdu);
2452     +
2453     + if (frag && !fill_crypt_header &&
2454     + enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
2455     + status->flag &= ~RX_FLAG_MMIC_STRIPPED;
2456     +
2457     ath10k_htt_rx_h_undecap(ar, msdu, status, first_hdr, enctype,
2458     is_decrypted);
2459    
2460     @@ -1877,6 +1989,11 @@ static void ath10k_htt_rx_h_mpdu(struct ath10k *ar,
2461    
2462     hdr = (void *)msdu->data;
2463     hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED);
2464     +
2465     + if (frag && !fill_crypt_header &&
2466     + enctype == HTT_RX_MPDU_ENCRYPT_TKIP_WPA)
2467     + status->flag &= ~RX_FLAG_IV_STRIPPED &
2468     + ~RX_FLAG_MMIC_STRIPPED;
2469     }
2470     }
2471    
2472     @@ -1984,14 +2101,62 @@ static void ath10k_htt_rx_h_unchain(struct ath10k *ar,
2473     ath10k_unchain_msdu(amsdu, unchain_cnt);
2474     }
2475    
2476     +static bool ath10k_htt_rx_validate_amsdu(struct ath10k *ar,
2477     + struct sk_buff_head *amsdu)
2478     +{
2479     + u8 *subframe_hdr;
2480     + struct sk_buff *first;
2481     + bool is_first, is_last;
2482     + struct htt_rx_desc *rxd;
2483     + struct ieee80211_hdr *hdr;
2484     + size_t hdr_len, crypto_len;
2485     + enum htt_rx_mpdu_encrypt_type enctype;
2486     + int bytes_aligned = ar->hw_params.decap_align_bytes;
2487     +
2488     + first = skb_peek(amsdu);
2489     +
2490     + rxd = (void *)first->data - sizeof(*rxd);
2491     + hdr = (void *)rxd->rx_hdr_status;
2492     +
2493     + is_first = !!(rxd->msdu_end.common.info0 &
2494     + __cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU));
2495     + is_last = !!(rxd->msdu_end.common.info0 &
2496     + __cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU));
2497     +
2498     + /* Return in case of non-aggregated msdu */
2499     + if (is_first && is_last)
2500     + return true;
2501     +
2502     + /* First msdu flag is not set for the first msdu of the list */
2503     + if (!is_first)
2504     + return false;
2505     +
2506     + enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
2507     + RX_MPDU_START_INFO0_ENCRYPT_TYPE);
2508     +
2509     + hdr_len = ieee80211_hdrlen(hdr->frame_control);
2510     + crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
2511     +
2512     + subframe_hdr = (u8 *)hdr + round_up(hdr_len, bytes_aligned) +
2513     + crypto_len;
2514     +
2515     + /* Validate if the amsdu has a proper first subframe.
2516     + * There are chances a single msdu can be received as amsdu when
2517     + * the unauthenticated amsdu flag of a QoS header
2518     + * gets flipped in non-SPP AMSDU's, in such cases the first
2519     + * subframe has llc/snap header in place of a valid da.
2520     + * return false if the da matches rfc1042 pattern
2521     + */
2522     + if (ether_addr_equal(subframe_hdr, rfc1042_header))
2523     + return false;
2524     +
2525     + return true;
2526     +}
2527     +
2528     static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar,
2529     struct sk_buff_head *amsdu,
2530     struct ieee80211_rx_status *rx_status)
2531     {
2532     - /* FIXME: It might be a good idea to do some fuzzy-testing to drop
2533     - * invalid/dangerous frames.
2534     - */
2535     -
2536     if (!rx_status->freq) {
2537     ath10k_dbg(ar, ATH10K_DBG_HTT, "no channel configured; ignoring frame(s)!\n");
2538     return false;
2539     @@ -2002,6 +2167,11 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar,
2540     return false;
2541     }
2542    
2543     + if (!ath10k_htt_rx_validate_amsdu(ar, amsdu)) {
2544     + ath10k_dbg(ar, ATH10K_DBG_HTT, "invalid amsdu received\n");
2545     + return false;
2546     + }
2547     +
2548     return true;
2549     }
2550    
2551     @@ -2064,7 +2234,8 @@ static int ath10k_htt_rx_handle_amsdu(struct ath10k_htt *htt)
2552     ath10k_htt_rx_h_unchain(ar, &amsdu, &drop_cnt, &unchain_cnt);
2553    
2554     ath10k_htt_rx_h_filter(ar, &amsdu, rx_status, &drop_cnt_filter);
2555     - ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err);
2556     + ath10k_htt_rx_h_mpdu(ar, &amsdu, rx_status, true, first_hdr, &err, 0,
2557     + false);
2558     msdus_to_queue = skb_queue_len(&amsdu);
2559     ath10k_htt_rx_h_enqueue(ar, &amsdu, rx_status);
2560    
2561     @@ -2197,6 +2368,11 @@ static bool ath10k_htt_rx_proc_rx_ind_hl(struct ath10k_htt *htt,
2562     fw_desc = &rx->fw_desc;
2563     rx_desc_len = fw_desc->len;
2564    
2565     + if (fw_desc->u.bits.discard) {
2566     + ath10k_dbg(ar, ATH10K_DBG_HTT, "htt discard mpdu\n");
2567     + goto err;
2568     + }
2569     +
2570     /* I have not yet seen any case where num_mpdu_ranges > 1.
2571     * qcacld does not seem handle that case either, so we introduce the
2572     * same limitiation here as well.
2573     @@ -2497,6 +2673,13 @@ static bool ath10k_htt_rx_proc_rx_frag_ind_hl(struct ath10k_htt *htt,
2574     rx_desc = (struct htt_hl_rx_desc *)(skb->data + tot_hdr_len);
2575     rx_desc_info = __le32_to_cpu(rx_desc->info);
2576    
2577     + hdr = (struct ieee80211_hdr *)((u8 *)rx_desc + rx_hl->fw_desc.len);
2578     +
2579     + if (is_multicast_ether_addr(hdr->addr1)) {
2580     + /* Discard the fragment with multicast DA */
2581     + goto err;
2582     + }
2583     +
2584     if (!MS(rx_desc_info, HTT_RX_DESC_HL_INFO_ENCRYPTED)) {
2585     spin_unlock_bh(&ar->data_lock);
2586     return ath10k_htt_rx_proc_rx_ind_hl(htt, &resp->rx_ind_hl, skb,
2587     @@ -2504,8 +2687,6 @@ static bool ath10k_htt_rx_proc_rx_frag_ind_hl(struct ath10k_htt *htt,
2588     HTT_RX_NON_TKIP_MIC);
2589     }
2590    
2591     - hdr = (struct ieee80211_hdr *)((u8 *)rx_desc + rx_hl->fw_desc.len);
2592     -
2593     if (ieee80211_has_retry(hdr->frame_control))
2594     goto err;
2595    
2596     @@ -3014,7 +3195,7 @@ static int ath10k_htt_rx_in_ord_ind(struct ath10k *ar, struct sk_buff *skb)
2597     ath10k_htt_rx_h_ppdu(ar, &amsdu, status, vdev_id);
2598     ath10k_htt_rx_h_filter(ar, &amsdu, status, NULL);
2599     ath10k_htt_rx_h_mpdu(ar, &amsdu, status, false, NULL,
2600     - NULL);
2601     + NULL, peer_id, frag);
2602     ath10k_htt_rx_h_enqueue(ar, &amsdu, status);
2603     break;
2604     case -EAGAIN:
2605     diff --git a/drivers/net/wireless/ath/ath10k/rx_desc.h b/drivers/net/wireless/ath/ath10k/rx_desc.h
2606     index dec1582005b94..13a1cae6b51b0 100644
2607     --- a/drivers/net/wireless/ath/ath10k/rx_desc.h
2608     +++ b/drivers/net/wireless/ath/ath10k/rx_desc.h
2609     @@ -1282,7 +1282,19 @@ struct fw_rx_desc_base {
2610     #define FW_RX_DESC_UDP (1 << 6)
2611    
2612     struct fw_rx_desc_hl {
2613     - u8 info0;
2614     + union {
2615     + struct {
2616     + u8 discard:1,
2617     + forward:1,
2618     + any_err:1,
2619     + dup_err:1,
2620     + reserved:1,
2621     + inspect:1,
2622     + extension:2;
2623     + } bits;
2624     + u8 info0;
2625     + } u;
2626     +
2627     u8 version;
2628     u8 len;
2629     u8 flags;
2630     diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
2631     index 54337d60f288b..085a134069f79 100644
2632     --- a/drivers/net/wireless/ath/ath6kl/debug.c
2633     +++ b/drivers/net/wireless/ath/ath6kl/debug.c
2634     @@ -1027,14 +1027,17 @@ static ssize_t ath6kl_lrssi_roam_write(struct file *file,
2635     {
2636     struct ath6kl *ar = file->private_data;
2637     unsigned long lrssi_roam_threshold;
2638     + int ret;
2639    
2640     if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
2641     return -EINVAL;
2642    
2643     ar->lrssi_roam_threshold = lrssi_roam_threshold;
2644    
2645     - ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
2646     + ret = ath6kl_wmi_set_roam_lrssi_cmd(ar->wmi, ar->lrssi_roam_threshold);
2647    
2648     + if (ret)
2649     + return ret;
2650     return count;
2651     }
2652    
2653     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
2654     index fc12598b2dd3f..c492d2d2db1df 100644
2655     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
2656     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
2657     @@ -1168,13 +1168,9 @@ static struct sdio_driver brcmf_sdmmc_driver = {
2658     },
2659     };
2660    
2661     -void brcmf_sdio_register(void)
2662     +int brcmf_sdio_register(void)
2663     {
2664     - int ret;
2665     -
2666     - ret = sdio_register_driver(&brcmf_sdmmc_driver);
2667     - if (ret)
2668     - brcmf_err("sdio_register_driver failed: %d\n", ret);
2669     + return sdio_register_driver(&brcmf_sdmmc_driver);
2670     }
2671    
2672     void brcmf_sdio_exit(void)
2673     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
2674     index 623c0168da79c..8b27494a5d3dc 100644
2675     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
2676     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
2677     @@ -274,11 +274,26 @@ void brcmf_bus_add_txhdrlen(struct device *dev, uint len);
2678    
2679     #ifdef CONFIG_BRCMFMAC_SDIO
2680     void brcmf_sdio_exit(void);
2681     -void brcmf_sdio_register(void);
2682     +int brcmf_sdio_register(void);
2683     +#else
2684     +static inline void brcmf_sdio_exit(void) { }
2685     +static inline int brcmf_sdio_register(void) { return 0; }
2686     #endif
2687     +
2688     #ifdef CONFIG_BRCMFMAC_USB
2689     void brcmf_usb_exit(void);
2690     -void brcmf_usb_register(void);
2691     +int brcmf_usb_register(void);
2692     +#else
2693     +static inline void brcmf_usb_exit(void) { }
2694     +static inline int brcmf_usb_register(void) { return 0; }
2695     +#endif
2696     +
2697     +#ifdef CONFIG_BRCMFMAC_PCIE
2698     +void brcmf_pcie_exit(void);
2699     +int brcmf_pcie_register(void);
2700     +#else
2701     +static inline void brcmf_pcie_exit(void) { }
2702     +static inline int brcmf_pcie_register(void) { return 0; }
2703     #endif
2704    
2705     #endif /* BRCMFMAC_BUS_H */
2706     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2707     index e9bb8dbdc9aa8..edb79e9665dc3 100644
2708     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2709     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
2710     @@ -1438,40 +1438,34 @@ void brcmf_bus_change_state(struct brcmf_bus *bus, enum brcmf_bus_state state)
2711     }
2712     }
2713    
2714     -static void brcmf_driver_register(struct work_struct *work)
2715     -{
2716     -#ifdef CONFIG_BRCMFMAC_SDIO
2717     - brcmf_sdio_register();
2718     -#endif
2719     -#ifdef CONFIG_BRCMFMAC_USB
2720     - brcmf_usb_register();
2721     -#endif
2722     -#ifdef CONFIG_BRCMFMAC_PCIE
2723     - brcmf_pcie_register();
2724     -#endif
2725     -}
2726     -static DECLARE_WORK(brcmf_driver_work, brcmf_driver_register);
2727     -
2728     int __init brcmf_core_init(void)
2729     {
2730     - if (!schedule_work(&brcmf_driver_work))
2731     - return -EBUSY;
2732     + int err;
2733     +
2734     + err = brcmf_sdio_register();
2735     + if (err)
2736     + return err;
2737     +
2738     + err = brcmf_usb_register();
2739     + if (err)
2740     + goto error_usb_register;
2741    
2742     + err = brcmf_pcie_register();
2743     + if (err)
2744     + goto error_pcie_register;
2745     return 0;
2746     +
2747     +error_pcie_register:
2748     + brcmf_usb_exit();
2749     +error_usb_register:
2750     + brcmf_sdio_exit();
2751     + return err;
2752     }
2753    
2754     void __exit brcmf_core_exit(void)
2755     {
2756     - cancel_work_sync(&brcmf_driver_work);
2757     -
2758     -#ifdef CONFIG_BRCMFMAC_SDIO
2759     brcmf_sdio_exit();
2760     -#endif
2761     -#ifdef CONFIG_BRCMFMAC_USB
2762     brcmf_usb_exit();
2763     -#endif
2764     -#ifdef CONFIG_BRCMFMAC_PCIE
2765     brcmf_pcie_exit();
2766     -#endif
2767     }
2768    
2769     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2770     index cb68f54a9c56e..bda042138e967 100644
2771     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2772     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
2773     @@ -2137,15 +2137,10 @@ static struct pci_driver brcmf_pciedrvr = {
2774     };
2775    
2776    
2777     -void brcmf_pcie_register(void)
2778     +int brcmf_pcie_register(void)
2779     {
2780     - int err;
2781     -
2782     brcmf_dbg(PCIE, "Enter\n");
2783     - err = pci_register_driver(&brcmf_pciedrvr);
2784     - if (err)
2785     - brcmf_err(NULL, "PCIE driver registration failed, err=%d\n",
2786     - err);
2787     + return pci_register_driver(&brcmf_pciedrvr);
2788     }
2789    
2790    
2791     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.h
2792     index d026401d20010..8e6c227e8315c 100644
2793     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.h
2794     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.h
2795     @@ -11,9 +11,4 @@ struct brcmf_pciedev {
2796     struct brcmf_pciedev_info *devinfo;
2797     };
2798    
2799     -
2800     -void brcmf_pcie_exit(void);
2801     -void brcmf_pcie_register(void);
2802     -
2803     -
2804     #endif /* BRCMFMAC_PCIE_H */
2805     diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2806     index 575ed19e91951..3b897f040371c 100644
2807     --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2808     +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
2809     @@ -1558,12 +1558,8 @@ void brcmf_usb_exit(void)
2810     usb_deregister(&brcmf_usbdrvr);
2811     }
2812    
2813     -void brcmf_usb_register(void)
2814     +int brcmf_usb_register(void)
2815     {
2816     - int ret;
2817     -
2818     brcmf_dbg(USB, "Enter\n");
2819     - ret = usb_register(&brcmf_usbdrvr);
2820     - if (ret)
2821     - brcmf_err("usb_register failed %d\n", ret);
2822     + return usb_register(&brcmf_usbdrvr);
2823     }
2824     diff --git a/drivers/net/wireless/marvell/libertas/mesh.c b/drivers/net/wireless/marvell/libertas/mesh.c
2825     index 2747c957d18c9..050fd403110ed 100644
2826     --- a/drivers/net/wireless/marvell/libertas/mesh.c
2827     +++ b/drivers/net/wireless/marvell/libertas/mesh.c
2828     @@ -801,24 +801,6 @@ static const struct attribute_group mesh_ie_group = {
2829     .attrs = mesh_ie_attrs,
2830     };
2831    
2832     -static void lbs_persist_config_init(struct net_device *dev)
2833     -{
2834     - int ret;
2835     - ret = sysfs_create_group(&(dev->dev.kobj), &boot_opts_group);
2836     - if (ret)
2837     - pr_err("failed to create boot_opts_group.\n");
2838     -
2839     - ret = sysfs_create_group(&(dev->dev.kobj), &mesh_ie_group);
2840     - if (ret)
2841     - pr_err("failed to create mesh_ie_group.\n");
2842     -}
2843     -
2844     -static void lbs_persist_config_remove(struct net_device *dev)
2845     -{
2846     - sysfs_remove_group(&(dev->dev.kobj), &boot_opts_group);
2847     - sysfs_remove_group(&(dev->dev.kobj), &mesh_ie_group);
2848     -}
2849     -
2850    
2851     /***************************************************************************
2852     * Initializing and starting, stopping mesh
2853     @@ -1019,6 +1001,10 @@ static int lbs_add_mesh(struct lbs_private *priv)
2854     SET_NETDEV_DEV(priv->mesh_dev, priv->dev->dev.parent);
2855    
2856     mesh_dev->flags |= IFF_BROADCAST | IFF_MULTICAST;
2857     + mesh_dev->sysfs_groups[0] = &lbs_mesh_attr_group;
2858     + mesh_dev->sysfs_groups[1] = &boot_opts_group;
2859     + mesh_dev->sysfs_groups[2] = &mesh_ie_group;
2860     +
2861     /* Register virtual mesh interface */
2862     ret = register_netdev(mesh_dev);
2863     if (ret) {
2864     @@ -1026,19 +1012,10 @@ static int lbs_add_mesh(struct lbs_private *priv)
2865     goto err_free_netdev;
2866     }
2867    
2868     - ret = sysfs_create_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
2869     - if (ret)
2870     - goto err_unregister;
2871     -
2872     - lbs_persist_config_init(mesh_dev);
2873     -
2874     /* Everything successful */
2875     ret = 0;
2876     goto done;
2877    
2878     -err_unregister:
2879     - unregister_netdev(mesh_dev);
2880     -
2881     err_free_netdev:
2882     free_netdev(mesh_dev);
2883    
2884     @@ -1059,8 +1036,6 @@ void lbs_remove_mesh(struct lbs_private *priv)
2885    
2886     netif_stop_queue(mesh_dev);
2887     netif_carrier_off(mesh_dev);
2888     - sysfs_remove_group(&(mesh_dev->dev.kobj), &lbs_mesh_attr_group);
2889     - lbs_persist_config_remove(mesh_dev);
2890     unregister_netdev(mesh_dev);
2891     priv->mesh_dev = NULL;
2892     kfree(mesh_dev->ieee80211_ptr);
2893     diff --git a/drivers/platform/x86/hp-wireless.c b/drivers/platform/x86/hp-wireless.c
2894     index 12c31fd5d5ae2..0753ef18e7211 100644
2895     --- a/drivers/platform/x86/hp-wireless.c
2896     +++ b/drivers/platform/x86/hp-wireless.c
2897     @@ -17,12 +17,14 @@ MODULE_LICENSE("GPL");
2898     MODULE_AUTHOR("Alex Hung");
2899     MODULE_ALIAS("acpi*:HPQ6001:*");
2900     MODULE_ALIAS("acpi*:WSTADEF:*");
2901     +MODULE_ALIAS("acpi*:AMDI0051:*");
2902    
2903     static struct input_dev *hpwl_input_dev;
2904    
2905     static const struct acpi_device_id hpwl_ids[] = {
2906     {"HPQ6001", 0},
2907     {"WSTADEF", 0},
2908     + {"AMDI0051", 0},
2909     {"", 0},
2910     };
2911    
2912     diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
2913     index 799cbe2ffcf36..8c0867bda8280 100644
2914     --- a/drivers/platform/x86/hp_accel.c
2915     +++ b/drivers/platform/x86/hp_accel.c
2916     @@ -88,6 +88,9 @@ MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
2917     static int lis3lv02d_acpi_init(struct lis3lv02d *lis3)
2918     {
2919     struct acpi_device *dev = lis3->bus_priv;
2920     + if (!lis3->init_required)
2921     + return 0;
2922     +
2923     if (acpi_evaluate_object(dev->handle, METHOD_NAME__INI,
2924     NULL, NULL) != AE_OK)
2925     return -EINVAL;
2926     @@ -356,6 +359,7 @@ static int lis3lv02d_add(struct acpi_device *device)
2927     }
2928    
2929     /* call the core layer do its init */
2930     + lis3_dev.init_required = true;
2931     ret = lis3lv02d_init_device(&lis3_dev);
2932     if (ret)
2933     return ret;
2934     @@ -403,11 +407,27 @@ static int lis3lv02d_suspend(struct device *dev)
2935    
2936     static int lis3lv02d_resume(struct device *dev)
2937     {
2938     + lis3_dev.init_required = false;
2939     + lis3lv02d_poweron(&lis3_dev);
2940     + return 0;
2941     +}
2942     +
2943     +static int lis3lv02d_restore(struct device *dev)
2944     +{
2945     + lis3_dev.init_required = true;
2946     lis3lv02d_poweron(&lis3_dev);
2947     return 0;
2948     }
2949    
2950     -static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
2951     +static const struct dev_pm_ops hp_accel_pm = {
2952     + .suspend = lis3lv02d_suspend,
2953     + .resume = lis3lv02d_resume,
2954     + .freeze = lis3lv02d_suspend,
2955     + .thaw = lis3lv02d_resume,
2956     + .poweroff = lis3lv02d_suspend,
2957     + .restore = lis3lv02d_restore,
2958     +};
2959     +
2960     #define HP_ACCEL_PM (&hp_accel_pm)
2961     #else
2962     #define HP_ACCEL_PM NULL
2963     diff --git a/drivers/platform/x86/intel_punit_ipc.c b/drivers/platform/x86/intel_punit_ipc.c
2964     index fa97834fdb78e..ccb44f2eb2407 100644
2965     --- a/drivers/platform/x86/intel_punit_ipc.c
2966     +++ b/drivers/platform/x86/intel_punit_ipc.c
2967     @@ -328,6 +328,7 @@ static const struct acpi_device_id punit_ipc_acpi_ids[] = {
2968     { "INT34D4", 0 },
2969     { }
2970     };
2971     +MODULE_DEVICE_TABLE(acpi, punit_ipc_acpi_ids);
2972    
2973     static struct platform_driver intel_punit_ipc_driver = {
2974     .probe = intel_punit_ipc_probe,
2975     diff --git a/drivers/platform/x86/touchscreen_dmi.c b/drivers/platform/x86/touchscreen_dmi.c
2976     index 7ed1189a7200c..515c66ca1aecb 100644
2977     --- a/drivers/platform/x86/touchscreen_dmi.c
2978     +++ b/drivers/platform/x86/touchscreen_dmi.c
2979     @@ -838,6 +838,14 @@ static const struct dmi_system_id touchscreen_dmi_table[] = {
2980     DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
2981     },
2982     },
2983     + {
2984     + /* Mediacom WinPad 7.0 W700 (same hw as Wintron surftab 7") */
2985     + .driver_data = (void *)&trekstor_surftab_wintron70_data,
2986     + .matches = {
2987     + DMI_MATCH(DMI_SYS_VENDOR, "MEDIACOM"),
2988     + DMI_MATCH(DMI_PRODUCT_NAME, "WinPad 7 W10 - WPW700"),
2989     + },
2990     + },
2991     {
2992     /* Mediacom Flexbook Edge 11 (same hw as TS Primebook C11) */
2993     .driver_data = (void *)&trekstor_primebook_c11_data,
2994     diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
2995     index 3645d1720c4b5..9628e0f3add3f 100644
2996     --- a/drivers/s390/cio/vfio_ccw_cp.c
2997     +++ b/drivers/s390/cio/vfio_ccw_cp.c
2998     @@ -636,6 +636,10 @@ int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb)
2999     {
3000     int ret;
3001    
3002     + /* this is an error in the caller */
3003     + if (cp->initialized)
3004     + return -EBUSY;
3005     +
3006     /*
3007     * XXX:
3008     * Only support prefetch enable mode now.
3009     diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
3010     index c25e8a54e8690..6e988233fb81f 100644
3011     --- a/drivers/scsi/BusLogic.c
3012     +++ b/drivers/scsi/BusLogic.c
3013     @@ -3077,11 +3077,11 @@ static int blogic_qcmd_lck(struct scsi_cmnd *command,
3014     ccb->opcode = BLOGIC_INITIATOR_CCB_SG;
3015     ccb->datalen = count * sizeof(struct blogic_sg_seg);
3016     if (blogic_multimaster_type(adapter))
3017     - ccb->data = (void *)((unsigned int) ccb->dma_handle +
3018     + ccb->data = (unsigned int) ccb->dma_handle +
3019     ((unsigned long) &ccb->sglist -
3020     - (unsigned long) ccb));
3021     + (unsigned long) ccb);
3022     else
3023     - ccb->data = ccb->sglist;
3024     + ccb->data = virt_to_32bit_virt(ccb->sglist);
3025    
3026     scsi_for_each_sg(command, sg, count, i) {
3027     ccb->sglist[i].segbytes = sg_dma_len(sg);
3028     diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
3029     index 6182cc8a0344a..e081ad47d1cf4 100644
3030     --- a/drivers/scsi/BusLogic.h
3031     +++ b/drivers/scsi/BusLogic.h
3032     @@ -814,7 +814,7 @@ struct blogic_ccb {
3033     unsigned char cdblen; /* Byte 2 */
3034     unsigned char sense_datalen; /* Byte 3 */
3035     u32 datalen; /* Bytes 4-7 */
3036     - void *data; /* Bytes 8-11 */
3037     + u32 data; /* Bytes 8-11 */
3038     unsigned char:8; /* Byte 12 */
3039     unsigned char:8; /* Byte 13 */
3040     enum blogic_adapter_status adapter_status; /* Byte 14 */
3041     diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
3042     index 7c86fd248129a..f751a12f92ea0 100644
3043     --- a/drivers/scsi/libsas/sas_port.c
3044     +++ b/drivers/scsi/libsas/sas_port.c
3045     @@ -25,7 +25,7 @@ static bool phy_is_wideport_member(struct asd_sas_port *port, struct asd_sas_phy
3046    
3047     static void sas_resume_port(struct asd_sas_phy *phy)
3048     {
3049     - struct domain_device *dev;
3050     + struct domain_device *dev, *n;
3051     struct asd_sas_port *port = phy->port;
3052     struct sas_ha_struct *sas_ha = phy->ha;
3053     struct sas_internal *si = to_sas_internal(sas_ha->core.shost->transportt);
3054     @@ -44,7 +44,7 @@ static void sas_resume_port(struct asd_sas_phy *phy)
3055     * 1/ presume every device came back
3056     * 2/ force the next revalidation to check all expander phys
3057     */
3058     - list_for_each_entry(dev, &port->dev_list, dev_list_node) {
3059     + list_for_each_entry_safe(dev, n, &port->dev_list, dev_list_node) {
3060     int i, rc;
3061    
3062     rc = sas_notify_lldd_dev_found(dev);
3063     diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c
3064     index c7560d7d16276..40dccc580e866 100644
3065     --- a/drivers/spi/spi-fsl-dspi.c
3066     +++ b/drivers/spi/spi-fsl-dspi.c
3067     @@ -1142,11 +1142,13 @@ poll_mode:
3068     ret = spi_register_controller(ctlr);
3069     if (ret != 0) {
3070     dev_err(&pdev->dev, "Problem registering DSPI ctlr\n");
3071     - goto out_free_irq;
3072     + goto out_release_dma;
3073     }
3074    
3075     return ret;
3076    
3077     +out_release_dma:
3078     + dspi_release_dma(dspi);
3079     out_free_irq:
3080     if (dspi->irq)
3081     free_irq(dspi->irq, dspi);
3082     diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
3083     index 6f3d64a1a2b3e..01b53d816497c 100644
3084     --- a/drivers/spi/spi-geni-qcom.c
3085     +++ b/drivers/spi/spi-geni-qcom.c
3086     @@ -552,7 +552,7 @@ static int spi_geni_probe(struct platform_device *pdev)
3087     return PTR_ERR(clk);
3088     }
3089    
3090     - spi = spi_alloc_master(&pdev->dev, sizeof(*mas));
3091     + spi = devm_spi_alloc_master(&pdev->dev, sizeof(*mas));
3092     if (!spi)
3093     return -ENOMEM;
3094    
3095     @@ -599,7 +599,6 @@ spi_geni_probe_free_irq:
3096     free_irq(mas->irq, spi);
3097     spi_geni_probe_runtime_disable:
3098     pm_runtime_disable(&pdev->dev);
3099     - spi_master_put(spi);
3100     return ret;
3101     }
3102    
3103     diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
3104     index a6c893ddbf280..cc4c18c3fb36d 100644
3105     --- a/drivers/staging/emxx_udc/emxx_udc.c
3106     +++ b/drivers/staging/emxx_udc/emxx_udc.c
3107     @@ -2064,7 +2064,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
3108     struct nbu2ss_ep *ep,
3109     int status)
3110     {
3111     - struct nbu2ss_req *req;
3112     + struct nbu2ss_req *req, *n;
3113    
3114     /* Endpoint Disable */
3115     _nbu2ss_epn_exit(udc, ep);
3116     @@ -2076,7 +2076,7 @@ static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
3117     return 0;
3118    
3119     /* called with irqs blocked */
3120     - list_for_each_entry(req, &ep->queue, queue) {
3121     + list_for_each_entry_safe(req, n, &ep->queue, queue) {
3122     _nbu2ss_ep_done(ep, req, status);
3123     }
3124    
3125     diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
3126     index 21527d84f9408..004f123bb0708 100644
3127     --- a/drivers/staging/iio/cdc/ad7746.c
3128     +++ b/drivers/staging/iio/cdc/ad7746.c
3129     @@ -702,7 +702,6 @@ static int ad7746_probe(struct i2c_client *client,
3130     indio_dev->num_channels = ARRAY_SIZE(ad7746_channels);
3131     else
3132     indio_dev->num_channels = ARRAY_SIZE(ad7746_channels) - 2;
3133     - indio_dev->num_channels = ARRAY_SIZE(ad7746_channels);
3134     indio_dev->modes = INDIO_DIRECT_MODE;
3135    
3136     if (pdata) {
3137     diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
3138     index 75484d6c5056a..c313c4f0e8563 100644
3139     --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
3140     +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
3141     @@ -230,6 +230,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
3142     if (ACPI_FAILURE(status))
3143     trip_cnt = 0;
3144     else {
3145     + int i;
3146     +
3147     int34x_thermal_zone->aux_trips =
3148     kcalloc(trip_cnt,
3149     sizeof(*int34x_thermal_zone->aux_trips),
3150     @@ -240,6 +242,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
3151     }
3152     trip_mask = BIT(trip_cnt) - 1;
3153     int34x_thermal_zone->aux_trip_nr = trip_cnt;
3154     + for (i = 0; i < trip_cnt; ++i)
3155     + int34x_thermal_zone->aux_trips[i] = THERMAL_TEMP_INVALID;
3156     }
3157    
3158     trip_cnt = int340x_thermal_read_trips(int34x_thermal_zone);
3159     diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
3160     index ddb4a973c6986..691931fdc1195 100644
3161     --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
3162     +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
3163     @@ -164,7 +164,7 @@ static int sys_get_trip_temp(struct thermal_zone_device *tzd,
3164     if (thres_reg_value)
3165     *temp = zonedev->tj_max - thres_reg_value * 1000;
3166     else
3167     - *temp = 0;
3168     + *temp = THERMAL_TEMP_INVALID;
3169     pr_debug("sys_get_trip_temp %d\n", *temp);
3170    
3171     return 0;
3172     diff --git a/drivers/thunderbolt/dma_port.c b/drivers/thunderbolt/dma_port.c
3173     index 847dd07a7b172..de219953c8b37 100644
3174     --- a/drivers/thunderbolt/dma_port.c
3175     +++ b/drivers/thunderbolt/dma_port.c
3176     @@ -364,15 +364,15 @@ int dma_port_flash_read(struct tb_dma_port *dma, unsigned int address,
3177     void *buf, size_t size)
3178     {
3179     unsigned int retries = DMA_PORT_RETRIES;
3180     - unsigned int offset;
3181     -
3182     - offset = address & 3;
3183     - address = address & ~3;
3184    
3185     do {
3186     - u32 nbytes = min_t(u32, size, MAIL_DATA_DWORDS * 4);
3187     + unsigned int offset;
3188     + size_t nbytes;
3189     int ret;
3190    
3191     + offset = address & 3;
3192     + nbytes = min_t(size_t, size + offset, MAIL_DATA_DWORDS * 4);
3193     +
3194     ret = dma_port_flash_read_block(dma, address, dma->buf,
3195     ALIGN(nbytes, 4));
3196     if (ret) {
3197     @@ -384,6 +384,7 @@ int dma_port_flash_read(struct tb_dma_port *dma, unsigned int address,
3198     return ret;
3199     }
3200    
3201     + nbytes -= offset;
3202     memcpy(buf, dma->buf + offset, nbytes);
3203    
3204     size -= nbytes;
3205     diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
3206     index 8814ff38aa67b..51346ca91c45c 100644
3207     --- a/drivers/tty/serial/8250/8250_pci.c
3208     +++ b/drivers/tty/serial/8250/8250_pci.c
3209     @@ -58,6 +58,8 @@ struct serial_private {
3210     int line[0];
3211     };
3212    
3213     +#define PCI_DEVICE_ID_HPE_PCI_SERIAL 0x37e
3214     +
3215     static const struct pci_device_id pci_use_msi[] = {
3216     { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9900,
3217     0xA000, 0x1000) },
3218     @@ -65,6 +67,8 @@ static const struct pci_device_id pci_use_msi[] = {
3219     0xA000, 0x1000) },
3220     { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922,
3221     0xA000, 0x1000) },
3222     + { PCI_DEVICE_SUB(PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL,
3223     + PCI_ANY_ID, PCI_ANY_ID) },
3224     { }
3225     };
3226    
3227     @@ -1965,6 +1969,16 @@ static struct pci_serial_quirk pci_serial_quirks[] __refdata = {
3228     .init = pci_hp_diva_init,
3229     .setup = pci_hp_diva_setup,
3230     },
3231     + /*
3232     + * HPE PCI serial device
3233     + */
3234     + {
3235     + .vendor = PCI_VENDOR_ID_HP_3PAR,
3236     + .device = PCI_DEVICE_ID_HPE_PCI_SERIAL,
3237     + .subvendor = PCI_ANY_ID,
3238     + .subdevice = PCI_ANY_ID,
3239     + .setup = pci_hp_diva_setup,
3240     + },
3241     /*
3242     * Intel
3243     */
3244     @@ -3903,21 +3917,26 @@ pciserial_init_ports(struct pci_dev *dev, const struct pciserial_board *board)
3245     uart.port.flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ;
3246     uart.port.uartclk = board->base_baud * 16;
3247    
3248     - if (pci_match_id(pci_use_msi, dev)) {
3249     - dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n");
3250     - pci_set_master(dev);
3251     - rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
3252     + if (board->flags & FL_NOIRQ) {
3253     + uart.port.irq = 0;
3254     } else {
3255     - dev_dbg(&dev->dev, "Using legacy interrupts\n");
3256     - rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY);
3257     - }
3258     - if (rc < 0) {
3259     - kfree(priv);
3260     - priv = ERR_PTR(rc);
3261     - goto err_deinit;
3262     + if (pci_match_id(pci_use_msi, dev)) {
3263     + dev_dbg(&dev->dev, "Using MSI(-X) interrupts\n");
3264     + pci_set_master(dev);
3265     + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_ALL_TYPES);
3266     + } else {
3267     + dev_dbg(&dev->dev, "Using legacy interrupts\n");
3268     + rc = pci_alloc_irq_vectors(dev, 1, 1, PCI_IRQ_LEGACY);
3269     + }
3270     + if (rc < 0) {
3271     + kfree(priv);
3272     + priv = ERR_PTR(rc);
3273     + goto err_deinit;
3274     + }
3275     +
3276     + uart.port.irq = pci_irq_vector(dev, 0);
3277     }
3278    
3279     - uart.port.irq = pci_irq_vector(dev, 0);
3280     uart.port.dev = &dev->dev;
3281    
3282     for (i = 0; i < nr_ports; i++) {
3283     @@ -4932,6 +4951,10 @@ static const struct pci_device_id serial_pci_tbl[] = {
3284     { PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_DIVA_AUX,
3285     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3286     pbn_b2_1_115200 },
3287     + /* HPE PCI serial device */
3288     + { PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL,
3289     + PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3290     + pbn_b1_1_115200 },
3291    
3292     { PCI_VENDOR_ID_DCI, PCI_DEVICE_ID_DCI_PCCOM2,
3293     PCI_ANY_ID, PCI_ANY_ID, 0, 0,
3294     diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
3295     index 8434bd5a8ec78..5bf8dd6198bbd 100644
3296     --- a/drivers/tty/serial/max310x.c
3297     +++ b/drivers/tty/serial/max310x.c
3298     @@ -1528,6 +1528,8 @@ static int __init max310x_uart_init(void)
3299    
3300     #ifdef CONFIG_SPI_MASTER
3301     ret = spi_register_driver(&max310x_spi_driver);
3302     + if (ret)
3303     + uart_unregister_driver(&max310x_uart);
3304     #endif
3305    
3306     return ret;
3307     diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c
3308     index 5690c09cc0417..944a4c0105795 100644
3309     --- a/drivers/tty/serial/rp2.c
3310     +++ b/drivers/tty/serial/rp2.c
3311     @@ -195,7 +195,6 @@ struct rp2_card {
3312     void __iomem *bar0;
3313     void __iomem *bar1;
3314     spinlock_t card_lock;
3315     - struct completion fw_loaded;
3316     };
3317    
3318     #define RP_ID(prod) PCI_VDEVICE(RP, (prod))
3319     @@ -664,17 +663,10 @@ static void rp2_remove_ports(struct rp2_card *card)
3320     card->initialized_ports = 0;
3321     }
3322    
3323     -static void rp2_fw_cb(const struct firmware *fw, void *context)
3324     +static int rp2_load_firmware(struct rp2_card *card, const struct firmware *fw)
3325     {
3326     - struct rp2_card *card = context;
3327     resource_size_t phys_base;
3328     - int i, rc = -ENOENT;
3329     -
3330     - if (!fw) {
3331     - dev_err(&card->pdev->dev, "cannot find '%s' firmware image\n",
3332     - RP2_FW_NAME);
3333     - goto no_fw;
3334     - }
3335     + int i, rc = 0;
3336    
3337     phys_base = pci_resource_start(card->pdev, 1);
3338    
3339     @@ -720,23 +712,13 @@ static void rp2_fw_cb(const struct firmware *fw, void *context)
3340     card->initialized_ports++;
3341     }
3342    
3343     - release_firmware(fw);
3344     -no_fw:
3345     - /*
3346     - * rp2_fw_cb() is called from a workqueue long after rp2_probe()
3347     - * has already returned success. So if something failed here,
3348     - * we'll just leave the now-dormant device in place until somebody
3349     - * unbinds it.
3350     - */
3351     - if (rc)
3352     - dev_warn(&card->pdev->dev, "driver initialization failed\n");
3353     -
3354     - complete(&card->fw_loaded);
3355     + return rc;
3356     }
3357    
3358     static int rp2_probe(struct pci_dev *pdev,
3359     const struct pci_device_id *id)
3360     {
3361     + const struct firmware *fw;
3362     struct rp2_card *card;
3363     struct rp2_uart_port *ports;
3364     void __iomem * const *bars;
3365     @@ -747,7 +729,6 @@ static int rp2_probe(struct pci_dev *pdev,
3366     return -ENOMEM;
3367     pci_set_drvdata(pdev, card);
3368     spin_lock_init(&card->card_lock);
3369     - init_completion(&card->fw_loaded);
3370    
3371     rc = pcim_enable_device(pdev);
3372     if (rc)
3373     @@ -780,21 +761,23 @@ static int rp2_probe(struct pci_dev *pdev,
3374     return -ENOMEM;
3375     card->ports = ports;
3376    
3377     - rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt,
3378     - IRQF_SHARED, DRV_NAME, card);
3379     - if (rc)
3380     + rc = request_firmware(&fw, RP2_FW_NAME, &pdev->dev);
3381     + if (rc < 0) {
3382     + dev_err(&pdev->dev, "cannot find '%s' firmware image\n",
3383     + RP2_FW_NAME);
3384     return rc;
3385     + }
3386    
3387     - /*
3388     - * Only catastrophic errors (e.g. ENOMEM) are reported here.
3389     - * If the FW image is missing, we'll find out in rp2_fw_cb()
3390     - * and print an error message.
3391     - */
3392     - rc = request_firmware_nowait(THIS_MODULE, 1, RP2_FW_NAME, &pdev->dev,
3393     - GFP_KERNEL, card, rp2_fw_cb);
3394     + rc = rp2_load_firmware(card, fw);
3395     +
3396     + release_firmware(fw);
3397     + if (rc < 0)
3398     + return rc;
3399     +
3400     + rc = devm_request_irq(&pdev->dev, pdev->irq, rp2_uart_interrupt,
3401     + IRQF_SHARED, DRV_NAME, card);
3402     if (rc)
3403     return rc;
3404     - dev_dbg(&pdev->dev, "waiting for firmware blob...\n");
3405    
3406     return 0;
3407     }
3408     @@ -803,7 +786,6 @@ static void rp2_remove(struct pci_dev *pdev)
3409     {
3410     struct rp2_card *card = pci_get_drvdata(pdev);
3411    
3412     - wait_for_completion(&card->fw_loaded);
3413     rp2_remove_ports(card);
3414     }
3415    
3416     diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
3417     index 51c3f579ccd02..2007a40feef9d 100644
3418     --- a/drivers/tty/serial/serial-tegra.c
3419     +++ b/drivers/tty/serial/serial-tegra.c
3420     @@ -332,7 +332,7 @@ static void tegra_uart_fifo_reset(struct tegra_uart_port *tup, u8 fcr_bits)
3421    
3422     do {
3423     lsr = tegra_uart_read(tup, UART_LSR);
3424     - if ((lsr | UART_LSR_TEMT) && !(lsr & UART_LSR_DR))
3425     + if ((lsr & UART_LSR_TEMT) && !(lsr & UART_LSR_DR))
3426     break;
3427     udelay(1);
3428     } while (--tmout);
3429     diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
3430     index e2ab6524119a5..fa3bd8a97b244 100644
3431     --- a/drivers/tty/serial/serial_core.c
3432     +++ b/drivers/tty/serial/serial_core.c
3433     @@ -863,9 +863,11 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
3434     goto check_and_exit;
3435     }
3436    
3437     - retval = security_locked_down(LOCKDOWN_TIOCSSERIAL);
3438     - if (retval && (change_irq || change_port))
3439     - goto exit;
3440     + if (change_irq || change_port) {
3441     + retval = security_locked_down(LOCKDOWN_TIOCSSERIAL);
3442     + if (retval)
3443     + goto exit;
3444     + }
3445    
3446     /*
3447     * Ask the low level driver to verify the settings.
3448     diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
3449     index 7d1529b11ae9c..de86e9021a8ff 100644
3450     --- a/drivers/tty/serial/sh-sci.c
3451     +++ b/drivers/tty/serial/sh-sci.c
3452     @@ -1026,10 +1026,10 @@ static int scif_set_rtrg(struct uart_port *port, int rx_trig)
3453     {
3454     unsigned int bits;
3455    
3456     + if (rx_trig >= port->fifosize)
3457     + rx_trig = port->fifosize - 1;
3458     if (rx_trig < 1)
3459     rx_trig = 1;
3460     - if (rx_trig >= port->fifosize)
3461     - rx_trig = port->fifosize;
3462    
3463     /* HSCIF can be set to an arbitrary level. */
3464     if (sci_getreg(port, HSRTRGR)->size) {
3465     diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
3466     index 35e89460b9ca8..d037deb958841 100644
3467     --- a/drivers/usb/core/devio.c
3468     +++ b/drivers/usb/core/devio.c
3469     @@ -1218,7 +1218,12 @@ static int proc_bulk(struct usb_dev_state *ps, void __user *arg)
3470     ret = usbfs_increase_memory_usage(len1 + sizeof(struct urb));
3471     if (ret)
3472     return ret;
3473     - tbuf = kmalloc(len1, GFP_KERNEL);
3474     +
3475     + /*
3476     + * len1 can be almost arbitrarily large. Don't WARN if it's
3477     + * too big, just fail the request.
3478     + */
3479     + tbuf = kmalloc(len1, GFP_KERNEL | __GFP_NOWARN);
3480     if (!tbuf) {
3481     ret = -ENOMEM;
3482     goto done;
3483     @@ -1691,7 +1696,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
3484     if (num_sgs) {
3485     as->urb->sg = kmalloc_array(num_sgs,
3486     sizeof(struct scatterlist),
3487     - GFP_KERNEL);
3488     + GFP_KERNEL | __GFP_NOWARN);
3489     if (!as->urb->sg) {
3490     ret = -ENOMEM;
3491     goto error;
3492     @@ -1726,7 +1731,7 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
3493     (uurb_start - as->usbm->vm_start);
3494     } else {
3495     as->urb->transfer_buffer = kmalloc(uurb->buffer_length,
3496     - GFP_KERNEL);
3497     + GFP_KERNEL | __GFP_NOWARN);
3498     if (!as->urb->transfer_buffer) {
3499     ret = -ENOMEM;
3500     goto error;
3501     diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
3502     index a97dd1ba964ee..a8f23f8bc6efd 100644
3503     --- a/drivers/usb/core/hub.h
3504     +++ b/drivers/usb/core/hub.h
3505     @@ -148,8 +148,10 @@ static inline unsigned hub_power_on_good_delay(struct usb_hub *hub)
3506     {
3507     unsigned delay = hub->descriptor->bPwrOn2PwrGood * 2;
3508    
3509     - /* Wait at least 100 msec for power to become stable */
3510     - return max(delay, 100U);
3511     + if (!hub->hdev->parent) /* root hub */
3512     + return delay;
3513     + else /* Wait at least 100 msec for power to become stable */
3514     + return max(delay, 100U);
3515     }
3516    
3517     static inline int hub_port_debounce_be_connected(struct usb_hub *hub,
3518     diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
3519     index 6145311a3855f..ecd83526f26fe 100644
3520     --- a/drivers/usb/dwc3/gadget.c
3521     +++ b/drivers/usb/dwc3/gadget.c
3522     @@ -1162,6 +1162,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
3523     req->start_sg = sg_next(s);
3524    
3525     req->num_queued_sgs++;
3526     + req->num_pending_sgs--;
3527    
3528     /*
3529     * The number of pending SG entries may not correspond to the
3530     @@ -1169,7 +1170,7 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
3531     * don't include unused SG entries.
3532     */
3533     if (length == 0) {
3534     - req->num_pending_sgs -= req->request.num_mapped_sgs - req->num_queued_sgs;
3535     + req->num_pending_sgs = 0;
3536     break;
3537     }
3538    
3539     @@ -2602,15 +2603,15 @@ static int dwc3_gadget_ep_reclaim_trb_sg(struct dwc3_ep *dep,
3540     struct dwc3_trb *trb = &dep->trb_pool[dep->trb_dequeue];
3541     struct scatterlist *sg = req->sg;
3542     struct scatterlist *s;
3543     - unsigned int pending = req->num_pending_sgs;
3544     + unsigned int num_queued = req->num_queued_sgs;
3545     unsigned int i;
3546     int ret = 0;
3547    
3548     - for_each_sg(sg, s, pending, i) {
3549     + for_each_sg(sg, s, num_queued, i) {
3550     trb = &dep->trb_pool[dep->trb_dequeue];
3551    
3552     req->sg = sg_next(s);
3553     - req->num_pending_sgs--;
3554     + req->num_queued_sgs--;
3555    
3556     ret = dwc3_gadget_ep_reclaim_completed_trb(dep, req,
3557     trb, event, status, true);
3558     @@ -2633,7 +2634,7 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,
3559    
3560     static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req)
3561     {
3562     - return req->num_pending_sgs == 0;
3563     + return req->num_pending_sgs == 0 && req->num_queued_sgs == 0;
3564     }
3565    
3566     static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
3567     @@ -2642,7 +2643,7 @@ static int dwc3_gadget_ep_cleanup_completed_request(struct dwc3_ep *dep,
3568     {
3569     int ret;
3570    
3571     - if (req->num_pending_sgs)
3572     + if (req->request.num_mapped_sgs)
3573     ret = dwc3_gadget_ep_reclaim_trb_sg(dep, req, event,
3574     status);
3575     else
3576     diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c
3577     index 33703140233aa..08a93cf68efff 100644
3578     --- a/drivers/usb/gadget/udc/renesas_usb3.c
3579     +++ b/drivers/usb/gadget/udc/renesas_usb3.c
3580     @@ -1473,7 +1473,7 @@ static void usb3_start_pipen(struct renesas_usb3_ep *usb3_ep,
3581     struct renesas_usb3_request *usb3_req)
3582     {
3583     struct renesas_usb3 *usb3 = usb3_ep_to_usb3(usb3_ep);
3584     - struct renesas_usb3_request *usb3_req_first = usb3_get_request(usb3_ep);
3585     + struct renesas_usb3_request *usb3_req_first;
3586     unsigned long flags;
3587     int ret = -EAGAIN;
3588     u32 enable_bits = 0;
3589     @@ -1481,7 +1481,8 @@ static void usb3_start_pipen(struct renesas_usb3_ep *usb3_ep,
3590     spin_lock_irqsave(&usb3->lock, flags);
3591     if (usb3_ep->halt || usb3_ep->started)
3592     goto out;
3593     - if (usb3_req != usb3_req_first)
3594     + usb3_req_first = __usb3_get_request(usb3_ep);
3595     + if (!usb3_req_first || usb3_req != usb3_req_first)
3596     goto out;
3597    
3598     if (usb3_pn_change(usb3, usb3_ep->num) < 0)
3599     diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c
3600     index a3dfc77578ea1..26baba3ab7d73 100644
3601     --- a/drivers/usb/misc/trancevibrator.c
3602     +++ b/drivers/usb/misc/trancevibrator.c
3603     @@ -61,9 +61,9 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
3604     /* Set speed */
3605     retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0),
3606     0x01, /* vendor request: set speed */
3607     - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER,
3608     + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
3609     tv->speed, /* speed value */
3610     - 0, NULL, 0, USB_CTRL_GET_TIMEOUT);
3611     + 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
3612     if (retval) {
3613     tv->speed = old;
3614     dev_dbg(&tv->udev->dev, "retval = %d\n", retval);
3615     diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
3616     index b5d6616442635..748139d262633 100644
3617     --- a/drivers/usb/misc/uss720.c
3618     +++ b/drivers/usb/misc/uss720.c
3619     @@ -736,6 +736,7 @@ static int uss720_probe(struct usb_interface *intf,
3620     parport_announce_port(pp);
3621    
3622     usb_set_intfdata(intf, pp);
3623     + usb_put_dev(usbdev);
3624     return 0;
3625    
3626     probe_abort:
3627     diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
3628     index c00e4177651a8..7c0181ae44e9c 100644
3629     --- a/drivers/usb/serial/ftdi_sio.c
3630     +++ b/drivers/usb/serial/ftdi_sio.c
3631     @@ -1034,6 +1034,9 @@ static const struct usb_device_id id_table_combined[] = {
3632     /* Sienna devices */
3633     { USB_DEVICE(FTDI_VID, FTDI_SIENNA_PID) },
3634     { USB_DEVICE(ECHELON_VID, ECHELON_U20_PID) },
3635     + /* IDS GmbH devices */
3636     + { USB_DEVICE(IDS_VID, IDS_SI31A_PID) },
3637     + { USB_DEVICE(IDS_VID, IDS_CM31A_PID) },
3638     /* U-Blox devices */
3639     { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ZED_PID) },
3640     { USB_DEVICE(UBLOX_VID, UBLOX_C099F9P_ODIN_PID) },
3641     diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h
3642     index 3d47c6d72256e..d854e04a4286e 100644
3643     --- a/drivers/usb/serial/ftdi_sio_ids.h
3644     +++ b/drivers/usb/serial/ftdi_sio_ids.h
3645     @@ -1567,6 +1567,13 @@
3646     #define UNJO_VID 0x22B7
3647     #define UNJO_ISODEBUG_V1_PID 0x150D
3648    
3649     +/*
3650     + * IDS GmbH
3651     + */
3652     +#define IDS_VID 0x2CAF
3653     +#define IDS_SI31A_PID 0x13A2
3654     +#define IDS_CM31A_PID 0x13A3
3655     +
3656     /*
3657     * U-Blox products (http://www.u-blox.com).
3658     */
3659     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
3660     index 5c167bc089a08..25d8fb3a7395f 100644
3661     --- a/drivers/usb/serial/option.c
3662     +++ b/drivers/usb/serial/option.c
3663     @@ -1240,6 +1240,10 @@ static const struct usb_device_id option_ids[] = {
3664     .driver_info = NCTRL(0) | RSVD(1) },
3665     { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1901, 0xff), /* Telit LN940 (MBIM) */
3666     .driver_info = NCTRL(0) },
3667     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x7010, 0xff), /* Telit LE910-S1 (RNDIS) */
3668     + .driver_info = NCTRL(2) },
3669     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x7011, 0xff), /* Telit LE910-S1 (ECM) */
3670     + .driver_info = NCTRL(2) },
3671     { USB_DEVICE(TELIT_VENDOR_ID, 0x9010), /* Telit SBL FN980 flashing device */
3672     .driver_info = NCTRL(0) | ZLP },
3673     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_MF622, 0xff, 0xff, 0xff) }, /* ZTE WCDMA products */
3674     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
3675     index e290b250f45cc..9600cee957697 100644
3676     --- a/drivers/usb/serial/pl2303.c
3677     +++ b/drivers/usb/serial/pl2303.c
3678     @@ -107,6 +107,7 @@ static const struct usb_device_id id_table[] = {
3679     { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
3680     { USB_DEVICE(SANWA_VENDOR_ID, SANWA_PRODUCT_ID) },
3681     { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530_PRODUCT_ID) },
3682     + { USB_DEVICE(ADLINK_VENDOR_ID, ADLINK_ND6530GC_PRODUCT_ID) },
3683     { USB_DEVICE(SMART_VENDOR_ID, SMART_PRODUCT_ID) },
3684     { USB_DEVICE(AT_VENDOR_ID, AT_VTKIT3_PRODUCT_ID) },
3685     { } /* Terminating entry */
3686     diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
3687     index a897680473a78..3e5442573fe4e 100644
3688     --- a/drivers/usb/serial/pl2303.h
3689     +++ b/drivers/usb/serial/pl2303.h
3690     @@ -152,6 +152,7 @@
3691     /* ADLINK ND-6530 RS232,RS485 and RS422 adapter */
3692     #define ADLINK_VENDOR_ID 0x0b63
3693     #define ADLINK_ND6530_PRODUCT_ID 0x6530
3694     +#define ADLINK_ND6530GC_PRODUCT_ID 0x653a
3695    
3696     /* SMART USB Serial Adapter */
3697     #define SMART_VENDOR_ID 0x0b8c
3698     diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
3699     index b1449d4914cca..acc115d20f812 100644
3700     --- a/drivers/usb/serial/ti_usb_3410_5052.c
3701     +++ b/drivers/usb/serial/ti_usb_3410_5052.c
3702     @@ -37,6 +37,7 @@
3703     /* Vendor and product ids */
3704     #define TI_VENDOR_ID 0x0451
3705     #define IBM_VENDOR_ID 0x04b3
3706     +#define STARTECH_VENDOR_ID 0x14b0
3707     #define TI_3410_PRODUCT_ID 0x3410
3708     #define IBM_4543_PRODUCT_ID 0x4543
3709     #define IBM_454B_PRODUCT_ID 0x454b
3710     @@ -372,6 +373,7 @@ static const struct usb_device_id ti_id_table_3410[] = {
3711     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) },
3712     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) },
3713     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) },
3714     + { USB_DEVICE(STARTECH_VENDOR_ID, TI_3410_PRODUCT_ID) },
3715     { } /* terminator */
3716     };
3717    
3718     @@ -410,6 +412,7 @@ static const struct usb_device_id ti_id_table_combined[] = {
3719     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1131_PRODUCT_ID) },
3720     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1150_PRODUCT_ID) },
3721     { USB_DEVICE(MXU1_VENDOR_ID, MXU1_1151_PRODUCT_ID) },
3722     + { USB_DEVICE(STARTECH_VENDOR_ID, TI_3410_PRODUCT_ID) },
3723     { } /* terminator */
3724     };
3725    
3726     diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
3727     index 95205bde240f7..eca3abc1a7cd9 100644
3728     --- a/fs/btrfs/extent_io.c
3729     +++ b/fs/btrfs/extent_io.c
3730     @@ -4648,7 +4648,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3731     __u64 start, __u64 len)
3732     {
3733     int ret = 0;
3734     - u64 off = start;
3735     + u64 off;
3736     u64 max = start + len;
3737     u32 flags = 0;
3738     u32 found_type;
3739     @@ -4684,6 +4684,11 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
3740     goto out_free_ulist;
3741     }
3742    
3743     + /*
3744     + * We can't initialize that to 'start' as this could miss extents due
3745     + * to extent item merging
3746     + */
3747     + off = 0;
3748     start = round_down(start, btrfs_inode_sectorsize(inode));
3749     len = round_up(max, btrfs_inode_sectorsize(inode)) - start;
3750    
3751     diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
3752     index de53e51669976..54647eb9c6ed2 100644
3753     --- a/fs/btrfs/tree-log.c
3754     +++ b/fs/btrfs/tree-log.c
3755     @@ -1846,8 +1846,6 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
3756     ret = btrfs_update_inode(trans, root, inode);
3757     } else if (ret == -EEXIST) {
3758     ret = 0;
3759     - } else {
3760     - BUG(); /* Logic Error */
3761     }
3762     iput(inode);
3763    
3764     diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
3765     index 81d9c4ea0e8f3..e068f82ffeddf 100644
3766     --- a/fs/cifs/smb2pdu.c
3767     +++ b/fs/cifs/smb2pdu.c
3768     @@ -979,6 +979,13 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
3769     /* Internal types */
3770     server->capabilities |= SMB2_NT_FIND | SMB2_LARGE_FILES;
3771    
3772     + /*
3773     + * SMB3.0 supports only 1 cipher and doesn't have a encryption neg context
3774     + * Set the cipher type manually.
3775     + */
3776     + if (server->dialect == SMB30_PROT_ID && (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
3777     + server->cipher_type = SMB2_ENCRYPTION_AES128_CCM;
3778     +
3779     security_blob = smb2_get_data_area_len(&blob_offset, &blob_length,
3780     (struct smb2_sync_hdr *)rsp);
3781     /*
3782     @@ -3604,10 +3611,10 @@ smb2_new_read_req(void **buf, unsigned int *total_len,
3783     * Related requests use info from previous read request
3784     * in chain.
3785     */
3786     - shdr->SessionId = 0xFFFFFFFF;
3787     + shdr->SessionId = 0xFFFFFFFFFFFFFFFF;
3788     shdr->TreeId = 0xFFFFFFFF;
3789     - req->PersistentFileId = 0xFFFFFFFF;
3790     - req->VolatileFileId = 0xFFFFFFFF;
3791     + req->PersistentFileId = 0xFFFFFFFFFFFFFFFF;
3792     + req->VolatileFileId = 0xFFFFFFFFFFFFFFFF;
3793     }
3794     }
3795     if (remaining_bytes > io_parms->length)
3796     diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
3797     index c9b605f6c9cb2..98b74cdabb99a 100644
3798     --- a/fs/nfs/filelayout/filelayout.c
3799     +++ b/fs/nfs/filelayout/filelayout.c
3800     @@ -717,7 +717,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
3801     if (unlikely(!p))
3802     goto out_err;
3803     fl->fh_array[i]->size = be32_to_cpup(p++);
3804     - if (sizeof(struct nfs_fh) < fl->fh_array[i]->size) {
3805     + if (fl->fh_array[i]->size > NFS_MAXFHSIZE) {
3806     printk(KERN_ERR "NFS: Too big fh %d received %d\n",
3807     i, fl->fh_array[i]->size);
3808     goto out_err;
3809     diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
3810     index 6b31cb5f9c9db..7c73097b2f4e5 100644
3811     --- a/fs/nfs/nfs4file.c
3812     +++ b/fs/nfs/nfs4file.c
3813     @@ -168,7 +168,7 @@ static loff_t nfs4_file_llseek(struct file *filep, loff_t offset, int whence)
3814     case SEEK_HOLE:
3815     case SEEK_DATA:
3816     ret = nfs42_proc_llseek(filep, offset, whence);
3817     - if (ret != -ENOTSUPP)
3818     + if (ret != -EOPNOTSUPP)
3819     return ret;
3820     /* Fall through */
3821     default:
3822     diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
3823     index 304ab4cdaa8c1..ff54ba3c82477 100644
3824     --- a/fs/nfs/nfs4proc.c
3825     +++ b/fs/nfs/nfs4proc.c
3826     @@ -1647,7 +1647,7 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state,
3827     rcu_read_unlock();
3828     trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0);
3829    
3830     - if (!signal_pending(current)) {
3831     + if (!fatal_signal_pending(current)) {
3832     if (schedule_timeout(5*HZ) == 0)
3833     status = -EAGAIN;
3834     else
3835     @@ -3416,7 +3416,7 @@ static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst,
3836     write_sequnlock(&state->seqlock);
3837     trace_nfs4_close_stateid_update_wait(state->inode, dst, 0);
3838    
3839     - if (signal_pending(current))
3840     + if (fatal_signal_pending(current))
3841     status = -EINTR;
3842     else
3843     if (schedule_timeout(5*HZ) != 0)
3844     diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
3845     index f4407dd426bf0..e3b85bfcfc7dc 100644
3846     --- a/fs/nfs/pagelist.c
3847     +++ b/fs/nfs/pagelist.c
3848     @@ -986,15 +986,16 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
3849    
3850     struct nfs_page *prev = NULL;
3851    
3852     - if (mirror->pg_count != 0) {
3853     - prev = nfs_list_entry(mirror->pg_list.prev);
3854     - } else {
3855     + if (list_empty(&mirror->pg_list)) {
3856     if (desc->pg_ops->pg_init)
3857     desc->pg_ops->pg_init(desc, req);
3858     if (desc->pg_error < 0)
3859     return 0;
3860     mirror->pg_base = req->wb_pgbase;
3861     - }
3862     + mirror->pg_count = 0;
3863     + mirror->pg_recoalesce = 0;
3864     + } else
3865     + prev = nfs_list_entry(mirror->pg_list.prev);
3866    
3867     if (desc->pg_maxretrans && req->wb_nio > desc->pg_maxretrans) {
3868     if (NFS_SERVER(desc->pg_inode)->flags & NFS_MOUNT_SOFTERR)
3869     @@ -1018,17 +1019,16 @@ static void nfs_pageio_doio(struct nfs_pageio_descriptor *desc)
3870     {
3871     struct nfs_pgio_mirror *mirror = nfs_pgio_current_mirror(desc);
3872    
3873     -
3874     if (!list_empty(&mirror->pg_list)) {
3875     int error = desc->pg_ops->pg_doio(desc);
3876     if (error < 0)
3877     desc->pg_error = error;
3878     - else
3879     + if (list_empty(&mirror->pg_list)) {
3880     mirror->pg_bytes_written += mirror->pg_count;
3881     - }
3882     - if (list_empty(&mirror->pg_list)) {
3883     - mirror->pg_count = 0;
3884     - mirror->pg_base = 0;
3885     + mirror->pg_count = 0;
3886     + mirror->pg_base = 0;
3887     + mirror->pg_recoalesce = 0;
3888     + }
3889     }
3890     }
3891    
3892     @@ -1122,7 +1122,6 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
3893    
3894     do {
3895     list_splice_init(&mirror->pg_list, &head);
3896     - mirror->pg_bytes_written -= mirror->pg_count;
3897     mirror->pg_count = 0;
3898     mirror->pg_base = 0;
3899     mirror->pg_recoalesce = 0;
3900     diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
3901     index 7e8c18218e68f..1b512df1003f9 100644
3902     --- a/fs/nfs/pnfs.c
3903     +++ b/fs/nfs/pnfs.c
3904     @@ -1285,6 +1285,11 @@ _pnfs_return_layout(struct inode *ino)
3905     {
3906     struct pnfs_layout_hdr *lo = NULL;
3907     struct nfs_inode *nfsi = NFS_I(ino);
3908     + struct pnfs_layout_range range = {
3909     + .iomode = IOMODE_ANY,
3910     + .offset = 0,
3911     + .length = NFS4_MAX_UINT64,
3912     + };
3913     LIST_HEAD(tmp_list);
3914     nfs4_stateid stateid;
3915     int status = 0;
3916     @@ -1311,16 +1316,10 @@ _pnfs_return_layout(struct inode *ino)
3917     }
3918     valid_layout = pnfs_layout_is_valid(lo);
3919     pnfs_clear_layoutcommit(ino, &tmp_list);
3920     - pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0);
3921     + pnfs_mark_matching_lsegs_return(lo, &tmp_list, &range, 0);
3922    
3923     - if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) {
3924     - struct pnfs_layout_range range = {
3925     - .iomode = IOMODE_ANY,
3926     - .offset = 0,
3927     - .length = NFS4_MAX_UINT64,
3928     - };
3929     + if (NFS_SERVER(ino)->pnfs_curr_ld->return_range)
3930     NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range);
3931     - }
3932    
3933     /* Don't send a LAYOUTRETURN if list was initially empty */
3934     if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) ||
3935     diff --git a/fs/proc/base.c b/fs/proc/base.c
3936     index 653c2d8aa1cd7..35114624fb036 100644
3937     --- a/fs/proc/base.c
3938     +++ b/fs/proc/base.c
3939     @@ -2556,6 +2556,10 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf,
3940     void *page;
3941     int rv;
3942    
3943     + /* A task may only write when it was the opener. */
3944     + if (file->f_cred != current_real_cred())
3945     + return -EPERM;
3946     +
3947     rcu_read_lock();
3948     task = pid_task(proc_pid(inode), PIDTYPE_PID);
3949     if (!task) {
3950     diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
3951     index 68782ba8b6e8d..69b9ccbe1ad0f 100644
3952     --- a/include/net/cfg80211.h
3953     +++ b/include/net/cfg80211.h
3954     @@ -5194,7 +5194,7 @@ unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
3955     */
3956     int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
3957     const u8 *addr, enum nl80211_iftype iftype,
3958     - u8 data_offset);
3959     + u8 data_offset, bool is_amsdu);
3960    
3961     /**
3962     * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3
3963     @@ -5206,7 +5206,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
3964     static inline int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
3965     enum nl80211_iftype iftype)
3966     {
3967     - return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0);
3968     + return ieee80211_data_to_8023_exthdr(skb, NULL, addr, iftype, 0, false);
3969     }
3970    
3971     /**
3972     diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
3973     index cee1c084e9f40..b16f9236de147 100644
3974     --- a/include/net/pkt_sched.h
3975     +++ b/include/net/pkt_sched.h
3976     @@ -118,12 +118,7 @@ void __qdisc_run(struct Qdisc *q);
3977     static inline void qdisc_run(struct Qdisc *q)
3978     {
3979     if (qdisc_run_begin(q)) {
3980     - /* NOLOCK qdisc must check 'state' under the qdisc seqlock
3981     - * to avoid racing with dev_qdisc_reset()
3982     - */
3983     - if (!(q->flags & TCQ_F_NOLOCK) ||
3984     - likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state)))
3985     - __qdisc_run(q);
3986     + __qdisc_run(q);
3987     qdisc_run_end(q);
3988     }
3989     }
3990     diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
3991     index b2ceec7b280d4..0852f3e51360a 100644
3992     --- a/include/net/sch_generic.h
3993     +++ b/include/net/sch_generic.h
3994     @@ -36,6 +36,7 @@ struct qdisc_rate_table {
3995     enum qdisc_state_t {
3996     __QDISC_STATE_SCHED,
3997     __QDISC_STATE_DEACTIVATED,
3998     + __QDISC_STATE_MISSED,
3999     };
4000    
4001     struct qdisc_size_table {
4002     @@ -156,8 +157,33 @@ static inline bool qdisc_is_empty(const struct Qdisc *qdisc)
4003     static inline bool qdisc_run_begin(struct Qdisc *qdisc)
4004     {
4005     if (qdisc->flags & TCQ_F_NOLOCK) {
4006     + if (spin_trylock(&qdisc->seqlock))
4007     + goto nolock_empty;
4008     +
4009     + /* If the MISSED flag is set, it means other thread has
4010     + * set the MISSED flag before second spin_trylock(), so
4011     + * we can return false here to avoid multi cpus doing
4012     + * the set_bit() and second spin_trylock() concurrently.
4013     + */
4014     + if (test_bit(__QDISC_STATE_MISSED, &qdisc->state))
4015     + return false;
4016     +
4017     + /* Set the MISSED flag before the second spin_trylock(),
4018     + * if the second spin_trylock() return false, it means
4019     + * other cpu holding the lock will do dequeuing for us
4020     + * or it will see the MISSED flag set after releasing
4021     + * lock and reschedule the net_tx_action() to do the
4022     + * dequeuing.
4023     + */
4024     + set_bit(__QDISC_STATE_MISSED, &qdisc->state);
4025     +
4026     + /* Retry again in case other CPU may not see the new flag
4027     + * after it releases the lock at the end of qdisc_run_end().
4028     + */
4029     if (!spin_trylock(&qdisc->seqlock))
4030     return false;
4031     +
4032     +nolock_empty:
4033     WRITE_ONCE(qdisc->empty, false);
4034     } else if (qdisc_is_running(qdisc)) {
4035     return false;
4036     @@ -173,8 +199,15 @@ static inline bool qdisc_run_begin(struct Qdisc *qdisc)
4037     static inline void qdisc_run_end(struct Qdisc *qdisc)
4038     {
4039     write_seqcount_end(&qdisc->running);
4040     - if (qdisc->flags & TCQ_F_NOLOCK)
4041     + if (qdisc->flags & TCQ_F_NOLOCK) {
4042     spin_unlock(&qdisc->seqlock);
4043     +
4044     + if (unlikely(test_bit(__QDISC_STATE_MISSED,
4045     + &qdisc->state))) {
4046     + clear_bit(__QDISC_STATE_MISSED, &qdisc->state);
4047     + __netif_schedule(qdisc);
4048     + }
4049     + }
4050     }
4051    
4052     static inline bool qdisc_may_bulk(const struct Qdisc *qdisc)
4053     diff --git a/include/net/sock.h b/include/net/sock.h
4054     index 4137fa1787903..a0728f24ecc53 100644
4055     --- a/include/net/sock.h
4056     +++ b/include/net/sock.h
4057     @@ -2150,13 +2150,15 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
4058     sk_mem_charge(sk, skb->truesize);
4059     }
4060    
4061     -static inline void skb_set_owner_sk_safe(struct sk_buff *skb, struct sock *sk)
4062     +static inline __must_check bool skb_set_owner_sk_safe(struct sk_buff *skb, struct sock *sk)
4063     {
4064     if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) {
4065     skb_orphan(skb);
4066     skb->destructor = sock_efree;
4067     skb->sk = sk;
4068     + return true;
4069     }
4070     + return false;
4071     }
4072    
4073     void sk_reset_timer(struct sock *sk, struct timer_list *timer,
4074     diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
4075     index 07cfa3249f83a..0a2d78e811cf5 100644
4076     --- a/net/bluetooth/cmtp/core.c
4077     +++ b/net/bluetooth/cmtp/core.c
4078     @@ -392,6 +392,11 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
4079     if (!(session->flags & BIT(CMTP_LOOPBACK))) {
4080     err = cmtp_attach_device(session);
4081     if (err < 0) {
4082     + /* Caller will call fput in case of failure, and so
4083     + * will cmtp_session kthread.
4084     + */
4085     + get_file(session->sock->file);
4086     +
4087     atomic_inc(&session->terminate);
4088     wake_up_interruptible(sk_sleep(session->sock->sk));
4089     up_write(&cmtp_session_sem);
4090     diff --git a/net/core/dev.c b/net/core/dev.c
4091     index a30878346f54b..e226f266da9e0 100644
4092     --- a/net/core/dev.c
4093     +++ b/net/core/dev.c
4094     @@ -3384,7 +3384,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
4095    
4096     if (q->flags & TCQ_F_NOLOCK) {
4097     rc = q->enqueue(skb, q, &to_free) & NET_XMIT_MASK;
4098     - qdisc_run(q);
4099     + if (likely(!netif_xmit_frozen_or_stopped(txq)))
4100     + qdisc_run(q);
4101    
4102     if (unlikely(to_free))
4103     kfree_skb_list(to_free);
4104     @@ -4515,25 +4516,43 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)
4105     sd->output_queue_tailp = &sd->output_queue;
4106     local_irq_enable();
4107    
4108     + rcu_read_lock();
4109     +
4110     while (head) {
4111     struct Qdisc *q = head;
4112     spinlock_t *root_lock = NULL;
4113    
4114     head = head->next_sched;
4115    
4116     - if (!(q->flags & TCQ_F_NOLOCK)) {
4117     - root_lock = qdisc_lock(q);
4118     - spin_lock(root_lock);
4119     - }
4120     /* We need to make sure head->next_sched is read
4121     * before clearing __QDISC_STATE_SCHED
4122     */
4123     smp_mb__before_atomic();
4124     +
4125     + if (!(q->flags & TCQ_F_NOLOCK)) {
4126     + root_lock = qdisc_lock(q);
4127     + spin_lock(root_lock);
4128     + } else if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED,
4129     + &q->state))) {
4130     + /* There is a synchronize_net() between
4131     + * STATE_DEACTIVATED flag being set and
4132     + * qdisc_reset()/some_qdisc_is_busy() in
4133     + * dev_deactivate(), so we can safely bail out
4134     + * early here to avoid data race between
4135     + * qdisc_deactivate() and some_qdisc_is_busy()
4136     + * for lockless qdisc.
4137     + */
4138     + clear_bit(__QDISC_STATE_SCHED, &q->state);
4139     + continue;
4140     + }
4141     +
4142     clear_bit(__QDISC_STATE_SCHED, &q->state);
4143     qdisc_run(q);
4144     if (root_lock)
4145     spin_unlock(root_lock);
4146     }
4147     +
4148     + rcu_read_unlock();
4149     }
4150    
4151     xfrm_dev_backlog(sd);
4152     diff --git a/net/core/filter.c b/net/core/filter.c
4153     index 7fbb274b7fe32..108bcf6000529 100644
4154     --- a/net/core/filter.c
4155     +++ b/net/core/filter.c
4156     @@ -3331,6 +3331,7 @@ static inline int __bpf_skb_change_head(struct sk_buff *skb, u32 head_room,
4157     __skb_push(skb, head_room);
4158     memset(skb->data, 0, head_room);
4159     skb_reset_mac_header(skb);
4160     + skb_reset_mac_len(skb);
4161     }
4162    
4163     return ret;
4164     diff --git a/net/core/neighbour.c b/net/core/neighbour.c
4165     index 6635b83113f8f..472a615775f32 100644
4166     --- a/net/core/neighbour.c
4167     +++ b/net/core/neighbour.c
4168     @@ -132,6 +132,9 @@ static void neigh_update_gc_list(struct neighbour *n)
4169     write_lock_bh(&n->tbl->lock);
4170     write_lock(&n->lock);
4171    
4172     + if (n->dead)
4173     + goto out;
4174     +
4175     /* remove from the gc list if new state is permanent or if neighbor
4176     * is externally learned; otherwise entry should be on the gc list
4177     */
4178     @@ -148,6 +151,7 @@ static void neigh_update_gc_list(struct neighbour *n)
4179     atomic_inc(&n->tbl->gc_entries);
4180     }
4181    
4182     +out:
4183     write_unlock(&n->lock);
4184     write_unlock_bh(&n->tbl->lock);
4185     }
4186     diff --git a/net/core/sock.c b/net/core/sock.c
4187     index 19c178aac0ae8..68f84fac63e0b 100644
4188     --- a/net/core/sock.c
4189     +++ b/net/core/sock.c
4190     @@ -2026,10 +2026,10 @@ void skb_orphan_partial(struct sk_buff *skb)
4191     if (skb_is_tcp_pure_ack(skb))
4192     return;
4193    
4194     - if (can_skb_orphan_partial(skb))
4195     - skb_set_owner_sk_safe(skb, skb->sk);
4196     - else
4197     - skb_orphan(skb);
4198     + if (can_skb_orphan_partial(skb) && skb_set_owner_sk_safe(skb, skb->sk))
4199     + return;
4200     +
4201     + skb_orphan(skb);
4202     }
4203     EXPORT_SYMBOL(skb_orphan_partial);
4204    
4205     diff --git a/net/dsa/master.c b/net/dsa/master.c
4206     index be0b4ed3b7d89..40eddec48f26e 100644
4207     --- a/net/dsa/master.c
4208     +++ b/net/dsa/master.c
4209     @@ -147,8 +147,7 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
4210     struct dsa_switch *ds = cpu_dp->ds;
4211     int port = cpu_dp->index;
4212     int len = ETH_GSTRING_LEN;
4213     - int mcount = 0, count;
4214     - unsigned int i;
4215     + int mcount = 0, count, i;
4216     uint8_t pfx[4];
4217     uint8_t *ndata;
4218    
4219     @@ -178,6 +177,8 @@ static void dsa_master_get_strings(struct net_device *dev, uint32_t stringset,
4220     */
4221     ds->ops->get_strings(ds, port, stringset, ndata);
4222     count = ds->ops->get_sset_count(ds, port, stringset);
4223     + if (count < 0)
4224     + return;
4225     for (i = 0; i < count; i++) {
4226     memmove(ndata + (i * len + sizeof(pfx)),
4227     ndata + i * len, len - sizeof(pfx));
4228     diff --git a/net/dsa/slave.c b/net/dsa/slave.c
4229     index 06f8874d53eea..75b4cd4bcafb9 100644
4230     --- a/net/dsa/slave.c
4231     +++ b/net/dsa/slave.c
4232     @@ -692,13 +692,15 @@ static int dsa_slave_get_sset_count(struct net_device *dev, int sset)
4233     struct dsa_switch *ds = dp->ds;
4234    
4235     if (sset == ETH_SS_STATS) {
4236     - int count;
4237     + int count = 0;
4238    
4239     - count = 4;
4240     - if (ds->ops->get_sset_count)
4241     - count += ds->ops->get_sset_count(ds, dp->index, sset);
4242     + if (ds->ops->get_sset_count) {
4243     + count = ds->ops->get_sset_count(ds, dp->index, sset);
4244     + if (count < 0)
4245     + return count;
4246     + }
4247    
4248     - return count;
4249     + return count + 4;
4250     }
4251    
4252     return -EOPNOTSUPP;
4253     diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
4254     index c875c9b6edbe9..7d0a6a7c9d283 100644
4255     --- a/net/ipv6/mcast.c
4256     +++ b/net/ipv6/mcast.c
4257     @@ -1604,10 +1604,7 @@ static struct sk_buff *mld_newpack(struct inet6_dev *idev, unsigned int mtu)
4258     IPV6_TLV_PADN, 0 };
4259    
4260     /* we assume size > sizeof(ra) here */
4261     - /* limit our allocations to order-0 page */
4262     - size = min_t(int, size, SKB_MAX_ORDER(0, 0));
4263     skb = sock_alloc_send_skb(sk, size, 1, &err);
4264     -
4265     if (!skb)
4266     return NULL;
4267    
4268     diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
4269     index c8cf1bbad74a2..45ee1971d9986 100644
4270     --- a/net/ipv6/reassembly.c
4271     +++ b/net/ipv6/reassembly.c
4272     @@ -344,7 +344,7 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
4273     hdr = ipv6_hdr(skb);
4274     fhdr = (struct frag_hdr *)skb_transport_header(skb);
4275    
4276     - if (!(fhdr->frag_off & htons(0xFFF9))) {
4277     + if (!(fhdr->frag_off & htons(IP6_OFFSET | IP6_MF))) {
4278     /* It is not a fragmented frame */
4279     skb->transport_header += sizeof(struct frag_hdr);
4280     __IP6_INC_STATS(net,
4281     @@ -352,6 +352,8 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
4282    
4283     IP6CB(skb)->nhoff = (u8 *)fhdr - skb_network_header(skb);
4284     IP6CB(skb)->flags |= IP6SKB_FRAGMENTED;
4285     + IP6CB(skb)->frag_max_size = ntohs(hdr->payload_len) +
4286     + sizeof(struct ipv6hdr);
4287     return 1;
4288     }
4289    
4290     diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
4291     index 268f1d8f440ba..a7933279a80b7 100644
4292     --- a/net/mac80211/ieee80211_i.h
4293     +++ b/net/mac80211/ieee80211_i.h
4294     @@ -50,12 +50,6 @@ struct ieee80211_local;
4295     #define IEEE80211_ENCRYPT_HEADROOM 8
4296     #define IEEE80211_ENCRYPT_TAILROOM 18
4297    
4298     -/* IEEE 802.11 (Ch. 9.5 Defragmentation) requires support for concurrent
4299     - * reception of at least three fragmented frames. This limit can be increased
4300     - * by changing this define, at the cost of slower frame reassembly and
4301     - * increased memory use (about 2 kB of RAM per entry). */
4302     -#define IEEE80211_FRAGMENT_MAX 4
4303     -
4304     /* power level hasn't been configured (or set to automatic) */
4305     #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
4306    
4307     @@ -88,18 +82,6 @@ extern const u8 ieee80211_ac_to_qos_mask[IEEE80211_NUM_ACS];
4308    
4309     #define IEEE80211_MAX_NAN_INSTANCE_ID 255
4310    
4311     -struct ieee80211_fragment_entry {
4312     - struct sk_buff_head skb_list;
4313     - unsigned long first_frag_time;
4314     - u16 seq;
4315     - u16 extra_len;
4316     - u16 last_frag;
4317     - u8 rx_queue;
4318     - bool check_sequential_pn; /* needed for CCMP/GCMP */
4319     - u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
4320     -};
4321     -
4322     -
4323     struct ieee80211_bss {
4324     u32 device_ts_beacon, device_ts_presp;
4325    
4326     @@ -240,8 +222,15 @@ struct ieee80211_rx_data {
4327     */
4328     int security_idx;
4329    
4330     - u32 tkip_iv32;
4331     - u16 tkip_iv16;
4332     + union {
4333     + struct {
4334     + u32 iv32;
4335     + u16 iv16;
4336     + } tkip;
4337     + struct {
4338     + u8 pn[IEEE80211_CCMP_PN_LEN];
4339     + } ccm_gcm;
4340     + };
4341     };
4342    
4343     struct ieee80211_csa_settings {
4344     @@ -894,9 +883,7 @@ struct ieee80211_sub_if_data {
4345    
4346     char name[IFNAMSIZ];
4347    
4348     - /* Fragment table for host-based reassembly */
4349     - struct ieee80211_fragment_entry fragments[IEEE80211_FRAGMENT_MAX];
4350     - unsigned int fragment_next;
4351     + struct ieee80211_fragment_cache frags;
4352    
4353     /* TID bitmap for NoAck policy */
4354     u16 noack_map;
4355     @@ -2256,4 +2243,7 @@ extern const struct ethtool_ops ieee80211_ethtool_ops;
4356     #define debug_noinline
4357     #endif
4358    
4359     +void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache);
4360     +void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache);
4361     +
4362     #endif /* IEEE80211_I_H */
4363     diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
4364     index 6089b09ec13b6..6f576306a4d74 100644
4365     --- a/net/mac80211/iface.c
4366     +++ b/net/mac80211/iface.c
4367     @@ -8,7 +8,7 @@
4368     * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
4369     * Copyright 2013-2014 Intel Mobile Communications GmbH
4370     * Copyright (c) 2016 Intel Deutschland GmbH
4371     - * Copyright (C) 2018 Intel Corporation
4372     + * Copyright (C) 2018-2021 Intel Corporation
4373     */
4374     #include <linux/slab.h>
4375     #include <linux/kernel.h>
4376     @@ -1108,16 +1108,12 @@ static void ieee80211_set_multicast_list(struct net_device *dev)
4377     */
4378     static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
4379     {
4380     - int i;
4381     -
4382     /* free extra data */
4383     ieee80211_free_keys(sdata, false);
4384    
4385     ieee80211_debugfs_remove_netdev(sdata);
4386    
4387     - for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
4388     - __skb_queue_purge(&sdata->fragments[i].skb_list);
4389     - sdata->fragment_next = 0;
4390     + ieee80211_destroy_frag_cache(&sdata->frags);
4391    
4392     if (ieee80211_vif_is_mesh(&sdata->vif))
4393     ieee80211_mesh_teardown_sdata(sdata);
4394     @@ -1827,8 +1823,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
4395     sdata->wdev.wiphy = local->hw.wiphy;
4396     sdata->local = local;
4397    
4398     - for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
4399     - skb_queue_head_init(&sdata->fragments[i].skb_list);
4400     + ieee80211_init_frag_cache(&sdata->frags);
4401    
4402     INIT_LIST_HEAD(&sdata->key_list);
4403    
4404     diff --git a/net/mac80211/key.c b/net/mac80211/key.c
4405     index efc1acc6543c9..fff7efc5b9713 100644
4406     --- a/net/mac80211/key.c
4407     +++ b/net/mac80211/key.c
4408     @@ -764,6 +764,7 @@ int ieee80211_key_link(struct ieee80211_key *key,
4409     struct ieee80211_sub_if_data *sdata,
4410     struct sta_info *sta)
4411     {
4412     + static atomic_t key_color = ATOMIC_INIT(0);
4413     struct ieee80211_key *old_key;
4414     int idx = key->conf.keyidx;
4415     bool pairwise = key->conf.flags & IEEE80211_KEY_FLAG_PAIRWISE;
4416     @@ -815,6 +816,12 @@ int ieee80211_key_link(struct ieee80211_key *key,
4417     key->sdata = sdata;
4418     key->sta = sta;
4419    
4420     + /*
4421     + * Assign a unique ID to every key so we can easily prevent mixed
4422     + * key and fragment cache attacks.
4423     + */
4424     + key->color = atomic_inc_return(&key_color);
4425     +
4426     increment_tailroom_need_count(sdata);
4427    
4428     ret = ieee80211_key_replace(sdata, sta, pairwise, old_key, key);
4429     diff --git a/net/mac80211/key.h b/net/mac80211/key.h
4430     index d6d6e89cf7dd2..c463938bec99e 100644
4431     --- a/net/mac80211/key.h
4432     +++ b/net/mac80211/key.h
4433     @@ -127,6 +127,8 @@ struct ieee80211_key {
4434     } debugfs;
4435     #endif
4436    
4437     + unsigned int color;
4438     +
4439     /*
4440     * key config, must be last because it contains key
4441     * material as variable length member
4442     diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
4443     index 1a15e7bae106a..3d7a5c5e586a6 100644
4444     --- a/net/mac80211/rx.c
4445     +++ b/net/mac80211/rx.c
4446     @@ -6,7 +6,7 @@
4447     * Copyright 2007-2010 Johannes Berg <johannes@sipsolutions.net>
4448     * Copyright 2013-2014 Intel Mobile Communications GmbH
4449     * Copyright(c) 2015 - 2017 Intel Deutschland GmbH
4450     - * Copyright (C) 2018-2019 Intel Corporation
4451     + * Copyright (C) 2018-2021 Intel Corporation
4452     */
4453    
4454     #include <linux/jiffies.h>
4455     @@ -2083,19 +2083,34 @@ ieee80211_rx_h_decrypt(struct ieee80211_rx_data *rx)
4456     return result;
4457     }
4458    
4459     +void ieee80211_init_frag_cache(struct ieee80211_fragment_cache *cache)
4460     +{
4461     + int i;
4462     +
4463     + for (i = 0; i < ARRAY_SIZE(cache->entries); i++)
4464     + skb_queue_head_init(&cache->entries[i].skb_list);
4465     +}
4466     +
4467     +void ieee80211_destroy_frag_cache(struct ieee80211_fragment_cache *cache)
4468     +{
4469     + int i;
4470     +
4471     + for (i = 0; i < ARRAY_SIZE(cache->entries); i++)
4472     + __skb_queue_purge(&cache->entries[i].skb_list);
4473     +}
4474     +
4475     static inline struct ieee80211_fragment_entry *
4476     -ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
4477     +ieee80211_reassemble_add(struct ieee80211_fragment_cache *cache,
4478     unsigned int frag, unsigned int seq, int rx_queue,
4479     struct sk_buff **skb)
4480     {
4481     struct ieee80211_fragment_entry *entry;
4482    
4483     - entry = &sdata->fragments[sdata->fragment_next++];
4484     - if (sdata->fragment_next >= IEEE80211_FRAGMENT_MAX)
4485     - sdata->fragment_next = 0;
4486     + entry = &cache->entries[cache->next++];
4487     + if (cache->next >= IEEE80211_FRAGMENT_MAX)
4488     + cache->next = 0;
4489    
4490     - if (!skb_queue_empty(&entry->skb_list))
4491     - __skb_queue_purge(&entry->skb_list);
4492     + __skb_queue_purge(&entry->skb_list);
4493    
4494     __skb_queue_tail(&entry->skb_list, *skb); /* no need for locking */
4495     *skb = NULL;
4496     @@ -2110,14 +2125,14 @@ ieee80211_reassemble_add(struct ieee80211_sub_if_data *sdata,
4497     }
4498    
4499     static inline struct ieee80211_fragment_entry *
4500     -ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
4501     +ieee80211_reassemble_find(struct ieee80211_fragment_cache *cache,
4502     unsigned int frag, unsigned int seq,
4503     int rx_queue, struct ieee80211_hdr *hdr)
4504     {
4505     struct ieee80211_fragment_entry *entry;
4506     int i, idx;
4507    
4508     - idx = sdata->fragment_next;
4509     + idx = cache->next;
4510     for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++) {
4511     struct ieee80211_hdr *f_hdr;
4512     struct sk_buff *f_skb;
4513     @@ -2126,7 +2141,7 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
4514     if (idx < 0)
4515     idx = IEEE80211_FRAGMENT_MAX - 1;
4516    
4517     - entry = &sdata->fragments[idx];
4518     + entry = &cache->entries[idx];
4519     if (skb_queue_empty(&entry->skb_list) || entry->seq != seq ||
4520     entry->rx_queue != rx_queue ||
4521     entry->last_frag + 1 != frag)
4522     @@ -2154,15 +2169,27 @@ ieee80211_reassemble_find(struct ieee80211_sub_if_data *sdata,
4523     return NULL;
4524     }
4525    
4526     +static bool requires_sequential_pn(struct ieee80211_rx_data *rx, __le16 fc)
4527     +{
4528     + return rx->key &&
4529     + (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP ||
4530     + rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 ||
4531     + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP ||
4532     + rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) &&
4533     + ieee80211_has_protected(fc);
4534     +}
4535     +
4536     static ieee80211_rx_result debug_noinline
4537     ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4538     {
4539     + struct ieee80211_fragment_cache *cache = &rx->sdata->frags;
4540     struct ieee80211_hdr *hdr;
4541     u16 sc;
4542     __le16 fc;
4543     unsigned int frag, seq;
4544     struct ieee80211_fragment_entry *entry;
4545     struct sk_buff *skb;
4546     + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(rx->skb);
4547    
4548     hdr = (struct ieee80211_hdr *)rx->skb->data;
4549     fc = hdr->frame_control;
4550     @@ -2178,6 +2205,9 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4551     goto out_no_led;
4552     }
4553    
4554     + if (rx->sta)
4555     + cache = &rx->sta->frags;
4556     +
4557     if (likely(!ieee80211_has_morefrags(fc) && frag == 0))
4558     goto out;
4559    
4560     @@ -2196,20 +2226,17 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4561    
4562     if (frag == 0) {
4563     /* This is the first fragment of a new frame. */
4564     - entry = ieee80211_reassemble_add(rx->sdata, frag, seq,
4565     + entry = ieee80211_reassemble_add(cache, frag, seq,
4566     rx->seqno_idx, &(rx->skb));
4567     - if (rx->key &&
4568     - (rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP ||
4569     - rx->key->conf.cipher == WLAN_CIPHER_SUITE_CCMP_256 ||
4570     - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP ||
4571     - rx->key->conf.cipher == WLAN_CIPHER_SUITE_GCMP_256) &&
4572     - ieee80211_has_protected(fc)) {
4573     + if (requires_sequential_pn(rx, fc)) {
4574     int queue = rx->security_idx;
4575    
4576     /* Store CCMP/GCMP PN so that we can verify that the
4577     * next fragment has a sequential PN value.
4578     */
4579     entry->check_sequential_pn = true;
4580     + entry->is_protected = true;
4581     + entry->key_color = rx->key->color;
4582     memcpy(entry->last_pn,
4583     rx->key->u.ccmp.rx_pn[queue],
4584     IEEE80211_CCMP_PN_LEN);
4585     @@ -2221,6 +2248,11 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4586     sizeof(rx->key->u.gcmp.rx_pn[queue]));
4587     BUILD_BUG_ON(IEEE80211_CCMP_PN_LEN !=
4588     IEEE80211_GCMP_PN_LEN);
4589     + } else if (rx->key &&
4590     + (ieee80211_has_protected(fc) ||
4591     + (status->flag & RX_FLAG_DECRYPTED))) {
4592     + entry->is_protected = true;
4593     + entry->key_color = rx->key->color;
4594     }
4595     return RX_QUEUED;
4596     }
4597     @@ -2228,7 +2260,7 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4598     /* This is a fragment for a frame that should already be pending in
4599     * fragment cache. Add this fragment to the end of the pending entry.
4600     */
4601     - entry = ieee80211_reassemble_find(rx->sdata, frag, seq,
4602     + entry = ieee80211_reassemble_find(cache, frag, seq,
4603     rx->seqno_idx, hdr);
4604     if (!entry) {
4605     I802_DEBUG_INC(rx->local->rx_handlers_drop_defrag);
4606     @@ -2243,25 +2275,39 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
4607     if (entry->check_sequential_pn) {
4608     int i;
4609     u8 pn[IEEE80211_CCMP_PN_LEN], *rpn;
4610     - int queue;
4611    
4612     - if (!rx->key ||
4613     - (rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP &&
4614     - rx->key->conf.cipher != WLAN_CIPHER_SUITE_CCMP_256 &&
4615     - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP &&
4616     - rx->key->conf.cipher != WLAN_CIPHER_SUITE_GCMP_256))
4617     + if (!requires_sequential_pn(rx, fc))
4618     + return RX_DROP_UNUSABLE;
4619     +
4620     + /* Prevent mixed key and fragment cache attacks */
4621     + if (entry->key_color != rx->key->color)
4622     return RX_DROP_UNUSABLE;
4623     +
4624     memcpy(pn, entry->last_pn, IEEE80211_CCMP_PN_LEN);
4625     for (i = IEEE80211_CCMP_PN_LEN - 1; i >= 0; i--) {
4626     pn[i]++;
4627     if (pn[i])
4628     break;
4629     }
4630     - queue = rx->security_idx;
4631     - rpn = rx->key->u.ccmp.rx_pn[queue];
4632     +
4633     + rpn = rx->ccm_gcm.pn;
4634     if (memcmp(pn, rpn, IEEE80211_CCMP_PN_LEN))
4635     return RX_DROP_UNUSABLE;
4636     memcpy(entry->last_pn, pn, IEEE80211_CCMP_PN_LEN);
4637     + } else if (entry->is_protected &&
4638     + (!rx->key ||
4639     + (!ieee80211_has_protected(fc) &&
4640     + !(status->flag & RX_FLAG_DECRYPTED)) ||
4641     + rx->key->color != entry->key_color)) {
4642     + /* Drop this as a mixed key or fragment cache attack, even
4643     + * if for TKIP Michael MIC should protect us, and WEP is a
4644     + * lost cause anyway.
4645     + */
4646     + return RX_DROP_UNUSABLE;
4647     + } else if (entry->is_protected && rx->key &&
4648     + entry->key_color != rx->key->color &&
4649     + (status->flag & RX_FLAG_DECRYPTED)) {
4650     + return RX_DROP_UNUSABLE;
4651     }
4652    
4653     skb_pull(rx->skb, ieee80211_hdrlen(fc));
4654     @@ -2447,13 +2493,13 @@ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc)
4655     struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
4656    
4657     /*
4658     - * Allow EAPOL frames to us/the PAE group address regardless
4659     - * of whether the frame was encrypted or not.
4660     + * Allow EAPOL frames to us/the PAE group address regardless of
4661     + * whether the frame was encrypted or not, and always disallow
4662     + * all other destination addresses for them.
4663     */
4664     - if (ehdr->h_proto == rx->sdata->control_port_protocol &&
4665     - (ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
4666     - ether_addr_equal(ehdr->h_dest, pae_group_addr)))
4667     - return true;
4668     + if (unlikely(ehdr->h_proto == rx->sdata->control_port_protocol))
4669     + return ether_addr_equal(ehdr->h_dest, rx->sdata->vif.addr) ||
4670     + ether_addr_equal(ehdr->h_dest, pae_group_addr);
4671    
4672     if (ieee80211_802_1x_port_control(rx) ||
4673     ieee80211_drop_unencrypted(rx, fc))
4674     @@ -2477,8 +2523,28 @@ static void ieee80211_deliver_skb_to_local_stack(struct sk_buff *skb,
4675     cfg80211_rx_control_port(dev, skb, noencrypt);
4676     dev_kfree_skb(skb);
4677     } else {
4678     + struct ethhdr *ehdr = (void *)skb_mac_header(skb);
4679     +
4680     memset(skb->cb, 0, sizeof(skb->cb));
4681    
4682     + /*
4683     + * 802.1X over 802.11 requires that the authenticator address
4684     + * be used for EAPOL frames. However, 802.1X allows the use of
4685     + * the PAE group address instead. If the interface is part of
4686     + * a bridge and we pass the frame with the PAE group address,
4687     + * then the bridge will forward it to the network (even if the
4688     + * client was not associated yet), which isn't supposed to
4689     + * happen.
4690     + * To avoid that, rewrite the destination address to our own
4691     + * address, so that the authenticator (e.g. hostapd) will see
4692     + * the frame, but bridge won't forward it anywhere else. Note
4693     + * that due to earlier filtering, the only other address can
4694     + * be the PAE group address.
4695     + */
4696     + if (unlikely(skb->protocol == sdata->control_port_protocol &&
4697     + !ether_addr_equal(ehdr->h_dest, sdata->vif.addr)))
4698     + ether_addr_copy(ehdr->h_dest, sdata->vif.addr);
4699     +
4700     /* deliver to local stack */
4701     if (rx->napi)
4702     napi_gro_receive(rx->napi, skb);
4703     @@ -2518,6 +2584,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
4704     if ((sdata->vif.type == NL80211_IFTYPE_AP ||
4705     sdata->vif.type == NL80211_IFTYPE_AP_VLAN) &&
4706     !(sdata->flags & IEEE80211_SDATA_DONT_BRIDGE_PACKETS) &&
4707     + ehdr->h_proto != rx->sdata->control_port_protocol &&
4708     (sdata->vif.type != NL80211_IFTYPE_AP_VLAN || !sdata->u.vlan.sta)) {
4709     if (is_multicast_ether_addr(ehdr->h_dest) &&
4710     ieee80211_vif_get_num_mcast_if(sdata) != 0) {
4711     @@ -2627,7 +2694,7 @@ __ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx, u8 data_offset)
4712     if (ieee80211_data_to_8023_exthdr(skb, &ethhdr,
4713     rx->sdata->vif.addr,
4714     rx->sdata->vif.type,
4715     - data_offset))
4716     + data_offset, true))
4717     return RX_DROP_UNUSABLE;
4718    
4719     ieee80211_amsdu_to_8023s(skb, &frame_list, dev->dev_addr,
4720     @@ -2684,6 +2751,23 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx)
4721     if (is_multicast_ether_addr(hdr->addr1))
4722     return RX_DROP_UNUSABLE;
4723    
4724     + if (rx->key) {
4725     + /*
4726     + * We should not receive A-MSDUs on pre-HT connections,
4727     + * and HT connections cannot use old ciphers. Thus drop
4728     + * them, as in those cases we couldn't even have SPP
4729     + * A-MSDUs or such.
4730     + */
4731     + switch (rx->key->conf.cipher) {
4732     + case WLAN_CIPHER_SUITE_WEP40:
4733     + case WLAN_CIPHER_SUITE_WEP104:
4734     + case WLAN_CIPHER_SUITE_TKIP:
4735     + return RX_DROP_UNUSABLE;
4736     + default:
4737     + break;
4738     + }
4739     + }
4740     +
4741     return __ieee80211_rx_h_amsdu(rx, 0);
4742     }
4743    
4744     diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
4745     index 4a23996dce044..82a1dd7b7d689 100644
4746     --- a/net/mac80211/sta_info.c
4747     +++ b/net/mac80211/sta_info.c
4748     @@ -4,7 +4,7 @@
4749     * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
4750     * Copyright 2013-2014 Intel Mobile Communications GmbH
4751     * Copyright (C) 2015 - 2017 Intel Deutschland GmbH
4752     - * Copyright (C) 2018-2020 Intel Corporation
4753     + * Copyright (C) 2018-2021 Intel Corporation
4754     */
4755    
4756     #include <linux/module.h>
4757     @@ -378,6 +378,8 @@ struct sta_info *sta_info_alloc(struct ieee80211_sub_if_data *sdata,
4758    
4759     u64_stats_init(&sta->rx_stats.syncp);
4760    
4761     + ieee80211_init_frag_cache(&sta->frags);
4762     +
4763     sta->sta_state = IEEE80211_STA_NONE;
4764    
4765     /* Mark TID as unreserved */
4766     @@ -1085,6 +1087,8 @@ static void __sta_info_destroy_part2(struct sta_info *sta)
4767    
4768     ieee80211_sta_debugfs_remove(sta);
4769    
4770     + ieee80211_destroy_frag_cache(&sta->frags);
4771     +
4772     cleanup_single_sta(sta);
4773     }
4774    
4775     diff --git a/net/mac80211/sta_info.h b/net/mac80211/sta_info.h
4776     index be1d9dfa760d4..2eb73be9b9865 100644
4777     --- a/net/mac80211/sta_info.h
4778     +++ b/net/mac80211/sta_info.h
4779     @@ -3,6 +3,7 @@
4780     * Copyright 2002-2005, Devicescape Software, Inc.
4781     * Copyright 2013-2014 Intel Mobile Communications GmbH
4782     * Copyright(c) 2015-2017 Intel Deutschland GmbH
4783     + * Copyright(c) 2020-2021 Intel Corporation
4784     */
4785    
4786     #ifndef STA_INFO_H
4787     @@ -425,6 +426,34 @@ struct ieee80211_sta_rx_stats {
4788     u64 msdu[IEEE80211_NUM_TIDS + 1];
4789     };
4790    
4791     +/*
4792     + * IEEE 802.11-2016 (10.6 "Defragmentation") recommends support for "concurrent
4793     + * reception of at least one MSDU per access category per associated STA"
4794     + * on APs, or "at least one MSDU per access category" on other interface types.
4795     + *
4796     + * This limit can be increased by changing this define, at the cost of slower
4797     + * frame reassembly and increased memory use while fragments are pending.
4798     + */
4799     +#define IEEE80211_FRAGMENT_MAX 4
4800     +
4801     +struct ieee80211_fragment_entry {
4802     + struct sk_buff_head skb_list;
4803     + unsigned long first_frag_time;
4804     + u16 seq;
4805     + u16 extra_len;
4806     + u16 last_frag;
4807     + u8 rx_queue;
4808     + u8 check_sequential_pn:1, /* needed for CCMP/GCMP */
4809     + is_protected:1;
4810     + u8 last_pn[6]; /* PN of the last fragment if CCMP was used */
4811     + unsigned int key_color;
4812     +};
4813     +
4814     +struct ieee80211_fragment_cache {
4815     + struct ieee80211_fragment_entry entries[IEEE80211_FRAGMENT_MAX];
4816     + unsigned int next;
4817     +};
4818     +
4819     /*
4820     * The bandwidth threshold below which the per-station CoDel parameters will be
4821     * scaled to be more lenient (to prevent starvation of slow stations). This
4822     @@ -518,6 +547,7 @@ struct ieee80211_sta_rx_stats {
4823     * @status_stats.last_ack_signal: last ACK signal
4824     * @status_stats.ack_signal_filled: last ACK signal validity
4825     * @status_stats.avg_ack_signal: average ACK signal
4826     + * @frags: fragment cache
4827     */
4828     struct sta_info {
4829     /* General information, mostly static */
4830     @@ -623,6 +653,8 @@ struct sta_info {
4831    
4832     struct cfg80211_chan_def tdls_chandef;
4833    
4834     + struct ieee80211_fragment_cache frags;
4835     +
4836     /* keep last! */
4837     struct ieee80211_sta sta;
4838     };
4839     diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
4840     index 91bf32af55e9a..bca47fad5a162 100644
4841     --- a/net/mac80211/wpa.c
4842     +++ b/net/mac80211/wpa.c
4843     @@ -3,6 +3,7 @@
4844     * Copyright 2002-2004, Instant802 Networks, Inc.
4845     * Copyright 2008, Jouni Malinen <j@w1.fi>
4846     * Copyright (C) 2016-2017 Intel Deutschland GmbH
4847     + * Copyright (C) 2020-2021 Intel Corporation
4848     */
4849    
4850     #include <linux/netdevice.h>
4851     @@ -167,8 +168,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
4852    
4853     update_iv:
4854     /* update IV in key information to be able to detect replays */
4855     - rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip_iv32;
4856     - rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip_iv16;
4857     + rx->key->u.tkip.rx[rx->security_idx].iv32 = rx->tkip.iv32;
4858     + rx->key->u.tkip.rx[rx->security_idx].iv16 = rx->tkip.iv16;
4859    
4860     return RX_CONTINUE;
4861    
4862     @@ -294,8 +295,8 @@ ieee80211_crypto_tkip_decrypt(struct ieee80211_rx_data *rx)
4863     key, skb->data + hdrlen,
4864     skb->len - hdrlen, rx->sta->sta.addr,
4865     hdr->addr1, hwaccel, rx->security_idx,
4866     - &rx->tkip_iv32,
4867     - &rx->tkip_iv16);
4868     + &rx->tkip.iv32,
4869     + &rx->tkip.iv16);
4870     if (res != TKIP_DECRYPT_OK)
4871     return RX_DROP_UNUSABLE;
4872    
4873     @@ -553,6 +554,8 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx,
4874     }
4875    
4876     memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
4877     + if (unlikely(ieee80211_is_frag(hdr)))
4878     + memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN);
4879     }
4880    
4881     /* Remove CCMP header and MIC */
4882     @@ -781,6 +784,8 @@ ieee80211_crypto_gcmp_decrypt(struct ieee80211_rx_data *rx)
4883     }
4884    
4885     memcpy(key->u.gcmp.rx_pn[queue], pn, IEEE80211_GCMP_PN_LEN);
4886     + if (unlikely(ieee80211_is_frag(hdr)))
4887     + memcpy(rx->ccm_gcm.pn, pn, IEEE80211_CCMP_PN_LEN);
4888     }
4889    
4890     /* Remove GCMP header and MIC */
4891     diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
4892     index 541eea74ef7a6..c37e09223cbb4 100644
4893     --- a/net/openvswitch/meter.c
4894     +++ b/net/openvswitch/meter.c
4895     @@ -460,6 +460,14 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
4896     spin_lock(&meter->lock);
4897    
4898     long_delta_ms = (now_ms - meter->used); /* ms */
4899     + if (long_delta_ms < 0) {
4900     + /* This condition means that we have several threads fighting
4901     + * for a meter lock, and the one who received the packets a
4902     + * bit later wins. Assuming that all racing threads received
4903     + * packets at the same time to avoid overflow.
4904     + */
4905     + long_delta_ms = 0;
4906     + }
4907    
4908     /* Make sure delta_ms will not be too large, so that bucket will not
4909     * wrap around below.
4910     diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
4911     index 2b88710994d71..76ed1a05ded27 100644
4912     --- a/net/sched/sch_dsmark.c
4913     +++ b/net/sched/sch_dsmark.c
4914     @@ -406,7 +406,8 @@ static void dsmark_reset(struct Qdisc *sch)
4915     struct dsmark_qdisc_data *p = qdisc_priv(sch);
4916    
4917     pr_debug("%s(sch %p,[qdisc %p])\n", __func__, sch, p);
4918     - qdisc_reset(p->q);
4919     + if (p->q)
4920     + qdisc_reset(p->q);
4921     sch->qstats.backlog = 0;
4922     sch->q.qlen = 0;
4923     }
4924     diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
4925     index 6e6147a81bc3a..9bc5cbe9809b8 100644
4926     --- a/net/sched/sch_generic.c
4927     +++ b/net/sched/sch_generic.c
4928     @@ -35,6 +35,25 @@
4929     const struct Qdisc_ops *default_qdisc_ops = &pfifo_fast_ops;
4930     EXPORT_SYMBOL(default_qdisc_ops);
4931    
4932     +static void qdisc_maybe_clear_missed(struct Qdisc *q,
4933     + const struct netdev_queue *txq)
4934     +{
4935     + clear_bit(__QDISC_STATE_MISSED, &q->state);
4936     +
4937     + /* Make sure the below netif_xmit_frozen_or_stopped()
4938     + * checking happens after clearing STATE_MISSED.
4939     + */
4940     + smp_mb__after_atomic();
4941     +
4942     + /* Checking netif_xmit_frozen_or_stopped() again to
4943     + * make sure STATE_MISSED is set if the STATE_MISSED
4944     + * set by netif_tx_wake_queue()'s rescheduling of
4945     + * net_tx_action() is cleared by the above clear_bit().
4946     + */
4947     + if (!netif_xmit_frozen_or_stopped(txq))
4948     + set_bit(__QDISC_STATE_MISSED, &q->state);
4949     +}
4950     +
4951     /* Main transmission queue. */
4952    
4953     /* Modifications to data participating in scheduling must be protected with
4954     @@ -74,6 +93,7 @@ static inline struct sk_buff *__skb_dequeue_bad_txq(struct Qdisc *q)
4955     }
4956     } else {
4957     skb = SKB_XOFF_MAGIC;
4958     + qdisc_maybe_clear_missed(q, txq);
4959     }
4960     }
4961    
4962     @@ -242,6 +262,7 @@ static struct sk_buff *dequeue_skb(struct Qdisc *q, bool *validate,
4963     }
4964     } else {
4965     skb = NULL;
4966     + qdisc_maybe_clear_missed(q, txq);
4967     }
4968     if (lock)
4969     spin_unlock(lock);
4970     @@ -251,8 +272,10 @@ validate:
4971     *validate = true;
4972    
4973     if ((q->flags & TCQ_F_ONETXQUEUE) &&
4974     - netif_xmit_frozen_or_stopped(txq))
4975     + netif_xmit_frozen_or_stopped(txq)) {
4976     + qdisc_maybe_clear_missed(q, txq);
4977     return skb;
4978     + }
4979    
4980     skb = qdisc_dequeue_skb_bad_txq(q);
4981     if (unlikely(skb)) {
4982     @@ -311,6 +334,8 @@ bool sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
4983     HARD_TX_LOCK(dev, txq, smp_processor_id());
4984     if (!netif_xmit_frozen_or_stopped(txq))
4985     skb = dev_hard_start_xmit(skb, dev, txq, &ret);
4986     + else
4987     + qdisc_maybe_clear_missed(q, txq);
4988    
4989     HARD_TX_UNLOCK(dev, txq);
4990     } else {
4991     @@ -645,8 +670,10 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
4992     {
4993     struct pfifo_fast_priv *priv = qdisc_priv(qdisc);
4994     struct sk_buff *skb = NULL;
4995     + bool need_retry = true;
4996     int band;
4997    
4998     +retry:
4999     for (band = 0; band < PFIFO_FAST_BANDS && !skb; band++) {
5000     struct skb_array *q = band2list(priv, band);
5001    
5002     @@ -657,6 +684,23 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc *qdisc)
5003     }
5004     if (likely(skb)) {
5005     qdisc_update_stats_at_dequeue(qdisc, skb);
5006     + } else if (need_retry &&
5007     + test_bit(__QDISC_STATE_MISSED, &qdisc->state)) {
5008     + /* Delay clearing the STATE_MISSED here to reduce
5009     + * the overhead of the second spin_trylock() in
5010     + * qdisc_run_begin() and __netif_schedule() calling
5011     + * in qdisc_run_end().
5012     + */
5013     + clear_bit(__QDISC_STATE_MISSED, &qdisc->state);
5014     +
5015     + /* Make sure dequeuing happens after clearing
5016     + * STATE_MISSED.
5017     + */
5018     + smp_mb__after_atomic();
5019     +
5020     + need_retry = false;
5021     +
5022     + goto retry;
5023     } else {
5024     WRITE_ONCE(qdisc->empty, true);
5025     }
5026     @@ -1157,8 +1201,10 @@ static void dev_reset_queue(struct net_device *dev,
5027     qdisc_reset(qdisc);
5028    
5029     spin_unlock_bh(qdisc_lock(qdisc));
5030     - if (nolock)
5031     + if (nolock) {
5032     + clear_bit(__QDISC_STATE_MISSED, &qdisc->state);
5033     spin_unlock_bh(&qdisc->seqlock);
5034     + }
5035     }
5036    
5037     static bool some_qdisc_is_busy(struct net_device *dev)
5038     diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c
5039     index e89e918b88e09..2fff79db1a59c 100644
5040     --- a/net/smc/smc_ism.c
5041     +++ b/net/smc/smc_ism.c
5042     @@ -289,11 +289,6 @@ struct smcd_dev *smcd_alloc_dev(struct device *parent, const char *name,
5043     INIT_LIST_HEAD(&smcd->vlan);
5044     smcd->event_wq = alloc_ordered_workqueue("ism_evt_wq-%s)",
5045     WQ_MEM_RECLAIM, name);
5046     - if (!smcd->event_wq) {
5047     - kfree(smcd->conn);
5048     - kfree(smcd);
5049     - return NULL;
5050     - }
5051     return smcd;
5052     }
5053     EXPORT_SYMBOL_GPL(smcd_alloc_dev);
5054     diff --git a/net/tipc/core.c b/net/tipc/core.c
5055     index e3d79f8b69d81..90cf7e0bbaf0f 100644
5056     --- a/net/tipc/core.c
5057     +++ b/net/tipc/core.c
5058     @@ -107,6 +107,9 @@ static void __net_exit tipc_exit_net(struct net *net)
5059     tipc_bcast_stop(net);
5060     tipc_nametbl_stop(net);
5061     tipc_sk_rht_destroy(net);
5062     +
5063     + while (atomic_read(&tn->wq_count))
5064     + cond_resched();
5065     }
5066    
5067     static struct pernet_operations tipc_net_ops = {
5068     diff --git a/net/tipc/core.h b/net/tipc/core.h
5069     index e119c4a88d63e..c6bda91f85810 100644
5070     --- a/net/tipc/core.h
5071     +++ b/net/tipc/core.h
5072     @@ -143,6 +143,8 @@ struct tipc_net {
5073    
5074     /* Work item for net finalize */
5075     struct tipc_net_work final_work;
5076     + /* The numbers of work queues in schedule */
5077     + atomic_t wq_count;
5078     };
5079    
5080     static inline struct tipc_net *tipc_net(struct net *net)
5081     diff --git a/net/tipc/msg.c b/net/tipc/msg.c
5082     index 46e89c992c2dc..e4ea942873d49 100644
5083     --- a/net/tipc/msg.c
5084     +++ b/net/tipc/msg.c
5085     @@ -141,18 +141,13 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
5086     if (unlikely(head))
5087     goto err;
5088     *buf = NULL;
5089     + if (skb_has_frag_list(frag) && __skb_linearize(frag))
5090     + goto err;
5091     frag = skb_unshare(frag, GFP_ATOMIC);
5092     if (unlikely(!frag))
5093     goto err;
5094     head = *headbuf = frag;
5095     TIPC_SKB_CB(head)->tail = NULL;
5096     - if (skb_is_nonlinear(head)) {
5097     - skb_walk_frags(head, tail) {
5098     - TIPC_SKB_CB(head)->tail = tail;
5099     - }
5100     - } else {
5101     - skb_frag_list_init(head);
5102     - }
5103     return 0;
5104     }
5105    
5106     diff --git a/net/tipc/socket.c b/net/tipc/socket.c
5107     index b2c36dcfc8e2f..cdade990fe445 100644
5108     --- a/net/tipc/socket.c
5109     +++ b/net/tipc/socket.c
5110     @@ -1210,7 +1210,10 @@ void tipc_sk_mcast_rcv(struct net *net, struct sk_buff_head *arrvq,
5111     spin_lock_bh(&inputq->lock);
5112     if (skb_peek(arrvq) == skb) {
5113     skb_queue_splice_tail_init(&tmpq, inputq);
5114     - __skb_dequeue(arrvq);
5115     + /* Decrease the skb's refcnt as increasing in the
5116     + * function tipc_skb_peek
5117     + */
5118     + kfree_skb(__skb_dequeue(arrvq));
5119     }
5120     spin_unlock_bh(&inputq->lock);
5121     __skb_queue_purge(&tmpq);
5122     diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
5123     index 8f0977a9d423c..1fb0535e2eb47 100644
5124     --- a/net/tipc/udp_media.c
5125     +++ b/net/tipc/udp_media.c
5126     @@ -802,6 +802,7 @@ static void cleanup_bearer(struct work_struct *work)
5127     kfree_rcu(rcast, rcu);
5128     }
5129    
5130     + atomic_dec(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
5131     dst_cache_destroy(&ub->rcast.dst_cache);
5132     udp_tunnel_sock_release(ub->ubsock);
5133     synchronize_net();
5134     @@ -822,6 +823,7 @@ static void tipc_udp_disable(struct tipc_bearer *b)
5135     RCU_INIT_POINTER(ub->bearer, NULL);
5136    
5137     /* sock_release need to be done outside of rtnl lock */
5138     + atomic_inc(&tipc_net(sock_net(ub->ubsock->sk))->wq_count);
5139     INIT_WORK(&ub->work, cleanup_bearer);
5140     schedule_work(&ub->work);
5141     }
5142     diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
5143     index 0d524ef0d8c80..cdb65aa54be70 100644
5144     --- a/net/tls/tls_sw.c
5145     +++ b/net/tls/tls_sw.c
5146     @@ -37,6 +37,7 @@
5147    
5148     #include <linux/sched/signal.h>
5149     #include <linux/module.h>
5150     +#include <linux/splice.h>
5151     #include <crypto/aead.h>
5152    
5153     #include <net/strparser.h>
5154     @@ -1278,7 +1279,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
5155     }
5156    
5157     static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
5158     - int flags, long timeo, int *err)
5159     + bool nonblock, long timeo, int *err)
5160     {
5161     struct tls_context *tls_ctx = tls_get_ctx(sk);
5162     struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
5163     @@ -1303,7 +1304,7 @@ static struct sk_buff *tls_wait_data(struct sock *sk, struct sk_psock *psock,
5164     if (sock_flag(sk, SOCK_DONE))
5165     return NULL;
5166    
5167     - if ((flags & MSG_DONTWAIT) || !timeo) {
5168     + if (nonblock || !timeo) {
5169     *err = -EAGAIN;
5170     return NULL;
5171     }
5172     @@ -1781,7 +1782,7 @@ int tls_sw_recvmsg(struct sock *sk,
5173     bool async_capable;
5174     bool async = false;
5175    
5176     - skb = tls_wait_data(sk, psock, flags, timeo, &err);
5177     + skb = tls_wait_data(sk, psock, flags & MSG_DONTWAIT, timeo, &err);
5178     if (!skb) {
5179     if (psock) {
5180     int ret = __tcp_bpf_recvmsg(sk, psock,
5181     @@ -1985,9 +1986,9 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
5182    
5183     lock_sock(sk);
5184    
5185     - timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
5186     + timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK);
5187    
5188     - skb = tls_wait_data(sk, NULL, flags, timeo, &err);
5189     + skb = tls_wait_data(sk, NULL, flags & SPLICE_F_NONBLOCK, timeo, &err);
5190     if (!skb)
5191     goto splice_read_end;
5192    
5193     diff --git a/net/wireless/util.c b/net/wireless/util.c
5194     index 9abafd76ec50e..82244e2fc1f54 100644
5195     --- a/net/wireless/util.c
5196     +++ b/net/wireless/util.c
5197     @@ -451,7 +451,7 @@ EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen);
5198    
5199     int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
5200     const u8 *addr, enum nl80211_iftype iftype,
5201     - u8 data_offset)
5202     + u8 data_offset, bool is_amsdu)
5203     {
5204     struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
5205     struct {
5206     @@ -539,7 +539,7 @@ int ieee80211_data_to_8023_exthdr(struct sk_buff *skb, struct ethhdr *ehdr,
5207     skb_copy_bits(skb, hdrlen, &payload, sizeof(payload));
5208     tmp.h_proto = payload.proto;
5209    
5210     - if (likely((ether_addr_equal(payload.hdr, rfc1042_header) &&
5211     + if (likely((!is_amsdu && ether_addr_equal(payload.hdr, rfc1042_header) &&
5212     tmp.h_proto != htons(ETH_P_AARP) &&
5213     tmp.h_proto != htons(ETH_P_IPX)) ||
5214     ether_addr_equal(payload.hdr, bridge_tunnel_header)))
5215     @@ -681,6 +681,9 @@ void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list,
5216     remaining = skb->len - offset;
5217     if (subframe_len > remaining)
5218     goto purge;
5219     + /* mitigate A-MSDU aggregation injection attacks */
5220     + if (ether_addr_equal(eth.h_dest, rfc1042_header))
5221     + goto purge;
5222    
5223     offset += sizeof(struct ethhdr);
5224     last = remaining <= subframe_len + padding;
5225     diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c
5226     index af6b4d89d6952..39911a637e802 100644
5227     --- a/sound/isa/gus/gus_main.c
5228     +++ b/sound/isa/gus/gus_main.c
5229     @@ -77,17 +77,8 @@ static const struct snd_kcontrol_new snd_gus_joystick_control = {
5230    
5231     static void snd_gus_init_control(struct snd_gus_card *gus)
5232     {
5233     - int ret;
5234     -
5235     - if (!gus->ace_flag) {
5236     - ret =
5237     - snd_ctl_add(gus->card,
5238     - snd_ctl_new1(&snd_gus_joystick_control,
5239     - gus));
5240     - if (ret)
5241     - snd_printk(KERN_ERR "gus: snd_ctl_add failed: %d\n",
5242     - ret);
5243     - }
5244     + if (!gus->ace_flag)
5245     + snd_ctl_add(gus->card, snd_ctl_new1(&snd_gus_joystick_control, gus));
5246     }
5247    
5248     /*
5249     diff --git a/sound/isa/sb/sb16_main.c b/sound/isa/sb/sb16_main.c
5250     index 0768bbf8fd713..679f9f48370ff 100644
5251     --- a/sound/isa/sb/sb16_main.c
5252     +++ b/sound/isa/sb/sb16_main.c
5253     @@ -864,14 +864,10 @@ int snd_sb16dsp_pcm(struct snd_sb *chip, int device)
5254     snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_sb16_playback_ops);
5255     snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_sb16_capture_ops);
5256    
5257     - if (chip->dma16 >= 0 && chip->dma8 != chip->dma16) {
5258     - err = snd_ctl_add(card, snd_ctl_new1(
5259     - &snd_sb16_dma_control, chip));
5260     - if (err)
5261     - return err;
5262     - } else {
5263     + if (chip->dma16 >= 0 && chip->dma8 != chip->dma16)
5264     + snd_ctl_add(card, snd_ctl_new1(&snd_sb16_dma_control, chip));
5265     + else
5266     pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
5267     - }
5268    
5269     snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
5270     card->dev,
5271     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
5272     index d02c49e1686b6..b9fa2ee0a40cb 100644
5273     --- a/sound/pci/hda/patch_realtek.c
5274     +++ b/sound/pci/hda/patch_realtek.c
5275     @@ -2593,6 +2593,28 @@ static const struct hda_model_fixup alc882_fixup_models[] = {
5276     {}
5277     };
5278    
5279     +static const struct snd_hda_pin_quirk alc882_pin_fixup_tbl[] = {
5280     + SND_HDA_PIN_QUIRK(0x10ec1220, 0x1043, "ASUS", ALC1220_FIXUP_CLEVO_P950,
5281     + {0x14, 0x01014010},
5282     + {0x15, 0x01011012},
5283     + {0x16, 0x01016011},
5284     + {0x18, 0x01a19040},
5285     + {0x19, 0x02a19050},
5286     + {0x1a, 0x0181304f},
5287     + {0x1b, 0x0221401f},
5288     + {0x1e, 0x01456130}),
5289     + SND_HDA_PIN_QUIRK(0x10ec1220, 0x1462, "MS-7C35", ALC1220_FIXUP_CLEVO_P950,
5290     + {0x14, 0x01015010},
5291     + {0x15, 0x01011012},
5292     + {0x16, 0x01011011},
5293     + {0x18, 0x01a11040},
5294     + {0x19, 0x02a19050},
5295     + {0x1a, 0x0181104f},
5296     + {0x1b, 0x0221401f},
5297     + {0x1e, 0x01451130}),
5298     + {}
5299     +};
5300     +
5301     /*
5302     * BIOS auto configuration
5303     */
5304     @@ -2634,6 +2656,7 @@ static int patch_alc882(struct hda_codec *codec)
5305    
5306     snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
5307     alc882_fixups);
5308     + snd_hda_pick_pin_fixup(codec, alc882_pin_fixup_tbl, alc882_fixups, true);
5309     snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
5310    
5311     alc_auto_parse_customize_define(codec);
5312     diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c
5313     index 6042194d95d3e..8894369e329af 100644
5314     --- a/sound/soc/codecs/cs35l33.c
5315     +++ b/sound/soc/codecs/cs35l33.c
5316     @@ -1201,6 +1201,7 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client,
5317     dev_err(&i2c_client->dev,
5318     "CS35L33 Device ID (%X). Expected ID %X\n",
5319     devid, CS35L33_CHIP_ID);
5320     + ret = -EINVAL;
5321     goto err_enable;
5322     }
5323    
5324     diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c
5325     index dcd2acb2c3cef..5faf8877137ae 100644
5326     --- a/sound/soc/codecs/cs42l42.c
5327     +++ b/sound/soc/codecs/cs42l42.c
5328     @@ -398,6 +398,9 @@ static const struct regmap_config cs42l42_regmap = {
5329     .reg_defaults = cs42l42_reg_defaults,
5330     .num_reg_defaults = ARRAY_SIZE(cs42l42_reg_defaults),
5331     .cache_type = REGCACHE_RBTREE,
5332     +
5333     + .use_single_read = true,
5334     + .use_single_write = true,
5335     };
5336    
5337     static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false);
5338     diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c
5339     index 7fb34422a2a4b..8f70dee958786 100644
5340     --- a/sound/soc/codecs/cs43130.c
5341     +++ b/sound/soc/codecs/cs43130.c
5342     @@ -1735,6 +1735,14 @@ static DEVICE_ATTR(hpload_dc_r, 0444, cs43130_show_dc_r, NULL);
5343     static DEVICE_ATTR(hpload_ac_l, 0444, cs43130_show_ac_l, NULL);
5344     static DEVICE_ATTR(hpload_ac_r, 0444, cs43130_show_ac_r, NULL);
5345    
5346     +static struct attribute *hpload_attrs[] = {
5347     + &dev_attr_hpload_dc_l.attr,
5348     + &dev_attr_hpload_dc_r.attr,
5349     + &dev_attr_hpload_ac_l.attr,
5350     + &dev_attr_hpload_ac_r.attr,
5351     +};
5352     +ATTRIBUTE_GROUPS(hpload);
5353     +
5354     static struct reg_sequence hp_en_cal_seq[] = {
5355     {CS43130_INT_MASK_4, CS43130_INT_MASK_ALL},
5356     {CS43130_HP_MEAS_LOAD_1, 0},
5357     @@ -2302,25 +2310,15 @@ static int cs43130_probe(struct snd_soc_component *component)
5358    
5359     cs43130->hpload_done = false;
5360     if (cs43130->dc_meas) {
5361     - ret = device_create_file(component->dev, &dev_attr_hpload_dc_l);
5362     - if (ret < 0)
5363     - return ret;
5364     -
5365     - ret = device_create_file(component->dev, &dev_attr_hpload_dc_r);
5366     - if (ret < 0)
5367     - return ret;
5368     -
5369     - ret = device_create_file(component->dev, &dev_attr_hpload_ac_l);
5370     - if (ret < 0)
5371     - return ret;
5372     -
5373     - ret = device_create_file(component->dev, &dev_attr_hpload_ac_r);
5374     - if (ret < 0)
5375     + ret = sysfs_create_groups(&component->dev->kobj, hpload_groups);
5376     + if (ret)
5377     return ret;
5378    
5379     cs43130->wq = create_singlethread_workqueue("cs43130_hp");
5380     - if (!cs43130->wq)
5381     + if (!cs43130->wq) {
5382     + sysfs_remove_groups(&component->dev->kobj, hpload_groups);
5383     return -ENOMEM;
5384     + }
5385     INIT_WORK(&cs43130->work, cs43130_imp_meas);
5386     }
5387    
5388     diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
5389     index 2040fecea17b3..5251818e10d33 100644
5390     --- a/sound/usb/mixer_quirks.c
5391     +++ b/sound/usb/mixer_quirks.c
5392     @@ -2268,7 +2268,7 @@ int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
5393     case USB_ID(0x1235, 0x8203): /* Focusrite Scarlett 6i6 2nd Gen */
5394     case USB_ID(0x1235, 0x8204): /* Focusrite Scarlett 18i8 2nd Gen */
5395     case USB_ID(0x1235, 0x8201): /* Focusrite Scarlett 18i20 2nd Gen */
5396     - err = snd_scarlett_gen2_controls_create(mixer);
5397     + err = snd_scarlett_gen2_init(mixer);
5398     break;
5399    
5400     case USB_ID(0x041e, 0x323b): /* Creative Sound Blaster E1 */
5401     diff --git a/sound/usb/mixer_scarlett_gen2.c b/sound/usb/mixer_scarlett_gen2.c
5402     index 74c00c905d245..7a10c9e22c46c 100644
5403     --- a/sound/usb/mixer_scarlett_gen2.c
5404     +++ b/sound/usb/mixer_scarlett_gen2.c
5405     @@ -635,7 +635,7 @@ static int scarlett2_usb(
5406     /* send a second message to get the response */
5407    
5408     err = snd_usb_ctl_msg(mixer->chip->dev,
5409     - usb_sndctrlpipe(mixer->chip->dev, 0),
5410     + usb_rcvctrlpipe(mixer->chip->dev, 0),
5411     SCARLETT2_USB_VENDOR_SPECIFIC_CMD_RESP,
5412     USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
5413     0,
5414     @@ -1997,38 +1997,11 @@ static int scarlett2_mixer_status_create(struct usb_mixer_interface *mixer)
5415     return usb_submit_urb(mixer->urb, GFP_KERNEL);
5416     }
5417    
5418     -/* Entry point */
5419     -int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer)
5420     +static int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer,
5421     + const struct scarlett2_device_info *info)
5422     {
5423     - const struct scarlett2_device_info *info;
5424     int err;
5425    
5426     - /* only use UAC_VERSION_2 */
5427     - if (!mixer->protocol)
5428     - return 0;
5429     -
5430     - switch (mixer->chip->usb_id) {
5431     - case USB_ID(0x1235, 0x8203):
5432     - info = &s6i6_gen2_info;
5433     - break;
5434     - case USB_ID(0x1235, 0x8204):
5435     - info = &s18i8_gen2_info;
5436     - break;
5437     - case USB_ID(0x1235, 0x8201):
5438     - info = &s18i20_gen2_info;
5439     - break;
5440     - default: /* device not (yet) supported */
5441     - return -EINVAL;
5442     - }
5443     -
5444     - if (!(mixer->chip->setup & SCARLETT2_ENABLE)) {
5445     - usb_audio_err(mixer->chip,
5446     - "Focusrite Scarlett Gen 2 Mixer Driver disabled; "
5447     - "use options snd_usb_audio device_setup=1 "
5448     - "to enable and report any issues to g@b4.vu");
5449     - return 0;
5450     - }
5451     -
5452     /* Initialise private data, routing, sequence number */
5453     err = scarlett2_init_private(mixer, info);
5454     if (err < 0)
5455     @@ -2073,3 +2046,51 @@ int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer)
5456    
5457     return 0;
5458     }
5459     +
5460     +int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer)
5461     +{
5462     + struct snd_usb_audio *chip = mixer->chip;
5463     + const struct scarlett2_device_info *info;
5464     + int err;
5465     +
5466     + /* only use UAC_VERSION_2 */
5467     + if (!mixer->protocol)
5468     + return 0;
5469     +
5470     + switch (chip->usb_id) {
5471     + case USB_ID(0x1235, 0x8203):
5472     + info = &s6i6_gen2_info;
5473     + break;
5474     + case USB_ID(0x1235, 0x8204):
5475     + info = &s18i8_gen2_info;
5476     + break;
5477     + case USB_ID(0x1235, 0x8201):
5478     + info = &s18i20_gen2_info;
5479     + break;
5480     + default: /* device not (yet) supported */
5481     + return -EINVAL;
5482     + }
5483     +
5484     + if (!(chip->setup & SCARLETT2_ENABLE)) {
5485     + usb_audio_info(chip,
5486     + "Focusrite Scarlett Gen 2 Mixer Driver disabled; "
5487     + "use options snd_usb_audio vid=0x%04x pid=0x%04x "
5488     + "device_setup=1 to enable and report any issues "
5489     + "to g@b4.vu",
5490     + USB_ID_VENDOR(chip->usb_id),
5491     + USB_ID_PRODUCT(chip->usb_id));
5492     + return 0;
5493     + }
5494     +
5495     + usb_audio_info(chip,
5496     + "Focusrite Scarlett Gen 2 Mixer Driver enabled pid=0x%04x",
5497     + USB_ID_PRODUCT(chip->usb_id));
5498     +
5499     + err = snd_scarlett_gen2_controls_create(mixer, info);
5500     + if (err < 0)
5501     + usb_audio_err(mixer->chip,
5502     + "Error initialising Scarlett Mixer Driver: %d",
5503     + err);
5504     +
5505     + return err;
5506     +}
5507     diff --git a/sound/usb/mixer_scarlett_gen2.h b/sound/usb/mixer_scarlett_gen2.h
5508     index 52e1dad77afd4..668c6b0cb50a6 100644
5509     --- a/sound/usb/mixer_scarlett_gen2.h
5510     +++ b/sound/usb/mixer_scarlett_gen2.h
5511     @@ -2,6 +2,6 @@
5512     #ifndef __USB_MIXER_SCARLETT_GEN2_H
5513     #define __USB_MIXER_SCARLETT_GEN2_H
5514    
5515     -int snd_scarlett_gen2_controls_create(struct usb_mixer_interface *mixer);
5516     +int snd_scarlett_gen2_init(struct usb_mixer_interface *mixer);
5517    
5518     #endif /* __USB_MIXER_SCARLETT_GEN2_H */
5519     diff --git a/tools/perf/pmu-events/jevents.c b/tools/perf/pmu-events/jevents.c
5520     index f4a0d72246cb7..47f57f5829d3a 100644
5521     --- a/tools/perf/pmu-events/jevents.c
5522     +++ b/tools/perf/pmu-events/jevents.c
5523     @@ -862,7 +862,7 @@ static int get_maxfds(void)
5524     struct rlimit rlim;
5525    
5526     if (getrlimit(RLIMIT_NOFILE, &rlim) == 0)
5527     - return min((int)rlim.rlim_max / 2, 512);
5528     + return min(rlim.rlim_max / 2, (rlim_t)512);
5529    
5530     return 512;
5531     }
5532     diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py
5533     index 04217e8f535aa..01acf3ea7619d 100755
5534     --- a/tools/perf/scripts/python/exported-sql-viewer.py
5535     +++ b/tools/perf/scripts/python/exported-sql-viewer.py
5536     @@ -91,6 +91,11 @@
5537     from __future__ import print_function
5538    
5539     import sys
5540     +# Only change warnings if the python -W option was not used
5541     +if not sys.warnoptions:
5542     + import warnings
5543     + # PySide2 causes deprecation warnings, ignore them.
5544     + warnings.filterwarnings("ignore", category=DeprecationWarning)
5545     import argparse
5546     import weakref
5547     import threading
5548     @@ -122,8 +127,9 @@ if pyside_version_1:
5549     from PySide.QtGui import *
5550     from PySide.QtSql import *
5551    
5552     -from decimal import *
5553     -from ctypes import *
5554     +from decimal import Decimal, ROUND_HALF_UP
5555     +from ctypes import CDLL, Structure, create_string_buffer, addressof, sizeof, \
5556     + c_void_p, c_bool, c_byte, c_char, c_int, c_uint, c_longlong, c_ulonglong
5557     from multiprocessing import Process, Array, Value, Event
5558    
5559     # xrange is range in Python3
5560     @@ -2495,7 +2501,7 @@ def CopyTableCellsToClipboard(view, as_csv=False, with_hdr=False):
5561     if with_hdr:
5562     model = indexes[0].model()
5563     for col in range(min_col, max_col + 1):
5564     - val = model.headerData(col, Qt.Horizontal)
5565     + val = model.headerData(col, Qt.Horizontal, Qt.DisplayRole)
5566     if as_csv:
5567     text += sep + ToCSValue(val)
5568     sep = ","
5569     diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
5570     index 7f53b63088b2c..eab7e8ef67899 100644
5571     --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
5572     +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
5573     @@ -1090,6 +1090,8 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
5574     decoder->set_fup_tx_flags = false;
5575     decoder->tx_flags = decoder->fup_tx_flags;
5576     decoder->state.type = INTEL_PT_TRANSACTION;
5577     + if (decoder->fup_tx_flags & INTEL_PT_ABORT_TX)
5578     + decoder->state.type |= INTEL_PT_BRANCH;
5579     decoder->state.from_ip = decoder->ip;
5580     decoder->state.to_ip = 0;
5581     decoder->state.flags = decoder->fup_tx_flags;
5582     @@ -1164,8 +1166,10 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
5583     return 0;
5584     if (err == -EAGAIN ||
5585     intel_pt_fup_with_nlip(decoder, &intel_pt_insn, ip, err)) {
5586     + bool no_tip = decoder->pkt_state != INTEL_PT_STATE_FUP;
5587     +
5588     decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
5589     - if (intel_pt_fup_event(decoder))
5590     + if (intel_pt_fup_event(decoder) && no_tip)
5591     return 0;
5592     return -EAGAIN;
5593     }
5594     diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
5595     index d0e0ce11faf58..9b7cc5f909b07 100644
5596     --- a/tools/perf/util/intel-pt.c
5597     +++ b/tools/perf/util/intel-pt.c
5598     @@ -602,8 +602,10 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
5599    
5600     *ip += intel_pt_insn->length;
5601    
5602     - if (to_ip && *ip == to_ip)
5603     + if (to_ip && *ip == to_ip) {
5604     + intel_pt_insn->length = 0;
5605     goto out_no_cache;
5606     + }
5607    
5608     if (*ip >= al.map->end)
5609     break;
5610     @@ -991,6 +993,7 @@ static void intel_pt_set_pid_tid_cpu(struct intel_pt *pt,
5611    
5612     static void intel_pt_sample_flags(struct intel_pt_queue *ptq)
5613     {
5614     + ptq->insn_len = 0;
5615     if (ptq->state->flags & INTEL_PT_ABORT_TX) {
5616     ptq->flags = PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT;
5617     } else if (ptq->state->flags & INTEL_PT_ASYNC) {
5618     diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
5619     index 0bb80619db580..f270b6abd64c5 100644
5620     --- a/tools/testing/selftests/gpio/Makefile
5621     +++ b/tools/testing/selftests/gpio/Makefile
5622     @@ -11,22 +11,24 @@ LDLIBS += $(MOUNT_LDLIBS)
5623    
5624     TEST_PROGS := gpio-mockup.sh
5625     TEST_FILES := gpio-mockup-sysfs.sh
5626     -TEST_PROGS_EXTENDED := gpio-mockup-chardev
5627     +TEST_GEN_PROGS_EXTENDED := gpio-mockup-chardev
5628    
5629     -GPIODIR := $(realpath ../../../gpio)
5630     -GPIOOBJ := gpio-utils.o
5631     +KSFT_KHDR_INSTALL := 1
5632     +include ../lib.mk
5633    
5634     -all: $(TEST_PROGS_EXTENDED)
5635     +GPIODIR := $(realpath ../../../gpio)
5636     +GPIOOUT := $(OUTPUT)/tools-gpio/
5637     +GPIOOBJ := $(GPIOOUT)/gpio-utils.o
5638    
5639     override define CLEAN
5640     - $(RM) $(TEST_PROGS_EXTENDED)
5641     - $(MAKE) -C $(GPIODIR) OUTPUT=$(GPIODIR)/ clean
5642     + $(RM) $(TEST_GEN_PROGS_EXTENDED)
5643     + $(RM) -rf $(GPIOOUT)
5644     endef
5645    
5646     -KSFT_KHDR_INSTALL := 1
5647     -include ../lib.mk
5648     +$(TEST_GEN_PROGS_EXTENDED): $(GPIOOBJ)
5649    
5650     -$(TEST_PROGS_EXTENDED): $(GPIODIR)/$(GPIOOBJ)
5651     +$(GPIOOUT):
5652     + mkdir -p $@
5653    
5654     -$(GPIODIR)/$(GPIOOBJ):
5655     - $(MAKE) OUTPUT=$(GPIODIR)/ -C $(GPIODIR)
5656     +$(GPIOOBJ): $(GPIOOUT)
5657     + $(MAKE) OUTPUT=$(GPIOOUT) -C $(GPIODIR)