Magellan Linux

Annotation of /trunk/kernel-alx/patches-5.4/0249-5.4.150-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (hide annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (18 months, 3 weeks ago) by niro
File size: 89801 byte(s)
-add missing
1 niro 3637 diff --git a/Makefile b/Makefile
2     index 1834f47fbaf61..c6b3a3d62f6ca 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,7 +1,7 @@
6     # SPDX-License-Identifier: GPL-2.0
7     VERSION = 5
8     PATCHLEVEL = 4
9     -SUBLEVEL = 149
10     +SUBLEVEL = 150
11     EXTRAVERSION =
12     NAME = Kleptomaniac Octopus
13    
14     diff --git a/arch/alpha/include/asm/io.h b/arch/alpha/include/asm/io.h
15     index 103270d5a9fc6..66a384a4ddbad 100644
16     --- a/arch/alpha/include/asm/io.h
17     +++ b/arch/alpha/include/asm/io.h
18     @@ -61,7 +61,7 @@ extern inline void set_hae(unsigned long new_hae)
19     * Change virtual addresses to physical addresses and vv.
20     */
21     #ifdef USE_48_BIT_KSEG
22     -static inline unsigned long virt_to_phys(void *address)
23     +static inline unsigned long virt_to_phys(volatile void *address)
24     {
25     return (unsigned long)address - IDENT_ADDR;
26     }
27     @@ -71,7 +71,7 @@ static inline void * phys_to_virt(unsigned long address)
28     return (void *) (address + IDENT_ADDR);
29     }
30     #else
31     -static inline unsigned long virt_to_phys(void *address)
32     +static inline unsigned long virt_to_phys(volatile void *address)
33     {
34     unsigned long phys = (unsigned long)address;
35    
36     @@ -107,7 +107,7 @@ static inline void * phys_to_virt(unsigned long address)
37     extern unsigned long __direct_map_base;
38     extern unsigned long __direct_map_size;
39    
40     -static inline unsigned long __deprecated virt_to_bus(void *address)
41     +static inline unsigned long __deprecated virt_to_bus(volatile void *address)
42     {
43     unsigned long phys = virt_to_phys(address);
44     unsigned long bus = phys + __direct_map_base;
45     diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
46     index 025e02d23da9b..de0eabff29353 100644
47     --- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
48     +++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts
49     @@ -138,6 +138,23 @@
50     max-link-speed = <2>;
51     reset-gpios = <&gpiosb 3 GPIO_ACTIVE_LOW>;
52     phys = <&comphy1 0>;
53     + /*
54     + * U-Boot port for Turris Mox has a bug which always expects that "ranges" DT property
55     + * contains exactly 2 ranges with 3 (child) address cells, 2 (parent) address cells and
56     + * 2 size cells and also expects that the second range starts at 16 MB offset. If these
57     + * conditions are not met then U-Boot crashes during loading kernel DTB file. PCIe address
58     + * space is 128 MB long, so the best split between MEM and IO is to use fixed 16 MB window
59     + * for IO and the rest 112 MB (64+32+16) for MEM, despite that maximal IO size is just 64 kB.
60     + * This bug is not present in U-Boot ports for other Armada 3700 devices and is fixed in
61     + * U-Boot version 2021.07. See relevant U-Boot commits (the last one contains fix):
62     + * https://source.denx.de/u-boot/u-boot/-/commit/cb2ddb291ee6fcbddd6d8f4ff49089dfe580f5d7
63     + * https://source.denx.de/u-boot/u-boot/-/commit/c64ac3b3185aeb3846297ad7391fc6df8ecd73bf
64     + * https://source.denx.de/u-boot/u-boot/-/commit/4a82fca8e330157081fc132a591ebd99ba02ee33
65     + */
66     + #address-cells = <3>;
67     + #size-cells = <2>;
68     + ranges = <0x81000000 0 0xe8000000 0 0xe8000000 0 0x01000000 /* Port 0 IO */
69     + 0x82000000 0 0xe9000000 0 0xe9000000 0 0x07000000>; /* Port 0 MEM */
70    
71     /* enabled by U-Boot if PCIe module is present */
72     status = "disabled";
73     diff --git a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
74     index 52767037e0494..c28611c1c251a 100644
75     --- a/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
76     +++ b/arch/arm64/boot/dts/marvell/armada-37xx.dtsi
77     @@ -487,8 +487,15 @@
78     #interrupt-cells = <1>;
79     msi-parent = <&pcie0>;
80     msi-controller;
81     - ranges = <0x82000000 0 0xe8000000 0 0xe8000000 0 0x1000000 /* Port 0 MEM */
82     - 0x81000000 0 0xe9000000 0 0xe9000000 0 0x10000>; /* Port 0 IO*/
83     + /*
84     + * The 128 MiB address range [0xe8000000-0xf0000000] is
85     + * dedicated for PCIe and can be assigned to 8 windows
86     + * with size a power of two. Use one 64 KiB window for
87     + * IO at the end and the remaining seven windows
88     + * (totaling 127 MiB) for MEM.
89     + */
90     + ranges = <0x82000000 0 0xe8000000 0 0xe8000000 0 0x07f00000 /* Port 0 MEM */
91     + 0x81000000 0 0xefff0000 0 0xefff0000 0 0x00010000>; /* Port 0 IO */
92     interrupt-map-mask = <0 0 0 7>;
93     interrupt-map = <0 0 0 1 &pcie_intc 0>,
94     <0 0 0 2 &pcie_intc 1>,
95     diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
96     index 7d7cfa128b71b..f61ef46ebff74 100644
97     --- a/arch/arm64/kernel/process.c
98     +++ b/arch/arm64/kernel/process.c
99     @@ -56,7 +56,7 @@
100    
101     #if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK)
102     #include <linux/stackprotector.h>
103     -unsigned long __stack_chk_guard __read_mostly;
104     +unsigned long __stack_chk_guard __ro_after_init;
105     EXPORT_SYMBOL(__stack_chk_guard);
106     #endif
107    
108     diff --git a/arch/m68k/include/asm/raw_io.h b/arch/m68k/include/asm/raw_io.h
109     index 8a6dc6e5a279c..8ab3c350bd530 100644
110     --- a/arch/m68k/include/asm/raw_io.h
111     +++ b/arch/m68k/include/asm/raw_io.h
112     @@ -17,21 +17,21 @@
113     * two accesses to memory, which may be undesirable for some devices.
114     */
115     #define in_8(addr) \
116     - ({ u8 __v = (*(__force volatile u8 *) (addr)); __v; })
117     + ({ u8 __v = (*(__force volatile u8 *) (unsigned long)(addr)); __v; })
118     #define in_be16(addr) \
119     - ({ u16 __v = (*(__force volatile u16 *) (addr)); __v; })
120     + ({ u16 __v = (*(__force volatile u16 *) (unsigned long)(addr)); __v; })
121     #define in_be32(addr) \
122     - ({ u32 __v = (*(__force volatile u32 *) (addr)); __v; })
123     + ({ u32 __v = (*(__force volatile u32 *) (unsigned long)(addr)); __v; })
124     #define in_le16(addr) \
125     - ({ u16 __v = le16_to_cpu(*(__force volatile __le16 *) (addr)); __v; })
126     + ({ u16 __v = le16_to_cpu(*(__force volatile __le16 *) (unsigned long)(addr)); __v; })
127     #define in_le32(addr) \
128     - ({ u32 __v = le32_to_cpu(*(__force volatile __le32 *) (addr)); __v; })
129     + ({ u32 __v = le32_to_cpu(*(__force volatile __le32 *) (unsigned long)(addr)); __v; })
130    
131     -#define out_8(addr,b) (void)((*(__force volatile u8 *) (addr)) = (b))
132     -#define out_be16(addr,w) (void)((*(__force volatile u16 *) (addr)) = (w))
133     -#define out_be32(addr,l) (void)((*(__force volatile u32 *) (addr)) = (l))
134     -#define out_le16(addr,w) (void)((*(__force volatile __le16 *) (addr)) = cpu_to_le16(w))
135     -#define out_le32(addr,l) (void)((*(__force volatile __le32 *) (addr)) = cpu_to_le32(l))
136     +#define out_8(addr,b) (void)((*(__force volatile u8 *) (unsigned long)(addr)) = (b))
137     +#define out_be16(addr,w) (void)((*(__force volatile u16 *) (unsigned long)(addr)) = (w))
138     +#define out_be32(addr,l) (void)((*(__force volatile u32 *) (unsigned long)(addr)) = (l))
139     +#define out_le16(addr,w) (void)((*(__force volatile __le16 *) (unsigned long)(addr)) = cpu_to_le16(w))
140     +#define out_le32(addr,l) (void)((*(__force volatile __le32 *) (unsigned long)(addr)) = cpu_to_le32(l))
141    
142     #define raw_inb in_8
143     #define raw_inw in_be16
144     diff --git a/arch/parisc/include/asm/page.h b/arch/parisc/include/asm/page.h
145     index 93caf17ac5e2f..9ebf3b0413d5f 100644
146     --- a/arch/parisc/include/asm/page.h
147     +++ b/arch/parisc/include/asm/page.h
148     @@ -181,7 +181,7 @@ extern int npmem_ranges;
149     #include <asm-generic/getorder.h>
150     #include <asm/pdc.h>
151    
152     -#define PAGE0 ((struct zeropage *)__PAGE_OFFSET)
153     +#define PAGE0 ((struct zeropage *)absolute_pointer(__PAGE_OFFSET))
154    
155     /* DEFINITION OF THE ZERO-PAGE (PAG0) */
156     /* based on work by Jason Eckhardt (jason@equator.com) */
157     diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c
158     index f89603855f1ec..b87e0002131dd 100644
159     --- a/arch/sparc/kernel/ioport.c
160     +++ b/arch/sparc/kernel/ioport.c
161     @@ -356,7 +356,9 @@ err_nomem:
162     void arch_dma_free(struct device *dev, size_t size, void *cpu_addr,
163     dma_addr_t dma_addr, unsigned long attrs)
164     {
165     - if (!sparc_dma_free_resource(cpu_addr, PAGE_ALIGN(size)))
166     + size = PAGE_ALIGN(size);
167     +
168     + if (!sparc_dma_free_resource(cpu_addr, size))
169     return;
170    
171     dma_make_coherent(dma_addr, size);
172     diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
173     index 8e645ddac58e2..30f171b7b00c2 100644
174     --- a/arch/sparc/kernel/mdesc.c
175     +++ b/arch/sparc/kernel/mdesc.c
176     @@ -39,6 +39,7 @@ struct mdesc_hdr {
177     u32 node_sz; /* node block size */
178     u32 name_sz; /* name block size */
179     u32 data_sz; /* data block size */
180     + char data[];
181     } __attribute__((aligned(16)));
182    
183     struct mdesc_elem {
184     @@ -612,7 +613,7 @@ EXPORT_SYMBOL(mdesc_get_node_info);
185    
186     static struct mdesc_elem *node_block(struct mdesc_hdr *mdesc)
187     {
188     - return (struct mdesc_elem *) (mdesc + 1);
189     + return (struct mdesc_elem *) mdesc->data;
190     }
191    
192     static void *name_block(struct mdesc_hdr *mdesc)
193     diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
194     index b99074ca5e686..65cf405cd9753 100644
195     --- a/arch/x86/xen/enlighten_pv.c
196     +++ b/arch/x86/xen/enlighten_pv.c
197     @@ -727,8 +727,8 @@ static void xen_write_idt_entry(gate_desc *dt, int entrynum, const gate_desc *g)
198     preempt_enable();
199     }
200    
201     -static void xen_convert_trap_info(const struct desc_ptr *desc,
202     - struct trap_info *traps)
203     +static unsigned xen_convert_trap_info(const struct desc_ptr *desc,
204     + struct trap_info *traps, bool full)
205     {
206     unsigned in, out, count;
207    
208     @@ -738,17 +738,18 @@ static void xen_convert_trap_info(const struct desc_ptr *desc,
209     for (in = out = 0; in < count; in++) {
210     gate_desc *entry = (gate_desc *)(desc->address) + in;
211    
212     - if (cvt_gate_to_trap(in, entry, &traps[out]))
213     + if (cvt_gate_to_trap(in, entry, &traps[out]) || full)
214     out++;
215     }
216     - traps[out].address = 0;
217     +
218     + return out;
219     }
220    
221     void xen_copy_trap_info(struct trap_info *traps)
222     {
223     const struct desc_ptr *desc = this_cpu_ptr(&idt_desc);
224    
225     - xen_convert_trap_info(desc, traps);
226     + xen_convert_trap_info(desc, traps, true);
227     }
228    
229     /* Load a new IDT into Xen. In principle this can be per-CPU, so we
230     @@ -758,6 +759,7 @@ static void xen_load_idt(const struct desc_ptr *desc)
231     {
232     static DEFINE_SPINLOCK(lock);
233     static struct trap_info traps[257];
234     + unsigned out;
235    
236     trace_xen_cpu_load_idt(desc);
237    
238     @@ -765,7 +767,8 @@ static void xen_load_idt(const struct desc_ptr *desc)
239    
240     memcpy(this_cpu_ptr(&idt_desc), desc, sizeof(idt_desc));
241    
242     - xen_convert_trap_info(desc, traps);
243     + out = xen_convert_trap_info(desc, traps, false);
244     + memset(&traps[out], 0, sizeof(traps[0]));
245    
246     xen_mc_flush();
247     if (HYPERVISOR_set_trap_table(traps))
248     diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
249     index cb3d44d200055..dde8d0acfb34f 100644
250     --- a/block/blk-cgroup.c
251     +++ b/block/blk-cgroup.c
252     @@ -1462,10 +1462,14 @@ enomem:
253     /* alloc failed, nothing's initialized yet, free everything */
254     spin_lock_irq(&q->queue_lock);
255     list_for_each_entry(blkg, &q->blkg_list, q_node) {
256     + struct blkcg *blkcg = blkg->blkcg;
257     +
258     + spin_lock(&blkcg->lock);
259     if (blkg->pd[pol->plid]) {
260     pol->pd_free_fn(blkg->pd[pol->plid]);
261     blkg->pd[pol->plid] = NULL;
262     }
263     + spin_unlock(&blkcg->lock);
264     }
265     spin_unlock_irq(&q->queue_lock);
266     ret = -ENOMEM;
267     @@ -1497,12 +1501,16 @@ void blkcg_deactivate_policy(struct request_queue *q,
268     __clear_bit(pol->plid, q->blkcg_pols);
269    
270     list_for_each_entry(blkg, &q->blkg_list, q_node) {
271     + struct blkcg *blkcg = blkg->blkcg;
272     +
273     + spin_lock(&blkcg->lock);
274     if (blkg->pd[pol->plid]) {
275     if (pol->pd_offline_fn)
276     pol->pd_offline_fn(blkg->pd[pol->plid]);
277     pol->pd_free_fn(blkg->pd[pol->plid]);
278     blkg->pd[pol->plid] = NULL;
279     }
280     + spin_unlock(&blkcg->lock);
281     }
282    
283     spin_unlock_irq(&q->queue_lock);
284     diff --git a/drivers/android/binder.c b/drivers/android/binder.c
285     index 89b590c9573ff..4eaef780844ea 100644
286     --- a/drivers/android/binder.c
287     +++ b/drivers/android/binder.c
288     @@ -2239,6 +2239,7 @@ static void binder_deferred_fd_close(int fd)
289     }
290    
291     static void binder_transaction_buffer_release(struct binder_proc *proc,
292     + struct binder_thread *thread,
293     struct binder_buffer *buffer,
294     binder_size_t failed_at,
295     bool is_failure)
296     @@ -2398,8 +2399,16 @@ static void binder_transaction_buffer_release(struct binder_proc *proc,
297     &proc->alloc, &fd, buffer,
298     offset, sizeof(fd));
299     WARN_ON(err);
300     - if (!err)
301     + if (!err) {
302     binder_deferred_fd_close(fd);
303     + /*
304     + * Need to make sure the thread goes
305     + * back to userspace to complete the
306     + * deferred close
307     + */
308     + if (thread)
309     + thread->looper_need_return = true;
310     + }
311     }
312     } break;
313     default:
314     @@ -3469,7 +3478,7 @@ err_bad_parent:
315     err_copy_data_failed:
316     binder_free_txn_fixups(t);
317     trace_binder_transaction_failed_buffer_release(t->buffer);
318     - binder_transaction_buffer_release(target_proc, t->buffer,
319     + binder_transaction_buffer_release(target_proc, NULL, t->buffer,
320     buffer_offset, true);
321     if (target_node)
322     binder_dec_node_tmpref(target_node);
323     @@ -3546,7 +3555,9 @@ err_invalid_target_handle:
324     * Cleanup buffer and free it.
325     */
326     static void
327     -binder_free_buf(struct binder_proc *proc, struct binder_buffer *buffer)
328     +binder_free_buf(struct binder_proc *proc,
329     + struct binder_thread *thread,
330     + struct binder_buffer *buffer)
331     {
332     binder_inner_proc_lock(proc);
333     if (buffer->transaction) {
334     @@ -3574,7 +3585,7 @@ binder_free_buf(struct binder_proc *proc, struct binder_buffer *buffer)
335     binder_node_inner_unlock(buf_node);
336     }
337     trace_binder_transaction_buffer_release(buffer);
338     - binder_transaction_buffer_release(proc, buffer, 0, false);
339     + binder_transaction_buffer_release(proc, thread, buffer, 0, false);
340     binder_alloc_free_buf(&proc->alloc, buffer);
341     }
342    
343     @@ -3775,7 +3786,7 @@ static int binder_thread_write(struct binder_proc *proc,
344     proc->pid, thread->pid, (u64)data_ptr,
345     buffer->debug_id,
346     buffer->transaction ? "active" : "finished");
347     - binder_free_buf(proc, buffer);
348     + binder_free_buf(proc, thread, buffer);
349     break;
350     }
351    
352     @@ -4463,7 +4474,7 @@ retry:
353     buffer->transaction = NULL;
354     binder_cleanup_transaction(t, "fd fixups failed",
355     BR_FAILED_REPLY);
356     - binder_free_buf(proc, buffer);
357     + binder_free_buf(proc, thread, buffer);
358     binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
359     "%d:%d %stransaction %d fd fixups failed %d/%d, line %d\n",
360     proc->pid, thread->pid,
361     diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c
362     index 880ffd8337187..6becf3363ad57 100644
363     --- a/drivers/edac/synopsys_edac.c
364     +++ b/drivers/edac/synopsys_edac.c
365     @@ -782,7 +782,7 @@ static void init_csrows(struct mem_ctl_info *mci)
366    
367     for (j = 0; j < csi->nr_channels; j++) {
368     dimm = csi->channels[j]->dimm;
369     - dimm->edac_mode = EDAC_FLAG_SECDED;
370     + dimm->edac_mode = EDAC_SECDED;
371     dimm->mtype = p_data->get_mtype(priv->baseaddr);
372     dimm->nr_pages = (size >> PAGE_SHIFT) / csi->nr_channels;
373     dimm->grain = SYNPS_EDAC_ERR_GRAIN;
374     diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c
375     index 4d8a876415874..37e54e375528e 100644
376     --- a/drivers/fpga/machxo2-spi.c
377     +++ b/drivers/fpga/machxo2-spi.c
378     @@ -223,8 +223,10 @@ static int machxo2_write_init(struct fpga_manager *mgr,
379     goto fail;
380    
381     get_status(spi, &status);
382     - if (test_bit(FAIL, &status))
383     + if (test_bit(FAIL, &status)) {
384     + ret = -EINVAL;
385     goto fail;
386     + }
387     dump_status_reg(&status);
388    
389     spi_message_init(&msg);
390     @@ -310,6 +312,7 @@ static int machxo2_write_complete(struct fpga_manager *mgr,
391     dump_status_reg(&status);
392     if (!test_bit(DONE, &status)) {
393     machxo2_cleanup(mgr);
394     + ret = -EINVAL;
395     goto fail;
396     }
397    
398     @@ -331,6 +334,7 @@ static int machxo2_write_complete(struct fpga_manager *mgr,
399     break;
400     if (++refreshloop == MACHXO2_MAX_REFRESH_LOOP) {
401     machxo2_cleanup(mgr);
402     + ret = -EINVAL;
403     goto fail;
404     }
405     } while (1);
406     diff --git a/drivers/gpio/gpio-uniphier.c b/drivers/gpio/gpio-uniphier.c
407     index 93cdcc41e9fbc..0f1cf50b4dcea 100644
408     --- a/drivers/gpio/gpio-uniphier.c
409     +++ b/drivers/gpio/gpio-uniphier.c
410     @@ -188,7 +188,7 @@ static void uniphier_gpio_irq_mask(struct irq_data *data)
411    
412     uniphier_gpio_reg_update(priv, UNIPHIER_GPIO_IRQ_EN, mask, 0);
413    
414     - return irq_chip_mask_parent(data);
415     + irq_chip_mask_parent(data);
416     }
417    
418     static void uniphier_gpio_irq_unmask(struct irq_data *data)
419     @@ -198,7 +198,7 @@ static void uniphier_gpio_irq_unmask(struct irq_data *data)
420    
421     uniphier_gpio_reg_update(priv, UNIPHIER_GPIO_IRQ_EN, mask, mask);
422    
423     - return irq_chip_unmask_parent(data);
424     + irq_chip_unmask_parent(data);
425     }
426    
427     static int uniphier_gpio_irq_set_type(struct irq_data *data, unsigned int type)
428     diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
429     index 97f9c001d8ff7..20f44ef9c4c9b 100644
430     --- a/drivers/irqchip/Kconfig
431     +++ b/drivers/irqchip/Kconfig
432     @@ -415,6 +415,7 @@ config MESON_IRQ_GPIO
433     config GOLDFISH_PIC
434     bool "Goldfish programmable interrupt controller"
435     depends on MIPS && (GOLDFISH || COMPILE_TEST)
436     + select GENERIC_IRQ_CHIP
437     select IRQ_DOMAIN
438     help
439     Say yes here to enable Goldfish interrupt controller driver used
440     diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
441     index f298313b87ac7..398c54387988a 100644
442     --- a/drivers/irqchip/irq-gic-v3-its.c
443     +++ b/drivers/irqchip/irq-gic-v3-its.c
444     @@ -3123,7 +3123,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq
445    
446     if (err) {
447     if (i > 0)
448     - its_vpe_irq_domain_free(domain, virq, i - 1);
449     + its_vpe_irq_domain_free(domain, virq, i);
450    
451     its_lpi_free(bitmap, base, nr_ids);
452     its_free_prop_table(vprop_page);
453     diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
454     index b72e82efaee52..c799bb81ab03d 100644
455     --- a/drivers/mcb/mcb-core.c
456     +++ b/drivers/mcb/mcb-core.c
457     @@ -277,8 +277,8 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
458    
459     bus_nr = ida_simple_get(&mcb_ida, 0, 0, GFP_KERNEL);
460     if (bus_nr < 0) {
461     - rc = bus_nr;
462     - goto err_free;
463     + kfree(bus);
464     + return ERR_PTR(bus_nr);
465     }
466    
467     bus->bus_nr = bus_nr;
468     @@ -293,12 +293,12 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)
469     dev_set_name(&bus->dev, "mcb:%d", bus_nr);
470     rc = device_add(&bus->dev);
471     if (rc)
472     - goto err_free;
473     + goto err_put;
474    
475     return bus;
476     -err_free:
477     - put_device(carrier);
478     - kfree(bus);
479     +
480     +err_put:
481     + put_device(&bus->dev);
482     return ERR_PTR(rc);
483     }
484     EXPORT_SYMBOL_GPL(mcb_alloc_bus);
485     diff --git a/drivers/md/md.c b/drivers/md/md.c
486     index 761d43829b2b7..c178b2f406de3 100644
487     --- a/drivers/md/md.c
488     +++ b/drivers/md/md.c
489     @@ -5535,10 +5535,6 @@ static int md_alloc(dev_t dev, char *name)
490     */
491     disk->flags |= GENHD_FL_EXT_DEVT;
492     mddev->gendisk = disk;
493     - /* As soon as we call add_disk(), another thread could get
494     - * through to md_open, so make sure it doesn't get too far
495     - */
496     - mutex_lock(&mddev->open_mutex);
497     add_disk(disk);
498    
499     error = kobject_add(&mddev->kobj, &disk_to_dev(disk)->kobj, "%s", "md");
500     @@ -5553,7 +5549,6 @@ static int md_alloc(dev_t dev, char *name)
501     if (mddev->kobj.sd &&
502     sysfs_create_group(&mddev->kobj, &md_bitmap_group))
503     pr_debug("pointless warning\n");
504     - mutex_unlock(&mddev->open_mutex);
505     abort:
506     mutex_unlock(&disks_mutex);
507     if (!error && mddev->kobj.sd) {
508     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
509     index e67f07faca789..7f590a9e3af79 100644
510     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
511     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
512     @@ -372,7 +372,7 @@ static bool bnxt_txr_netif_try_stop_queue(struct bnxt *bp,
513     * netif_tx_queue_stopped().
514     */
515     smp_mb();
516     - if (bnxt_tx_avail(bp, txr) > bp->tx_wake_thresh) {
517     + if (bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh) {
518     netif_tx_wake_queue(txq);
519     return false;
520     }
521     @@ -701,7 +701,7 @@ next_tx_int:
522     smp_mb();
523    
524     if (unlikely(netif_tx_queue_stopped(txq)) &&
525     - bnxt_tx_avail(bp, txr) > bp->tx_wake_thresh &&
526     + bnxt_tx_avail(bp, txr) >= bp->tx_wake_thresh &&
527     READ_ONCE(txr->dev_state) != BNXT_DEV_STATE_CLOSING)
528     netif_tx_wake_queue(txq);
529     }
530     @@ -2206,7 +2206,7 @@ static int __bnxt_poll_work(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
531     if (TX_CMP_TYPE(txcmp) == CMP_TYPE_TX_L2_CMP) {
532     tx_pkts++;
533     /* return full budget so NAPI will complete. */
534     - if (unlikely(tx_pkts > bp->tx_wake_thresh)) {
535     + if (unlikely(tx_pkts >= bp->tx_wake_thresh)) {
536     rx_pkts = budget;
537     raw_cons = NEXT_RAW_CMP(raw_cons);
538     if (budget)
539     @@ -3329,7 +3329,7 @@ static int bnxt_init_tx_rings(struct bnxt *bp)
540     u16 i;
541    
542     bp->tx_wake_thresh = max_t(int, bp->tx_ring_size / 2,
543     - MAX_SKB_FRAGS + 1);
544     + BNXT_MIN_TX_DESC_CNT);
545    
546     for (i = 0; i < bp->tx_nr_rings; i++) {
547     struct bnxt_tx_ring_info *txr = &bp->tx_ring[i];
548     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
549     index 510ff01bdad8c..8ba369c0100b4 100644
550     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
551     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
552     @@ -601,6 +601,11 @@ struct nqe_cn {
553     #define BNXT_MAX_RX_JUM_DESC_CNT (RX_DESC_CNT * MAX_RX_AGG_PAGES - 1)
554     #define BNXT_MAX_TX_DESC_CNT (TX_DESC_CNT * MAX_TX_PAGES - 1)
555    
556     +/* Minimum TX BDs for a TX packet with MAX_SKB_FRAGS + 1. We need one extra
557     + * BD because the first TX BD is always a long BD.
558     + */
559     +#define BNXT_MIN_TX_DESC_CNT (MAX_SKB_FRAGS + 2)
560     +
561     #define RX_RING(x) (((x) & ~(RX_DESC_CNT - 1)) >> (BNXT_PAGE_SHIFT - 4))
562     #define RX_IDX(x) ((x) & (RX_DESC_CNT - 1))
563    
564     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
565     index 2118523782246..97aff84fd1d17 100644
566     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
567     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
568     @@ -744,7 +744,7 @@ static int bnxt_set_ringparam(struct net_device *dev,
569    
570     if ((ering->rx_pending > BNXT_MAX_RX_DESC_CNT) ||
571     (ering->tx_pending > BNXT_MAX_TX_DESC_CNT) ||
572     - (ering->tx_pending <= MAX_SKB_FRAGS))
573     + (ering->tx_pending < BNXT_MIN_TX_DESC_CNT))
574     return -EINVAL;
575    
576     if (netif_running(dev))
577     diff --git a/drivers/net/ethernet/cadence/macb_pci.c b/drivers/net/ethernet/cadence/macb_pci.c
578     index 617b3b728dd04..94f3babfad309 100644
579     --- a/drivers/net/ethernet/cadence/macb_pci.c
580     +++ b/drivers/net/ethernet/cadence/macb_pci.c
581     @@ -112,9 +112,9 @@ static void macb_remove(struct pci_dev *pdev)
582     struct platform_device *plat_dev = pci_get_drvdata(pdev);
583     struct macb_platform_data *plat_data = dev_get_platdata(&plat_dev->dev);
584    
585     - platform_device_unregister(plat_dev);
586     clk_unregister(plat_data->pclk);
587     clk_unregister(plat_data->hclk);
588     + platform_device_unregister(plat_dev);
589     }
590    
591     static const struct pci_device_id dev_id_table[] = {
592     diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
593     index b77eaf31bd4ed..cee77326e7e85 100644
594     --- a/drivers/net/ethernet/freescale/enetc/enetc.c
595     +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
596     @@ -1222,7 +1222,6 @@ static void enetc_clear_bdrs(struct enetc_ndev_priv *priv)
597     static int enetc_setup_irqs(struct enetc_ndev_priv *priv)
598     {
599     struct pci_dev *pdev = priv->si->pdev;
600     - cpumask_t cpu_mask;
601     int i, j, err;
602    
603     for (i = 0; i < priv->bdr_int_num; i++) {
604     @@ -1249,9 +1248,7 @@ static int enetc_setup_irqs(struct enetc_ndev_priv *priv)
605    
606     enetc_wr(hw, ENETC_SIMSITRV(idx), entry);
607     }
608     - cpumask_clear(&cpu_mask);
609     - cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
610     - irq_set_affinity_hint(irq, &cpu_mask);
611     + irq_set_affinity_hint(irq, get_cpu_mask(i % num_online_cpus()));
612     }
613    
614     return 0;
615     diff --git a/drivers/net/ethernet/i825xx/82596.c b/drivers/net/ethernet/i825xx/82596.c
616     index 92929750f8325..54d5b402b0e8d 100644
617     --- a/drivers/net/ethernet/i825xx/82596.c
618     +++ b/drivers/net/ethernet/i825xx/82596.c
619     @@ -1155,7 +1155,7 @@ struct net_device * __init i82596_probe(int unit)
620     err = -ENODEV;
621     goto out;
622     }
623     - memcpy(eth_addr, (void *) 0xfffc1f2c, ETH_ALEN); /* YUCK! Get addr from NOVRAM */
624     + memcpy(eth_addr, absolute_pointer(0xfffc1f2c), ETH_ALEN); /* YUCK! Get addr from NOVRAM */
625     dev->base_addr = MVME_I596_BASE;
626     dev->irq = (unsigned) MVME16x_IRQ_I596;
627     goto found;
628     diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
629     index cd165e52ed33c..d029179a4804c 100644
630     --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
631     +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
632     @@ -371,6 +371,9 @@ mlx4_en_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
633     int nhoff = skb_network_offset(skb);
634     int ret = 0;
635    
636     + if (skb->encapsulation)
637     + return -EPROTONOSUPPORT;
638     +
639     if (skb->protocol != htons(ETH_P_IP))
640     return -EPROTONOSUPPORT;
641    
642     diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
643     index 9adbaccd0c5ed..934740d604709 100644
644     --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
645     +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
646     @@ -1307,6 +1307,14 @@ qed_iwarp_wait_cid_map_cleared(struct qed_hwfn *p_hwfn, struct qed_bmap *bmap)
647     prev_weight = weight;
648    
649     while (weight) {
650     + /* If the HW device is during recovery, all resources are
651     + * immediately reset without receiving a per-cid indication
652     + * from HW. In this case we don't expect the cid_map to be
653     + * cleared.
654     + */
655     + if (p_hwfn->cdev->recov_in_prog)
656     + return 0;
657     +
658     msleep(QED_IWARP_MAX_CID_CLEAN_TIME);
659    
660     weight = bitmap_weight(bmap->bitmap, bmap->max_count);
661     diff --git a/drivers/net/ethernet/qlogic/qed/qed_roce.c b/drivers/net/ethernet/qlogic/qed/qed_roce.c
662     index 83817bb50e9fa..6e6563b51d688 100644
663     --- a/drivers/net/ethernet/qlogic/qed/qed_roce.c
664     +++ b/drivers/net/ethernet/qlogic/qed/qed_roce.c
665     @@ -107,6 +107,14 @@ void qed_roce_stop(struct qed_hwfn *p_hwfn)
666     * Beyond the added delay we clear the bitmap anyway.
667     */
668     while (bitmap_weight(rcid_map->bitmap, rcid_map->max_count)) {
669     + /* If the HW device is during recovery, all resources are
670     + * immediately reset without receiving a per-cid indication
671     + * from HW. In this case we don't expect the cid bitmap to be
672     + * cleared.
673     + */
674     + if (p_hwfn->cdev->recov_in_prog)
675     + return;
676     +
677     msleep(100);
678     if (wait_count++ > 20) {
679     DP_NOTICE(p_hwfn, "cid bitmap wait timed out\n");
680     diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
681     index 4e7cfd3bfcd2e..e09851c7da9b8 100644
682     --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
683     +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
684     @@ -225,7 +225,7 @@ static void stmmac_clk_csr_set(struct stmmac_priv *priv)
685     priv->clk_csr = STMMAC_CSR_100_150M;
686     else if ((clk_rate >= CSR_F_150M) && (clk_rate < CSR_F_250M))
687     priv->clk_csr = STMMAC_CSR_150_250M;
688     - else if ((clk_rate >= CSR_F_250M) && (clk_rate < CSR_F_300M))
689     + else if ((clk_rate >= CSR_F_250M) && (clk_rate <= CSR_F_300M))
690     priv->clk_csr = STMMAC_CSR_250_300M;
691     }
692    
693     diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
694     index da13683d52d1a..bd0beb16d68a9 100644
695     --- a/drivers/net/hamradio/6pack.c
696     +++ b/drivers/net/hamradio/6pack.c
697     @@ -68,9 +68,9 @@
698     #define SIXP_DAMA_OFF 0
699    
700     /* default level 2 parameters */
701     -#define SIXP_TXDELAY (HZ/4) /* in 1 s */
702     +#define SIXP_TXDELAY 25 /* 250 ms */
703     #define SIXP_PERSIST 50 /* in 256ths */
704     -#define SIXP_SLOTTIME (HZ/10) /* in 1 s */
705     +#define SIXP_SLOTTIME 10 /* 100 ms */
706     #define SIXP_INIT_RESYNC_TIMEOUT (3*HZ/2) /* in 1 s */
707     #define SIXP_RESYNC_TIMEOUT 5*HZ /* in 1 s */
708    
709     diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
710     index 22450c4a92251..9ad1f093c4ae1 100644
711     --- a/drivers/net/usb/hso.c
712     +++ b/drivers/net/usb/hso.c
713     @@ -2704,14 +2704,14 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
714    
715     serial = kzalloc(sizeof(*serial), GFP_KERNEL);
716     if (!serial)
717     - goto exit;
718     + goto err_free_dev;
719    
720     hso_dev->port_data.dev_serial = serial;
721     serial->parent = hso_dev;
722    
723     if (hso_serial_common_create
724     (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE))
725     - goto exit;
726     + goto err_free_serial;
727    
728     serial->tx_data_length--;
729     serial->write_data = hso_mux_serial_write_data;
730     @@ -2727,11 +2727,9 @@ struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface,
731     /* done, return it */
732     return hso_dev;
733    
734     -exit:
735     - if (serial) {
736     - tty_unregister_device(tty_drv, serial->minor);
737     - kfree(serial);
738     - }
739     +err_free_serial:
740     + kfree(serial);
741     +err_free_dev:
742     kfree(hso_dev);
743     return NULL;
744    
745     diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
746     index 590b040e90a34..016a67fd41989 100644
747     --- a/drivers/nvme/host/multipath.c
748     +++ b/drivers/nvme/host/multipath.c
749     @@ -522,14 +522,17 @@ static int nvme_update_ana_state(struct nvme_ctrl *ctrl,
750    
751     down_read(&ctrl->namespaces_rwsem);
752     list_for_each_entry(ns, &ctrl->namespaces, list) {
753     - unsigned nsid = le32_to_cpu(desc->nsids[n]);
754     -
755     + unsigned nsid;
756     +again:
757     + nsid = le32_to_cpu(desc->nsids[n]);
758     if (ns->head->ns_id < nsid)
759     continue;
760     if (ns->head->ns_id == nsid)
761     nvme_update_ns_ana_state(desc, ns);
762     if (++n == nr_nsids)
763     break;
764     + if (ns->head->ns_id > nsid)
765     + goto again;
766     }
767     up_read(&ctrl->namespaces_rwsem);
768     return 0;
769     diff --git a/drivers/platform/x86/intel_punit_ipc.c b/drivers/platform/x86/intel_punit_ipc.c
770     index ccb44f2eb2407..af3a28623e869 100644
771     --- a/drivers/platform/x86/intel_punit_ipc.c
772     +++ b/drivers/platform/x86/intel_punit_ipc.c
773     @@ -8,7 +8,6 @@
774     * which provide mailbox interface for power management usage.
775     */
776    
777     -#include <linux/acpi.h>
778     #include <linux/bitops.h>
779     #include <linux/delay.h>
780     #include <linux/device.h>
781     @@ -335,7 +334,7 @@ static struct platform_driver intel_punit_ipc_driver = {
782     .remove = intel_punit_ipc_remove,
783     .driver = {
784     .name = "intel_punit_ipc",
785     - .acpi_match_table = ACPI_PTR(punit_ipc_acpi_ids),
786     + .acpi_match_table = punit_ipc_acpi_ids,
787     },
788     };
789    
790     diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
791     index 45db19e31b348..f0ecfe565660a 100644
792     --- a/drivers/scsi/lpfc/lpfc_attr.c
793     +++ b/drivers/scsi/lpfc/lpfc_attr.c
794     @@ -5881,7 +5881,8 @@ lpfc_sg_seg_cnt_show(struct device *dev, struct device_attribute *attr,
795     len = scnprintf(buf, PAGE_SIZE, "SGL sz: %d total SGEs: %d\n",
796     phba->cfg_sg_dma_buf_size, phba->cfg_total_seg_cnt);
797    
798     - len += scnprintf(buf + len, PAGE_SIZE, "Cfg: %d SCSI: %d NVME: %d\n",
799     + len += scnprintf(buf + len, PAGE_SIZE - len,
800     + "Cfg: %d SCSI: %d NVME: %d\n",
801     phba->cfg_sg_seg_cnt, phba->cfg_scsi_seg_cnt,
802     phba->cfg_nvme_seg_cnt);
803     return len;
804     diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
805     index 643b8ae36cbeb..5dae7ac0d3efe 100644
806     --- a/drivers/scsi/qla2xxx/qla_init.c
807     +++ b/drivers/scsi/qla2xxx/qla_init.c
808     @@ -6803,7 +6803,8 @@ qla2x00_abort_isp(scsi_qla_host_t *vha)
809     return 0;
810     break;
811     case QLA2XXX_INI_MODE_DUAL:
812     - if (!qla_dual_mode_enabled(vha))
813     + if (!qla_dual_mode_enabled(vha) &&
814     + !qla_ini_mode_enabled(vha))
815     return 0;
816     break;
817     case QLA2XXX_INI_MODE_ENABLED:
818     diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
819     index 77bba91b57147..6f21cb75d95fd 100644
820     --- a/drivers/scsi/scsi_transport_iscsi.c
821     +++ b/drivers/scsi/scsi_transport_iscsi.c
822     @@ -434,9 +434,7 @@ static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
823     struct iscsi_transport *t = iface->transport;
824     int param = -1;
825    
826     - if (attr == &dev_attr_iface_enabled.attr)
827     - param = ISCSI_NET_PARAM_IFACE_ENABLE;
828     - else if (attr == &dev_attr_iface_def_taskmgmt_tmo.attr)
829     + if (attr == &dev_attr_iface_def_taskmgmt_tmo.attr)
830     param = ISCSI_IFACE_PARAM_DEF_TASKMGMT_TMO;
831     else if (attr == &dev_attr_iface_header_digest.attr)
832     param = ISCSI_IFACE_PARAM_HDRDGST_EN;
833     @@ -476,7 +474,9 @@ static umode_t iscsi_iface_attr_is_visible(struct kobject *kobj,
834     if (param != -1)
835     return t->attr_is_visible(ISCSI_IFACE_PARAM, param);
836    
837     - if (attr == &dev_attr_iface_vlan_id.attr)
838     + if (attr == &dev_attr_iface_enabled.attr)
839     + param = ISCSI_NET_PARAM_IFACE_ENABLE;
840     + else if (attr == &dev_attr_iface_vlan_id.attr)
841     param = ISCSI_NET_PARAM_VLAN_ID;
842     else if (attr == &dev_attr_iface_vlan_priority.attr)
843     param = ISCSI_NET_PARAM_VLAN_PRIORITY;
844     diff --git a/drivers/spi/spi-tegra20-slink.c b/drivers/spi/spi-tegra20-slink.c
845     index 2a1905c43a0b7..9b59539c87359 100644
846     --- a/drivers/spi/spi-tegra20-slink.c
847     +++ b/drivers/spi/spi-tegra20-slink.c
848     @@ -1205,7 +1205,7 @@ static int tegra_slink_resume(struct device *dev)
849     }
850     #endif
851    
852     -static int tegra_slink_runtime_suspend(struct device *dev)
853     +static int __maybe_unused tegra_slink_runtime_suspend(struct device *dev)
854     {
855     struct spi_master *master = dev_get_drvdata(dev);
856     struct tegra_slink_data *tspi = spi_master_get_devdata(master);
857     @@ -1217,7 +1217,7 @@ static int tegra_slink_runtime_suspend(struct device *dev)
858     return 0;
859     }
860    
861     -static int tegra_slink_runtime_resume(struct device *dev)
862     +static int __maybe_unused tegra_slink_runtime_resume(struct device *dev)
863     {
864     struct spi_master *master = dev_get_drvdata(dev);
865     struct tegra_slink_data *tspi = spi_master_get_devdata(master);
866     diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
867     index fc1bd68889c91..0e6bebc20695d 100644
868     --- a/drivers/staging/greybus/uart.c
869     +++ b/drivers/staging/greybus/uart.c
870     @@ -789,6 +789,17 @@ out:
871     gbphy_runtime_put_autosuspend(gb_tty->gbphy_dev);
872     }
873    
874     +static void gb_tty_port_destruct(struct tty_port *port)
875     +{
876     + struct gb_tty *gb_tty = container_of(port, struct gb_tty, port);
877     +
878     + if (gb_tty->minor != GB_NUM_MINORS)
879     + release_minor(gb_tty);
880     + kfifo_free(&gb_tty->write_fifo);
881     + kfree(gb_tty->buffer);
882     + kfree(gb_tty);
883     +}
884     +
885     static const struct tty_operations gb_ops = {
886     .install = gb_tty_install,
887     .open = gb_tty_open,
888     @@ -814,6 +825,7 @@ static const struct tty_port_operations gb_port_ops = {
889     .dtr_rts = gb_tty_dtr_rts,
890     .activate = gb_tty_port_activate,
891     .shutdown = gb_tty_port_shutdown,
892     + .destruct = gb_tty_port_destruct,
893     };
894    
895     static int gb_uart_probe(struct gbphy_device *gbphy_dev,
896     @@ -826,17 +838,11 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
897     int retval;
898     int minor;
899    
900     - gb_tty = kzalloc(sizeof(*gb_tty), GFP_KERNEL);
901     - if (!gb_tty)
902     - return -ENOMEM;
903     -
904     connection = gb_connection_create(gbphy_dev->bundle,
905     le16_to_cpu(gbphy_dev->cport_desc->id),
906     gb_uart_request_handler);
907     - if (IS_ERR(connection)) {
908     - retval = PTR_ERR(connection);
909     - goto exit_tty_free;
910     - }
911     + if (IS_ERR(connection))
912     + return PTR_ERR(connection);
913    
914     max_payload = gb_operation_get_payload_size_max(connection);
915     if (max_payload < sizeof(struct gb_uart_send_data_request)) {
916     @@ -844,13 +850,23 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
917     goto exit_connection_destroy;
918     }
919    
920     + gb_tty = kzalloc(sizeof(*gb_tty), GFP_KERNEL);
921     + if (!gb_tty) {
922     + retval = -ENOMEM;
923     + goto exit_connection_destroy;
924     + }
925     +
926     + tty_port_init(&gb_tty->port);
927     + gb_tty->port.ops = &gb_port_ops;
928     + gb_tty->minor = GB_NUM_MINORS;
929     +
930     gb_tty->buffer_payload_max = max_payload -
931     sizeof(struct gb_uart_send_data_request);
932    
933     gb_tty->buffer = kzalloc(gb_tty->buffer_payload_max, GFP_KERNEL);
934     if (!gb_tty->buffer) {
935     retval = -ENOMEM;
936     - goto exit_connection_destroy;
937     + goto exit_put_port;
938     }
939    
940     INIT_WORK(&gb_tty->tx_work, gb_uart_tx_write_work);
941     @@ -858,7 +874,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
942     retval = kfifo_alloc(&gb_tty->write_fifo, GB_UART_WRITE_FIFO_SIZE,
943     GFP_KERNEL);
944     if (retval)
945     - goto exit_buf_free;
946     + goto exit_put_port;
947    
948     gb_tty->credits = GB_UART_FIRMWARE_CREDITS;
949     init_completion(&gb_tty->credits_complete);
950     @@ -872,7 +888,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
951     } else {
952     retval = minor;
953     }
954     - goto exit_kfifo_free;
955     + goto exit_put_port;
956     }
957    
958     gb_tty->minor = minor;
959     @@ -881,9 +897,6 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
960     init_waitqueue_head(&gb_tty->wioctl);
961     mutex_init(&gb_tty->mutex);
962    
963     - tty_port_init(&gb_tty->port);
964     - gb_tty->port.ops = &gb_port_ops;
965     -
966     gb_tty->connection = connection;
967     gb_tty->gbphy_dev = gbphy_dev;
968     gb_connection_set_data(connection, gb_tty);
969     @@ -891,7 +904,7 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
970    
971     retval = gb_connection_enable_tx(connection);
972     if (retval)
973     - goto exit_release_minor;
974     + goto exit_put_port;
975    
976     send_control(gb_tty, gb_tty->ctrlout);
977    
978     @@ -918,16 +931,10 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
979    
980     exit_connection_disable:
981     gb_connection_disable(connection);
982     -exit_release_minor:
983     - release_minor(gb_tty);
984     -exit_kfifo_free:
985     - kfifo_free(&gb_tty->write_fifo);
986     -exit_buf_free:
987     - kfree(gb_tty->buffer);
988     +exit_put_port:
989     + tty_port_put(&gb_tty->port);
990     exit_connection_destroy:
991     gb_connection_destroy(connection);
992     -exit_tty_free:
993     - kfree(gb_tty);
994    
995     return retval;
996     }
997     @@ -958,15 +965,10 @@ static void gb_uart_remove(struct gbphy_device *gbphy_dev)
998     gb_connection_disable_rx(connection);
999     tty_unregister_device(gb_tty_driver, gb_tty->minor);
1000    
1001     - /* FIXME - free transmit / receive buffers */
1002     -
1003     gb_connection_disable(connection);
1004     - tty_port_destroy(&gb_tty->port);
1005     gb_connection_destroy(connection);
1006     - release_minor(gb_tty);
1007     - kfifo_free(&gb_tty->write_fifo);
1008     - kfree(gb_tty->buffer);
1009     - kfree(gb_tty);
1010     +
1011     + tty_port_put(&gb_tty->port);
1012     }
1013    
1014     static int gb_tty_init(void)
1015     diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
1016     index 576523d0326c8..a902e2a053ee3 100644
1017     --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
1018     +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c
1019     @@ -179,7 +179,7 @@ static int tcc_offset_update(unsigned int tcc)
1020     return 0;
1021     }
1022    
1023     -static unsigned int tcc_offset_save;
1024     +static int tcc_offset_save = -1;
1025    
1026     static ssize_t tcc_offset_degree_celsius_store(struct device *dev,
1027     struct device_attribute *attr, const char *buf,
1028     @@ -703,7 +703,8 @@ static int proc_thermal_resume(struct device *dev)
1029     proc_dev = dev_get_drvdata(dev);
1030     proc_thermal_read_ppcc(proc_dev);
1031    
1032     - tcc_offset_update(tcc_offset_save);
1033     + if (tcc_offset_save >= 0)
1034     + tcc_offset_update(tcc_offset_save);
1035    
1036     return 0;
1037     }
1038     diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
1039     index f526ce31f5a2f..20eab56b02cb9 100644
1040     --- a/drivers/thermal/thermal_core.c
1041     +++ b/drivers/thermal/thermal_core.c
1042     @@ -228,15 +228,14 @@ int thermal_build_list_of_policies(char *buf)
1043     {
1044     struct thermal_governor *pos;
1045     ssize_t count = 0;
1046     - ssize_t size = PAGE_SIZE;
1047    
1048     mutex_lock(&thermal_governor_lock);
1049    
1050     list_for_each_entry(pos, &thermal_governor_list, governor_list) {
1051     - size = PAGE_SIZE - count;
1052     - count += scnprintf(buf + count, size, "%s ", pos->name);
1053     + count += scnprintf(buf + count, PAGE_SIZE - count, "%s ",
1054     + pos->name);
1055     }
1056     - count += scnprintf(buf + count, size, "\n");
1057     + count += scnprintf(buf + count, PAGE_SIZE - count, "\n");
1058    
1059     mutex_unlock(&thermal_governor_lock);
1060    
1061     diff --git a/drivers/tty/serial/mvebu-uart.c b/drivers/tty/serial/mvebu-uart.c
1062     index 51b4d8d1dcaca..13db15118cb94 100644
1063     --- a/drivers/tty/serial/mvebu-uart.c
1064     +++ b/drivers/tty/serial/mvebu-uart.c
1065     @@ -164,7 +164,7 @@ static unsigned int mvebu_uart_tx_empty(struct uart_port *port)
1066     st = readl(port->membase + UART_STAT);
1067     spin_unlock_irqrestore(&port->lock, flags);
1068    
1069     - return (st & STAT_TX_FIFO_EMP) ? TIOCSER_TEMT : 0;
1070     + return (st & STAT_TX_EMP) ? TIOCSER_TEMT : 0;
1071     }
1072    
1073     static unsigned int mvebu_uart_get_mctrl(struct uart_port *port)
1074     diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
1075     index 36f1a4d870eb1..ff345a8e0fcc6 100644
1076     --- a/drivers/tty/synclink_gt.c
1077     +++ b/drivers/tty/synclink_gt.c
1078     @@ -137,37 +137,14 @@ MODULE_PARM_DESC(maxframe, "Maximum frame size used by device (4096 to 65535)");
1079     */
1080     static struct tty_driver *serial_driver;
1081    
1082     -static int open(struct tty_struct *tty, struct file * filp);
1083     -static void close(struct tty_struct *tty, struct file * filp);
1084     -static void hangup(struct tty_struct *tty);
1085     -static void set_termios(struct tty_struct *tty, struct ktermios *old_termios);
1086     -
1087     -static int write(struct tty_struct *tty, const unsigned char *buf, int count);
1088     -static int put_char(struct tty_struct *tty, unsigned char ch);
1089     -static void send_xchar(struct tty_struct *tty, char ch);
1090     static void wait_until_sent(struct tty_struct *tty, int timeout);
1091     -static int write_room(struct tty_struct *tty);
1092     -static void flush_chars(struct tty_struct *tty);
1093     static void flush_buffer(struct tty_struct *tty);
1094     -static void tx_hold(struct tty_struct *tty);
1095     static void tx_release(struct tty_struct *tty);
1096    
1097     -static int ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg);
1098     -static int chars_in_buffer(struct tty_struct *tty);
1099     -static void throttle(struct tty_struct * tty);
1100     -static void unthrottle(struct tty_struct * tty);
1101     -static int set_break(struct tty_struct *tty, int break_state);
1102     -
1103     /*
1104     - * generic HDLC support and callbacks
1105     + * generic HDLC support
1106     */
1107     -#if SYNCLINK_GENERIC_HDLC
1108     #define dev_to_port(D) (dev_to_hdlc(D)->priv)
1109     -static void hdlcdev_tx_done(struct slgt_info *info);
1110     -static void hdlcdev_rx(struct slgt_info *info, char *buf, int size);
1111     -static int hdlcdev_init(struct slgt_info *info);
1112     -static void hdlcdev_exit(struct slgt_info *info);
1113     -#endif
1114    
1115    
1116     /*
1117     @@ -186,9 +163,6 @@ struct cond_wait {
1118     wait_queue_entry_t wait;
1119     unsigned int data;
1120     };
1121     -static void init_cond_wait(struct cond_wait *w, unsigned int data);
1122     -static void add_cond_wait(struct cond_wait **head, struct cond_wait *w);
1123     -static void remove_cond_wait(struct cond_wait **head, struct cond_wait *w);
1124     static void flush_cond_wait(struct cond_wait **head);
1125    
1126     /*
1127     @@ -443,12 +417,8 @@ static void shutdown(struct slgt_info *info);
1128     static void program_hw(struct slgt_info *info);
1129     static void change_params(struct slgt_info *info);
1130    
1131     -static int register_test(struct slgt_info *info);
1132     -static int irq_test(struct slgt_info *info);
1133     -static int loopback_test(struct slgt_info *info);
1134     static int adapter_test(struct slgt_info *info);
1135    
1136     -static void reset_adapter(struct slgt_info *info);
1137     static void reset_port(struct slgt_info *info);
1138     static void async_mode(struct slgt_info *info);
1139     static void sync_mode(struct slgt_info *info);
1140     @@ -457,41 +427,23 @@ static void rx_stop(struct slgt_info *info);
1141     static void rx_start(struct slgt_info *info);
1142     static void reset_rbufs(struct slgt_info *info);
1143     static void free_rbufs(struct slgt_info *info, unsigned int first, unsigned int last);
1144     -static void rdma_reset(struct slgt_info *info);
1145     static bool rx_get_frame(struct slgt_info *info);
1146     static bool rx_get_buf(struct slgt_info *info);
1147    
1148     static void tx_start(struct slgt_info *info);
1149     static void tx_stop(struct slgt_info *info);
1150     static void tx_set_idle(struct slgt_info *info);
1151     -static unsigned int free_tbuf_count(struct slgt_info *info);
1152     static unsigned int tbuf_bytes(struct slgt_info *info);
1153     static void reset_tbufs(struct slgt_info *info);
1154     static void tdma_reset(struct slgt_info *info);
1155     static bool tx_load(struct slgt_info *info, const char *buf, unsigned int count);
1156    
1157     -static void get_signals(struct slgt_info *info);
1158     -static void set_signals(struct slgt_info *info);
1159     -static void enable_loopback(struct slgt_info *info);
1160     +static void get_gtsignals(struct slgt_info *info);
1161     +static void set_gtsignals(struct slgt_info *info);
1162     static void set_rate(struct slgt_info *info, u32 data_rate);
1163    
1164     -static int bh_action(struct slgt_info *info);
1165     -static void bh_handler(struct work_struct *work);
1166     static void bh_transmit(struct slgt_info *info);
1167     -static void isr_serial(struct slgt_info *info);
1168     -static void isr_rdma(struct slgt_info *info);
1169     static void isr_txeom(struct slgt_info *info, unsigned short status);
1170     -static void isr_tdma(struct slgt_info *info);
1171     -
1172     -static int alloc_dma_bufs(struct slgt_info *info);
1173     -static void free_dma_bufs(struct slgt_info *info);
1174     -static int alloc_desc(struct slgt_info *info);
1175     -static void free_desc(struct slgt_info *info);
1176     -static int alloc_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count);
1177     -static void free_bufs(struct slgt_info *info, struct slgt_desc *bufs, int count);
1178     -
1179     -static int alloc_tmp_rbuf(struct slgt_info *info);
1180     -static void free_tmp_rbuf(struct slgt_info *info);
1181    
1182     static void tx_timeout(struct timer_list *t);
1183     static void rx_timeout(struct timer_list *t);
1184     @@ -509,10 +461,6 @@ static int tx_abort(struct slgt_info *info);
1185     static int rx_enable(struct slgt_info *info, int enable);
1186     static int modem_input_wait(struct slgt_info *info,int arg);
1187     static int wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr);
1188     -static int tiocmget(struct tty_struct *tty);
1189     -static int tiocmset(struct tty_struct *tty,
1190     - unsigned int set, unsigned int clear);
1191     -static int set_break(struct tty_struct *tty, int break_state);
1192     static int get_interface(struct slgt_info *info, int __user *if_mode);
1193     static int set_interface(struct slgt_info *info, int if_mode);
1194     static int set_gpio(struct slgt_info *info, struct gpio_desc __user *gpio);
1195     @@ -526,9 +474,6 @@ static int set_xctrl(struct slgt_info *info, int if_mode);
1196     /*
1197     * driver functions
1198     */
1199     -static void add_device(struct slgt_info *info);
1200     -static void device_init(int adapter_num, struct pci_dev *pdev);
1201     -static int claim_resources(struct slgt_info *info);
1202     static void release_resources(struct slgt_info *info);
1203    
1204     /*
1205     @@ -776,7 +721,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1206     if ((old_termios->c_cflag & CBAUD) && !C_BAUD(tty)) {
1207     info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
1208     spin_lock_irqsave(&info->lock,flags);
1209     - set_signals(info);
1210     + set_gtsignals(info);
1211     spin_unlock_irqrestore(&info->lock,flags);
1212     }
1213    
1214     @@ -786,7 +731,7 @@ static void set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1215     if (!C_CRTSCTS(tty) || !tty_throttled(tty))
1216     info->signals |= SerialSignal_RTS;
1217     spin_lock_irqsave(&info->lock,flags);
1218     - set_signals(info);
1219     + set_gtsignals(info);
1220     spin_unlock_irqrestore(&info->lock,flags);
1221     }
1222    
1223     @@ -1237,7 +1182,7 @@ static inline void line_info(struct seq_file *m, struct slgt_info *info)
1224    
1225     /* output current serial signal states */
1226     spin_lock_irqsave(&info->lock,flags);
1227     - get_signals(info);
1228     + get_gtsignals(info);
1229     spin_unlock_irqrestore(&info->lock,flags);
1230    
1231     stat_buf[0] = 0;
1232     @@ -1337,7 +1282,7 @@ static void throttle(struct tty_struct * tty)
1233     if (C_CRTSCTS(tty)) {
1234     spin_lock_irqsave(&info->lock,flags);
1235     info->signals &= ~SerialSignal_RTS;
1236     - set_signals(info);
1237     + set_gtsignals(info);
1238     spin_unlock_irqrestore(&info->lock,flags);
1239     }
1240     }
1241     @@ -1362,7 +1307,7 @@ static void unthrottle(struct tty_struct * tty)
1242     if (C_CRTSCTS(tty)) {
1243     spin_lock_irqsave(&info->lock,flags);
1244     info->signals |= SerialSignal_RTS;
1245     - set_signals(info);
1246     + set_gtsignals(info);
1247     spin_unlock_irqrestore(&info->lock,flags);
1248     }
1249     }
1250     @@ -1534,7 +1479,7 @@ static int hdlcdev_open(struct net_device *dev)
1251    
1252     /* inform generic HDLC layer of current DCD status */
1253     spin_lock_irqsave(&info->lock, flags);
1254     - get_signals(info);
1255     + get_gtsignals(info);
1256     spin_unlock_irqrestore(&info->lock, flags);
1257     if (info->signals & SerialSignal_DCD)
1258     netif_carrier_on(dev);
1259     @@ -2290,7 +2235,7 @@ static void isr_txeom(struct slgt_info *info, unsigned short status)
1260     if (info->params.mode != MGSL_MODE_ASYNC && info->drop_rts_on_tx_done) {
1261     info->signals &= ~SerialSignal_RTS;
1262     info->drop_rts_on_tx_done = false;
1263     - set_signals(info);
1264     + set_gtsignals(info);
1265     }
1266    
1267     #if SYNCLINK_GENERIC_HDLC
1268     @@ -2455,7 +2400,7 @@ static void shutdown(struct slgt_info *info)
1269    
1270     if (!info->port.tty || info->port.tty->termios.c_cflag & HUPCL) {
1271     info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
1272     - set_signals(info);
1273     + set_gtsignals(info);
1274     }
1275    
1276     flush_cond_wait(&info->gpio_wait_q);
1277     @@ -2483,7 +2428,7 @@ static void program_hw(struct slgt_info *info)
1278     else
1279     async_mode(info);
1280    
1281     - set_signals(info);
1282     + set_gtsignals(info);
1283    
1284     info->dcd_chkcount = 0;
1285     info->cts_chkcount = 0;
1286     @@ -2491,7 +2436,7 @@ static void program_hw(struct slgt_info *info)
1287     info->dsr_chkcount = 0;
1288    
1289     slgt_irq_on(info, IRQ_DCD | IRQ_CTS | IRQ_DSR | IRQ_RI);
1290     - get_signals(info);
1291     + get_gtsignals(info);
1292    
1293     if (info->netcount ||
1294     (info->port.tty && info->port.tty->termios.c_cflag & CREAD))
1295     @@ -2735,7 +2680,7 @@ static int wait_mgsl_event(struct slgt_info *info, int __user *mask_ptr)
1296     spin_lock_irqsave(&info->lock,flags);
1297    
1298     /* return immediately if state matches requested events */
1299     - get_signals(info);
1300     + get_gtsignals(info);
1301     s = info->signals;
1302    
1303     events = mask &
1304     @@ -3153,7 +3098,7 @@ static int tiocmget(struct tty_struct *tty)
1305     unsigned long flags;
1306    
1307     spin_lock_irqsave(&info->lock,flags);
1308     - get_signals(info);
1309     + get_gtsignals(info);
1310     spin_unlock_irqrestore(&info->lock,flags);
1311    
1312     result = ((info->signals & SerialSignal_RTS) ? TIOCM_RTS:0) +
1313     @@ -3192,7 +3137,7 @@ static int tiocmset(struct tty_struct *tty,
1314     info->signals &= ~SerialSignal_DTR;
1315    
1316     spin_lock_irqsave(&info->lock,flags);
1317     - set_signals(info);
1318     + set_gtsignals(info);
1319     spin_unlock_irqrestore(&info->lock,flags);
1320     return 0;
1321     }
1322     @@ -3203,7 +3148,7 @@ static int carrier_raised(struct tty_port *port)
1323     struct slgt_info *info = container_of(port, struct slgt_info, port);
1324    
1325     spin_lock_irqsave(&info->lock,flags);
1326     - get_signals(info);
1327     + get_gtsignals(info);
1328     spin_unlock_irqrestore(&info->lock,flags);
1329     return (info->signals & SerialSignal_DCD) ? 1 : 0;
1330     }
1331     @@ -3218,7 +3163,7 @@ static void dtr_rts(struct tty_port *port, int on)
1332     info->signals |= SerialSignal_RTS | SerialSignal_DTR;
1333     else
1334     info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
1335     - set_signals(info);
1336     + set_gtsignals(info);
1337     spin_unlock_irqrestore(&info->lock,flags);
1338     }
1339    
1340     @@ -4017,10 +3962,10 @@ static void tx_start(struct slgt_info *info)
1341    
1342     if (info->params.mode != MGSL_MODE_ASYNC) {
1343     if (info->params.flags & HDLC_FLAG_AUTO_RTS) {
1344     - get_signals(info);
1345     + get_gtsignals(info);
1346     if (!(info->signals & SerialSignal_RTS)) {
1347     info->signals |= SerialSignal_RTS;
1348     - set_signals(info);
1349     + set_gtsignals(info);
1350     info->drop_rts_on_tx_done = true;
1351     }
1352     }
1353     @@ -4074,7 +4019,7 @@ static void reset_port(struct slgt_info *info)
1354     rx_stop(info);
1355    
1356     info->signals &= ~(SerialSignal_RTS | SerialSignal_DTR);
1357     - set_signals(info);
1358     + set_gtsignals(info);
1359    
1360     slgt_irq_off(info, IRQ_ALL | IRQ_MASTER);
1361     }
1362     @@ -4496,7 +4441,7 @@ static void tx_set_idle(struct slgt_info *info)
1363     /*
1364     * get state of V24 status (input) signals
1365     */
1366     -static void get_signals(struct slgt_info *info)
1367     +static void get_gtsignals(struct slgt_info *info)
1368     {
1369     unsigned short status = rd_reg16(info, SSR);
1370    
1371     @@ -4558,7 +4503,7 @@ static void msc_set_vcr(struct slgt_info *info)
1372     /*
1373     * set state of V24 control (output) signals
1374     */
1375     -static void set_signals(struct slgt_info *info)
1376     +static void set_gtsignals(struct slgt_info *info)
1377     {
1378     unsigned char val = rd_reg8(info, VCR);
1379     if (info->signals & SerialSignal_DTR)
1380     diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
1381     index c0604c60ebd01..e139cda35f639 100644
1382     --- a/drivers/usb/class/cdc-acm.c
1383     +++ b/drivers/usb/class/cdc-acm.c
1384     @@ -725,7 +725,8 @@ static void acm_port_destruct(struct tty_port *port)
1385     {
1386     struct acm *acm = container_of(port, struct acm, port);
1387    
1388     - acm_release_minor(acm);
1389     + if (acm->minor != ACM_MINOR_INVALID)
1390     + acm_release_minor(acm);
1391     usb_put_intf(acm->control);
1392     kfree(acm->country_codes);
1393     kfree(acm);
1394     @@ -1356,8 +1357,10 @@ made_compressed_probe:
1395     usb_get_intf(acm->control); /* undone in destruct() */
1396    
1397     minor = acm_alloc_minor(acm);
1398     - if (minor < 0)
1399     + if (minor < 0) {
1400     + acm->minor = ACM_MINOR_INVALID;
1401     goto alloc_fail1;
1402     + }
1403    
1404     acm->minor = minor;
1405     acm->dev = usb_dev;
1406     diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
1407     index b95ff769072e7..ef7fe5eacff69 100644
1408     --- a/drivers/usb/class/cdc-acm.h
1409     +++ b/drivers/usb/class/cdc-acm.h
1410     @@ -22,6 +22,8 @@
1411     #define ACM_TTY_MAJOR 166
1412     #define ACM_TTY_MINORS 256
1413    
1414     +#define ACM_MINOR_INVALID ACM_TTY_MINORS
1415     +
1416     /*
1417     * Requests.
1418     */
1419     diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
1420     index d0f45600b6698..48ff9c66ae46d 100644
1421     --- a/drivers/usb/core/hcd.c
1422     +++ b/drivers/usb/core/hcd.c
1423     @@ -2636,6 +2636,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
1424     {
1425     int retval;
1426     struct usb_device *rhdev;
1427     + struct usb_hcd *shared_hcd;
1428    
1429     if (!hcd->skip_phy_initialization && usb_hcd_is_primary_hcd(hcd)) {
1430     hcd->phy_roothub = usb_phy_roothub_alloc(hcd->self.sysdev);
1431     @@ -2792,13 +2793,26 @@ int usb_add_hcd(struct usb_hcd *hcd,
1432     goto err_hcd_driver_start;
1433     }
1434    
1435     + /* starting here, usbcore will pay attention to the shared HCD roothub */
1436     + shared_hcd = hcd->shared_hcd;
1437     + if (!usb_hcd_is_primary_hcd(hcd) && shared_hcd && HCD_DEFER_RH_REGISTER(shared_hcd)) {
1438     + retval = register_root_hub(shared_hcd);
1439     + if (retval != 0)
1440     + goto err_register_root_hub;
1441     +
1442     + if (shared_hcd->uses_new_polling && HCD_POLL_RH(shared_hcd))
1443     + usb_hcd_poll_rh_status(shared_hcd);
1444     + }
1445     +
1446     /* starting here, usbcore will pay attention to this root hub */
1447     - retval = register_root_hub(hcd);
1448     - if (retval != 0)
1449     - goto err_register_root_hub;
1450     + if (!HCD_DEFER_RH_REGISTER(hcd)) {
1451     + retval = register_root_hub(hcd);
1452     + if (retval != 0)
1453     + goto err_register_root_hub;
1454    
1455     - if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
1456     - usb_hcd_poll_rh_status(hcd);
1457     + if (hcd->uses_new_polling && HCD_POLL_RH(hcd))
1458     + usb_hcd_poll_rh_status(hcd);
1459     + }
1460    
1461     return retval;
1462    
1463     @@ -2841,6 +2855,7 @@ EXPORT_SYMBOL_GPL(usb_add_hcd);
1464     void usb_remove_hcd(struct usb_hcd *hcd)
1465     {
1466     struct usb_device *rhdev = hcd->self.root_hub;
1467     + bool rh_registered;
1468    
1469     dev_info(hcd->self.controller, "remove, state %x\n", hcd->state);
1470    
1471     @@ -2851,6 +2866,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
1472    
1473     dev_dbg(hcd->self.controller, "roothub graceful disconnect\n");
1474     spin_lock_irq (&hcd_root_hub_lock);
1475     + rh_registered = hcd->rh_registered;
1476     hcd->rh_registered = 0;
1477     spin_unlock_irq (&hcd_root_hub_lock);
1478    
1479     @@ -2860,7 +2876,8 @@ void usb_remove_hcd(struct usb_hcd *hcd)
1480     cancel_work_sync(&hcd->died_work);
1481    
1482     mutex_lock(&usb_bus_idr_lock);
1483     - usb_disconnect(&rhdev); /* Sets rhdev to NULL */
1484     + if (rh_registered)
1485     + usb_disconnect(&rhdev); /* Sets rhdev to NULL */
1486     mutex_unlock(&usb_bus_idr_lock);
1487    
1488     /*
1489     diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
1490     index 66dfcdbd1e03a..e8b25dae09499 100644
1491     --- a/drivers/usb/dwc2/gadget.c
1492     +++ b/drivers/usb/dwc2/gadget.c
1493     @@ -115,10 +115,16 @@ static inline bool using_desc_dma(struct dwc2_hsotg *hsotg)
1494     */
1495     static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep)
1496     {
1497     + struct dwc2_hsotg *hsotg = hs_ep->parent;
1498     + u16 limit = DSTS_SOFFN_LIMIT;
1499     +
1500     + if (hsotg->gadget.speed != USB_SPEED_HIGH)
1501     + limit >>= 3;
1502     +
1503     hs_ep->target_frame += hs_ep->interval;
1504     - if (hs_ep->target_frame > DSTS_SOFFN_LIMIT) {
1505     + if (hs_ep->target_frame > limit) {
1506     hs_ep->frame_overrun = true;
1507     - hs_ep->target_frame &= DSTS_SOFFN_LIMIT;
1508     + hs_ep->target_frame &= limit;
1509     } else {
1510     hs_ep->frame_overrun = false;
1511     }
1512     @@ -136,10 +142,16 @@ static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep)
1513     */
1514     static inline void dwc2_gadget_dec_frame_num_by_one(struct dwc2_hsotg_ep *hs_ep)
1515     {
1516     + struct dwc2_hsotg *hsotg = hs_ep->parent;
1517     + u16 limit = DSTS_SOFFN_LIMIT;
1518     +
1519     + if (hsotg->gadget.speed != USB_SPEED_HIGH)
1520     + limit >>= 3;
1521     +
1522     if (hs_ep->target_frame)
1523     hs_ep->target_frame -= 1;
1524     else
1525     - hs_ep->target_frame = DSTS_SOFFN_LIMIT;
1526     + hs_ep->target_frame = limit;
1527     }
1528    
1529     /**
1530     @@ -1018,6 +1030,12 @@ static void dwc2_gadget_start_isoc_ddma(struct dwc2_hsotg_ep *hs_ep)
1531     dwc2_writel(hsotg, ctrl, depctl);
1532     }
1533    
1534     +static bool dwc2_gadget_target_frame_elapsed(struct dwc2_hsotg_ep *hs_ep);
1535     +static void dwc2_hsotg_complete_request(struct dwc2_hsotg *hsotg,
1536     + struct dwc2_hsotg_ep *hs_ep,
1537     + struct dwc2_hsotg_req *hs_req,
1538     + int result);
1539     +
1540     /**
1541     * dwc2_hsotg_start_req - start a USB request from an endpoint's queue
1542     * @hsotg: The controller state.
1543     @@ -1170,14 +1188,19 @@ static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
1544     }
1545     }
1546    
1547     - if (hs_ep->isochronous && hs_ep->interval == 1) {
1548     - hs_ep->target_frame = dwc2_hsotg_read_frameno(hsotg);
1549     - dwc2_gadget_incr_frame_num(hs_ep);
1550     -
1551     - if (hs_ep->target_frame & 0x1)
1552     - ctrl |= DXEPCTL_SETODDFR;
1553     - else
1554     - ctrl |= DXEPCTL_SETEVENFR;
1555     + if (hs_ep->isochronous) {
1556     + if (!dwc2_gadget_target_frame_elapsed(hs_ep)) {
1557     + if (hs_ep->interval == 1) {
1558     + if (hs_ep->target_frame & 0x1)
1559     + ctrl |= DXEPCTL_SETODDFR;
1560     + else
1561     + ctrl |= DXEPCTL_SETEVENFR;
1562     + }
1563     + ctrl |= DXEPCTL_CNAK;
1564     + } else {
1565     + dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
1566     + return;
1567     + }
1568     }
1569    
1570     ctrl |= DXEPCTL_EPENA; /* ensure ep enabled */
1571     @@ -1325,12 +1348,16 @@ static bool dwc2_gadget_target_frame_elapsed(struct dwc2_hsotg_ep *hs_ep)
1572     u32 target_frame = hs_ep->target_frame;
1573     u32 current_frame = hsotg->frame_number;
1574     bool frame_overrun = hs_ep->frame_overrun;
1575     + u16 limit = DSTS_SOFFN_LIMIT;
1576     +
1577     + if (hsotg->gadget.speed != USB_SPEED_HIGH)
1578     + limit >>= 3;
1579    
1580     if (!frame_overrun && current_frame >= target_frame)
1581     return true;
1582    
1583     if (frame_overrun && current_frame >= target_frame &&
1584     - ((current_frame - target_frame) < DSTS_SOFFN_LIMIT / 2))
1585     + ((current_frame - target_frame) < limit / 2))
1586     return true;
1587    
1588     return false;
1589     @@ -1712,11 +1739,9 @@ static struct dwc2_hsotg_req *get_ep_head(struct dwc2_hsotg_ep *hs_ep)
1590     */
1591     static void dwc2_gadget_start_next_request(struct dwc2_hsotg_ep *hs_ep)
1592     {
1593     - u32 mask;
1594     struct dwc2_hsotg *hsotg = hs_ep->parent;
1595     int dir_in = hs_ep->dir_in;
1596     struct dwc2_hsotg_req *hs_req;
1597     - u32 epmsk_reg = dir_in ? DIEPMSK : DOEPMSK;
1598    
1599     if (!list_empty(&hs_ep->queue)) {
1600     hs_req = get_ep_head(hs_ep);
1601     @@ -1732,9 +1757,6 @@ static void dwc2_gadget_start_next_request(struct dwc2_hsotg_ep *hs_ep)
1602     } else {
1603     dev_dbg(hsotg->dev, "%s: No more ISOC-OUT requests\n",
1604     __func__);
1605     - mask = dwc2_readl(hsotg, epmsk_reg);
1606     - mask |= DOEPMSK_OUTTKNEPDISMSK;
1607     - dwc2_writel(hsotg, mask, epmsk_reg);
1608     }
1609     }
1610    
1611     @@ -2304,19 +2326,6 @@ static void dwc2_hsotg_ep0_zlp(struct dwc2_hsotg *hsotg, bool dir_in)
1612     dwc2_hsotg_program_zlp(hsotg, hsotg->eps_out[0]);
1613     }
1614    
1615     -static void dwc2_hsotg_change_ep_iso_parity(struct dwc2_hsotg *hsotg,
1616     - u32 epctl_reg)
1617     -{
1618     - u32 ctrl;
1619     -
1620     - ctrl = dwc2_readl(hsotg, epctl_reg);
1621     - if (ctrl & DXEPCTL_EOFRNUM)
1622     - ctrl |= DXEPCTL_SETEVENFR;
1623     - else
1624     - ctrl |= DXEPCTL_SETODDFR;
1625     - dwc2_writel(hsotg, ctrl, epctl_reg);
1626     -}
1627     -
1628     /*
1629     * dwc2_gadget_get_xfersize_ddma - get transferred bytes amount from desc
1630     * @hs_ep - The endpoint on which transfer went
1631     @@ -2437,20 +2446,11 @@ static void dwc2_hsotg_handle_outdone(struct dwc2_hsotg *hsotg, int epnum)
1632     dwc2_hsotg_ep0_zlp(hsotg, true);
1633     }
1634    
1635     - /*
1636     - * Slave mode OUT transfers do not go through XferComplete so
1637     - * adjust the ISOC parity here.
1638     - */
1639     - if (!using_dma(hsotg)) {
1640     - if (hs_ep->isochronous && hs_ep->interval == 1)
1641     - dwc2_hsotg_change_ep_iso_parity(hsotg, DOEPCTL(epnum));
1642     - else if (hs_ep->isochronous && hs_ep->interval > 1)
1643     - dwc2_gadget_incr_frame_num(hs_ep);
1644     - }
1645     -
1646     /* Set actual frame number for completed transfers */
1647     - if (!using_desc_dma(hsotg) && hs_ep->isochronous)
1648     - req->frame_number = hsotg->frame_number;
1649     + if (!using_desc_dma(hsotg) && hs_ep->isochronous) {
1650     + req->frame_number = hs_ep->target_frame;
1651     + dwc2_gadget_incr_frame_num(hs_ep);
1652     + }
1653    
1654     dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, result);
1655     }
1656     @@ -2764,6 +2764,12 @@ static void dwc2_hsotg_complete_in(struct dwc2_hsotg *hsotg,
1657     return;
1658     }
1659    
1660     + /* Set actual frame number for completed transfers */
1661     + if (!using_desc_dma(hsotg) && hs_ep->isochronous) {
1662     + hs_req->req.frame_number = hs_ep->target_frame;
1663     + dwc2_gadget_incr_frame_num(hs_ep);
1664     + }
1665     +
1666     dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, 0);
1667     }
1668    
1669     @@ -2824,23 +2830,18 @@ static void dwc2_gadget_handle_ep_disabled(struct dwc2_hsotg_ep *hs_ep)
1670    
1671     dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index);
1672    
1673     - if (hs_ep->isochronous) {
1674     - dwc2_hsotg_complete_in(hsotg, hs_ep);
1675     - return;
1676     - }
1677     -
1678     if ((epctl & DXEPCTL_STALL) && (epctl & DXEPCTL_EPTYPE_BULK)) {
1679     int dctl = dwc2_readl(hsotg, DCTL);
1680    
1681     dctl |= DCTL_CGNPINNAK;
1682     dwc2_writel(hsotg, dctl, DCTL);
1683     }
1684     - return;
1685     - }
1686     + } else {
1687    
1688     - if (dctl & DCTL_GOUTNAKSTS) {
1689     - dctl |= DCTL_CGOUTNAK;
1690     - dwc2_writel(hsotg, dctl, DCTL);
1691     + if (dctl & DCTL_GOUTNAKSTS) {
1692     + dctl |= DCTL_CGOUTNAK;
1693     + dwc2_writel(hsotg, dctl, DCTL);
1694     + }
1695     }
1696    
1697     if (!hs_ep->isochronous)
1698     @@ -2861,8 +2862,6 @@ static void dwc2_gadget_handle_ep_disabled(struct dwc2_hsotg_ep *hs_ep)
1699     /* Update current frame number value. */
1700     hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg);
1701     } while (dwc2_gadget_target_frame_elapsed(hs_ep));
1702     -
1703     - dwc2_gadget_start_next_request(hs_ep);
1704     }
1705    
1706     /**
1707     @@ -2879,8 +2878,8 @@ static void dwc2_gadget_handle_ep_disabled(struct dwc2_hsotg_ep *hs_ep)
1708     static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
1709     {
1710     struct dwc2_hsotg *hsotg = ep->parent;
1711     + struct dwc2_hsotg_req *hs_req;
1712     int dir_in = ep->dir_in;
1713     - u32 doepmsk;
1714    
1715     if (dir_in || !ep->isochronous)
1716     return;
1717     @@ -2894,28 +2893,39 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
1718     return;
1719     }
1720    
1721     - if (ep->interval > 1 &&
1722     - ep->target_frame == TARGET_FRAME_INITIAL) {
1723     + if (ep->target_frame == TARGET_FRAME_INITIAL) {
1724     u32 ctrl;
1725    
1726     ep->target_frame = hsotg->frame_number;
1727     - dwc2_gadget_incr_frame_num(ep);
1728     + if (ep->interval > 1) {
1729     + ctrl = dwc2_readl(hsotg, DOEPCTL(ep->index));
1730     + if (ep->target_frame & 0x1)
1731     + ctrl |= DXEPCTL_SETODDFR;
1732     + else
1733     + ctrl |= DXEPCTL_SETEVENFR;
1734    
1735     - ctrl = dwc2_readl(hsotg, DOEPCTL(ep->index));
1736     - if (ep->target_frame & 0x1)
1737     - ctrl |= DXEPCTL_SETODDFR;
1738     - else
1739     - ctrl |= DXEPCTL_SETEVENFR;
1740     + dwc2_writel(hsotg, ctrl, DOEPCTL(ep->index));
1741     + }
1742     + }
1743     +
1744     + while (dwc2_gadget_target_frame_elapsed(ep)) {
1745     + hs_req = get_ep_head(ep);
1746     + if (hs_req)
1747     + dwc2_hsotg_complete_request(hsotg, ep, hs_req, -ENODATA);
1748    
1749     - dwc2_writel(hsotg, ctrl, DOEPCTL(ep->index));
1750     + dwc2_gadget_incr_frame_num(ep);
1751     + /* Update current frame number value. */
1752     + hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg);
1753     }
1754    
1755     - dwc2_gadget_start_next_request(ep);
1756     - doepmsk = dwc2_readl(hsotg, DOEPMSK);
1757     - doepmsk &= ~DOEPMSK_OUTTKNEPDISMSK;
1758     - dwc2_writel(hsotg, doepmsk, DOEPMSK);
1759     + if (!ep->req)
1760     + dwc2_gadget_start_next_request(ep);
1761     +
1762     }
1763    
1764     +static void dwc2_hsotg_ep_stop_xfr(struct dwc2_hsotg *hsotg,
1765     + struct dwc2_hsotg_ep *hs_ep);
1766     +
1767     /**
1768     * dwc2_gadget_handle_nak - handle NAK interrupt
1769     * @hs_ep: The endpoint on which interrupt is asserted.
1770     @@ -2933,7 +2943,9 @@ static void dwc2_gadget_handle_out_token_ep_disabled(struct dwc2_hsotg_ep *ep)
1771     static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
1772     {
1773     struct dwc2_hsotg *hsotg = hs_ep->parent;
1774     + struct dwc2_hsotg_req *hs_req;
1775     int dir_in = hs_ep->dir_in;
1776     + u32 ctrl;
1777    
1778     if (!dir_in || !hs_ep->isochronous)
1779     return;
1780     @@ -2975,13 +2987,29 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep)
1781    
1782     dwc2_writel(hsotg, ctrl, DIEPCTL(hs_ep->index));
1783     }
1784     -
1785     - dwc2_hsotg_complete_request(hsotg, hs_ep,
1786     - get_ep_head(hs_ep), 0);
1787     }
1788    
1789     - if (!using_desc_dma(hsotg))
1790     + if (using_desc_dma(hsotg))
1791     + return;
1792     +
1793     + ctrl = dwc2_readl(hsotg, DIEPCTL(hs_ep->index));
1794     + if (ctrl & DXEPCTL_EPENA)
1795     + dwc2_hsotg_ep_stop_xfr(hsotg, hs_ep);
1796     + else
1797     + dwc2_hsotg_txfifo_flush(hsotg, hs_ep->fifo_index);
1798     +
1799     + while (dwc2_gadget_target_frame_elapsed(hs_ep)) {
1800     + hs_req = get_ep_head(hs_ep);
1801     + if (hs_req)
1802     + dwc2_hsotg_complete_request(hsotg, hs_ep, hs_req, -ENODATA);
1803     +
1804     dwc2_gadget_incr_frame_num(hs_ep);
1805     + /* Update current frame number value. */
1806     + hsotg->frame_number = dwc2_hsotg_read_frameno(hsotg);
1807     + }
1808     +
1809     + if (!hs_ep->req)
1810     + dwc2_gadget_start_next_request(hs_ep);
1811     }
1812    
1813     /**
1814     @@ -3039,21 +3067,15 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx,
1815    
1816     /* In DDMA handle isochronous requests separately */
1817     if (using_desc_dma(hsotg) && hs_ep->isochronous) {
1818     - /* XferCompl set along with BNA */
1819     - if (!(ints & DXEPINT_BNAINTR))
1820     - dwc2_gadget_complete_isoc_request_ddma(hs_ep);
1821     + dwc2_gadget_complete_isoc_request_ddma(hs_ep);
1822     } else if (dir_in) {
1823     /*
1824     * We get OutDone from the FIFO, so we only
1825     * need to look at completing IN requests here
1826     * if operating slave mode
1827     */
1828     - if (hs_ep->isochronous && hs_ep->interval > 1)
1829     - dwc2_gadget_incr_frame_num(hs_ep);
1830     -
1831     - dwc2_hsotg_complete_in(hsotg, hs_ep);
1832     - if (ints & DXEPINT_NAKINTRPT)
1833     - ints &= ~DXEPINT_NAKINTRPT;
1834     + if (!hs_ep->isochronous || !(ints & DXEPINT_NAKINTRPT))
1835     + dwc2_hsotg_complete_in(hsotg, hs_ep);
1836    
1837     if (idx == 0 && !hs_ep->req)
1838     dwc2_hsotg_enqueue_setup(hsotg);
1839     @@ -3062,10 +3084,8 @@ static void dwc2_hsotg_epint(struct dwc2_hsotg *hsotg, unsigned int idx,
1840     * We're using DMA, we need to fire an OutDone here
1841     * as we ignore the RXFIFO.
1842     */
1843     - if (hs_ep->isochronous && hs_ep->interval > 1)
1844     - dwc2_gadget_incr_frame_num(hs_ep);
1845     -
1846     - dwc2_hsotg_handle_outdone(hsotg, idx);
1847     + if (!hs_ep->isochronous || !(ints & DXEPINT_OUTTKNEPDIS))
1848     + dwc2_hsotg_handle_outdone(hsotg, idx);
1849     }
1850     }
1851    
1852     @@ -4055,6 +4075,7 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
1853     mask |= DIEPMSK_NAKMSK;
1854     dwc2_writel(hsotg, mask, DIEPMSK);
1855     } else {
1856     + epctrl |= DXEPCTL_SNAK;
1857     mask = dwc2_readl(hsotg, DOEPMSK);
1858     mask |= DOEPMSK_OUTTKNEPDISMSK;
1859     dwc2_writel(hsotg, mask, DOEPMSK);
1860     diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
1861     index a766476fd742e..ca0aebb5bd0cc 100644
1862     --- a/drivers/usb/gadget/udc/r8a66597-udc.c
1863     +++ b/drivers/usb/gadget/udc/r8a66597-udc.c
1864     @@ -1250,7 +1250,7 @@ static void set_feature(struct r8a66597 *r8a66597, struct usb_ctrlrequest *ctrl)
1865     do {
1866     tmp = r8a66597_read(r8a66597, INTSTS0) & CTSQ;
1867     udelay(1);
1868     - } while (tmp != CS_IDST || timeout-- > 0);
1869     + } while (tmp != CS_IDST && timeout-- > 0);
1870    
1871     if (tmp == CS_IDST)
1872     r8a66597_bset(r8a66597,
1873     diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
1874     index 505da4999e208..02a2afd130eb6 100644
1875     --- a/drivers/usb/host/xhci.c
1876     +++ b/drivers/usb/host/xhci.c
1877     @@ -693,6 +693,7 @@ int xhci_run(struct usb_hcd *hcd)
1878     if (ret)
1879     xhci_free_command(xhci, command);
1880     }
1881     + set_bit(HCD_FLAG_DEFER_RH_REGISTER, &hcd->flags);
1882     xhci_dbg_trace(xhci, trace_xhci_dbg_init,
1883     "Finished xhci_run for USB2 roothub");
1884    
1885     diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
1886     index 39453287b5c36..4ecfbf6bb1fa8 100644
1887     --- a/drivers/usb/musb/tusb6010.c
1888     +++ b/drivers/usb/musb/tusb6010.c
1889     @@ -190,6 +190,7 @@ tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
1890     }
1891     if (len > 0) {
1892     /* Write the rest 1 - 3 bytes to FIFO */
1893     + val = 0;
1894     memcpy(&val, buf, len);
1895     musb_writel(fifo, 0, val);
1896     }
1897     diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
1898     index 8e5878ec656d0..004b6598706b1 100644
1899     --- a/drivers/usb/serial/cp210x.c
1900     +++ b/drivers/usb/serial/cp210x.c
1901     @@ -234,6 +234,7 @@ static const struct usb_device_id id_table[] = {
1902     { USB_DEVICE(0x1FB9, 0x0602) }, /* Lake Shore Model 648 Magnet Power Supply */
1903     { USB_DEVICE(0x1FB9, 0x0700) }, /* Lake Shore Model 737 VSM Controller */
1904     { USB_DEVICE(0x1FB9, 0x0701) }, /* Lake Shore Model 776 Hall Matrix */
1905     + { USB_DEVICE(0x2184, 0x0030) }, /* GW Instek GDM-834x Digital Multimeter */
1906     { USB_DEVICE(0x2626, 0xEA60) }, /* Aruba Networks 7xxx USB Serial Console */
1907     { USB_DEVICE(0x3195, 0xF190) }, /* Link Instruments MSO-19 */
1908     { USB_DEVICE(0x3195, 0xF280) }, /* Link Instruments MSO-28 */
1909     diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
1910     index 2b8a0d4b66fce..84b6093ed1d28 100644
1911     --- a/drivers/usb/serial/mos7840.c
1912     +++ b/drivers/usb/serial/mos7840.c
1913     @@ -114,7 +114,6 @@
1914     #define BANDB_DEVICE_ID_USOPTL4_2P 0xBC02
1915     #define BANDB_DEVICE_ID_USOPTL4_4 0xAC44
1916     #define BANDB_DEVICE_ID_USOPTL4_4P 0xBC03
1917     -#define BANDB_DEVICE_ID_USOPTL2_4 0xAC24
1918    
1919     /* This driver also supports
1920     * ATEN UC2324 device using Moschip MCS7840
1921     @@ -196,7 +195,6 @@ static const struct usb_device_id id_table[] = {
1922     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_2P)},
1923     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4)},
1924     {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL4_4P)},
1925     - {USB_DEVICE(USB_VENDOR_ID_BANDB, BANDB_DEVICE_ID_USOPTL2_4)},
1926     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2324)},
1927     {USB_DEVICE(USB_VENDOR_ID_ATENINTL, ATENINTL_DEVICE_ID_UC2322)},
1928     {USB_DEVICE(USB_VENDOR_ID_MOXA, MOXA_DEVICE_ID_2210)},
1929     diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
1930     index d42ca13569965..82016d9781460 100644
1931     --- a/drivers/usb/serial/option.c
1932     +++ b/drivers/usb/serial/option.c
1933     @@ -1205,6 +1205,14 @@ static const struct usb_device_id option_ids[] = {
1934     .driver_info = NCTRL(0) | RSVD(1) },
1935     { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1056, 0xff), /* Telit FD980 */
1936     .driver_info = NCTRL(2) | RSVD(3) },
1937     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1060, 0xff), /* Telit LN920 (rmnet) */
1938     + .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
1939     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1061, 0xff), /* Telit LN920 (MBIM) */
1940     + .driver_info = NCTRL(0) | RSVD(1) },
1941     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1062, 0xff), /* Telit LN920 (RNDIS) */
1942     + .driver_info = NCTRL(2) | RSVD(3) },
1943     + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1063, 0xff), /* Telit LN920 (ECM) */
1944     + .driver_info = NCTRL(0) | RSVD(1) },
1945     { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910),
1946     .driver_info = NCTRL(0) | RSVD(1) | RSVD(3) },
1947     { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_ME910_DUAL_MODEM),
1948     @@ -1650,7 +1658,6 @@ static const struct usb_device_id option_ids[] = {
1949     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0060, 0xff, 0xff, 0xff) },
1950     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
1951     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
1952     - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
1953     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff),
1954     .driver_info = RSVD(1) },
1955     { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff),
1956     @@ -2068,6 +2075,8 @@ static const struct usb_device_id option_ids[] = {
1957     .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
1958     { USB_DEVICE(0x0489, 0xe0b5), /* Foxconn T77W968 ESIM */
1959     .driver_info = RSVD(0) | RSVD(1) | RSVD(6) },
1960     + { USB_DEVICE_INTERFACE_CLASS(0x0489, 0xe0db, 0xff), /* Foxconn T99W265 MBIM */
1961     + .driver_info = RSVD(3) },
1962     { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */
1963     .driver_info = RSVD(4) | RSVD(5) | RSVD(6) },
1964     { USB_DEVICE(0x2cb7, 0x0104), /* Fibocom NL678 series */
1965     diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1966     index 861153d294b67..7442793fe0502 100644
1967     --- a/drivers/usb/storage/unusual_devs.h
1968     +++ b/drivers/usb/storage/unusual_devs.h
1969     @@ -416,9 +416,16 @@ UNUSUAL_DEV( 0x04cb, 0x0100, 0x0000, 0x2210,
1970     USB_SC_UFI, USB_PR_DEVICE, NULL, US_FL_FIX_INQUIRY | US_FL_SINGLE_LUN),
1971    
1972     /*
1973     - * Reported by Ondrej Zary <linux@rainbow-software.org>
1974     + * Reported by Ondrej Zary <linux@zary.sk>
1975     * The device reports one sector more and breaks when that sector is accessed
1976     + * Firmwares older than 2.6c (the latest one and the only that claims Linux
1977     + * support) have also broken tag handling
1978     */
1979     +UNUSUAL_DEV( 0x04ce, 0x0002, 0x0000, 0x026b,
1980     + "ScanLogic",
1981     + "SL11R-IDE",
1982     + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1983     + US_FL_FIX_CAPACITY | US_FL_BULK_IGNORE_TAG),
1984     UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
1985     "ScanLogic",
1986     "SL11R-IDE",
1987     diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
1988     index c7db6c943ba51..2f72753c3e225 100644
1989     --- a/drivers/usb/storage/unusual_uas.h
1990     +++ b/drivers/usb/storage/unusual_uas.h
1991     @@ -50,7 +50,7 @@ UNUSUAL_DEV(0x059f, 0x1061, 0x0000, 0x9999,
1992     "LaCie",
1993     "Rugged USB3-FW",
1994     USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1995     - US_FL_IGNORE_UAS),
1996     + US_FL_NO_REPORT_OPCODES | US_FL_NO_SAME),
1997    
1998     /*
1999     * Apricorn USB3 dongle sometimes returns "USBSUSBSUSBS" in response to SCSI
2000     diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
2001     index ebb05517b6aa1..be31c296eed4c 100644
2002     --- a/drivers/xen/balloon.c
2003     +++ b/drivers/xen/balloon.c
2004     @@ -43,6 +43,8 @@
2005     #include <linux/sched.h>
2006     #include <linux/cred.h>
2007     #include <linux/errno.h>
2008     +#include <linux/freezer.h>
2009     +#include <linux/kthread.h>
2010     #include <linux/mm.h>
2011     #include <linux/memblock.h>
2012     #include <linux/pagemap.h>
2013     @@ -117,7 +119,7 @@ static struct ctl_table xen_root[] = {
2014     #define EXTENT_ORDER (fls(XEN_PFN_PER_PAGE) - 1)
2015    
2016     /*
2017     - * balloon_process() state:
2018     + * balloon_thread() state:
2019     *
2020     * BP_DONE: done or nothing to do,
2021     * BP_WAIT: wait to be rescheduled,
2022     @@ -132,6 +134,8 @@ enum bp_state {
2023     BP_ECANCELED
2024     };
2025    
2026     +/* Main waiting point for xen-balloon thread. */
2027     +static DECLARE_WAIT_QUEUE_HEAD(balloon_thread_wq);
2028    
2029     static DEFINE_MUTEX(balloon_mutex);
2030    
2031     @@ -146,10 +150,6 @@ static xen_pfn_t frame_list[PAGE_SIZE / sizeof(xen_pfn_t)];
2032     static LIST_HEAD(ballooned_pages);
2033     static DECLARE_WAIT_QUEUE_HEAD(balloon_wq);
2034    
2035     -/* Main work function, always executed in process context. */
2036     -static void balloon_process(struct work_struct *work);
2037     -static DECLARE_DELAYED_WORK(balloon_worker, balloon_process);
2038     -
2039     /* When ballooning out (allocating memory to return to Xen) we don't really
2040     want the kernel to try too hard since that can trigger the oom killer. */
2041     #define GFP_BALLOON \
2042     @@ -383,7 +383,7 @@ static void xen_online_page(struct page *page, unsigned int order)
2043     static int xen_memory_notifier(struct notifier_block *nb, unsigned long val, void *v)
2044     {
2045     if (val == MEM_ONLINE)
2046     - schedule_delayed_work(&balloon_worker, 0);
2047     + wake_up(&balloon_thread_wq);
2048    
2049     return NOTIFY_OK;
2050     }
2051     @@ -508,18 +508,43 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
2052     }
2053    
2054     /*
2055     - * As this is a work item it is guaranteed to run as a single instance only.
2056     + * Stop waiting if either state is not BP_EAGAIN and ballooning action is
2057     + * needed, or if the credit has changed while state is BP_EAGAIN.
2058     + */
2059     +static bool balloon_thread_cond(enum bp_state state, long credit)
2060     +{
2061     + if (state != BP_EAGAIN)
2062     + credit = 0;
2063     +
2064     + return current_credit() != credit || kthread_should_stop();
2065     +}
2066     +
2067     +/*
2068     + * As this is a kthread it is guaranteed to run as a single instance only.
2069     * We may of course race updates of the target counts (which are protected
2070     * by the balloon lock), or with changes to the Xen hard limit, but we will
2071     * recover from these in time.
2072     */
2073     -static void balloon_process(struct work_struct *work)
2074     +static int balloon_thread(void *unused)
2075     {
2076     enum bp_state state = BP_DONE;
2077     long credit;
2078     + unsigned long timeout;
2079     +
2080     + set_freezable();
2081     + for (;;) {
2082     + if (state == BP_EAGAIN)
2083     + timeout = balloon_stats.schedule_delay * HZ;
2084     + else
2085     + timeout = 3600 * HZ;
2086     + credit = current_credit();
2087    
2088     + wait_event_freezable_timeout(balloon_thread_wq,
2089     + balloon_thread_cond(state, credit), timeout);
2090     +
2091     + if (kthread_should_stop())
2092     + return 0;
2093    
2094     - do {
2095     mutex_lock(&balloon_mutex);
2096    
2097     credit = current_credit();
2098     @@ -546,12 +571,7 @@ static void balloon_process(struct work_struct *work)
2099     mutex_unlock(&balloon_mutex);
2100    
2101     cond_resched();
2102     -
2103     - } while (credit && state == BP_DONE);
2104     -
2105     - /* Schedule more work if there is some still to be done. */
2106     - if (state == BP_EAGAIN)
2107     - schedule_delayed_work(&balloon_worker, balloon_stats.schedule_delay * HZ);
2108     + }
2109     }
2110    
2111     /* Resets the Xen limit, sets new target, and kicks off processing. */
2112     @@ -559,7 +579,7 @@ void balloon_set_new_target(unsigned long target)
2113     {
2114     /* No need for lock. Not read-modify-write updates. */
2115     balloon_stats.target_pages = target;
2116     - schedule_delayed_work(&balloon_worker, 0);
2117     + wake_up(&balloon_thread_wq);
2118     }
2119     EXPORT_SYMBOL_GPL(balloon_set_new_target);
2120    
2121     @@ -664,7 +684,7 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
2122    
2123     /* The balloon may be too large now. Shrink it if needed. */
2124     if (current_credit())
2125     - schedule_delayed_work(&balloon_worker, 0);
2126     + wake_up(&balloon_thread_wq);
2127    
2128     mutex_unlock(&balloon_mutex);
2129     }
2130     @@ -696,6 +716,8 @@ static void __init balloon_add_region(unsigned long start_pfn,
2131    
2132     static int __init balloon_init(void)
2133     {
2134     + struct task_struct *task;
2135     +
2136     if (!xen_domain())
2137     return -ENODEV;
2138    
2139     @@ -739,6 +761,12 @@ static int __init balloon_init(void)
2140     }
2141     #endif
2142    
2143     + task = kthread_run(balloon_thread, NULL, "xen-balloon");
2144     + if (IS_ERR(task)) {
2145     + pr_err("xen-balloon thread could not be started, ballooning will not work!\n");
2146     + return PTR_ERR(task);
2147     + }
2148     +
2149     /* Init the xen-balloon driver. */
2150     xen_balloon_init();
2151    
2152     diff --git a/fs/afs/dir.c b/fs/afs/dir.c
2153     index e7494cd49ce7b..8c39533d122a5 100644
2154     --- a/fs/afs/dir.c
2155     +++ b/fs/afs/dir.c
2156     @@ -977,9 +977,9 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,
2157     */
2158     static int afs_d_revalidate_rcu(struct dentry *dentry)
2159     {
2160     - struct afs_vnode *dvnode, *vnode;
2161     + struct afs_vnode *dvnode;
2162     struct dentry *parent;
2163     - struct inode *dir, *inode;
2164     + struct inode *dir;
2165     long dir_version, de_version;
2166    
2167     _enter("%p", dentry);
2168     @@ -1009,18 +1009,6 @@ static int afs_d_revalidate_rcu(struct dentry *dentry)
2169     return -ECHILD;
2170     }
2171    
2172     - /* Check to see if the vnode referred to by the dentry still
2173     - * has a callback.
2174     - */
2175     - if (d_really_is_positive(dentry)) {
2176     - inode = d_inode_rcu(dentry);
2177     - if (inode) {
2178     - vnode = AFS_FS_I(inode);
2179     - if (!afs_check_validity(vnode))
2180     - return -ECHILD;
2181     - }
2182     - }
2183     -
2184     return 1; /* Still valid */
2185     }
2186    
2187     @@ -1056,17 +1044,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
2188     if (IS_ERR(key))
2189     key = NULL;
2190    
2191     - if (d_really_is_positive(dentry)) {
2192     - inode = d_inode(dentry);
2193     - if (inode) {
2194     - vnode = AFS_FS_I(inode);
2195     - afs_validate(vnode, key);
2196     - if (test_bit(AFS_VNODE_DELETED, &vnode->flags))
2197     - goto out_bad;
2198     - }
2199     - }
2200     -
2201     - /* lock down the parent dentry so we can peer at it */
2202     + /* Hold the parent dentry so we can peer at it */
2203     parent = dget_parent(dentry);
2204     dir = AFS_FS_I(d_inode(parent));
2205    
2206     @@ -1075,7 +1053,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
2207    
2208     if (test_bit(AFS_VNODE_DELETED, &dir->flags)) {
2209     _debug("%pd: parent dir deleted", dentry);
2210     - goto out_bad_parent;
2211     + goto not_found;
2212     }
2213    
2214     /* We only need to invalidate a dentry if the server's copy changed
2215     @@ -1101,12 +1079,12 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
2216     case 0:
2217     /* the filename maps to something */
2218     if (d_really_is_negative(dentry))
2219     - goto out_bad_parent;
2220     + goto not_found;
2221     inode = d_inode(dentry);
2222     if (is_bad_inode(inode)) {
2223     printk("kAFS: afs_d_revalidate: %pd2 has bad inode\n",
2224     dentry);
2225     - goto out_bad_parent;
2226     + goto not_found;
2227     }
2228    
2229     vnode = AFS_FS_I(inode);
2230     @@ -1128,9 +1106,6 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
2231     dentry, fid.unique,
2232     vnode->fid.unique,
2233     vnode->vfs_inode.i_generation);
2234     - write_seqlock(&vnode->cb_lock);
2235     - set_bit(AFS_VNODE_DELETED, &vnode->flags);
2236     - write_sequnlock(&vnode->cb_lock);
2237     goto not_found;
2238     }
2239     goto out_valid;
2240     @@ -1145,7 +1120,7 @@ static int afs_d_revalidate(struct dentry *dentry, unsigned int flags)
2241     default:
2242     _debug("failed to iterate dir %pd: %d",
2243     parent, ret);
2244     - goto out_bad_parent;
2245     + goto not_found;
2246     }
2247    
2248     out_valid:
2249     @@ -1156,16 +1131,9 @@ out_valid_noupdate:
2250     _leave(" = 1 [valid]");
2251     return 1;
2252    
2253     - /* the dirent, if it exists, now points to a different vnode */
2254     not_found:
2255     - spin_lock(&dentry->d_lock);
2256     - dentry->d_flags |= DCACHE_NFSFS_RENAMED;
2257     - spin_unlock(&dentry->d_lock);
2258     -
2259     -out_bad_parent:
2260     _debug("dropping dentry %pd2", dentry);
2261     dput(parent);
2262     -out_bad:
2263     key_put(key);
2264    
2265     _leave(" = 0 [bad]");
2266     diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c
2267     index 90500b6c41fc6..1cd39f6a9c3ad 100644
2268     --- a/fs/btrfs/space-info.c
2269     +++ b/fs/btrfs/space-info.c
2270     @@ -262,9 +262,10 @@ static void __btrfs_dump_space_info(struct btrfs_fs_info *fs_info,
2271     {
2272     lockdep_assert_held(&info->lock);
2273    
2274     - btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull",
2275     + /* The free space could be negative in case of overcommit */
2276     + btrfs_info(fs_info, "space_info %llu has %lld free, is %sfull",
2277     info->flags,
2278     - info->total_bytes - btrfs_space_info_used(info, true),
2279     + (s64)(info->total_bytes - btrfs_space_info_used(info, true)),
2280     info->full ? "" : "not ");
2281     btrfs_info(fs_info,
2282     "space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu",
2283     diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
2284     index da0720f41ebcb..86bdebd2ece65 100644
2285     --- a/fs/cifs/connect.c
2286     +++ b/fs/cifs/connect.c
2287     @@ -3691,9 +3691,10 @@ cifs_match_super(struct super_block *sb, void *data)
2288     spin_lock(&cifs_tcp_ses_lock);
2289     cifs_sb = CIFS_SB(sb);
2290     tlink = cifs_get_tlink(cifs_sb_master_tlink(cifs_sb));
2291     - if (IS_ERR(tlink)) {
2292     + if (tlink == NULL) {
2293     + /* can not match superblock if tlink were ever null */
2294     spin_unlock(&cifs_tcp_ses_lock);
2295     - return rc;
2296     + return 0;
2297     }
2298     tcon = tlink_tcon(tlink);
2299     ses = tcon->ses;
2300     diff --git a/fs/cifs/file.c b/fs/cifs/file.c
2301     index 1aac8d38f887d..a9746af5a44db 100644
2302     --- a/fs/cifs/file.c
2303     +++ b/fs/cifs/file.c
2304     @@ -2989,7 +2989,7 @@ static void collect_uncached_write_data(struct cifs_aio_ctx *ctx)
2305     struct cifs_tcon *tcon;
2306     struct cifs_sb_info *cifs_sb;
2307     struct dentry *dentry = ctx->cfile->dentry;
2308     - int rc;
2309     + ssize_t rc;
2310    
2311     tcon = tlink_tcon(ctx->cfile->tlink);
2312     cifs_sb = CIFS_SB(dentry->d_sb);
2313     diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
2314     index 50a863fc17792..207ec61569ea4 100644
2315     --- a/fs/ocfs2/dlmglue.c
2316     +++ b/fs/ocfs2/dlmglue.c
2317     @@ -3933,7 +3933,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2318     oi = OCFS2_I(inode);
2319     oi->ip_dir_lock_gen++;
2320     mlog(0, "generation: %u\n", oi->ip_dir_lock_gen);
2321     - goto out;
2322     + goto out_forget;
2323     }
2324    
2325     if (!S_ISREG(inode->i_mode))
2326     @@ -3964,6 +3964,7 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres,
2327     filemap_fdatawait(mapping);
2328     }
2329    
2330     +out_forget:
2331     forget_all_cached_acls(inode);
2332    
2333     out:
2334     diff --git a/fs/qnx4/dir.c b/fs/qnx4/dir.c
2335     index a6ee23aadd283..66645a5a35f30 100644
2336     --- a/fs/qnx4/dir.c
2337     +++ b/fs/qnx4/dir.c
2338     @@ -15,13 +15,48 @@
2339     #include <linux/buffer_head.h>
2340     #include "qnx4.h"
2341    
2342     +/*
2343     + * A qnx4 directory entry is an inode entry or link info
2344     + * depending on the status field in the last byte. The
2345     + * first byte is where the name start either way, and a
2346     + * zero means it's empty.
2347     + *
2348     + * Also, due to a bug in gcc, we don't want to use the
2349     + * real (differently sized) name arrays in the inode and
2350     + * link entries, but always the 'de_name[]' one in the
2351     + * fake struct entry.
2352     + *
2353     + * See
2354     + *
2355     + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c6
2356     + *
2357     + * for details, but basically gcc will take the size of the
2358     + * 'name' array from one of the used union entries randomly.
2359     + *
2360     + * This use of 'de_name[]' (48 bytes) avoids the false positive
2361     + * warnings that would happen if gcc decides to use 'inode.di_name'
2362     + * (16 bytes) even when the pointer and size were to come from
2363     + * 'link.dl_name' (48 bytes).
2364     + *
2365     + * In all cases the actual name pointer itself is the same, it's
2366     + * only the gcc internal 'what is the size of this field' logic
2367     + * that can get confused.
2368     + */
2369     +union qnx4_directory_entry {
2370     + struct {
2371     + const char de_name[48];
2372     + u8 de_pad[15];
2373     + u8 de_status;
2374     + };
2375     + struct qnx4_inode_entry inode;
2376     + struct qnx4_link_info link;
2377     +};
2378     +
2379     static int qnx4_readdir(struct file *file, struct dir_context *ctx)
2380     {
2381     struct inode *inode = file_inode(file);
2382     unsigned int offset;
2383     struct buffer_head *bh;
2384     - struct qnx4_inode_entry *de;
2385     - struct qnx4_link_info *le;
2386     unsigned long blknum;
2387     int ix, ino;
2388     int size;
2389     @@ -38,27 +73,27 @@ static int qnx4_readdir(struct file *file, struct dir_context *ctx)
2390     }
2391     ix = (ctx->pos >> QNX4_DIR_ENTRY_SIZE_BITS) % QNX4_INODES_PER_BLOCK;
2392     for (; ix < QNX4_INODES_PER_BLOCK; ix++, ctx->pos += QNX4_DIR_ENTRY_SIZE) {
2393     + union qnx4_directory_entry *de;
2394     +
2395     offset = ix * QNX4_DIR_ENTRY_SIZE;
2396     - de = (struct qnx4_inode_entry *) (bh->b_data + offset);
2397     - if (!de->di_fname[0])
2398     + de = (union qnx4_directory_entry *) (bh->b_data + offset);
2399     +
2400     + if (!de->de_name[0])
2401     continue;
2402     - if (!(de->di_status & (QNX4_FILE_USED|QNX4_FILE_LINK)))
2403     + if (!(de->de_status & (QNX4_FILE_USED|QNX4_FILE_LINK)))
2404     continue;
2405     - if (!(de->di_status & QNX4_FILE_LINK))
2406     - size = QNX4_SHORT_NAME_MAX;
2407     - else
2408     - size = QNX4_NAME_MAX;
2409     - size = strnlen(de->di_fname, size);
2410     - QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, de->di_fname));
2411     - if (!(de->di_status & QNX4_FILE_LINK))
2412     + if (!(de->de_status & QNX4_FILE_LINK)) {
2413     + size = sizeof(de->inode.di_fname);
2414     ino = blknum * QNX4_INODES_PER_BLOCK + ix - 1;
2415     - else {
2416     - le = (struct qnx4_link_info*)de;
2417     - ino = ( le32_to_cpu(le->dl_inode_blk) - 1 ) *
2418     + } else {
2419     + size = sizeof(de->link.dl_fname);
2420     + ino = ( le32_to_cpu(de->link.dl_inode_blk) - 1 ) *
2421     QNX4_INODES_PER_BLOCK +
2422     - le->dl_inode_ndx;
2423     + de->link.dl_inode_ndx;
2424     }
2425     - if (!dir_emit(ctx, de->di_fname, size, ino, DT_UNKNOWN)) {
2426     + size = strnlen(de->de_name, size);
2427     + QNX4DEBUG((KERN_INFO "qnx4_readdir:%.*s\n", size, name));
2428     + if (!dir_emit(ctx, de->de_name, size, ino, DT_UNKNOWN)) {
2429     brelse(bh);
2430     return 0;
2431     }
2432     diff --git a/include/linux/compiler.h b/include/linux/compiler.h
2433     index 9446e8fbe55c5..bce983406aaf3 100644
2434     --- a/include/linux/compiler.h
2435     +++ b/include/linux/compiler.h
2436     @@ -233,6 +233,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
2437     (typeof(ptr)) (__ptr + (off)); })
2438     #endif
2439    
2440     +#define absolute_pointer(val) RELOC_HIDE((void *)(val), 0)
2441     +
2442     #ifndef OPTIMIZER_HIDE_VAR
2443     /* Make the optimizer believe the variable can be manipulated arbitrarily. */
2444     #define OPTIMIZER_HIDE_VAR(var) \
2445     diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
2446     index 712b2a603645f..c0eb85b2981e0 100644
2447     --- a/include/linux/usb/hcd.h
2448     +++ b/include/linux/usb/hcd.h
2449     @@ -124,6 +124,7 @@ struct usb_hcd {
2450     #define HCD_FLAG_RH_RUNNING 5 /* root hub is running? */
2451     #define HCD_FLAG_DEAD 6 /* controller has died? */
2452     #define HCD_FLAG_INTF_AUTHORIZED 7 /* authorize interfaces? */
2453     +#define HCD_FLAG_DEFER_RH_REGISTER 8 /* Defer roothub registration */
2454    
2455     /* The flags can be tested using these macros; they are likely to
2456     * be slightly faster than test_bit().
2457     @@ -134,6 +135,7 @@ struct usb_hcd {
2458     #define HCD_WAKEUP_PENDING(hcd) ((hcd)->flags & (1U << HCD_FLAG_WAKEUP_PENDING))
2459     #define HCD_RH_RUNNING(hcd) ((hcd)->flags & (1U << HCD_FLAG_RH_RUNNING))
2460     #define HCD_DEAD(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEAD))
2461     +#define HCD_DEFER_RH_REGISTER(hcd) ((hcd)->flags & (1U << HCD_FLAG_DEFER_RH_REGISTER))
2462    
2463     /*
2464     * Specifies if interfaces are authorized by default
2465     diff --git a/include/trace/events/erofs.h b/include/trace/events/erofs.h
2466     index 27f5caa6299a3..ecfad7641096e 100644
2467     --- a/include/trace/events/erofs.h
2468     +++ b/include/trace/events/erofs.h
2469     @@ -35,20 +35,20 @@ TRACE_EVENT(erofs_lookup,
2470     TP_STRUCT__entry(
2471     __field(dev_t, dev )
2472     __field(erofs_nid_t, nid )
2473     - __field(const char *, name )
2474     + __string(name, dentry->d_name.name )
2475     __field(unsigned int, flags )
2476     ),
2477    
2478     TP_fast_assign(
2479     __entry->dev = dir->i_sb->s_dev;
2480     __entry->nid = EROFS_I(dir)->nid;
2481     - __entry->name = dentry->d_name.name;
2482     + __assign_str(name, dentry->d_name.name);
2483     __entry->flags = flags;
2484     ),
2485    
2486     TP_printk("dev = (%d,%d), pnid = %llu, name:%s, flags:%x",
2487     show_dev_nid(__entry),
2488     - __entry->name,
2489     + __get_str(name),
2490     __entry->flags)
2491     );
2492    
2493     diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
2494     index 60383b28549be..9c5fa5c529031 100644
2495     --- a/kernel/bpf/verifier.c
2496     +++ b/kernel/bpf/verifier.c
2497     @@ -6839,6 +6839,8 @@ static int check_btf_line(struct bpf_verifier_env *env,
2498     nr_linfo = attr->line_info_cnt;
2499     if (!nr_linfo)
2500     return 0;
2501     + if (nr_linfo > INT_MAX / sizeof(struct bpf_line_info))
2502     + return -EINVAL;
2503    
2504     rec_size = attr->line_info_rec_size;
2505     if (rec_size < MIN_BPF_LINEINFO_SIZE ||
2506     diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
2507     index 884333b9fc767..749b27851f45d 100644
2508     --- a/kernel/trace/blktrace.c
2509     +++ b/kernel/trace/blktrace.c
2510     @@ -1656,6 +1656,14 @@ static int blk_trace_remove_queue(struct request_queue *q)
2511     if (bt == NULL)
2512     return -EINVAL;
2513    
2514     + if (bt->trace_state == Blktrace_running) {
2515     + bt->trace_state = Blktrace_stopped;
2516     + spin_lock_irq(&running_trace_lock);
2517     + list_del_init(&bt->running_list);
2518     + spin_unlock_irq(&running_trace_lock);
2519     + relay_flush(bt->rchan);
2520     + }
2521     +
2522     put_probe_ref();
2523     synchronize_rcu();
2524     blk_trace_free(bt);
2525     diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
2526     index bb68290ad68d8..9a6f66e0e9a27 100644
2527     --- a/net/ipv6/ip6_fib.c
2528     +++ b/net/ipv6/ip6_fib.c
2529     @@ -1310,7 +1310,6 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
2530     int err = -ENOMEM;
2531     int allow_create = 1;
2532     int replace_required = 0;
2533     - int sernum = fib6_new_sernum(info->nl_net);
2534    
2535     if (info->nlh) {
2536     if (!(info->nlh->nlmsg_flags & NLM_F_CREATE))
2537     @@ -1410,7 +1409,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
2538     if (!err) {
2539     if (rt->nh)
2540     list_add(&rt->nh_list, &rt->nh->f6i_list);
2541     - __fib6_update_sernum_upto_root(rt, sernum);
2542     + __fib6_update_sernum_upto_root(rt, fib6_new_sernum(info->nl_net));
2543     fib6_start_gc(info->nl_net, rt);
2544     }
2545    
2546     diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c
2547     index aee9ccfa99c22..ade1232699bbf 100644
2548     --- a/net/smc/smc_clc.c
2549     +++ b/net/smc/smc_clc.c
2550     @@ -164,7 +164,8 @@ static int smc_clc_prfx_set(struct socket *clcsock,
2551     goto out_rel;
2552     }
2553     /* get address to which the internal TCP socket is bound */
2554     - kernel_getsockname(clcsock, (struct sockaddr *)&addrs);
2555     + if (kernel_getsockname(clcsock, (struct sockaddr *)&addrs) < 0)
2556     + goto out_rel;
2557     /* analyze IP specific data of net_device belonging to TCP socket */
2558     addr6 = (struct sockaddr_in6 *)&addrs;
2559     rcu_read_lock();