Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.9/0317-4.9.218-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3592 - (hide annotations) (download)
Thu Aug 13 10:21:33 2020 UTC (4 years, 1 month ago) by niro
File size: 94803 byte(s)
linux-218
1 niro 3592 diff --git a/Documentation/devicetree/bindings/powerpc/fsl/fman.txt b/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
2     index df873d1f3b7c..2aaae210317b 100644
3     --- a/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
4     +++ b/Documentation/devicetree/bindings/powerpc/fsl/fman.txt
5     @@ -110,6 +110,13 @@ PROPERTIES
6     Usage: required
7     Definition: See soc/fsl/qman.txt and soc/fsl/bman.txt
8    
9     +- fsl,erratum-a050385
10     + Usage: optional
11     + Value type: boolean
12     + Definition: A boolean property. Indicates the presence of the
13     + erratum A050385 which indicates that DMA transactions that are
14     + split can result in a FMan lock.
15     +
16     =============================================================================
17     FMan MURAM Node
18    
19     diff --git a/Makefile b/Makefile
20     index 96b230200cbe..1a491b3afc0c 100644
21     --- a/Makefile
22     +++ b/Makefile
23     @@ -1,6 +1,6 @@
24     VERSION = 4
25     PATCHLEVEL = 9
26     -SUBLEVEL = 217
27     +SUBLEVEL = 218
28     EXTRAVERSION =
29     NAME = Roaring Lionus
30    
31     diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi
32     index a1a928064b53..204ba77e3e4d 100644
33     --- a/arch/arm/boot/dts/dra7.dtsi
34     +++ b/arch/arm/boot/dts/dra7.dtsi
35     @@ -123,6 +123,7 @@
36     #address-cells = <1>;
37     #size-cells = <1>;
38     ranges = <0x0 0x0 0x0 0xc0000000>;
39     + dma-ranges = <0x80000000 0x0 0x80000000 0x80000000>;
40     ti,hwmods = "l3_main_1", "l3_main_2";
41     reg = <0x0 0x44000000 0x0 0x1000000>,
42     <0x0 0x45000000 0x0 0x1000>;
43     @@ -282,6 +283,7 @@
44     device_type = "pci";
45     ranges = <0x81000000 0 0 0x03000 0 0x00010000
46     0x82000000 0 0x20013000 0x13000 0 0xffed000>;
47     + dma-ranges = <0x02000000 0x0 0x00000000 0x00000000 0x1 0x00000000>;
48     bus-range = <0x00 0xff>;
49     #interrupt-cells = <1>;
50     num-lanes = <1>;
51     @@ -319,6 +321,7 @@
52     device_type = "pci";
53     ranges = <0x81000000 0 0 0x03000 0 0x00010000
54     0x82000000 0 0x30013000 0x13000 0 0xffed000>;
55     + dma-ranges = <0x02000000 0x0 0x00000000 0x00000000 0x1 0x00000000>;
56     bus-range = <0x00 0xff>;
57     #interrupt-cells = <1>;
58     num-lanes = <1>;
59     diff --git a/arch/arm/boot/dts/omap5.dtsi b/arch/arm/boot/dts/omap5.dtsi
60     index 1d1d8e90cd80..a76266f242a1 100644
61     --- a/arch/arm/boot/dts/omap5.dtsi
62     +++ b/arch/arm/boot/dts/omap5.dtsi
63     @@ -131,6 +131,7 @@
64     #address-cells = <1>;
65     #size-cells = <1>;
66     ranges = <0 0 0 0xc0000000>;
67     + dma-ranges = <0x80000000 0x0 0x80000000 0x80000000>;
68     ti,hwmods = "l3_main_1", "l3_main_2", "l3_main_3";
69     reg = <0 0x44000000 0 0x2000>,
70     <0 0x44800000 0 0x3000>,
71     diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h
72     index 3626655175a2..b7205c254c0d 100644
73     --- a/arch/arm64/include/asm/alternative.h
74     +++ b/arch/arm64/include/asm/alternative.h
75     @@ -215,7 +215,7 @@ alternative_endif
76    
77     .macro user_alt, label, oldinstr, newinstr, cond
78     9999: alternative_insn "\oldinstr", "\newinstr", \cond
79     - _ASM_EXTABLE 9999b, \label
80     + _asm_extable 9999b, \label
81     .endm
82    
83     /*
84     diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
85     index b2d6de9f6f4f..13b9c20a84b5 100644
86     --- a/arch/arm64/kernel/smp.c
87     +++ b/arch/arm64/kernel/smp.c
88     @@ -901,11 +901,22 @@ void tick_broadcast(const struct cpumask *mask)
89     }
90     #endif
91    
92     +/*
93     + * The number of CPUs online, not counting this CPU (which may not be
94     + * fully online and so not counted in num_online_cpus()).
95     + */
96     +static inline unsigned int num_other_online_cpus(void)
97     +{
98     + unsigned int this_cpu_online = cpu_online(smp_processor_id());
99     +
100     + return num_online_cpus() - this_cpu_online;
101     +}
102     +
103     void smp_send_stop(void)
104     {
105     unsigned long timeout;
106    
107     - if (num_online_cpus() > 1) {
108     + if (num_other_online_cpus()) {
109     cpumask_t mask;
110    
111     cpumask_copy(&mask, cpu_online_mask);
112     @@ -919,10 +930,10 @@ void smp_send_stop(void)
113    
114     /* Wait up to one second for other CPUs to stop */
115     timeout = USEC_PER_SEC;
116     - while (num_online_cpus() > 1 && timeout--)
117     + while (num_other_online_cpus() && timeout--)
118     udelay(1);
119    
120     - if (num_online_cpus() > 1)
121     + if (num_other_online_cpus())
122     pr_warning("SMP: failed to stop secondary CPUs %*pbl\n",
123     cpumask_pr_args(cpu_online_mask));
124     }
125     diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
126     index 50d365060855..c20510497c49 100644
127     --- a/arch/powerpc/kernel/vmlinux.lds.S
128     +++ b/arch/powerpc/kernel/vmlinux.lds.S
129     @@ -315,6 +315,12 @@ SECTIONS
130     *(.branch_lt)
131     }
132    
133     +#ifdef CONFIG_DEBUG_INFO_BTF
134     + .BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {
135     + *(.BTF)
136     + }
137     +#endif
138     +
139     .opd : AT(ADDR(.opd) - LOAD_OFFSET) {
140     *(.opd)
141     }
142     diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
143     index 8bd336651de5..1fa4545c55e3 100644
144     --- a/arch/x86/kvm/vmx.c
145     +++ b/arch/x86/kvm/vmx.c
146     @@ -6564,8 +6564,8 @@ static int handle_ept_misconfig(struct kvm_vcpu *vcpu)
147     return 1;
148     }
149     else
150     - return x86_emulate_instruction(vcpu, gpa, EMULTYPE_SKIP,
151     - NULL, 0) == EMULATE_DONE;
152     + return emulate_instruction(vcpu, EMULTYPE_SKIP) ==
153     + EMULATE_DONE;
154     }
155    
156     ret = kvm_mmu_page_fault(vcpu, gpa, PFERR_RSVD_MASK, NULL, 0);
157     diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
158     index 7f4b3c59df47..102b4e78f4e6 100644
159     --- a/arch/x86/mm/fault.c
160     +++ b/arch/x86/mm/fault.c
161     @@ -285,7 +285,7 @@ static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
162     return pmd_k;
163     }
164    
165     -void vmalloc_sync_all(void)
166     +static void vmalloc_sync(void)
167     {
168     unsigned long address;
169    
170     @@ -312,6 +312,16 @@ void vmalloc_sync_all(void)
171     }
172     }
173    
174     +void vmalloc_sync_mappings(void)
175     +{
176     + vmalloc_sync();
177     +}
178     +
179     +void vmalloc_sync_unmappings(void)
180     +{
181     + vmalloc_sync();
182     +}
183     +
184     /*
185     * 32-bit:
186     *
187     @@ -406,11 +416,23 @@ out:
188    
189     #else /* CONFIG_X86_64: */
190    
191     -void vmalloc_sync_all(void)
192     +void vmalloc_sync_mappings(void)
193     {
194     + /*
195     + * 64-bit mappings might allocate new p4d/pud pages
196     + * that need to be propagated to all tasks' PGDs.
197     + */
198     sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END, 0);
199     }
200    
201     +void vmalloc_sync_unmappings(void)
202     +{
203     + /*
204     + * Unmappings never allocate or free p4d/pud pages.
205     + * No work is required here.
206     + */
207     +}
208     +
209     /*
210     * 64-bit:
211     *
212     diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
213     index a6e3c8dc2be4..acb4e7523a1d 100644
214     --- a/drivers/acpi/apei/ghes.c
215     +++ b/drivers/acpi/apei/ghes.c
216     @@ -234,7 +234,7 @@ static int ghes_estatus_pool_expand(unsigned long len)
217     * New allocation must be visible in all pgd before it can be found by
218     * an NMI allocating from the pool.
219     */
220     - vmalloc_sync_all();
221     + vmalloc_sync_mappings();
222    
223     return gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
224     }
225     diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
226     index 17aedaaf364c..e05dda92398c 100644
227     --- a/drivers/gpu/drm/drm_dp_mst_topology.c
228     +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
229     @@ -980,20 +980,9 @@ static struct drm_dp_mst_port *drm_dp_mst_get_port_ref_locked(struct drm_dp_mst_
230     static struct drm_dp_mst_port *drm_dp_get_validated_port_ref(struct drm_dp_mst_topology_mgr *mgr, struct drm_dp_mst_port *port)
231     {
232     struct drm_dp_mst_port *rport = NULL;
233     -
234     mutex_lock(&mgr->lock);
235     - /*
236     - * Port may or may not be 'valid' but we don't care about that when
237     - * destroying the port and we are guaranteed that the port pointer
238     - * will be valid until we've finished
239     - */
240     - if (current_work() == &mgr->destroy_connector_work) {
241     - kref_get(&port->kref);
242     - rport = port;
243     - } else if (mgr->mst_primary) {
244     - rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary,
245     - port);
246     - }
247     + if (mgr->mst_primary)
248     + rport = drm_dp_mst_get_port_ref_locked(mgr->mst_primary, port);
249     mutex_unlock(&mgr->lock);
250     return rport;
251     }
252     diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
253     index e07cb1fe4860..2b6c04acb24f 100644
254     --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
255     +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
256     @@ -1775,8 +1775,9 @@ static int exynos_dsi_probe(struct platform_device *pdev)
257     ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(dsi->supplies),
258     dsi->supplies);
259     if (ret) {
260     - dev_info(dev, "failed to get regulators: %d\n", ret);
261     - return -EPROBE_DEFER;
262     + if (ret != -EPROBE_DEFER)
263     + dev_info(dev, "failed to get regulators: %d\n", ret);
264     + return ret;
265     }
266    
267     dsi->clks = devm_kzalloc(dev,
268     @@ -1789,9 +1790,10 @@ static int exynos_dsi_probe(struct platform_device *pdev)
269     dsi->clks[i] = devm_clk_get(dev, clk_names[i]);
270     if (IS_ERR(dsi->clks[i])) {
271     if (strcmp(clk_names[i], "sclk_mipi") == 0) {
272     - strcpy(clk_names[i], OLD_SCLK_MIPI_CLK_NAME);
273     - i--;
274     - continue;
275     + dsi->clks[i] = devm_clk_get(dev,
276     + OLD_SCLK_MIPI_CLK_NAME);
277     + if (!IS_ERR(dsi->clks[i]))
278     + continue;
279     }
280    
281     dev_info(dev, "failed to get the clock: %s\n",
282     diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c
283     index 7bdd1bfbeedd..73713b239464 100644
284     --- a/drivers/hwtracing/intel_th/msu.c
285     +++ b/drivers/hwtracing/intel_th/msu.c
286     @@ -497,7 +497,7 @@ static int msc_configure(struct msc *msc)
287     lockdep_assert_held(&msc->buf_mutex);
288    
289     if (msc->mode > MSC_MODE_MULTI)
290     - return -ENOTSUPP;
291     + return -EINVAL;
292    
293     if (msc->mode == MSC_MODE_MULTI)
294     msc_buffer_clear_hw_header(msc);
295     @@ -948,7 +948,7 @@ static int msc_buffer_alloc(struct msc *msc, unsigned long *nr_pages,
296     } else if (msc->mode == MSC_MODE_MULTI) {
297     ret = msc_buffer_multi_alloc(msc, nr_pages, nr_wins);
298     } else {
299     - ret = -ENOTSUPP;
300     + ret = -EINVAL;
301     }
302    
303     if (!ret) {
304     @@ -1171,7 +1171,7 @@ static ssize_t intel_th_msc_read(struct file *file, char __user *buf,
305     if (ret >= 0)
306     *ppos = iter->offset;
307     } else {
308     - ret = -ENOTSUPP;
309     + ret = -EINVAL;
310     }
311    
312     put_count:
313     diff --git a/drivers/i2c/busses/i2c-hix5hd2.c b/drivers/i2c/busses/i2c-hix5hd2.c
314     index ae7f3180f7e8..75c8bbb4774f 100644
315     --- a/drivers/i2c/busses/i2c-hix5hd2.c
316     +++ b/drivers/i2c/busses/i2c-hix5hd2.c
317     @@ -498,6 +498,7 @@ static int hix5hd2_i2c_remove(struct platform_device *pdev)
318     i2c_del_adapter(&priv->adap);
319     pm_runtime_disable(priv->dev);
320     pm_runtime_set_suspended(priv->dev);
321     + clk_disable_unprepare(priv->clk);
322    
323     return 0;
324     }
325     diff --git a/drivers/iio/magnetometer/ak8974.c b/drivers/iio/magnetometer/ak8974.c
326     index dd3fcd1704f8..752237f0889e 100644
327     --- a/drivers/iio/magnetometer/ak8974.c
328     +++ b/drivers/iio/magnetometer/ak8974.c
329     @@ -477,7 +477,7 @@ static int ak8974_read_raw(struct iio_dev *indio_dev,
330     * We read all axes and discard all but one, for optimized
331     * reading, use the triggered buffer.
332     */
333     - *val = le16_to_cpu(hw_values[chan->address]);
334     + *val = (s16)le16_to_cpu(hw_values[chan->address]);
335    
336     ret = IIO_VAL_INT;
337     }
338     diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c
339     index a99fb5cac5a0..1f5b6b5b1018 100644
340     --- a/drivers/input/touchscreen/raydium_i2c_ts.c
341     +++ b/drivers/input/touchscreen/raydium_i2c_ts.c
342     @@ -441,7 +441,7 @@ static int raydium_i2c_write_object(struct i2c_client *client,
343     return 0;
344     }
345    
346     -static bool raydium_i2c_boot_trigger(struct i2c_client *client)
347     +static int raydium_i2c_boot_trigger(struct i2c_client *client)
348     {
349     static const u8 cmd[7][6] = {
350     { 0x08, 0x0C, 0x09, 0x00, 0x50, 0xD7 },
351     @@ -469,7 +469,7 @@ static bool raydium_i2c_boot_trigger(struct i2c_client *client)
352     return 0;
353     }
354    
355     -static bool raydium_i2c_fw_trigger(struct i2c_client *client)
356     +static int raydium_i2c_fw_trigger(struct i2c_client *client)
357     {
358     static const u8 cmd[5][11] = {
359     { 0, 0x09, 0x71, 0x0C, 0x09, 0x00, 0x50, 0xD7, 0, 0, 0 },
360     diff --git a/drivers/media/usb/b2c2/flexcop-usb.c b/drivers/media/usb/b2c2/flexcop-usb.c
361     index 78809bb5e69e..a93fc1839e13 100644
362     --- a/drivers/media/usb/b2c2/flexcop-usb.c
363     +++ b/drivers/media/usb/b2c2/flexcop-usb.c
364     @@ -511,6 +511,9 @@ static int flexcop_usb_init(struct flexcop_usb *fc_usb)
365     return ret;
366     }
367    
368     + if (fc_usb->uintf->cur_altsetting->desc.bNumEndpoints < 1)
369     + return -ENODEV;
370     +
371     switch (fc_usb->udev->speed) {
372     case USB_SPEED_LOW:
373     err("cannot handle USB speed because it is too slow.");
374     @@ -544,9 +547,6 @@ static int flexcop_usb_probe(struct usb_interface *intf,
375     struct flexcop_device *fc = NULL;
376     int ret;
377    
378     - if (intf->cur_altsetting->desc.bNumEndpoints < 1)
379     - return -ENODEV;
380     -
381     if ((fc = flexcop_device_kmalloc(sizeof(struct flexcop_usb))) == NULL) {
382     err("out of memory\n");
383     return -ENOMEM;
384     diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c
385     index 563f690cd978..4a5ea74c91d4 100644
386     --- a/drivers/media/usb/dvb-usb/dib0700_core.c
387     +++ b/drivers/media/usb/dvb-usb/dib0700_core.c
388     @@ -812,7 +812,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d, struct usb_interface *intf)
389    
390     /* Starting in firmware 1.20, the RC info is provided on a bulk pipe */
391    
392     - if (intf->altsetting[0].desc.bNumEndpoints < rc_ep + 1)
393     + if (intf->cur_altsetting->desc.bNumEndpoints < rc_ep + 1)
394     return -ENODEV;
395    
396     purb = usb_alloc_urb(0, GFP_KERNEL);
397     @@ -832,7 +832,7 @@ int dib0700_rc_setup(struct dvb_usb_device *d, struct usb_interface *intf)
398     * Some devices like the Hauppauge NovaTD model 52009 use an interrupt
399     * endpoint, while others use a bulk one.
400     */
401     - e = &intf->altsetting[0].endpoint[rc_ep].desc;
402     + e = &intf->cur_altsetting->endpoint[rc_ep].desc;
403     if (usb_endpoint_dir_in(e)) {
404     if (usb_endpoint_xfer_bulk(e)) {
405     pipe = usb_rcvbulkpipe(d->udev, rc_ep);
406     diff --git a/drivers/media/usb/gspca/ov519.c b/drivers/media/usb/gspca/ov519.c
407     index 7ac38905080a..25871bcc03a9 100644
408     --- a/drivers/media/usb/gspca/ov519.c
409     +++ b/drivers/media/usb/gspca/ov519.c
410     @@ -3482,6 +3482,11 @@ static void ov511_mode_init_regs(struct sd *sd)
411     return;
412     }
413    
414     + if (alt->desc.bNumEndpoints < 1) {
415     + sd->gspca_dev.usb_err = -ENODEV;
416     + return;
417     + }
418     +
419     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
420     reg_w(sd, R51x_FIFO_PSIZE, packet_size >> 5);
421    
422     @@ -3607,6 +3612,11 @@ static void ov518_mode_init_regs(struct sd *sd)
423     return;
424     }
425    
426     + if (alt->desc.bNumEndpoints < 1) {
427     + sd->gspca_dev.usb_err = -ENODEV;
428     + return;
429     + }
430     +
431     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
432     ov518_reg_w32(sd, R51x_FIFO_PSIZE, packet_size & ~7, 2);
433    
434     diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx.c b/drivers/media/usb/gspca/stv06xx/stv06xx.c
435     index 6ac93d8db427..7d255529ed4c 100644
436     --- a/drivers/media/usb/gspca/stv06xx/stv06xx.c
437     +++ b/drivers/media/usb/gspca/stv06xx/stv06xx.c
438     @@ -293,6 +293,9 @@ static int stv06xx_start(struct gspca_dev *gspca_dev)
439     return -EIO;
440     }
441    
442     + if (alt->desc.bNumEndpoints < 1)
443     + return -ENODEV;
444     +
445     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
446     err = stv06xx_write_bridge(sd, STV_ISO_SIZE_L, packet_size);
447     if (err < 0)
448     @@ -317,11 +320,21 @@ out:
449    
450     static int stv06xx_isoc_init(struct gspca_dev *gspca_dev)
451     {
452     + struct usb_interface_cache *intfc;
453     struct usb_host_interface *alt;
454     struct sd *sd = (struct sd *) gspca_dev;
455    
456     + intfc = gspca_dev->dev->actconfig->intf_cache[0];
457     +
458     + if (intfc->num_altsetting < 2)
459     + return -ENODEV;
460     +
461     + alt = &intfc->altsetting[1];
462     +
463     + if (alt->desc.bNumEndpoints < 1)
464     + return -ENODEV;
465     +
466     /* Start isoc bandwidth "negotiation" at max isoc bandwidth */
467     - alt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];
468     alt->endpoint[0].desc.wMaxPacketSize =
469     cpu_to_le16(sd->sensor->max_packet_size[gspca_dev->curr_mode]);
470    
471     @@ -334,6 +347,10 @@ static int stv06xx_isoc_nego(struct gspca_dev *gspca_dev)
472     struct usb_host_interface *alt;
473     struct sd *sd = (struct sd *) gspca_dev;
474    
475     + /*
476     + * Existence of altsetting and endpoint was verified in
477     + * stv06xx_isoc_init()
478     + */
479     alt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];
480     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
481     min_packet_size = sd->sensor->min_packet_size[gspca_dev->curr_mode];
482     diff --git a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
483     index 8d785edcccf2..cc88c059b8d7 100644
484     --- a/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
485     +++ b/drivers/media/usb/gspca/stv06xx/stv06xx_pb0100.c
486     @@ -198,6 +198,10 @@ static int pb0100_start(struct sd *sd)
487     alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
488     if (!alt)
489     return -ENODEV;
490     +
491     + if (alt->desc.bNumEndpoints < 1)
492     + return -ENODEV;
493     +
494     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
495    
496     /* If we don't have enough bandwidth use a lower framerate */
497     diff --git a/drivers/media/usb/gspca/xirlink_cit.c b/drivers/media/usb/gspca/xirlink_cit.c
498     index d5ed9d36ce25..2a555b0f0058 100644
499     --- a/drivers/media/usb/gspca/xirlink_cit.c
500     +++ b/drivers/media/usb/gspca/xirlink_cit.c
501     @@ -1455,6 +1455,9 @@ static int cit_get_packet_size(struct gspca_dev *gspca_dev)
502     return -EIO;
503     }
504    
505     + if (alt->desc.bNumEndpoints < 1)
506     + return -ENODEV;
507     +
508     return le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
509     }
510    
511     @@ -2638,6 +2641,7 @@ static int sd_start(struct gspca_dev *gspca_dev)
512    
513     static int sd_isoc_init(struct gspca_dev *gspca_dev)
514     {
515     + struct usb_interface_cache *intfc;
516     struct usb_host_interface *alt;
517     int max_packet_size;
518    
519     @@ -2653,8 +2657,17 @@ static int sd_isoc_init(struct gspca_dev *gspca_dev)
520     break;
521     }
522    
523     + intfc = gspca_dev->dev->actconfig->intf_cache[0];
524     +
525     + if (intfc->num_altsetting < 2)
526     + return -ENODEV;
527     +
528     + alt = &intfc->altsetting[1];
529     +
530     + if (alt->desc.bNumEndpoints < 1)
531     + return -ENODEV;
532     +
533     /* Start isoc bandwidth "negotiation" at max isoc bandwidth */
534     - alt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];
535     alt->endpoint[0].desc.wMaxPacketSize = cpu_to_le16(max_packet_size);
536    
537     return 0;
538     @@ -2677,6 +2690,9 @@ static int sd_isoc_nego(struct gspca_dev *gspca_dev)
539     break;
540     }
541    
542     + /*
543     + * Existence of altsetting and endpoint was verified in sd_isoc_init()
544     + */
545     alt = &gspca_dev->dev->actconfig->intf_cache[0]->altsetting[1];
546     packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
547     if (packet_size <= min_packet_size)
548     diff --git a/drivers/media/usb/usbtv/usbtv-core.c b/drivers/media/usb/usbtv/usbtv-core.c
549     index e56a49a5e8b1..d8ce7d75ff18 100644
550     --- a/drivers/media/usb/usbtv/usbtv-core.c
551     +++ b/drivers/media/usb/usbtv/usbtv-core.c
552     @@ -56,7 +56,7 @@ int usbtv_set_regs(struct usbtv *usbtv, const u16 regs[][2], int size)
553    
554     ret = usb_control_msg(usbtv->udev, pipe, USBTV_REQUEST_REG,
555     USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
556     - value, index, NULL, 0, 0);
557     + value, index, NULL, 0, USB_CTRL_GET_TIMEOUT);
558     if (ret < 0)
559     return ret;
560     }
561     diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c
562     index 494e263daa74..b7ee8043a133 100644
563     --- a/drivers/misc/altera-stapl/altera.c
564     +++ b/drivers/misc/altera-stapl/altera.c
565     @@ -2126,8 +2126,8 @@ exit_done:
566     return status;
567     }
568    
569     -static int altera_get_note(u8 *p, s32 program_size,
570     - s32 *offset, char *key, char *value, int length)
571     +static int altera_get_note(u8 *p, s32 program_size, s32 *offset,
572     + char *key, char *value, int keylen, int vallen)
573     /*
574     * Gets key and value of NOTE fields in the JBC file.
575     * Can be called in two modes: if offset pointer is NULL,
576     @@ -2184,7 +2184,7 @@ static int altera_get_note(u8 *p, s32 program_size,
577     &p[note_table + (8 * i) + 4])];
578    
579     if (value != NULL)
580     - strlcpy(value, value_ptr, length);
581     + strlcpy(value, value_ptr, vallen);
582    
583     }
584     }
585     @@ -2203,13 +2203,13 @@ static int altera_get_note(u8 *p, s32 program_size,
586     strlcpy(key, &p[note_strings +
587     get_unaligned_be32(
588     &p[note_table + (8 * i)])],
589     - length);
590     + keylen);
591    
592     if (value != NULL)
593     strlcpy(value, &p[note_strings +
594     get_unaligned_be32(
595     &p[note_table + (8 * i) + 4])],
596     - length);
597     + vallen);
598    
599     *offset = i + 1;
600     }
601     @@ -2463,7 +2463,7 @@ int altera_init(struct altera_config *config, const struct firmware *fw)
602     __func__, (format_version == 2) ? "Jam STAPL" :
603     "pre-standardized Jam 1.1");
604     while (altera_get_note((u8 *)fw->data, fw->size,
605     - &offset, key, value, 256) == 0)
606     + &offset, key, value, 32, 256) == 0)
607     printk(KERN_INFO "%s: NOTE \"%s\" = \"%s\"\n",
608     __func__, key, value);
609     }
610     diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
611     index 7f7af312e7ad..c354711f8f56 100644
612     --- a/drivers/mmc/host/sdhci-of-at91.c
613     +++ b/drivers/mmc/host/sdhci-of-at91.c
614     @@ -126,7 +126,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
615     {
616     sdhci_reset(host, mask);
617    
618     - if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
619     + if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
620     + || mmc_gpio_get_cd(host->mmc) >= 0)
621     sdhci_at91_set_force_card_detect(host);
622     }
623    
624     @@ -354,8 +355,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
625     * detection procedure using the SDMCC_CD signal is bypassed.
626     * This bit is reset when a software reset for all command is performed
627     * so we need to implement our own reset function to set back this bit.
628     + *
629     + * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
630     */
631     - if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
632     + if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
633     + || mmc_gpio_get_cd(host->mmc) >= 0)
634     sdhci_at91_set_force_card_detect(host);
635    
636     pm_runtime_put_autosuspend(&pdev->dev);
637     diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c
638     index 453a2ea7895b..94b37c60fdd0 100644
639     --- a/drivers/net/can/slcan.c
640     +++ b/drivers/net/can/slcan.c
641     @@ -621,7 +621,10 @@ err_free_chan:
642     tty->disc_data = NULL;
643     clear_bit(SLF_INUSE, &sl->flags);
644     slc_free_netdev(sl->dev);
645     + /* do not call free_netdev before rtnl_unlock */
646     + rtnl_unlock();
647     free_netdev(sl->dev);
648     + return err;
649    
650     err_exit:
651     rtnl_unlock();
652     diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
653     index f2904afe10e4..bb6bc84995a2 100644
654     --- a/drivers/net/ethernet/marvell/mvneta.c
655     +++ b/drivers/net/ethernet/marvell/mvneta.c
656     @@ -2690,10 +2690,9 @@ static int mvneta_poll(struct napi_struct *napi, int budget)
657     /* For the case where the last mvneta_poll did not process all
658     * RX packets
659     */
660     - rx_queue = fls(((cause_rx_tx >> 8) & 0xff));
661     -
662     cause_rx_tx |= port->cause_rx_tx;
663    
664     + rx_queue = fls(((cause_rx_tx >> 8) & 0xff));
665     if (rx_queue) {
666     rx_queue = rx_queue - 1;
667     if (pp->bm_priv)
668     diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
669     index d4747caf1e7c..bebddb8b997e 100644
670     --- a/drivers/net/ethernet/micrel/ks8851_mll.c
671     +++ b/drivers/net/ethernet/micrel/ks8851_mll.c
672     @@ -474,6 +474,50 @@ static int msg_enable;
673     * chip is busy transferring packet data (RX/TX FIFO accesses).
674     */
675    
676     +/**
677     + * ks_check_endian - Check whether endianness of the bus is correct
678     + * @ks : The chip information
679     + *
680     + * The KS8851-16MLL EESK pin allows selecting the endianness of the 16bit
681     + * bus. To maintain optimum performance, the bus endianness should be set
682     + * such that it matches the endianness of the CPU.
683     + */
684     +
685     +static int ks_check_endian(struct ks_net *ks)
686     +{
687     + u16 cider;
688     +
689     + /*
690     + * Read CIDER register first, however read it the "wrong" way around.
691     + * If the endian strap on the KS8851-16MLL in incorrect and the chip
692     + * is operating in different endianness than the CPU, then the meaning
693     + * of BE[3:0] byte-enable bits is also swapped such that:
694     + * BE[3,2,1,0] becomes BE[1,0,3,2]
695     + *
696     + * Luckily for us, the byte-enable bits are the top four MSbits of
697     + * the address register and the CIDER register is at offset 0xc0.
698     + * Hence, by reading address 0xc0c0, which is not impacted by endian
699     + * swapping, we assert either BE[3:2] or BE[1:0] while reading the
700     + * CIDER register.
701     + *
702     + * If the bus configuration is correct, reading 0xc0c0 asserts
703     + * BE[3:2] and this read returns 0x0000, because to read register
704     + * with bottom two LSbits of address set to 0, BE[1:0] must be
705     + * asserted.
706     + *
707     + * If the bus configuration is NOT correct, reading 0xc0c0 asserts
708     + * BE[1:0] and this read returns non-zero 0x8872 value.
709     + */
710     + iowrite16(BE3 | BE2 | KS_CIDER, ks->hw_addr_cmd);
711     + cider = ioread16(ks->hw_addr);
712     + if (!cider)
713     + return 0;
714     +
715     + netdev_err(ks->netdev, "incorrect EESK endian strap setting\n");
716     +
717     + return -EINVAL;
718     +}
719     +
720     /**
721     * ks_rdreg16 - read 16 bit register from device
722     * @ks : The chip information
723     @@ -484,7 +528,7 @@ static int msg_enable;
724    
725     static u16 ks_rdreg16(struct ks_net *ks, int offset)
726     {
727     - ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
728     + ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));
729     iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
730     return ioread16(ks->hw_addr);
731     }
732     @@ -499,7 +543,7 @@ static u16 ks_rdreg16(struct ks_net *ks, int offset)
733    
734     static void ks_wrreg16(struct ks_net *ks, int offset, u16 value)
735     {
736     - ks->cmd_reg_cache = (u16)offset | ((BE3 | BE2) >> (offset & 0x02));
737     + ks->cmd_reg_cache = (u16)offset | ((BE1 | BE0) << (offset & 0x02));
738     iowrite16(ks->cmd_reg_cache, ks->hw_addr_cmd);
739     iowrite16(value, ks->hw_addr);
740     }
741     @@ -515,7 +559,7 @@ static inline void ks_inblk(struct ks_net *ks, u16 *wptr, u32 len)
742     {
743     len >>= 1;
744     while (len--)
745     - *wptr++ = be16_to_cpu(ioread16(ks->hw_addr));
746     + *wptr++ = (u16)ioread16(ks->hw_addr);
747     }
748    
749     /**
750     @@ -529,7 +573,7 @@ static inline void ks_outblk(struct ks_net *ks, u16 *wptr, u32 len)
751     {
752     len >>= 1;
753     while (len--)
754     - iowrite16(cpu_to_be16(*wptr++), ks->hw_addr);
755     + iowrite16(*wptr++, ks->hw_addr);
756     }
757    
758     static void ks_disable_int(struct ks_net *ks)
759     @@ -1535,6 +1579,10 @@ static int ks8851_probe(struct platform_device *pdev)
760     goto err_free;
761     }
762    
763     + err = ks_check_endian(ks);
764     + if (err)
765     + goto err_free;
766     +
767     netdev->irq = platform_get_irq(pdev, 0);
768    
769     if ((int)netdev->irq < 0) {
770     diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
771     index ea44a2456ce1..11dd7c8d576d 100644
772     --- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
773     +++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c
774     @@ -2313,7 +2313,7 @@ static int __init sxgbe_cmdline_opt(char *str)
775     if (!str || !*str)
776     return -EINVAL;
777     while ((opt = strsep(&str, ",")) != NULL) {
778     - if (!strncmp(opt, "eee_timer:", 6)) {
779     + if (!strncmp(opt, "eee_timer:", 10)) {
780     if (kstrtoint(opt + 10, 0, &eee_timer))
781     goto err;
782     }
783     diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
784     index 8c64b06cb98c..da8bf327a3e9 100644
785     --- a/drivers/net/macsec.c
786     +++ b/drivers/net/macsec.c
787     @@ -19,6 +19,7 @@
788     #include <net/genetlink.h>
789     #include <net/sock.h>
790     #include <net/gro_cells.h>
791     +#include <linux/if_arp.h>
792    
793     #include <uapi/linux/if_macsec.h>
794    
795     @@ -3219,6 +3220,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
796     real_dev = __dev_get_by_index(net, nla_get_u32(tb[IFLA_LINK]));
797     if (!real_dev)
798     return -ENODEV;
799     + if (real_dev->type != ARPHRD_ETHER)
800     + return -EINVAL;
801    
802     dev->priv_flags |= IFF_MACSEC;
803    
804     diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
805     index 987bb1db8265..bc4542d9a08d 100644
806     --- a/drivers/net/vxlan.c
807     +++ b/drivers/net/vxlan.c
808     @@ -2354,10 +2354,19 @@ static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan,
809     /* Setup stats when device is created */
810     static int vxlan_init(struct net_device *dev)
811     {
812     + struct vxlan_dev *vxlan = netdev_priv(dev);
813     + int err;
814     +
815     dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
816     if (!dev->tstats)
817     return -ENOMEM;
818    
819     + err = gro_cells_init(&vxlan->gro_cells, dev);
820     + if (err) {
821     + free_percpu(dev->tstats);
822     + return err;
823     + }
824     +
825     return 0;
826     }
827    
828     @@ -2623,8 +2632,6 @@ static void vxlan_setup(struct net_device *dev)
829    
830     vxlan->dev = dev;
831    
832     - gro_cells_init(&vxlan->gro_cells, dev);
833     -
834     for (h = 0; h < FDB_HASH_SIZE; ++h)
835     INIT_HLIST_HEAD(&vxlan->fdb_head[h]);
836     }
837     diff --git a/drivers/nfc/fdp/fdp.c b/drivers/nfc/fdp/fdp.c
838     index 7c1eaea3b685..d2fe134052f0 100644
839     --- a/drivers/nfc/fdp/fdp.c
840     +++ b/drivers/nfc/fdp/fdp.c
841     @@ -192,7 +192,7 @@ static int fdp_nci_send_patch(struct nci_dev *ndev, u8 conn_id, u8 type)
842     const struct firmware *fw;
843     struct sk_buff *skb;
844     unsigned long len;
845     - u8 max_size, payload_size;
846     + int max_size, payload_size;
847     int rc = 0;
848    
849     if ((type == NCI_PATCH_TYPE_OTP && !info->otp_patch) ||
850     @@ -215,8 +215,7 @@ static int fdp_nci_send_patch(struct nci_dev *ndev, u8 conn_id, u8 type)
851    
852     while (len) {
853    
854     - payload_size = min_t(unsigned long, (unsigned long) max_size,
855     - len);
856     + payload_size = min_t(unsigned long, max_size, len);
857    
858     skb = nci_skb_alloc(ndev, (NCI_CTRL_HDR_SIZE + payload_size),
859     GFP_KERNEL);
860     diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
861     index 0723c97ebea3..ef850ddb8718 100644
862     --- a/drivers/rtc/Kconfig
863     +++ b/drivers/rtc/Kconfig
864     @@ -304,6 +304,7 @@ config RTC_DRV_MAX6900
865     config RTC_DRV_MAX8907
866     tristate "Maxim MAX8907"
867     depends on MFD_MAX8907
868     + select REGMAP_IRQ
869     help
870     If you say yes here you will get support for the
871     RTC of Maxim MAX8907 PMIC.
872     diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
873     index c5bc41d97f84..7760b9a1e0ae 100644
874     --- a/drivers/scsi/ipr.c
875     +++ b/drivers/scsi/ipr.c
876     @@ -9818,6 +9818,7 @@ static void ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
877     ioa_cfg->max_devs_supported = ipr_max_devs;
878    
879     if (ioa_cfg->sis64) {
880     + host->max_channel = IPR_MAX_SIS64_BUSES;
881     host->max_id = IPR_MAX_SIS64_TARGETS_PER_BUS;
882     host->max_lun = IPR_MAX_SIS64_LUNS_PER_TARGET;
883     if (ipr_max_devs > IPR_MAX_SIS64_DEVS)
884     @@ -9826,6 +9827,7 @@ static void ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
885     + ((sizeof(struct ipr_config_table_entry64)
886     * ioa_cfg->max_devs_supported)));
887     } else {
888     + host->max_channel = IPR_VSET_BUS;
889     host->max_id = IPR_MAX_NUM_TARGETS_PER_BUS;
890     host->max_lun = IPR_MAX_NUM_LUNS_PER_TARGET;
891     if (ipr_max_devs > IPR_MAX_PHYSICAL_DEVS)
892     @@ -9835,7 +9837,6 @@ static void ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
893     * ioa_cfg->max_devs_supported)));
894     }
895    
896     - host->max_channel = IPR_VSET_BUS;
897     host->unique_id = host->host_no;
898     host->max_cmd_len = IPR_MAX_CDB_LEN;
899     host->can_queue = ioa_cfg->max_cmds;
900     diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
901     index 8995053d01b3..5b2388266c4c 100644
902     --- a/drivers/scsi/ipr.h
903     +++ b/drivers/scsi/ipr.h
904     @@ -1306,6 +1306,7 @@ struct ipr_resource_entry {
905     #define IPR_ARRAY_VIRTUAL_BUS 0x1
906     #define IPR_VSET_VIRTUAL_BUS 0x2
907     #define IPR_IOAFP_VIRTUAL_BUS 0x3
908     +#define IPR_MAX_SIS64_BUSES 0x4
909    
910     #define IPR_GET_RES_PHYS_LOC(res) \
911     (((res)->bus << 24) | ((res)->target << 8) | (res)->lun)
912     diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
913     index 62d6955ac69b..671bf1e03ee1 100644
914     --- a/drivers/scsi/sd.c
915     +++ b/drivers/scsi/sd.c
916     @@ -2949,9 +2949,11 @@ static int sd_revalidate_disk(struct gendisk *disk)
917     if (sd_validate_opt_xfer_size(sdkp, dev_max)) {
918     q->limits.io_opt = logical_to_bytes(sdp, sdkp->opt_xfer_blocks);
919     rw_max = logical_to_sectors(sdp, sdkp->opt_xfer_blocks);
920     - } else
921     + } else {
922     + q->limits.io_opt = 0;
923     rw_max = min_not_zero(logical_to_sectors(sdp, dev_max),
924     (sector_t)BLK_DEF_MAX_SECTORS);
925     + }
926    
927     /* Do not exceed controller limit */
928     rw_max = min(rw_max, queue_max_hw_sectors(q));
929     diff --git a/drivers/spi/spi-qup.c b/drivers/spi/spi-qup.c
930     index 1bfa889b8427..88b108e1c85f 100644
931     --- a/drivers/spi/spi-qup.c
932     +++ b/drivers/spi/spi-qup.c
933     @@ -974,6 +974,11 @@ static int spi_qup_suspend(struct device *device)
934     struct spi_qup *controller = spi_master_get_devdata(master);
935     int ret;
936    
937     + if (pm_runtime_suspended(device)) {
938     + ret = spi_qup_pm_resume_runtime(device);
939     + if (ret)
940     + return ret;
941     + }
942     ret = spi_master_suspend(master);
943     if (ret)
944     return ret;
945     @@ -982,10 +987,8 @@ static int spi_qup_suspend(struct device *device)
946     if (ret)
947     return ret;
948    
949     - if (!pm_runtime_suspended(device)) {
950     - clk_disable_unprepare(controller->cclk);
951     - clk_disable_unprepare(controller->iclk);
952     - }
953     + clk_disable_unprepare(controller->cclk);
954     + clk_disable_unprepare(controller->iclk);
955     return 0;
956     }
957    
958     diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
959     index 18aeaceee286..d26c0eda2d9e 100644
960     --- a/drivers/spi/spi-zynqmp-gqspi.c
961     +++ b/drivers/spi/spi-zynqmp-gqspi.c
962     @@ -415,9 +415,6 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high)
963    
964     zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, genfifoentry);
965    
966     - /* Dummy generic FIFO entry */
967     - zynqmp_gqspi_write(xqspi, GQSPI_GEN_FIFO_OFST, 0x0);
968     -
969     /* Manually start the generic FIFO command */
970     zynqmp_gqspi_write(xqspi, GQSPI_CONFIG_OFST,
971     zynqmp_gqspi_read(xqspi, GQSPI_CONFIG_OFST) |
972     diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c
973     index f7f4cd6fb55b..8d2678b22c36 100644
974     --- a/drivers/staging/greybus/tools/loopback_test.c
975     +++ b/drivers/staging/greybus/tools/loopback_test.c
976     @@ -20,6 +20,7 @@
977     #include <signal.h>
978    
979     #define MAX_NUM_DEVICES 10
980     +#define MAX_SYSFS_PREFIX 0x80
981     #define MAX_SYSFS_PATH 0x200
982     #define CSV_MAX_LINE 0x1000
983     #define SYSFS_MAX_INT 0x20
984     @@ -68,7 +69,7 @@ struct loopback_results {
985     };
986    
987     struct loopback_device {
988     - char name[MAX_SYSFS_PATH];
989     + char name[MAX_STR_LEN];
990     char sysfs_entry[MAX_SYSFS_PATH];
991     char debugfs_entry[MAX_SYSFS_PATH];
992     struct loopback_results results;
993     @@ -94,8 +95,8 @@ struct loopback_test {
994     int stop_all;
995     int poll_count;
996     char test_name[MAX_STR_LEN];
997     - char sysfs_prefix[MAX_SYSFS_PATH];
998     - char debugfs_prefix[MAX_SYSFS_PATH];
999     + char sysfs_prefix[MAX_SYSFS_PREFIX];
1000     + char debugfs_prefix[MAX_SYSFS_PREFIX];
1001     struct timespec poll_timeout;
1002     struct loopback_device devices[MAX_NUM_DEVICES];
1003     struct loopback_results aggregate_results;
1004     @@ -646,7 +647,7 @@ baddir:
1005     static int open_poll_files(struct loopback_test *t)
1006     {
1007     struct loopback_device *dev;
1008     - char buf[MAX_STR_LEN];
1009     + char buf[MAX_SYSFS_PATH + MAX_STR_LEN];
1010     char dummy;
1011     int fds_idx = 0;
1012     int i;
1013     @@ -917,10 +918,10 @@ int main(int argc, char *argv[])
1014     t.iteration_max = atoi(optarg);
1015     break;
1016     case 'S':
1017     - snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", optarg);
1018     + snprintf(t.sysfs_prefix, MAX_SYSFS_PREFIX, "%s", optarg);
1019     break;
1020     case 'D':
1021     - snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", optarg);
1022     + snprintf(t.debugfs_prefix, MAX_SYSFS_PREFIX, "%s", optarg);
1023     break;
1024     case 'm':
1025     t.mask = atol(optarg);
1026     @@ -971,10 +972,10 @@ int main(int argc, char *argv[])
1027     }
1028    
1029     if (!strcmp(t.sysfs_prefix, ""))
1030     - snprintf(t.sysfs_prefix, MAX_SYSFS_PATH, "%s", sysfs_prefix);
1031     + snprintf(t.sysfs_prefix, MAX_SYSFS_PREFIX, "%s", sysfs_prefix);
1032    
1033     if (!strcmp(t.debugfs_prefix, ""))
1034     - snprintf(t.debugfs_prefix, MAX_SYSFS_PATH, "%s", debugfs_prefix);
1035     + snprintf(t.debugfs_prefix, MAX_SYSFS_PREFIX, "%s", debugfs_prefix);
1036    
1037     ret = find_loopback_devices(&t);
1038     if (ret)
1039     diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
1040     index 537a99eba6af..c14088075c59 100644
1041     --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
1042     +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
1043     @@ -40,12 +40,14 @@ static struct usb_device_id rtw_usb_id_tbl[] = {
1044     /****** 8188EUS ********/
1045     {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
1046     {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
1047     + {USB_DEVICE(0x0B05, 0x18F0)}, /* ASUS USB-N10 Nano B1 */
1048     {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
1049     {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
1050     {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */
1051     {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */
1052     {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */
1053     {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */
1054     + {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */
1055     {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
1056     {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */
1057     {} /* Terminating entry */
1058     diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
1059     index 97ca4ecca8a9..37bc3c664630 100644
1060     --- a/drivers/staging/speakup/main.c
1061     +++ b/drivers/staging/speakup/main.c
1062     @@ -565,8 +565,7 @@ static u_long get_word(struct vc_data *vc)
1063     return 0;
1064     } else if ((tmpx < vc->vc_cols - 2)
1065     && (ch == SPACE || ch == 0 || IS_WDLM(ch))
1066     - && ((char)get_char(vc, (u_short *) &tmp_pos + 1, &temp) >
1067     - SPACE)) {
1068     + && ((char)get_char(vc, (u_short *)tmp_pos + 1, &temp) > SPACE)) {
1069     tmp_pos += 2;
1070     tmpx++;
1071     } else
1072     diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c
1073     index 6a107f8a06e2..52ad5c137d9f 100644
1074     --- a/drivers/staging/wlan-ng/hfa384x_usb.c
1075     +++ b/drivers/staging/wlan-ng/hfa384x_usb.c
1076     @@ -3443,6 +3443,8 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev,
1077     WLAN_HDR_A4_LEN + WLAN_DATA_MAXLEN + WLAN_CRC_LEN)) {
1078     pr_debug("overlen frm: len=%zd\n",
1079     skblen - sizeof(struct p80211_caphdr));
1080     +
1081     + return;
1082     }
1083    
1084     skb = dev_alloc_skb(skblen);
1085     diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c
1086     index bfb6b0a6528d..f7149bb23180 100644
1087     --- a/drivers/staging/wlan-ng/prism2usb.c
1088     +++ b/drivers/staging/wlan-ng/prism2usb.c
1089     @@ -179,6 +179,7 @@ static void prism2sta_disconnect_usb(struct usb_interface *interface)
1090    
1091     cancel_work_sync(&hw->link_bh);
1092     cancel_work_sync(&hw->commsqual_bh);
1093     + cancel_work_sync(&hw->usb_work);
1094    
1095     /* Now we complete any outstanding commands
1096     * and tell everyone who is waiting for their
1097     diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c
1098     index 1edc1a36db4a..225689c76623 100644
1099     --- a/drivers/tty/vt/selection.c
1100     +++ b/drivers/tty/vt/selection.c
1101     @@ -80,6 +80,11 @@ void clear_selection(void)
1102     }
1103     }
1104    
1105     +bool vc_is_sel(struct vc_data *vc)
1106     +{
1107     + return vc == sel_cons;
1108     +}
1109     +
1110     /*
1111     * User settable table: what characters are to be considered alphabetic?
1112     * 256 bits. Locked by the console lock.
1113     diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
1114     index c1d3b685a587..29fb08c8a2fd 100644
1115     --- a/drivers/tty/vt/vt.c
1116     +++ b/drivers/tty/vt/vt.c
1117     @@ -595,8 +595,9 @@ static void hide_softcursor(struct vc_data *vc)
1118    
1119     static void hide_cursor(struct vc_data *vc)
1120     {
1121     - if (vc == sel_cons)
1122     + if (vc_is_sel(vc))
1123     clear_selection();
1124     +
1125     vc->vc_sw->con_cursor(vc, CM_ERASE);
1126     hide_softcursor(vc);
1127     }
1128     @@ -606,7 +607,7 @@ static void set_cursor(struct vc_data *vc)
1129     if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)
1130     return;
1131     if (vc->vc_deccm) {
1132     - if (vc == sel_cons)
1133     + if (vc_is_sel(vc))
1134     clear_selection();
1135     add_softcursor(vc);
1136     if ((vc->vc_cursor_type & 0x0f) != 1)
1137     @@ -753,6 +754,17 @@ static void visual_init(struct vc_data *vc, int num, int init)
1138     vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
1139     }
1140    
1141     +static void vc_port_destruct(struct tty_port *port)
1142     +{
1143     + struct vc_data *vc = container_of(port, struct vc_data, port);
1144     +
1145     + kfree(vc);
1146     +}
1147     +
1148     +static const struct tty_port_operations vc_port_ops = {
1149     + .destruct = vc_port_destruct,
1150     +};
1151     +
1152     int vc_allocate(unsigned int currcons) /* return 0 on success */
1153     {
1154     struct vt_notifier_param param;
1155     @@ -778,6 +790,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
1156    
1157     vc_cons[currcons].d = vc;
1158     tty_port_init(&vc->port);
1159     + vc->port.ops = &vc_port_ops;
1160     INIT_WORK(&vc_cons[currcons].SAK_work, vc_SAK);
1161    
1162     visual_init(vc, currcons, 1);
1163     @@ -876,7 +889,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1164     if (!newscreen)
1165     return -ENOMEM;
1166    
1167     - if (vc == sel_cons)
1168     + if (vc_is_sel(vc))
1169     clear_selection();
1170    
1171     old_rows = vc->vc_rows;
1172     @@ -2896,6 +2909,7 @@ static int con_install(struct tty_driver *driver, struct tty_struct *tty)
1173    
1174     tty->driver_data = vc;
1175     vc->port.tty = tty;
1176     + tty_port_get(&vc->port);
1177    
1178     if (!tty->winsize.ws_row && !tty->winsize.ws_col) {
1179     tty->winsize.ws_row = vc_cons[currcons].d->vc_rows;
1180     @@ -2931,6 +2945,13 @@ static void con_shutdown(struct tty_struct *tty)
1181     console_unlock();
1182     }
1183    
1184     +static void con_cleanup(struct tty_struct *tty)
1185     +{
1186     + struct vc_data *vc = tty->driver_data;
1187     +
1188     + tty_port_put(&vc->port);
1189     +}
1190     +
1191     static int default_color = 7; /* white */
1192     static int default_italic_color = 2; // green (ASCII)
1193     static int default_underline_color = 3; // cyan (ASCII)
1194     @@ -3055,7 +3076,8 @@ static const struct tty_operations con_ops = {
1195     .throttle = con_throttle,
1196     .unthrottle = con_unthrottle,
1197     .resize = vt_resize,
1198     - .shutdown = con_shutdown
1199     + .shutdown = con_shutdown,
1200     + .cleanup = con_cleanup,
1201     };
1202    
1203     static struct cdev vc0_cdev;
1204     diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
1205     index e8efb270dc8f..4ed0d77e5918 100644
1206     --- a/drivers/tty/vt/vt_ioctl.c
1207     +++ b/drivers/tty/vt/vt_ioctl.c
1208     @@ -38,11 +38,32 @@
1209     #include <linux/kbd_diacr.h>
1210     #include <linux/selection.h>
1211    
1212     -char vt_dont_switch;
1213     -extern struct tty_driver *console_driver;
1214     +bool vt_dont_switch;
1215    
1216     -#define VT_IS_IN_USE(i) (console_driver->ttys[i] && console_driver->ttys[i]->count)
1217     -#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || vc_cons[i].d == sel_cons)
1218     +static inline bool vt_in_use(unsigned int i)
1219     +{
1220     + const struct vc_data *vc = vc_cons[i].d;
1221     +
1222     + /*
1223     + * console_lock must be held to prevent the vc from being deallocated
1224     + * while we're checking whether it's in-use.
1225     + */
1226     + WARN_CONSOLE_UNLOCKED();
1227     +
1228     + return vc && kref_read(&vc->port.kref) > 1;
1229     +}
1230     +
1231     +static inline bool vt_busy(int i)
1232     +{
1233     + if (vt_in_use(i))
1234     + return true;
1235     + if (i == fg_console)
1236     + return true;
1237     + if (vc_is_sel(vc_cons[i].d))
1238     + return true;
1239     +
1240     + return false;
1241     +}
1242    
1243     /*
1244     * Console (vt and kd) routines, as defined by USL SVR4 manual, and by
1245     @@ -292,16 +313,14 @@ static int vt_disallocate(unsigned int vc_num)
1246     int ret = 0;
1247    
1248     console_lock();
1249     - if (VT_BUSY(vc_num))
1250     + if (vt_busy(vc_num))
1251     ret = -EBUSY;
1252     else if (vc_num)
1253     vc = vc_deallocate(vc_num);
1254     console_unlock();
1255    
1256     - if (vc && vc_num >= MIN_NR_CONSOLES) {
1257     - tty_port_destroy(&vc->port);
1258     - kfree(vc);
1259     - }
1260     + if (vc && vc_num >= MIN_NR_CONSOLES)
1261     + tty_port_put(&vc->port);
1262    
1263     return ret;
1264     }
1265     @@ -314,17 +333,15 @@ static void vt_disallocate_all(void)
1266    
1267     console_lock();
1268     for (i = 1; i < MAX_NR_CONSOLES; i++)
1269     - if (!VT_BUSY(i))
1270     + if (!vt_busy(i))
1271     vc[i] = vc_deallocate(i);
1272     else
1273     vc[i] = NULL;
1274     console_unlock();
1275    
1276     for (i = 1; i < MAX_NR_CONSOLES; i++) {
1277     - if (vc[i] && i >= MIN_NR_CONSOLES) {
1278     - tty_port_destroy(&vc[i]->port);
1279     - kfree(vc[i]);
1280     - }
1281     + if (vc[i] && i >= MIN_NR_CONSOLES)
1282     + tty_port_put(&vc[i]->port);
1283     }
1284     }
1285    
1286     @@ -338,22 +355,13 @@ int vt_ioctl(struct tty_struct *tty,
1287     {
1288     struct vc_data *vc = tty->driver_data;
1289     struct console_font_op op; /* used in multiple places here */
1290     - unsigned int console;
1291     + unsigned int console = vc->vc_num;
1292     unsigned char ucval;
1293     unsigned int uival;
1294     void __user *up = (void __user *)arg;
1295     int i, perm;
1296     int ret = 0;
1297    
1298     - console = vc->vc_num;
1299     -
1300     -
1301     - if (!vc_cons_allocated(console)) { /* impossible? */
1302     - ret = -ENOIOCTLCMD;
1303     - goto out;
1304     - }
1305     -
1306     -
1307     /*
1308     * To have permissions to do most of the vt ioctls, we either have
1309     * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
1310     @@ -644,15 +652,16 @@ int vt_ioctl(struct tty_struct *tty,
1311     struct vt_stat __user *vtstat = up;
1312     unsigned short state, mask;
1313    
1314     - /* Review: FIXME: Console lock ? */
1315     if (put_user(fg_console + 1, &vtstat->v_active))
1316     ret = -EFAULT;
1317     else {
1318     state = 1; /* /dev/tty0 is always open */
1319     + console_lock(); /* required by vt_in_use() */
1320     for (i = 0, mask = 2; i < MAX_NR_CONSOLES && mask;
1321     ++i, mask <<= 1)
1322     - if (VT_IS_IN_USE(i))
1323     + if (vt_in_use(i))
1324     state |= mask;
1325     + console_unlock();
1326     ret = put_user(state, &vtstat->v_state);
1327     }
1328     break;
1329     @@ -662,10 +671,11 @@ int vt_ioctl(struct tty_struct *tty,
1330     * Returns the first available (non-opened) console.
1331     */
1332     case VT_OPENQRY:
1333     - /* FIXME: locking ? - but then this is a stupid API */
1334     + console_lock(); /* required by vt_in_use() */
1335     for (i = 0; i < MAX_NR_CONSOLES; ++i)
1336     - if (! VT_IS_IN_USE(i))
1337     + if (!vt_in_use(i))
1338     break;
1339     + console_unlock();
1340     uival = i < MAX_NR_CONSOLES ? (i+1) : -1;
1341     goto setint;
1342    
1343     @@ -1014,12 +1024,12 @@ int vt_ioctl(struct tty_struct *tty,
1344     case VT_LOCKSWITCH:
1345     if (!capable(CAP_SYS_TTY_CONFIG))
1346     return -EPERM;
1347     - vt_dont_switch = 1;
1348     + vt_dont_switch = true;
1349     break;
1350     case VT_UNLOCKSWITCH:
1351     if (!capable(CAP_SYS_TTY_CONFIG))
1352     return -EPERM;
1353     - vt_dont_switch = 0;
1354     + vt_dont_switch = false;
1355     break;
1356     case VT_GETHIFONTMASK:
1357     ret = put_user(vc->vc_hi_font_mask,
1358     @@ -1187,18 +1197,10 @@ long vt_compat_ioctl(struct tty_struct *tty,
1359     {
1360     struct vc_data *vc = tty->driver_data;
1361     struct console_font_op op; /* used in multiple places here */
1362     - unsigned int console;
1363     void __user *up = (void __user *)arg;
1364     int perm;
1365     int ret = 0;
1366    
1367     - console = vc->vc_num;
1368     -
1369     - if (!vc_cons_allocated(console)) { /* impossible? */
1370     - ret = -ENOIOCTLCMD;
1371     - goto out;
1372     - }
1373     -
1374     /*
1375     * To have permissions to do most of the vt ioctls, we either have
1376     * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
1377     @@ -1258,7 +1260,7 @@ long vt_compat_ioctl(struct tty_struct *tty,
1378     arg = (unsigned long)compat_ptr(arg);
1379     goto fallback;
1380     }
1381     -out:
1382     +
1383     return ret;
1384    
1385     fallback:
1386     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1387     index b2edbd4bf8c4..5b0bffba4aac 100644
1388     --- a/drivers/usb/class/cdc-acm.c
1389     +++ b/drivers/usb/class/cdc-acm.c
1390     @@ -828,10 +828,10 @@ static int get_serial_info(struct acm *acm, struct serial_struct __user *info)
1391     tmp.flags = ASYNC_LOW_LATENCY;
1392     tmp.xmit_fifo_size = acm->writesize;
1393     tmp.baud_base = le32_to_cpu(acm->line.dwDTERate);
1394     - tmp.close_delay = acm->port.close_delay / 10;
1395     + tmp.close_delay = jiffies_to_msecs(acm->port.close_delay) / 10;
1396     tmp.closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
1397     ASYNC_CLOSING_WAIT_NONE :
1398     - acm->port.closing_wait / 10;
1399     + jiffies_to_msecs(acm->port.closing_wait) / 10;
1400    
1401     if (copy_to_user(info, &tmp, sizeof(tmp)))
1402     return -EFAULT;
1403     @@ -844,20 +844,28 @@ static int set_serial_info(struct acm *acm,
1404     {
1405     struct serial_struct new_serial;
1406     unsigned int closing_wait, close_delay;
1407     + unsigned int old_closing_wait, old_close_delay;
1408     int retval = 0;
1409    
1410     if (copy_from_user(&new_serial, newinfo, sizeof(new_serial)))
1411     return -EFAULT;
1412    
1413     - close_delay = new_serial.close_delay * 10;
1414     + close_delay = msecs_to_jiffies(new_serial.close_delay * 10);
1415     closing_wait = new_serial.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
1416     - ASYNC_CLOSING_WAIT_NONE : new_serial.closing_wait * 10;
1417     + ASYNC_CLOSING_WAIT_NONE :
1418     + msecs_to_jiffies(new_serial.closing_wait * 10);
1419     +
1420     + /* we must redo the rounding here, so that the values match */
1421     + old_close_delay = jiffies_to_msecs(acm->port.close_delay) / 10;
1422     + old_closing_wait = acm->port.closing_wait == ASYNC_CLOSING_WAIT_NONE ?
1423     + ASYNC_CLOSING_WAIT_NONE :
1424     + jiffies_to_msecs(acm->port.closing_wait) / 10;
1425    
1426     mutex_lock(&acm->port.mutex);
1427    
1428     if (!capable(CAP_SYS_ADMIN)) {
1429     - if ((close_delay != acm->port.close_delay) ||
1430     - (closing_wait != acm->port.closing_wait))
1431     + if ((new_serial.close_delay != old_close_delay) ||
1432     + (new_serial.closing_wait != old_closing_wait))
1433     retval = -EPERM;
1434     else
1435     retval = -EOPNOTSUPP;
1436     diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1437     index 64c03e871f2d..6c4bb47922ac 100644
1438     --- a/drivers/usb/core/quirks.c
1439     +++ b/drivers/usb/core/quirks.c
1440     @@ -229,6 +229,12 @@ static const struct usb_device_id usb_quirk_list[] = {
1441     { USB_DEVICE(0x0b05, 0x17e0), .driver_info =
1442     USB_QUIRK_IGNORE_REMOTE_WAKEUP },
1443    
1444     + /* Realtek hub in Dell WD19 (Type-C) */
1445     + { USB_DEVICE(0x0bda, 0x0487), .driver_info = USB_QUIRK_NO_LPM },
1446     +
1447     + /* Generic RTL8153 based ethernet adapters */
1448     + { USB_DEVICE(0x0bda, 0x8153), .driver_info = USB_QUIRK_NO_LPM },
1449     +
1450     /* Action Semiconductor flash disk */
1451     { USB_DEVICE(0x10d6, 0x2200), .driver_info =
1452     USB_QUIRK_STRING_FETCH_255 },
1453     diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
1454     index ca8b0b1ae37d..781283a5138e 100644
1455     --- a/drivers/usb/host/xhci-plat.c
1456     +++ b/drivers/usb/host/xhci-plat.c
1457     @@ -335,6 +335,7 @@ MODULE_DEVICE_TABLE(acpi, usb_xhci_acpi_match);
1458     static struct platform_driver usb_xhci_driver = {
1459     .probe = xhci_plat_probe,
1460     .remove = xhci_plat_remove,
1461     + .shutdown = usb_hcd_platform_shutdown,
1462     .driver = {
1463     .name = "xhci-hcd",
1464     .pm = DEV_PM_OPS,
1465     diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
1466     index 19b5f08cb423..01ef25bd37e3 100644
1467     --- a/drivers/usb/musb/musb_host.c
1468     +++ b/drivers/usb/musb/musb_host.c
1469     @@ -1494,10 +1494,7 @@ done:
1470     * We need to map sg if the transfer_buffer is
1471     * NULL.
1472     */
1473     - if (!urb->transfer_buffer)
1474     - qh->use_sg = true;
1475     -
1476     - if (qh->use_sg) {
1477     + if (!urb->transfer_buffer) {
1478     /* sg_miter_start is already done in musb_ep_program */
1479     if (!sg_miter_next(&qh->sg_miter)) {
1480     dev_err(musb->controller, "error: sg list empty\n");
1481     @@ -1505,9 +1502,8 @@ done:
1482     status = -EINVAL;
1483     goto done;
1484     }
1485     - urb->transfer_buffer = qh->sg_miter.addr;
1486     length = min_t(u32, length, qh->sg_miter.length);
1487     - musb_write_fifo(hw_ep, length, urb->transfer_buffer);
1488     + musb_write_fifo(hw_ep, length, qh->sg_miter.addr);
1489     qh->sg_miter.consumed = length;
1490     sg_miter_stop(&qh->sg_miter);
1491     } else {
1492     @@ -1516,11 +1512,6 @@ done:
1493    
1494     qh->segsize = length;
1495    
1496     - if (qh->use_sg) {
1497     - if (offset + length >= urb->transfer_buffer_length)
1498     - qh->use_sg = false;
1499     - }
1500     -
1501     musb_ep_select(mbase, epnum);
1502     musb_writew(epio, MUSB_TXCSR,
1503     MUSB_TXCSR_H_WZC_BITS | MUSB_TXCSR_TXPKTRDY);
1504     @@ -2040,8 +2031,10 @@ finish:
1505     urb->actual_length += xfer_len;
1506     qh->offset += xfer_len;
1507     if (done) {
1508     - if (qh->use_sg)
1509     + if (qh->use_sg) {
1510     qh->use_sg = false;
1511     + urb->transfer_buffer = NULL;
1512     + }
1513    
1514     if (urb->status == -EINPROGRESS)
1515     urb->status = status;
1516     diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
1517     index 191588006e0e..77555242e259 100644
1518     --- a/drivers/usb/serial/io_edgeport.c
1519     +++ b/drivers/usb/serial/io_edgeport.c
1520     @@ -634,7 +634,7 @@ static void edge_interrupt_callback(struct urb *urb)
1521     /* grab the txcredits for the ports if available */
1522     position = 2;
1523     portNumber = 0;
1524     - while ((position < length) &&
1525     + while ((position < length - 1) &&
1526     (portNumber < edge_serial->serial->num_ports)) {
1527     txCredits = data[position] | (data[position+1] << 8);
1528     if (txCredits) {
1529     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1530     index 5ea4cd10abc7..737b6652a0b5 100644
1531     --- a/drivers/usb/serial/option.c
1532     +++ b/drivers/usb/serial/option.c
1533     @@ -1172,6 +1172,8 @@ static const struct usb_device_id option_ids[] = {
1534     .driver_info = NCTRL(0) },
1535     { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x110a, 0xff), /* Telit ME910G1 */
1536     .driver_info = NCTRL(0) | RSVD(3) },
1537     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x110b, 0xff), /* Telit ME910G1 (ECM) */
1538     + .driver_info = NCTRL(0) },
1539     { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
1540     .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
1541     { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
1542     @@ -1981,8 +1983,14 @@ static const struct usb_device_id option_ids[] = {
1543     { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */
1544     { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */
1545     { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x7e11, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/A3 */
1546     + { USB_DEVICE_INTERFACE_CLASS(0x1435, 0xd191, 0xff), /* Wistron Neweb D19Q1 */
1547     + .driver_info = RSVD(1) | RSVD(4) },
1548     + { USB_DEVICE_INTERFACE_CLASS(0x1690, 0x7588, 0xff), /* ASKEY WWHC050 */
1549     + .driver_info = RSVD(1) | RSVD(4) },
1550     { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2031, 0xff), /* Olicard 600 */
1551     .driver_info = RSVD(4) },
1552     + { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2033, 0xff), /* BroadMobi BM806U */
1553     + .driver_info = RSVD(4) },
1554     { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x2060, 0xff), /* BroadMobi BM818 */
1555     .driver_info = RSVD(4) },
1556     { USB_DEVICE_INTERFACE_CLASS(0x2020, 0x4000, 0xff) }, /* OLICARD300 - MT6225 */
1557     diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
1558     index 8fd5e19846ef..4fcded2971d1 100644
1559     --- a/drivers/usb/serial/pl2303.c
1560     +++ b/drivers/usb/serial/pl2303.c
1561     @@ -88,6 +88,7 @@ static const struct usb_device_id id_table[] = {
1562     { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
1563     { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
1564     { USB_DEVICE(HP_VENDOR_ID, HP_LD220TA_PRODUCT_ID) },
1565     + { USB_DEVICE(HP_VENDOR_ID, HP_LD381_PRODUCT_ID) },
1566     { USB_DEVICE(HP_VENDOR_ID, HP_LD960_PRODUCT_ID) },
1567     { USB_DEVICE(HP_VENDOR_ID, HP_LD960TA_PRODUCT_ID) },
1568     { USB_DEVICE(HP_VENDOR_ID, HP_LCM220_PRODUCT_ID) },
1569     diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
1570     index 496cbccbf26c..54d2fb974a41 100644
1571     --- a/drivers/usb/serial/pl2303.h
1572     +++ b/drivers/usb/serial/pl2303.h
1573     @@ -128,6 +128,7 @@
1574     #define HP_LM920_PRODUCT_ID 0x026b
1575     #define HP_TD620_PRODUCT_ID 0x0956
1576     #define HP_LD960_PRODUCT_ID 0x0b39
1577     +#define HP_LD381_PRODUCT_ID 0x0f7f
1578     #define HP_LCM220_PRODUCT_ID 0x3139
1579     #define HP_LCM960_PRODUCT_ID 0x3239
1580     #define HP_LD220_PRODUCT_ID 0x3524
1581     diff --git a/fs/inode.c b/fs/inode.c
1582     index 30a97292e965..0d993ce7a940 100644
1583     --- a/fs/inode.c
1584     +++ b/fs/inode.c
1585     @@ -135,6 +135,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
1586     inode->i_sb = sb;
1587     inode->i_blkbits = sb->s_blocksize_bits;
1588     inode->i_flags = 0;
1589     + atomic64_set(&inode->i_sequence, 0);
1590     atomic_set(&inode->i_count, 1);
1591     inode->i_op = &empty_iops;
1592     inode->i_fop = &no_open_fops;
1593     diff --git a/fs/libfs.c b/fs/libfs.c
1594     index 9dc0e1ed8228..278457f22148 100644
1595     --- a/fs/libfs.c
1596     +++ b/fs/libfs.c
1597     @@ -799,7 +799,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
1598     {
1599     struct simple_attr *attr;
1600    
1601     - attr = kmalloc(sizeof(*attr), GFP_KERNEL);
1602     + attr = kzalloc(sizeof(*attr), GFP_KERNEL);
1603     if (!attr)
1604     return -ENOMEM;
1605    
1606     @@ -839,9 +839,11 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
1607     if (ret)
1608     return ret;
1609    
1610     - if (*ppos) { /* continued read */
1611     + if (*ppos && attr->get_buf[0]) {
1612     + /* continued read */
1613     size = strlen(attr->get_buf);
1614     - } else { /* first read */
1615     + } else {
1616     + /* first read */
1617     u64 val;
1618     ret = attr->get(attr->data, &val);
1619     if (ret)
1620     diff --git a/include/linux/fs.h b/include/linux/fs.h
1621     index 5244df520bed..c2c04f891785 100644
1622     --- a/include/linux/fs.h
1623     +++ b/include/linux/fs.h
1624     @@ -679,6 +679,7 @@ struct inode {
1625     struct rcu_head i_rcu;
1626     };
1627     u64 i_version;
1628     + atomic64_t i_sequence; /* see futex */
1629     atomic_t i_count;
1630     atomic_t i_dio_count;
1631     atomic_t i_writecount;
1632     diff --git a/include/linux/futex.h b/include/linux/futex.h
1633     index 6435f46d6e13..c015fa91e7cc 100644
1634     --- a/include/linux/futex.h
1635     +++ b/include/linux/futex.h
1636     @@ -34,23 +34,26 @@ handle_futex_death(u32 __user *uaddr, struct task_struct *curr, int pi);
1637    
1638     union futex_key {
1639     struct {
1640     + u64 i_seq;
1641     unsigned long pgoff;
1642     - struct inode *inode;
1643     - int offset;
1644     + unsigned int offset;
1645     } shared;
1646     struct {
1647     + union {
1648     + struct mm_struct *mm;
1649     + u64 __tmp;
1650     + };
1651     unsigned long address;
1652     - struct mm_struct *mm;
1653     - int offset;
1654     + unsigned int offset;
1655     } private;
1656     struct {
1657     + u64 ptr;
1658     unsigned long word;
1659     - void *ptr;
1660     - int offset;
1661     + unsigned int offset;
1662     } both;
1663     };
1664    
1665     -#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = NULL } }
1666     +#define FUTEX_KEY_INIT (union futex_key) { .both = { .ptr = 0ULL } }
1667    
1668     #ifdef CONFIG_FUTEX
1669     extern void exit_robust_list(struct task_struct *curr);
1670     diff --git a/include/linux/kref.h b/include/linux/kref.h
1671     index e15828fd71f1..e2df6d397ff0 100644
1672     --- a/include/linux/kref.h
1673     +++ b/include/linux/kref.h
1674     @@ -33,6 +33,11 @@ static inline void kref_init(struct kref *kref)
1675     atomic_set(&kref->refcount, 1);
1676     }
1677    
1678     +static inline int kref_read(const struct kref *kref)
1679     +{
1680     + return atomic_read(&kref->refcount);
1681     +}
1682     +
1683     /**
1684     * kref_get - increment refcount for object.
1685     * @kref: object.
1686     diff --git a/include/linux/selection.h b/include/linux/selection.h
1687     index 8e4624efdb6f..f1070e4180ee 100644
1688     --- a/include/linux/selection.h
1689     +++ b/include/linux/selection.h
1690     @@ -12,8 +12,8 @@
1691    
1692     struct tty_struct;
1693    
1694     -extern struct vc_data *sel_cons;
1695     struct tty_struct;
1696     +struct vc_data;
1697    
1698     extern void clear_selection(void);
1699     extern int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *tty);
1700     @@ -22,6 +22,8 @@ extern int sel_loadlut(char __user *p);
1701     extern int mouse_reporting(void);
1702     extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry);
1703    
1704     +bool vc_is_sel(struct vc_data *vc);
1705     +
1706     extern int console_blanked;
1707    
1708     extern const unsigned char color_table[];
1709     diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
1710     index 3d9d786a943c..d868a735545b 100644
1711     --- a/include/linux/vmalloc.h
1712     +++ b/include/linux/vmalloc.h
1713     @@ -93,8 +93,9 @@ extern int remap_vmalloc_range_partial(struct vm_area_struct *vma,
1714    
1715     extern int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
1716     unsigned long pgoff);
1717     -void vmalloc_sync_all(void);
1718     -
1719     +void vmalloc_sync_mappings(void);
1720     +void vmalloc_sync_unmappings(void);
1721     +
1722     /*
1723     * Lowlevel-APIs (not for driver use!)
1724     */
1725     diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
1726     index 6abd24f258bc..362db91266e6 100644
1727     --- a/include/linux/vt_kern.h
1728     +++ b/include/linux/vt_kern.h
1729     @@ -141,7 +141,7 @@ static inline bool vt_force_oops_output(struct vc_data *vc)
1730     return false;
1731     }
1732    
1733     -extern char vt_dont_switch;
1734     +extern bool vt_dont_switch;
1735     extern int default_utf8;
1736     extern int global_cursor_default;
1737    
1738     diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
1739     index ca7e277e8b5f..e10314223cbf 100644
1740     --- a/kernel/bpf/syscall.c
1741     +++ b/kernel/bpf/syscall.c
1742     @@ -802,7 +802,7 @@ static int bpf_obj_get(const union bpf_attr *attr)
1743    
1744     SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, size)
1745     {
1746     - union bpf_attr attr = {};
1747     + union bpf_attr attr;
1748     int err;
1749    
1750     if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN))
1751     @@ -838,6 +838,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz
1752     }
1753    
1754     /* copy attributes from user space, may be less than sizeof(bpf_attr) */
1755     + memset(&attr, 0, sizeof(attr));
1756     if (copy_from_user(&attr, uattr, size) != 0)
1757     return -EFAULT;
1758    
1759     diff --git a/kernel/futex.c b/kernel/futex.c
1760     index 2e766ffff2cb..7123d9cab456 100644
1761     --- a/kernel/futex.c
1762     +++ b/kernel/futex.c
1763     @@ -390,9 +390,9 @@ static inline int hb_waiters_pending(struct futex_hash_bucket *hb)
1764     */
1765     static struct futex_hash_bucket *hash_futex(union futex_key *key)
1766     {
1767     - u32 hash = jhash2((u32*)&key->both.word,
1768     - (sizeof(key->both.word)+sizeof(key->both.ptr))/4,
1769     + u32 hash = jhash2((u32 *)key, offsetof(typeof(*key), both.offset) / 4,
1770     key->both.offset);
1771     +
1772     return &futex_queues[hash & (futex_hashsize - 1)];
1773     }
1774    
1775     @@ -434,7 +434,7 @@ static void get_futex_key_refs(union futex_key *key)
1776    
1777     switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
1778     case FUT_OFF_INODE:
1779     - ihold(key->shared.inode); /* implies smp_mb(); (B) */
1780     + smp_mb(); /* explicit smp_mb(); (B) */
1781     break;
1782     case FUT_OFF_MMSHARED:
1783     futex_get_mm(key); /* implies smp_mb(); (B) */
1784     @@ -468,7 +468,6 @@ static void drop_futex_key_refs(union futex_key *key)
1785    
1786     switch (key->both.offset & (FUT_OFF_INODE|FUT_OFF_MMSHARED)) {
1787     case FUT_OFF_INODE:
1788     - iput(key->shared.inode);
1789     break;
1790     case FUT_OFF_MMSHARED:
1791     mmdrop(key->private.mm);
1792     @@ -476,6 +475,46 @@ static void drop_futex_key_refs(union futex_key *key)
1793     }
1794     }
1795    
1796     +/*
1797     + * Generate a machine wide unique identifier for this inode.
1798     + *
1799     + * This relies on u64 not wrapping in the life-time of the machine; which with
1800     + * 1ns resolution means almost 585 years.
1801     + *
1802     + * This further relies on the fact that a well formed program will not unmap
1803     + * the file while it has a (shared) futex waiting on it. This mapping will have
1804     + * a file reference which pins the mount and inode.
1805     + *
1806     + * If for some reason an inode gets evicted and read back in again, it will get
1807     + * a new sequence number and will _NOT_ match, even though it is the exact same
1808     + * file.
1809     + *
1810     + * It is important that match_futex() will never have a false-positive, esp.
1811     + * for PI futexes that can mess up the state. The above argues that false-negatives
1812     + * are only possible for malformed programs.
1813     + */
1814     +static u64 get_inode_sequence_number(struct inode *inode)
1815     +{
1816     + static atomic64_t i_seq;
1817     + u64 old;
1818     +
1819     + /* Does the inode already have a sequence number? */
1820     + old = atomic64_read(&inode->i_sequence);
1821     + if (likely(old))
1822     + return old;
1823     +
1824     + for (;;) {
1825     + u64 new = atomic64_add_return(1, &i_seq);
1826     + if (WARN_ON_ONCE(!new))
1827     + continue;
1828     +
1829     + old = atomic64_cmpxchg_relaxed(&inode->i_sequence, 0, new);
1830     + if (old)
1831     + return old;
1832     + return new;
1833     + }
1834     +}
1835     +
1836     /**
1837     * get_futex_key() - Get parameters which are the keys for a futex
1838     * @uaddr: virtual address of the futex
1839     @@ -488,9 +527,15 @@ static void drop_futex_key_refs(union futex_key *key)
1840     *
1841     * The key words are stored in *key on success.
1842     *
1843     - * For shared mappings, it's (page->index, file_inode(vma->vm_file),
1844     - * offset_within_page). For private mappings, it's (uaddr, current->mm).
1845     - * We can usually work out the index without swapping in the page.
1846     + * For shared mappings (when @fshared), the key is:
1847     + * ( inode->i_sequence, page->index, offset_within_page )
1848     + * [ also see get_inode_sequence_number() ]
1849     + *
1850     + * For private mappings (or when !@fshared), the key is:
1851     + * ( current->mm, address, 0 )
1852     + *
1853     + * This allows (cross process, where applicable) identification of the futex
1854     + * without keeping the page pinned for the duration of the FUTEX_WAIT.
1855     *
1856     * lock_page() might sleep, the caller should not hold a spinlock.
1857     */
1858     @@ -630,8 +675,6 @@ again:
1859     key->private.mm = mm;
1860     key->private.address = address;
1861    
1862     - get_futex_key_refs(key); /* implies smp_mb(); (B) */
1863     -
1864     } else {
1865     struct inode *inode;
1866    
1867     @@ -663,40 +706,14 @@ again:
1868     goto again;
1869     }
1870    
1871     - /*
1872     - * Take a reference unless it is about to be freed. Previously
1873     - * this reference was taken by ihold under the page lock
1874     - * pinning the inode in place so i_lock was unnecessary. The
1875     - * only way for this check to fail is if the inode was
1876     - * truncated in parallel which is almost certainly an
1877     - * application bug. In such a case, just retry.
1878     - *
1879     - * We are not calling into get_futex_key_refs() in file-backed
1880     - * cases, therefore a successful atomic_inc return below will
1881     - * guarantee that get_futex_key() will still imply smp_mb(); (B).
1882     - */
1883     - if (!atomic_inc_not_zero(&inode->i_count)) {
1884     - rcu_read_unlock();
1885     - put_page(page);
1886     -
1887     - goto again;
1888     - }
1889     -
1890     - /* Should be impossible but lets be paranoid for now */
1891     - if (WARN_ON_ONCE(inode->i_mapping != mapping)) {
1892     - err = -EFAULT;
1893     - rcu_read_unlock();
1894     - iput(inode);
1895     -
1896     - goto out;
1897     - }
1898     -
1899     key->both.offset |= FUT_OFF_INODE; /* inode-based key */
1900     - key->shared.inode = inode;
1901     + key->shared.i_seq = get_inode_sequence_number(inode);
1902     key->shared.pgoff = basepage_index(tail);
1903     rcu_read_unlock();
1904     }
1905    
1906     + get_futex_key_refs(key); /* implies smp_mb(); (B) */
1907     +
1908     out:
1909     put_page(page);
1910     return err;
1911     diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
1912     index be7f489788e2..b2fc2a581b86 100644
1913     --- a/kernel/irq/manage.c
1914     +++ b/kernel/irq/manage.c
1915     @@ -233,7 +233,11 @@ int irq_set_affinity_locked(struct irq_data *data, const struct cpumask *mask,
1916    
1917     if (desc->affinity_notify) {
1918     kref_get(&desc->affinity_notify->kref);
1919     - schedule_work(&desc->affinity_notify->work);
1920     + if (!schedule_work(&desc->affinity_notify->work)) {
1921     + /* Work was already scheduled, drop our extra ref */
1922     + kref_put(&desc->affinity_notify->kref,
1923     + desc->affinity_notify->release);
1924     + }
1925     }
1926     irqd_set(data, IRQD_AFFINITY_SET);
1927    
1928     @@ -333,7 +337,10 @@ irq_set_affinity_notifier(unsigned int irq, struct irq_affinity_notify *notify)
1929     raw_spin_unlock_irqrestore(&desc->lock, flags);
1930    
1931     if (old_notify) {
1932     - cancel_work_sync(&old_notify->work);
1933     + if (cancel_work_sync(&old_notify->work)) {
1934     + /* Pending work had a ref, put that one too */
1935     + kref_put(&old_notify->kref, old_notify->release);
1936     + }
1937     kref_put(&old_notify->kref, old_notify->release);
1938     }
1939    
1940     diff --git a/kernel/notifier.c b/kernel/notifier.c
1941     index fd2c9acbcc19..0f70f1b6fdaa 100644
1942     --- a/kernel/notifier.c
1943     +++ b/kernel/notifier.c
1944     @@ -552,7 +552,7 @@ NOKPROBE_SYMBOL(notify_die);
1945    
1946     int register_die_notifier(struct notifier_block *nb)
1947     {
1948     - vmalloc_sync_all();
1949     + vmalloc_sync_mappings();
1950     return atomic_notifier_chain_register(&die_chain, nb);
1951     }
1952     EXPORT_SYMBOL_GPL(register_die_notifier);
1953     diff --git a/mm/memcontrol.c b/mm/memcontrol.c
1954     index b85a1c040bc9..2f7f934bf435 100644
1955     --- a/mm/memcontrol.c
1956     +++ b/mm/memcontrol.c
1957     @@ -3481,7 +3481,7 @@ static void __mem_cgroup_usage_unregister_event(struct mem_cgroup *memcg,
1958     struct mem_cgroup_thresholds *thresholds;
1959     struct mem_cgroup_threshold_ary *new;
1960     unsigned long usage;
1961     - int i, j, size;
1962     + int i, j, size, entries;
1963    
1964     mutex_lock(&memcg->thresholds_lock);
1965    
1966     @@ -3501,14 +3501,20 @@ static void __mem_cgroup_usage_unregister_event(struct mem_cgroup *memcg,
1967     __mem_cgroup_threshold(memcg, type == _MEMSWAP);
1968    
1969     /* Calculate new number of threshold */
1970     - size = 0;
1971     + size = entries = 0;
1972     for (i = 0; i < thresholds->primary->size; i++) {
1973     if (thresholds->primary->entries[i].eventfd != eventfd)
1974     size++;
1975     + else
1976     + entries++;
1977     }
1978    
1979     new = thresholds->spare;
1980    
1981     + /* If no items related to eventfd have been cleared, nothing to do */
1982     + if (!entries)
1983     + goto unlock;
1984     +
1985     /* Set thresholds array to NULL if we don't have thresholds */
1986     if (!size) {
1987     kfree(new);
1988     diff --git a/mm/nommu.c b/mm/nommu.c
1989     index 44265e00b701..b40ec74f364c 100644
1990     --- a/mm/nommu.c
1991     +++ b/mm/nommu.c
1992     @@ -445,10 +445,14 @@ void vm_unmap_aliases(void)
1993     EXPORT_SYMBOL_GPL(vm_unmap_aliases);
1994    
1995     /*
1996     - * Implement a stub for vmalloc_sync_all() if the architecture chose not to
1997     - * have one.
1998     + * Implement a stub for vmalloc_sync_[un]mapping() if the architecture
1999     + * chose not to have one.
2000     */
2001     -void __weak vmalloc_sync_all(void)
2002     +void __weak vmalloc_sync_mappings(void)
2003     +{
2004     +}
2005     +
2006     +void __weak vmalloc_sync_unmappings(void)
2007     {
2008     }
2009    
2010     diff --git a/mm/slub.c b/mm/slub.c
2011     index 4a5b2a0f9360..9b44423f1cf0 100644
2012     --- a/mm/slub.c
2013     +++ b/mm/slub.c
2014     @@ -1909,8 +1909,6 @@ static void *get_partial(struct kmem_cache *s, gfp_t flags, int node,
2015    
2016     if (node == NUMA_NO_NODE)
2017     searchnode = numa_mem_id();
2018     - else if (!node_present_pages(node))
2019     - searchnode = node_to_mem_node(node);
2020    
2021     object = get_partial_node(s, get_node(s, searchnode), c, flags);
2022     if (object || node != NUMA_NO_NODE)
2023     @@ -2506,17 +2504,27 @@ static void *___slab_alloc(struct kmem_cache *s, gfp_t gfpflags, int node,
2024     struct page *page;
2025    
2026     page = c->page;
2027     - if (!page)
2028     + if (!page) {
2029     + /*
2030     + * if the node is not online or has no normal memory, just
2031     + * ignore the node constraint
2032     + */
2033     + if (unlikely(node != NUMA_NO_NODE &&
2034     + !node_state(node, N_NORMAL_MEMORY)))
2035     + node = NUMA_NO_NODE;
2036     goto new_slab;
2037     + }
2038     redo:
2039    
2040     if (unlikely(!node_match(page, node))) {
2041     - int searchnode = node;
2042     -
2043     - if (node != NUMA_NO_NODE && !node_present_pages(node))
2044     - searchnode = node_to_mem_node(node);
2045     -
2046     - if (unlikely(!node_match(page, searchnode))) {
2047     + /*
2048     + * same as above but node_match() being false already
2049     + * implies node != NUMA_NO_NODE
2050     + */
2051     + if (!node_state(node, N_NORMAL_MEMORY)) {
2052     + node = NUMA_NO_NODE;
2053     + goto redo;
2054     + } else {
2055     stat(s, ALLOC_NODE_MISMATCH);
2056     deactivate_slab(s, page, c->freelist);
2057     c->page = NULL;
2058     @@ -2935,11 +2943,13 @@ redo:
2059     barrier();
2060    
2061     if (likely(page == c->page)) {
2062     - set_freepointer(s, tail_obj, c->freelist);
2063     + void **freelist = READ_ONCE(c->freelist);
2064     +
2065     + set_freepointer(s, tail_obj, freelist);
2066    
2067     if (unlikely(!this_cpu_cmpxchg_double(
2068     s->cpu_slab->freelist, s->cpu_slab->tid,
2069     - c->freelist, tid,
2070     + freelist, tid,
2071     head, next_tid(tid)))) {
2072    
2073     note_cmpxchg_failure("slab_free", s, tid);
2074     diff --git a/mm/vmalloc.c b/mm/vmalloc.c
2075     index dd66f1fb3fcf..153deec1df35 100644
2076     --- a/mm/vmalloc.c
2077     +++ b/mm/vmalloc.c
2078     @@ -1711,7 +1711,7 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
2079     * First make sure the mappings are removed from all page-tables
2080     * before they are freed.
2081     */
2082     - vmalloc_sync_all();
2083     + vmalloc_sync_unmappings();
2084    
2085     /*
2086     * In this function, newly allocated vm_struct has VM_UNINITIALIZED
2087     @@ -2247,16 +2247,19 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
2088     EXPORT_SYMBOL(remap_vmalloc_range);
2089    
2090     /*
2091     - * Implement a stub for vmalloc_sync_all() if the architecture chose not to
2092     - * have one.
2093     + * Implement stubs for vmalloc_sync_[un]mappings () if the architecture chose
2094     + * not to have one.
2095     *
2096     * The purpose of this function is to make sure the vmalloc area
2097     * mappings are identical in all page-tables in the system.
2098     */
2099     -void __weak vmalloc_sync_all(void)
2100     +void __weak vmalloc_sync_mappings(void)
2101     {
2102     }
2103    
2104     +void __weak vmalloc_sync_unmappings(void)
2105     +{
2106     +}
2107    
2108     static int f(pte_t *pte, pgtable_t table, unsigned long addr, void *data)
2109     {
2110     diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
2111     index 21bffde6e4bf..76d55a80f3b9 100644
2112     --- a/net/dsa/tag_brcm.c
2113     +++ b/net/dsa/tag_brcm.c
2114     @@ -84,6 +84,8 @@ static struct sk_buff *brcm_tag_xmit(struct sk_buff *skb, struct net_device *dev
2115     brcm_tag[2] = BRCM_IG_DSTMAP2_MASK;
2116     brcm_tag[3] = (1 << p->port) & BRCM_IG_DSTMAP1_MASK;
2117    
2118     + skb->offload_fwd_mark = 1;
2119     +
2120     return skb;
2121    
2122     out_free:
2123     diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c
2124     index 6705420b3111..d7206581145d 100644
2125     --- a/net/hsr/hsr_framereg.c
2126     +++ b/net/hsr/hsr_framereg.c
2127     @@ -468,13 +468,9 @@ int hsr_get_node_data(struct hsr_priv *hsr,
2128     struct hsr_port *port;
2129     unsigned long tdiff;
2130    
2131     -
2132     - rcu_read_lock();
2133     node = find_node_by_AddrA(&hsr->node_db, addr);
2134     - if (!node) {
2135     - rcu_read_unlock();
2136     - return -ENOENT; /* No such entry */
2137     - }
2138     + if (!node)
2139     + return -ENOENT;
2140    
2141     ether_addr_copy(addr_b, node->MacAddressB);
2142    
2143     @@ -509,7 +505,5 @@ int hsr_get_node_data(struct hsr_priv *hsr,
2144     *addr_b_ifindex = -1;
2145     }
2146    
2147     - rcu_read_unlock();
2148     -
2149     return 0;
2150     }
2151     diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c
2152     index d4d1617f43a8..4f869d05410f 100644
2153     --- a/net/hsr/hsr_netlink.c
2154     +++ b/net/hsr/hsr_netlink.c
2155     @@ -137,6 +137,7 @@ static struct genl_family hsr_genl_family = {
2156     .name = "HSR",
2157     .version = 1,
2158     .maxattr = HSR_A_MAX,
2159     + .netnsok = true,
2160     };
2161    
2162     static const struct genl_multicast_group hsr_mcgrps[] = {
2163     @@ -264,17 +265,16 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
2164     if (!na)
2165     goto invalid;
2166    
2167     - hsr_dev = __dev_get_by_index(genl_info_net(info),
2168     - nla_get_u32(info->attrs[HSR_A_IFINDEX]));
2169     + rcu_read_lock();
2170     + hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
2171     + nla_get_u32(info->attrs[HSR_A_IFINDEX]));
2172     if (!hsr_dev)
2173     - goto invalid;
2174     + goto rcu_unlock;
2175     if (!is_hsr_master(hsr_dev))
2176     - goto invalid;
2177     -
2178     + goto rcu_unlock;
2179    
2180     /* Send reply */
2181     -
2182     - skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
2183     + skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
2184     if (!skb_out) {
2185     res = -ENOMEM;
2186     goto fail;
2187     @@ -326,12 +326,10 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
2188     res = nla_put_u16(skb_out, HSR_A_IF1_SEQ, hsr_node_if1_seq);
2189     if (res < 0)
2190     goto nla_put_failure;
2191     - rcu_read_lock();
2192     port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_A);
2193     if (port)
2194     res = nla_put_u32(skb_out, HSR_A_IF1_IFINDEX,
2195     port->dev->ifindex);
2196     - rcu_read_unlock();
2197     if (res < 0)
2198     goto nla_put_failure;
2199    
2200     @@ -341,20 +339,22 @@ static int hsr_get_node_status(struct sk_buff *skb_in, struct genl_info *info)
2201     res = nla_put_u16(skb_out, HSR_A_IF2_SEQ, hsr_node_if2_seq);
2202     if (res < 0)
2203     goto nla_put_failure;
2204     - rcu_read_lock();
2205     port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
2206     if (port)
2207     res = nla_put_u32(skb_out, HSR_A_IF2_IFINDEX,
2208     port->dev->ifindex);
2209     - rcu_read_unlock();
2210     if (res < 0)
2211     goto nla_put_failure;
2212    
2213     + rcu_read_unlock();
2214     +
2215     genlmsg_end(skb_out, msg_head);
2216     genlmsg_unicast(genl_info_net(info), skb_out, info->snd_portid);
2217    
2218     return 0;
2219    
2220     +rcu_unlock:
2221     + rcu_read_unlock();
2222     invalid:
2223     netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL);
2224     return 0;
2225     @@ -364,6 +364,7 @@ nla_put_failure:
2226     /* Fall through */
2227    
2228     fail:
2229     + rcu_read_unlock();
2230     return res;
2231     }
2232    
2233     @@ -371,16 +372,14 @@ fail:
2234     */
2235     static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
2236     {
2237     - /* For receiving */
2238     - struct nlattr *na;
2239     + unsigned char addr[ETH_ALEN];
2240     struct net_device *hsr_dev;
2241     -
2242     - /* For sending */
2243     struct sk_buff *skb_out;
2244     - void *msg_head;
2245     struct hsr_priv *hsr;
2246     - void *pos;
2247     - unsigned char addr[ETH_ALEN];
2248     + bool restart = false;
2249     + struct nlattr *na;
2250     + void *pos = NULL;
2251     + void *msg_head;
2252     int res;
2253    
2254     if (!info)
2255     @@ -390,17 +389,17 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
2256     if (!na)
2257     goto invalid;
2258    
2259     - hsr_dev = __dev_get_by_index(genl_info_net(info),
2260     - nla_get_u32(info->attrs[HSR_A_IFINDEX]));
2261     + rcu_read_lock();
2262     + hsr_dev = dev_get_by_index_rcu(genl_info_net(info),
2263     + nla_get_u32(info->attrs[HSR_A_IFINDEX]));
2264     if (!hsr_dev)
2265     - goto invalid;
2266     + goto rcu_unlock;
2267     if (!is_hsr_master(hsr_dev))
2268     - goto invalid;
2269     -
2270     + goto rcu_unlock;
2271    
2272     +restart:
2273     /* Send reply */
2274     -
2275     - skb_out = genlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
2276     + skb_out = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_ATOMIC);
2277     if (!skb_out) {
2278     res = -ENOMEM;
2279     goto fail;
2280     @@ -414,18 +413,26 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
2281     goto nla_put_failure;
2282     }
2283    
2284     - res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
2285     - if (res < 0)
2286     - goto nla_put_failure;
2287     + if (!restart) {
2288     + res = nla_put_u32(skb_out, HSR_A_IFINDEX, hsr_dev->ifindex);
2289     + if (res < 0)
2290     + goto nla_put_failure;
2291     + }
2292    
2293     hsr = netdev_priv(hsr_dev);
2294    
2295     - rcu_read_lock();
2296     - pos = hsr_get_next_node(hsr, NULL, addr);
2297     + if (!pos)
2298     + pos = hsr_get_next_node(hsr, NULL, addr);
2299     while (pos) {
2300     res = nla_put(skb_out, HSR_A_NODE_ADDR, ETH_ALEN, addr);
2301     if (res < 0) {
2302     - rcu_read_unlock();
2303     + if (res == -EMSGSIZE) {
2304     + genlmsg_end(skb_out, msg_head);
2305     + genlmsg_unicast(genl_info_net(info), skb_out,
2306     + info->snd_portid);
2307     + restart = true;
2308     + goto restart;
2309     + }
2310     goto nla_put_failure;
2311     }
2312     pos = hsr_get_next_node(hsr, pos, addr);
2313     @@ -437,15 +444,18 @@ static int hsr_get_node_list(struct sk_buff *skb_in, struct genl_info *info)
2314    
2315     return 0;
2316    
2317     +rcu_unlock:
2318     + rcu_read_unlock();
2319     invalid:
2320     netlink_ack(skb_in, nlmsg_hdr(skb_in), -EINVAL);
2321     return 0;
2322    
2323     nla_put_failure:
2324     - kfree_skb(skb_out);
2325     + nlmsg_free(skb_out);
2326     /* Fall through */
2327    
2328     fail:
2329     + rcu_read_unlock();
2330     return res;
2331     }
2332    
2333     diff --git a/net/hsr/hsr_slave.c b/net/hsr/hsr_slave.c
2334     index 4ff6e02d8b73..3d94f547db00 100644
2335     --- a/net/hsr/hsr_slave.c
2336     +++ b/net/hsr/hsr_slave.c
2337     @@ -151,16 +151,16 @@ int hsr_add_port(struct hsr_priv *hsr, struct net_device *dev,
2338     if (port == NULL)
2339     return -ENOMEM;
2340    
2341     + port->hsr = hsr;
2342     + port->dev = dev;
2343     + port->type = type;
2344     +
2345     if (type != HSR_PT_MASTER) {
2346     res = hsr_portdev_setup(dev, port);
2347     if (res)
2348     goto fail_dev_setup;
2349     }
2350    
2351     - port->hsr = hsr;
2352     - port->dev = dev;
2353     - port->type = type;
2354     -
2355     list_add_tail_rcu(&port->port_list, &hsr->ports);
2356     synchronize_rcu();
2357    
2358     diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig
2359     index b54b3ca939db..4d265d4a0dbe 100644
2360     --- a/net/ipv4/Kconfig
2361     +++ b/net/ipv4/Kconfig
2362     @@ -298,6 +298,7 @@ config SYN_COOKIES
2363    
2364     config NET_IPVTI
2365     tristate "Virtual (secure) IP: tunneling"
2366     + depends on IPV6 || IPV6=n
2367     select INET_TUNNEL
2368     select NET_IP_TUNNEL
2369     depends on INET_XFRM_MODE_TUNNEL
2370     diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
2371     index ec417156f388..58e0dab06f19 100644
2372     --- a/net/ipv4/ip_vti.c
2373     +++ b/net/ipv4/ip_vti.c
2374     @@ -208,17 +208,39 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,
2375     int mtu;
2376    
2377     if (!dst) {
2378     - struct rtable *rt;
2379     -
2380     - fl->u.ip4.flowi4_oif = dev->ifindex;
2381     - fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
2382     - rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4);
2383     - if (IS_ERR(rt)) {
2384     + switch (skb->protocol) {
2385     + case htons(ETH_P_IP): {
2386     + struct rtable *rt;
2387     +
2388     + fl->u.ip4.flowi4_oif = dev->ifindex;
2389     + fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
2390     + rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4);
2391     + if (IS_ERR(rt)) {
2392     + dev->stats.tx_carrier_errors++;
2393     + goto tx_error_icmp;
2394     + }
2395     + dst = &rt->dst;
2396     + skb_dst_set(skb, dst);
2397     + break;
2398     + }
2399     +#if IS_ENABLED(CONFIG_IPV6)
2400     + case htons(ETH_P_IPV6):
2401     + fl->u.ip6.flowi6_oif = dev->ifindex;
2402     + fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC;
2403     + dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6);
2404     + if (dst->error) {
2405     + dst_release(dst);
2406     + dst = NULL;
2407     + dev->stats.tx_carrier_errors++;
2408     + goto tx_error_icmp;
2409     + }
2410     + skb_dst_set(skb, dst);
2411     + break;
2412     +#endif
2413     + default:
2414     dev->stats.tx_carrier_errors++;
2415     goto tx_error_icmp;
2416     }
2417     - dst = &rt->dst;
2418     - skb_dst_set(skb, dst);
2419     }
2420    
2421     dst_hold(dst);
2422     diff --git a/net/ipv4/route.c b/net/ipv4/route.c
2423     index 6058dbc4e2c1..8f5c6fa54ac0 100644
2424     --- a/net/ipv4/route.c
2425     +++ b/net/ipv4/route.c
2426     @@ -991,21 +991,22 @@ out: kfree_skb(skb);
2427     static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu)
2428     {
2429     struct dst_entry *dst = &rt->dst;
2430     + u32 old_mtu = ipv4_mtu(dst);
2431     struct fib_result res;
2432     bool lock = false;
2433    
2434     if (ip_mtu_locked(dst))
2435     return;
2436    
2437     - if (ipv4_mtu(dst) < mtu)
2438     + if (old_mtu < mtu)
2439     return;
2440    
2441     if (mtu < ip_rt_min_pmtu) {
2442     lock = true;
2443     - mtu = ip_rt_min_pmtu;
2444     + mtu = min(old_mtu, ip_rt_min_pmtu);
2445     }
2446    
2447     - if (rt->rt_pmtu == mtu &&
2448     + if (rt->rt_pmtu == mtu && !lock &&
2449     time_before(jiffies, dst->expires - ip_rt_mtu_expires / 2))
2450     return;
2451    
2452     diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
2453     index a266fac08426..b9f5155a77ef 100644
2454     --- a/net/ipv6/ip6_vti.c
2455     +++ b/net/ipv6/ip6_vti.c
2456     @@ -315,7 +315,7 @@ static int vti6_rcv(struct sk_buff *skb)
2457    
2458     if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
2459     rcu_read_unlock();
2460     - return 0;
2461     + goto discard;
2462     }
2463    
2464     ipv6h = ipv6_hdr(skb);
2465     @@ -454,15 +454,33 @@ vti6_xmit(struct sk_buff *skb, struct net_device *dev, struct flowi *fl)
2466     int mtu;
2467    
2468     if (!dst) {
2469     - fl->u.ip6.flowi6_oif = dev->ifindex;
2470     - fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC;
2471     - dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6);
2472     - if (dst->error) {
2473     - dst_release(dst);
2474     - dst = NULL;
2475     + switch (skb->protocol) {
2476     + case htons(ETH_P_IP): {
2477     + struct rtable *rt;
2478     +
2479     + fl->u.ip4.flowi4_oif = dev->ifindex;
2480     + fl->u.ip4.flowi4_flags |= FLOWI_FLAG_ANYSRC;
2481     + rt = __ip_route_output_key(dev_net(dev), &fl->u.ip4);
2482     + if (IS_ERR(rt))
2483     + goto tx_err_link_failure;
2484     + dst = &rt->dst;
2485     + skb_dst_set(skb, dst);
2486     + break;
2487     + }
2488     + case htons(ETH_P_IPV6):
2489     + fl->u.ip6.flowi6_oif = dev->ifindex;
2490     + fl->u.ip6.flowi6_flags |= FLOWI_FLAG_ANYSRC;
2491     + dst = ip6_route_output(dev_net(dev), NULL, &fl->u.ip6);
2492     + if (dst->error) {
2493     + dst_release(dst);
2494     + dst = NULL;
2495     + goto tx_err_link_failure;
2496     + }
2497     + skb_dst_set(skb, dst);
2498     + break;
2499     + default:
2500     goto tx_err_link_failure;
2501     }
2502     - skb_dst_set(skb, dst);
2503     }
2504    
2505     dst_hold(dst);
2506     diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c
2507     index 5f4c228b82e5..f7eaa1051b5b 100644
2508     --- a/net/mac80211/mesh_hwmp.c
2509     +++ b/net/mac80211/mesh_hwmp.c
2510     @@ -1131,7 +1131,8 @@ int mesh_nexthop_resolve(struct ieee80211_sub_if_data *sdata,
2511     }
2512     }
2513    
2514     - if (!(mpath->flags & MESH_PATH_RESOLVING))
2515     + if (!(mpath->flags & MESH_PATH_RESOLVING) &&
2516     + mesh_path_sel_is_hwmp(sdata))
2517     mesh_queue_preq(mpath, PREQ_Q_F_START);
2518    
2519     if (skb_queue_len(&mpath->frame_queue) >= MESH_FRAME_QUEUE_LEN)
2520     diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
2521     index c800bc7c5176..4f7061c3b770 100644
2522     --- a/net/mac80211/sta_info.c
2523     +++ b/net/mac80211/sta_info.c
2524     @@ -3,6 +3,7 @@
2525     * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
2526     * Copyright 2013-2014 Intel Mobile Communications GmbH
2527     * Copyright (C) 2015 - 2016 Intel Deutschland GmbH
2528     + * Copyright (C) 2018-2020 Intel Corporation
2529     *
2530     * This program is free software; you can redistribute it and/or modify
2531     * it under the terms of the GNU General Public License version 2 as
2532     @@ -945,6 +946,11 @@ static void __sta_info_destroy_part2(struct sta_info *sta)
2533     might_sleep();
2534     lockdep_assert_held(&local->sta_mtx);
2535    
2536     + while (sta->sta_state == IEEE80211_STA_AUTHORIZED) {
2537     + ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
2538     + WARN_ON_ONCE(ret);
2539     + }
2540     +
2541     /* now keys can no longer be reached */
2542     ieee80211_free_sta_keys(local, sta);
2543    
2544     diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
2545     index f8de166b788a..850264fac378 100644
2546     --- a/net/mac80211/tx.c
2547     +++ b/net/mac80211/tx.c
2548     @@ -3412,8 +3412,26 @@ begin:
2549     tx.skb = skb;
2550     tx.sdata = vif_to_sdata(info->control.vif);
2551    
2552     - if (txq->sta)
2553     + if (txq->sta) {
2554     tx.sta = container_of(txq->sta, struct sta_info, sta);
2555     + /*
2556     + * Drop unicast frames to unauthorised stations unless they are
2557     + * EAPOL frames from the local station.
2558     + */
2559     + if (unlikely(ieee80211_is_data(hdr->frame_control) &&
2560     + !ieee80211_vif_is_mesh(&tx.sdata->vif) &&
2561     + tx.sdata->vif.type != NL80211_IFTYPE_OCB &&
2562     + !is_multicast_ether_addr(hdr->addr1) &&
2563     + !test_sta_flag(tx.sta, WLAN_STA_AUTHORIZED) &&
2564     + (!(info->control.flags &
2565     + IEEE80211_TX_CTRL_PORT_CTRL_PROTO) ||
2566     + !ether_addr_equal(tx.sdata->vif.addr,
2567     + hdr->addr2)))) {
2568     + I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
2569     + ieee80211_free_txskb(&local->hw, skb);
2570     + goto begin;
2571     + }
2572     + }
2573    
2574     /*
2575     * The key can be removed while the packet was queued, so need to call
2576     diff --git a/net/netfilter/nft_fwd_netdev.c b/net/netfilter/nft_fwd_netdev.c
2577     index 763ebc3e0b2b..f93047f974e1 100644
2578     --- a/net/netfilter/nft_fwd_netdev.c
2579     +++ b/net/netfilter/nft_fwd_netdev.c
2580     @@ -62,6 +62,13 @@ nla_put_failure:
2581     return -1;
2582     }
2583    
2584     +static int nft_fwd_validate(const struct nft_ctx *ctx,
2585     + const struct nft_expr *expr,
2586     + const struct nft_data **data)
2587     +{
2588     + return nft_chain_validate_hooks(ctx->chain, (1 << NF_NETDEV_INGRESS));
2589     +}
2590     +
2591     static struct nft_expr_type nft_fwd_netdev_type;
2592     static const struct nft_expr_ops nft_fwd_netdev_ops = {
2593     .type = &nft_fwd_netdev_type,
2594     @@ -69,6 +76,7 @@ static const struct nft_expr_ops nft_fwd_netdev_ops = {
2595     .eval = nft_fwd_netdev_eval,
2596     .init = nft_fwd_netdev_init,
2597     .dump = nft_fwd_netdev_dump,
2598     + .validate = nft_fwd_validate,
2599     };
2600    
2601     static struct nft_expr_type nft_fwd_netdev_type __read_mostly = {
2602     diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c
2603     index 455fc8f83d0a..f20373588a99 100644
2604     --- a/net/sched/cls_route.c
2605     +++ b/net/sched/cls_route.c
2606     @@ -542,8 +542,8 @@ static int route4_change(struct net *net, struct sk_buff *in_skb,
2607     fp = &b->ht[h];
2608     for (pfp = rtnl_dereference(*fp); pfp;
2609     fp = &pfp->next, pfp = rtnl_dereference(*fp)) {
2610     - if (pfp == f) {
2611     - *fp = f->next;
2612     + if (pfp == fold) {
2613     + rcu_assign_pointer(*fp, fold->next);
2614     break;
2615     }
2616     }
2617     diff --git a/net/sched/cls_tcindex.c b/net/sched/cls_tcindex.c
2618     index 3e1695b66e31..ab66e2b38e66 100644
2619     --- a/net/sched/cls_tcindex.c
2620     +++ b/net/sched/cls_tcindex.c
2621     @@ -325,6 +325,7 @@ tcindex_set_parms(struct net *net, struct tcf_proto *tp, unsigned long base,
2622    
2623     if (tcindex_alloc_perfect_hash(cp) < 0)
2624     goto errout;
2625     + cp->alloc_hash = cp->hash;
2626     for (i = 0; i < min(cp->hash, p->hash); i++)
2627     cp->perfect[i].res = p->perfect[i].res;
2628     balloc = 1;
2629     diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
2630     index 155b1591b17a..69d061d4ed4f 100644
2631     --- a/net/xfrm/xfrm_policy.c
2632     +++ b/net/xfrm/xfrm_policy.c
2633     @@ -336,7 +336,9 @@ EXPORT_SYMBOL(xfrm_policy_destroy);
2634    
2635     static void xfrm_policy_kill(struct xfrm_policy *policy)
2636     {
2637     + write_lock_bh(&policy->lock);
2638     policy->walk.dead = 1;
2639     + write_unlock_bh(&policy->lock);
2640    
2641     atomic_inc(&policy->genid);
2642    
2643     diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
2644     index ff641b2e1577..feb24ca530f2 100644
2645     --- a/net/xfrm/xfrm_user.c
2646     +++ b/net/xfrm/xfrm_user.c
2647     @@ -109,7 +109,8 @@ static inline int verify_sec_ctx_len(struct nlattr **attrs)
2648     return 0;
2649    
2650     uctx = nla_data(rt);
2651     - if (uctx->len != (sizeof(struct xfrm_user_sec_ctx) + uctx->ctx_len))
2652     + if (uctx->len > nla_len(rt) ||
2653     + uctx->len != (sizeof(struct xfrm_user_sec_ctx) + uctx->ctx_len))
2654     return -EINVAL;
2655    
2656     return 0;
2657     @@ -2175,6 +2176,9 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
2658     xfrm_mark_get(attrs, &mark);
2659    
2660     err = verify_newpolicy_info(&ua->policy);
2661     + if (err)
2662     + goto free_state;
2663     + err = verify_sec_ctx_len(attrs);
2664     if (err)
2665     goto free_state;
2666    
2667     diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
2668     index d08b6fbdfa85..1532038f6005 100644
2669     --- a/scripts/Makefile.extrawarn
2670     +++ b/scripts/Makefile.extrawarn
2671     @@ -70,5 +70,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format)
2672     KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
2673     KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
2674     KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
2675     +KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast)
2676     endif
2677     endif
2678     diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
2679     index 790fbf6cf2d7..e4e0f6a8d07b 100644
2680     --- a/scripts/dtc/dtc-lexer.l
2681     +++ b/scripts/dtc/dtc-lexer.l
2682     @@ -38,7 +38,6 @@ LINECOMMENT "//".*\n
2683     #include "srcpos.h"
2684     #include "dtc-parser.tab.h"
2685    
2686     -YYLTYPE yylloc;
2687     extern bool treesource_error;
2688    
2689     /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
2690     diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
2691     index ba525c2f9fc2..750f7a4e3ece 100644
2692     --- a/scripts/dtc/dtc-lexer.lex.c_shipped
2693     +++ b/scripts/dtc/dtc-lexer.lex.c_shipped
2694     @@ -637,7 +637,6 @@ char *yytext;
2695     #include "srcpos.h"
2696     #include "dtc-parser.tab.h"
2697    
2698     -YYLTYPE yylloc;
2699     extern bool treesource_error;
2700    
2701     /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
2702     diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
2703     index c6888d76ca5e..0e3dd6014ce5 100644
2704     --- a/sound/core/oss/pcm_plugin.c
2705     +++ b/sound/core/oss/pcm_plugin.c
2706     @@ -111,7 +111,7 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
2707     while (plugin->next) {
2708     if (plugin->dst_frames)
2709     frames = plugin->dst_frames(plugin, frames);
2710     - if (snd_BUG_ON((snd_pcm_sframes_t)frames <= 0))
2711     + if ((snd_pcm_sframes_t)frames <= 0)
2712     return -ENXIO;
2713     plugin = plugin->next;
2714     err = snd_pcm_plugin_alloc(plugin, frames);
2715     @@ -123,7 +123,7 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
2716     while (plugin->prev) {
2717     if (plugin->src_frames)
2718     frames = plugin->src_frames(plugin, frames);
2719     - if (snd_BUG_ON((snd_pcm_sframes_t)frames <= 0))
2720     + if ((snd_pcm_sframes_t)frames <= 0)
2721     return -ENXIO;
2722     plugin = plugin->prev;
2723     err = snd_pcm_plugin_alloc(plugin, frames);
2724     @@ -209,6 +209,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
2725     if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
2726     plugin = snd_pcm_plug_last(plug);
2727     while (plugin && drv_frames > 0) {
2728     + if (drv_frames > plugin->buf_frames)
2729     + drv_frames = plugin->buf_frames;
2730     plugin_prev = plugin->prev;
2731     if (plugin->src_frames)
2732     drv_frames = plugin->src_frames(plugin, drv_frames);
2733     @@ -220,6 +222,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
2734     plugin_next = plugin->next;
2735     if (plugin->dst_frames)
2736     drv_frames = plugin->dst_frames(plugin, drv_frames);
2737     + if (drv_frames > plugin->buf_frames)
2738     + drv_frames = plugin->buf_frames;
2739     plugin = plugin_next;
2740     }
2741     } else
2742     @@ -248,11 +252,15 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
2743     if (frames < 0)
2744     return frames;
2745     }
2746     + if (frames > plugin->buf_frames)
2747     + frames = plugin->buf_frames;
2748     plugin = plugin_next;
2749     }
2750     } else if (stream == SNDRV_PCM_STREAM_CAPTURE) {
2751     plugin = snd_pcm_plug_last(plug);
2752     while (plugin) {
2753     + if (frames > plugin->buf_frames)
2754     + frames = plugin->buf_frames;
2755     plugin_prev = plugin->prev;
2756     if (plugin->src_frames) {
2757     frames = plugin->src_frames(plugin, frames);
2758     diff --git a/sound/core/seq/oss/seq_oss_midi.c b/sound/core/seq/oss/seq_oss_midi.c
2759     index 9debd1b8fd28..cdfb8f92d554 100644
2760     --- a/sound/core/seq/oss/seq_oss_midi.c
2761     +++ b/sound/core/seq/oss/seq_oss_midi.c
2762     @@ -615,6 +615,7 @@ send_midi_event(struct seq_oss_devinfo *dp, struct snd_seq_event *ev, struct seq
2763     len = snd_seq_oss_timer_start(dp->timer);
2764     if (ev->type == SNDRV_SEQ_EVENT_SYSEX) {
2765     snd_seq_oss_readq_sysex(dp->readq, mdev->seq_device, ev);
2766     + snd_midi_event_reset_decode(mdev->coder);
2767     } else {
2768     len = snd_midi_event_decode(mdev->coder, msg, sizeof(msg), ev);
2769     if (len > 0)
2770     diff --git a/sound/core/seq/seq_virmidi.c b/sound/core/seq/seq_virmidi.c
2771     index 1ebb34656241..d6fc84c11796 100644
2772     --- a/sound/core/seq/seq_virmidi.c
2773     +++ b/sound/core/seq/seq_virmidi.c
2774     @@ -95,6 +95,7 @@ static int snd_virmidi_dev_receive_event(struct snd_virmidi_dev *rdev,
2775     if ((ev->flags & SNDRV_SEQ_EVENT_LENGTH_MASK) != SNDRV_SEQ_EVENT_LENGTH_VARIABLE)
2776     continue;
2777     snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream);
2778     + snd_midi_event_reset_decode(vmidi->parser);
2779     } else {
2780     len = snd_midi_event_decode(vmidi->parser, msg, sizeof(msg), ev);
2781     if (len > 0)
2782     diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
2783     index a64612db1f15..000b59d474ab 100644
2784     --- a/sound/pci/hda/patch_realtek.c
2785     +++ b/sound/pci/hda/patch_realtek.c
2786     @@ -4212,6 +4212,8 @@ static void alc_determine_headset_type(struct hda_codec *codec)
2787     is_ctia = (val & 0x1c02) == 0x1c02;
2788     break;
2789     case 0x10ec0225:
2790     + codec->power_save_node = 1;
2791     + /* fall through */
2792     case 0x10ec0295:
2793     case 0x10ec0299:
2794     alc_process_coef_fw(codec, coef0225);
2795     diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
2796     index 09189249d0d1..ea3a9bd05e68 100644
2797     --- a/sound/usb/line6/driver.c
2798     +++ b/sound/usb/line6/driver.c
2799     @@ -306,7 +306,7 @@ static void line6_data_received(struct urb *urb)
2800     line6_midibuf_read(mb, line6->buffer_message,
2801     LINE6_MIDI_MESSAGE_MAXLEN);
2802    
2803     - if (done == 0)
2804     + if (done <= 0)
2805     break;
2806    
2807     line6->message_length = done;
2808     diff --git a/sound/usb/line6/midibuf.c b/sound/usb/line6/midibuf.c
2809     index 36a610ba342e..c931d48801eb 100644
2810     --- a/sound/usb/line6/midibuf.c
2811     +++ b/sound/usb/line6/midibuf.c
2812     @@ -163,7 +163,7 @@ int line6_midibuf_read(struct midi_buffer *this, unsigned char *data,
2813     int midi_length_prev =
2814     midibuf_message_length(this->command_prev);
2815    
2816     - if (midi_length_prev > 0) {
2817     + if (midi_length_prev > 1) {
2818     midi_length = midi_length_prev - 1;
2819     repeat = 1;
2820     } else
2821     diff --git a/tools/perf/Makefile b/tools/perf/Makefile
2822     index cd86fd7b35c4..ebcc0868b99e 100644
2823     --- a/tools/perf/Makefile
2824     +++ b/tools/perf/Makefile
2825     @@ -34,7 +34,7 @@ endif
2826     # Only pass canonical directory names as the output directory:
2827     #
2828     ifneq ($(O),)
2829     - FULL_O := $(shell readlink -f $(O) || echo $(O))
2830     + FULL_O := $(shell cd $(PWD); readlink -f $(O) || echo $(O))
2831     endif
2832    
2833     #
2834     diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
2835     index df6892596dc2..ab8ebfa2159d 100644
2836     --- a/tools/perf/util/map.c
2837     +++ b/tools/perf/util/map.c
2838     @@ -88,7 +88,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
2839     return true;
2840     }
2841    
2842     - if (!strncmp(filename, "/system/lib/", 11)) {
2843     + if (!strncmp(filename, "/system/lib/", 12)) {
2844     char *ndk, *app;
2845     const char *arch;
2846     size_t ndk_length;
2847     diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
2848     index ffaa798df75e..82e4f158c88e 100644
2849     --- a/tools/perf/util/probe-finder.c
2850     +++ b/tools/perf/util/probe-finder.c
2851     @@ -623,14 +623,19 @@ static int convert_to_trace_point(Dwarf_Die *sp_die, Dwfl_Module *mod,
2852     return -EINVAL;
2853     }
2854    
2855     - /* Try to get actual symbol name from symtab */
2856     - symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
2857     + if (dwarf_entrypc(sp_die, &eaddr) == 0) {
2858     + /* If the DIE has entrypc, use it. */
2859     + symbol = dwarf_diename(sp_die);
2860     + } else {
2861     + /* Try to get actual symbol name and address from symtab */
2862     + symbol = dwfl_module_addrsym(mod, paddr, &sym, NULL);
2863     + eaddr = sym.st_value;
2864     + }
2865     if (!symbol) {
2866     pr_warning("Failed to find symbol at 0x%lx\n",
2867     (unsigned long)paddr);
2868     return -ENOENT;
2869     }
2870     - eaddr = sym.st_value;
2871    
2872     tp->offset = (unsigned long)(paddr - eaddr);
2873     tp->address = (unsigned long)paddr;
2874     diff --git a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
2875     index 2116df9ad832..c097a3748674 100644
2876     --- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
2877     +++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
2878     @@ -83,7 +83,7 @@ static struct pci_access *pci_acc;
2879     static struct pci_dev *amd_fam14h_pci_dev;
2880     static int nbp1_entered;
2881    
2882     -struct timespec start_time;
2883     +static struct timespec start_time;
2884     static unsigned long long timediff;
2885    
2886     #ifdef DEBUG
2887     diff --git a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
2888     index 5b3205f16217..5277df27191f 100644
2889     --- a/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
2890     +++ b/tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
2891     @@ -21,7 +21,7 @@ struct cpuidle_monitor cpuidle_sysfs_monitor;
2892    
2893     static unsigned long long **previous_count;
2894     static unsigned long long **current_count;
2895     -struct timespec start_time;
2896     +static struct timespec start_time;
2897     static unsigned long long timediff;
2898    
2899     static int cpuidle_get_count_percent(unsigned int id, double *percent,
2900     diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
2901     index 05f953f0f0a0..80a21cb67d94 100644
2902     --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
2903     +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
2904     @@ -29,6 +29,8 @@ struct cpuidle_monitor *all_monitors[] = {
2905     0
2906     };
2907    
2908     +int cpu_count;
2909     +
2910     static struct cpuidle_monitor *monitors[MONITORS_MAX];
2911     static unsigned int avail_monitors;
2912    
2913     diff --git a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
2914     index 9e43f3371fbc..3558bbae2b5d 100644
2915     --- a/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
2916     +++ b/tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
2917     @@ -18,7 +18,7 @@
2918     #define CSTATE_NAME_LEN 5
2919     #define CSTATE_DESC_LEN 60
2920    
2921     -int cpu_count;
2922     +extern int cpu_count;
2923    
2924     /* Hard to define the right names ...: */
2925     enum power_range_e {
2926     diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
2927     index 7ea4438b801d..882c18201c7c 100644
2928     --- a/tools/scripts/Makefile.include
2929     +++ b/tools/scripts/Makefile.include
2930     @@ -1,7 +1,7 @@
2931     ifneq ($(O),)
2932     ifeq ($(origin O), command line)
2933     - dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
2934     - ABSOLUTE_O := $(shell cd $(O) ; pwd)
2935     + dummy := $(if $(shell cd $(PWD); test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
2936     + ABSOLUTE_O := $(shell cd $(PWD); cd $(O) ; pwd)
2937     OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
2938     COMMAND_O := O=$(ABSOLUTE_O)
2939     ifeq ($(objtree),)