Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.4 commit in: /
Date: Fri, 26 Nov 2021 12:02:47
Message-Id: 1637928147.624c17b0dc2ec2406317faecce318276fec2f0c8.mpagano@gentoo
1 commit: 624c17b0dc2ec2406317faecce318276fec2f0c8
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 26 12:02:27 2021 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 26 12:02:27 2021 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=624c17b0
7
8 Linux patch 4.4.293
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1292_linux-4.4.293.patch | 5121 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 5125 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index d34f841c..6036ab4e 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -1211,6 +1211,10 @@ Patch: 1291_linux-4.4.292.patc
21 From: http://www.kernel.org
22 Desc: Linux 4.4.292
23
24 +Patch: 1292_linux-4.4.293.patc
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.293
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1292_linux-4.4.293.patch b/1292_linux-4.4.293.patch
33 new file mode 100644
34 index 00000000..2e7f484d
35 --- /dev/null
36 +++ b/1292_linux-4.4.293.patch
37 @@ -0,0 +1,5121 @@
38 +diff --git a/Makefile b/Makefile
39 +index 0815258259560..fb5a475073fbe 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 4
45 +-SUBLEVEL = 292
46 ++SUBLEVEL = 293
47 + EXTRAVERSION =
48 + NAME = Blurry Fish Butt
49 +
50 +diff --git a/arch/arm/Makefile b/arch/arm/Makefile
51 +index 3a4774dfc1f78..201db287afb88 100644
52 +--- a/arch/arm/Makefile
53 ++++ b/arch/arm/Makefile
54 +@@ -66,15 +66,15 @@ KBUILD_CFLAGS += $(call cc-option,-fno-ipa-sra)
55 + # Note that GCC does not numerically define an architecture version
56 + # macro, but instead defines a whole series of macros which makes
57 + # testing for a specific architecture or later rather impossible.
58 +-arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m -Wa,-march=armv7-m
59 +-arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)
60 +-arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6,-march=armv5t -Wa$(comma)-march=armv6)
61 ++arch-$(CONFIG_CPU_32v7M) =-D__LINUX_ARM_ARCH__=7 -march=armv7-m
62 ++arch-$(CONFIG_CPU_32v7) =-D__LINUX_ARM_ARCH__=7 -march=armv7-a
63 ++arch-$(CONFIG_CPU_32v6) =-D__LINUX_ARM_ARCH__=6 -march=armv6
64 + # Only override the compiler option if ARMv6. The ARMv6K extensions are
65 + # always available in ARMv7
66 + ifeq ($(CONFIG_CPU_32v6),y)
67 +-arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 $(call cc-option,-march=armv6k,-march=armv5t -Wa$(comma)-march=armv6k)
68 ++arch-$(CONFIG_CPU_32v6K) =-D__LINUX_ARM_ARCH__=6 -march=armv6k
69 + endif
70 +-arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 $(call cc-option,-march=armv5te,-march=armv4t)
71 ++arch-$(CONFIG_CPU_32v5) =-D__LINUX_ARM_ARCH__=5 -march=armv5te
72 + arch-$(CONFIG_CPU_32v4T) =-D__LINUX_ARM_ARCH__=4 -march=armv4t
73 + arch-$(CONFIG_CPU_32v4) =-D__LINUX_ARM_ARCH__=4 -march=armv4
74 + arch-$(CONFIG_CPU_32v3) =-D__LINUX_ARM_ARCH__=3 -march=armv3
75 +@@ -88,7 +88,7 @@ tune-$(CONFIG_CPU_ARM720T) =-mtune=arm7tdmi
76 + tune-$(CONFIG_CPU_ARM740T) =-mtune=arm7tdmi
77 + tune-$(CONFIG_CPU_ARM9TDMI) =-mtune=arm9tdmi
78 + tune-$(CONFIG_CPU_ARM940T) =-mtune=arm9tdmi
79 +-tune-$(CONFIG_CPU_ARM946E) =$(call cc-option,-mtune=arm9e,-mtune=arm9tdmi)
80 ++tune-$(CONFIG_CPU_ARM946E) =-mtune=arm9e
81 + tune-$(CONFIG_CPU_ARM920T) =-mtune=arm9tdmi
82 + tune-$(CONFIG_CPU_ARM922T) =-mtune=arm9tdmi
83 + tune-$(CONFIG_CPU_ARM925T) =-mtune=arm9tdmi
84 +@@ -96,11 +96,11 @@ tune-$(CONFIG_CPU_ARM926T) =-mtune=arm9tdmi
85 + tune-$(CONFIG_CPU_FA526) =-mtune=arm9tdmi
86 + tune-$(CONFIG_CPU_SA110) =-mtune=strongarm110
87 + tune-$(CONFIG_CPU_SA1100) =-mtune=strongarm1100
88 +-tune-$(CONFIG_CPU_XSCALE) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
89 +-tune-$(CONFIG_CPU_XSC3) =$(call cc-option,-mtune=xscale,-mtune=strongarm110) -Wa,-mcpu=xscale
90 +-tune-$(CONFIG_CPU_FEROCEON) =$(call cc-option,-mtune=marvell-f,-mtune=xscale)
91 +-tune-$(CONFIG_CPU_V6) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
92 +-tune-$(CONFIG_CPU_V6K) =$(call cc-option,-mtune=arm1136j-s,-mtune=strongarm)
93 ++tune-$(CONFIG_CPU_XSCALE) =-mtune=xscale
94 ++tune-$(CONFIG_CPU_XSC3) =-mtune=xscale
95 ++tune-$(CONFIG_CPU_FEROCEON) =-mtune=xscale
96 ++tune-$(CONFIG_CPU_V6) =-mtune=arm1136j-s
97 ++tune-$(CONFIG_CPU_V6K) =-mtune=arm1136j-s
98 +
99 + # Evaluate tune cc-option calls now
100 + tune-y := $(tune-y)
101 +diff --git a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
102 +index 73e272fadc202..58d288fddd9c2 100644
103 +--- a/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
104 ++++ b/arch/arm/boot/dts/omap-gpmc-smsc9221.dtsi
105 +@@ -28,7 +28,7 @@
106 + compatible = "smsc,lan9221","smsc,lan9115";
107 + bank-width = <2>;
108 +
109 +- gpmc,mux-add-data;
110 ++ gpmc,mux-add-data = <0>;
111 + gpmc,cs-on-ns = <0>;
112 + gpmc,cs-rd-off-ns = <42>;
113 + gpmc,cs-wr-off-ns = <36>;
114 +diff --git a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
115 +index 82e98ee3023ad..3dbeb7a6c569c 100644
116 +--- a/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
117 ++++ b/arch/arm/boot/dts/omap3-overo-tobiduo-common.dtsi
118 +@@ -25,7 +25,7 @@
119 + compatible = "smsc,lan9221","smsc,lan9115";
120 + bank-width = <2>;
121 +
122 +- gpmc,mux-add-data;
123 ++ gpmc,mux-add-data = <0>;
124 + gpmc,cs-on-ns = <0>;
125 + gpmc,cs-rd-off-ns = <42>;
126 + gpmc,cs-wr-off-ns = <36>;
127 +diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c
128 +index 6e8a50de40e2b..c10c1de244eba 100644
129 +--- a/arch/arm/kernel/stacktrace.c
130 ++++ b/arch/arm/kernel/stacktrace.c
131 +@@ -51,8 +51,7 @@ int notrace unwind_frame(struct stackframe *frame)
132 +
133 + frame->sp = frame->fp;
134 + frame->fp = *(unsigned long *)(fp);
135 +- frame->pc = frame->lr;
136 +- frame->lr = *(unsigned long *)(fp + 4);
137 ++ frame->pc = *(unsigned long *)(fp + 4);
138 + #else
139 + /* check current frame pointer is within bounds */
140 + if (fp < low + 12 || fp > high - 4)
141 +diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
142 +index 71115afb71a05..f46089b24588f 100644
143 +--- a/arch/arm/mm/Kconfig
144 ++++ b/arch/arm/mm/Kconfig
145 +@@ -724,7 +724,7 @@ config CPU_BIG_ENDIAN
146 + config CPU_ENDIAN_BE8
147 + bool
148 + depends on CPU_BIG_ENDIAN
149 +- default CPU_V6 || CPU_V6K || CPU_V7
150 ++ default CPU_V6 || CPU_V6K || CPU_V7 || CPU_V7M
151 + help
152 + Support for the BE-8 (big-endian) mode on ARMv6 and ARMv7 processors.
153 +
154 +diff --git a/arch/hexagon/lib/io.c b/arch/hexagon/lib/io.c
155 +index 885c9626d5e08..e5dfed1cf151b 100644
156 +--- a/arch/hexagon/lib/io.c
157 ++++ b/arch/hexagon/lib/io.c
158 +@@ -40,6 +40,7 @@ void __raw_readsw(const void __iomem *addr, void *data, int len)
159 + *dst++ = *src;
160 +
161 + }
162 ++EXPORT_SYMBOL(__raw_readsw);
163 +
164 + /*
165 + * __raw_writesw - read words a short at a time
166 +@@ -60,6 +61,7 @@ void __raw_writesw(void __iomem *addr, const void *data, int len)
167 +
168 +
169 + }
170 ++EXPORT_SYMBOL(__raw_writesw);
171 +
172 + /* Pretty sure len is pre-adjusted for the length of the access already */
173 + void __raw_readsl(const void __iomem *addr, void *data, int len)
174 +@@ -75,6 +77,7 @@ void __raw_readsl(const void __iomem *addr, void *data, int len)
175 +
176 +
177 + }
178 ++EXPORT_SYMBOL(__raw_readsl);
179 +
180 + void __raw_writesl(void __iomem *addr, const void *data, int len)
181 + {
182 +@@ -89,3 +92,4 @@ void __raw_writesl(void __iomem *addr, const void *data, int len)
183 +
184 +
185 + }
186 ++EXPORT_SYMBOL(__raw_writesl);
187 +diff --git a/arch/ia64/Kconfig.debug b/arch/ia64/Kconfig.debug
188 +index de9d507ba0fd4..ee6c7f75f479d 100644
189 +--- a/arch/ia64/Kconfig.debug
190 ++++ b/arch/ia64/Kconfig.debug
191 +@@ -41,7 +41,7 @@ config DISABLE_VHPT
192 +
193 + config IA64_DEBUG_CMPXCHG
194 + bool "Turn on compare-and-exchange bug checking (slow!)"
195 +- depends on DEBUG_KERNEL
196 ++ depends on DEBUG_KERNEL && PRINTK
197 + help
198 + Selecting this option turns on bug checking for the IA-64
199 + compare-and-exchange instructions. This is slow! Itaniums
200 +diff --git a/arch/m68k/Kconfig.machine b/arch/m68k/Kconfig.machine
201 +index 61dc643c0b05c..16a737b9bd660 100644
202 +--- a/arch/m68k/Kconfig.machine
203 ++++ b/arch/m68k/Kconfig.machine
204 +@@ -184,6 +184,7 @@ config INIT_LCD
205 + config MEMORY_RESERVE
206 + int "Memory reservation (MiB)"
207 + depends on (UCSIMM || UCDIMM)
208 ++ default 0
209 + help
210 + Reserve certain memory regions on 68x328 based boards.
211 +
212 +diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
213 +index 9f1376788820e..98312d3e4f414 100644
214 +--- a/arch/mips/Kconfig
215 ++++ b/arch/mips/Kconfig
216 +@@ -211,6 +211,9 @@ config BCM63XX
217 + select SYS_SUPPORTS_32BIT_KERNEL
218 + select SYS_SUPPORTS_BIG_ENDIAN
219 + select SYS_HAS_EARLY_PRINTK
220 ++ select SYS_HAS_CPU_BMIPS32_3300
221 ++ select SYS_HAS_CPU_BMIPS4350
222 ++ select SYS_HAS_CPU_BMIPS4380
223 + select SWAP_IO_SPACE
224 + select ARCH_REQUIRE_GPIOLIB
225 + select HAVE_CLK
226 +diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c
227 +index 637565284732d..ef268c9aac80d 100644
228 +--- a/arch/mips/bcm63xx/clk.c
229 ++++ b/arch/mips/bcm63xx/clk.c
230 +@@ -333,6 +333,12 @@ void clk_disable(struct clk *clk)
231 +
232 + EXPORT_SYMBOL(clk_disable);
233 +
234 ++struct clk *clk_get_parent(struct clk *clk)
235 ++{
236 ++ return NULL;
237 ++}
238 ++EXPORT_SYMBOL(clk_get_parent);
239 ++
240 + unsigned long clk_get_rate(struct clk *clk)
241 + {
242 + return clk->rate;
243 +diff --git a/arch/mips/lantiq/xway/dma.c b/arch/mips/lantiq/xway/dma.c
244 +index 34a116e840d8b..35b7d1a0cad35 100644
245 +--- a/arch/mips/lantiq/xway/dma.c
246 ++++ b/arch/mips/lantiq/xway/dma.c
247 +@@ -21,6 +21,7 @@
248 + #include <linux/dma-mapping.h>
249 + #include <linux/module.h>
250 + #include <linux/clk.h>
251 ++#include <linux/delay.h>
252 + #include <linux/err.h>
253 +
254 + #include <lantiq_soc.h>
255 +@@ -39,6 +40,7 @@
256 + #define LTQ_DMA_PCTRL 0x44
257 + #define LTQ_DMA_IRNEN 0xf4
258 +
259 ++#define DMA_ID_CHNR GENMASK(26, 20) /* channel number */
260 + #define DMA_DESCPT BIT(3) /* descriptor complete irq */
261 + #define DMA_TX BIT(8) /* TX channel direction */
262 + #define DMA_CHAN_ON BIT(0) /* channel on / off bit */
263 +@@ -49,7 +51,6 @@
264 + #define DMA_POLL BIT(31) /* turn on channel polling */
265 + #define DMA_CLK_DIV4 BIT(6) /* polling clock divider */
266 + #define DMA_2W_BURST BIT(1) /* 2 word burst length */
267 +-#define DMA_MAX_CHANNEL 20 /* the soc has 20 channels */
268 + #define DMA_ETOP_ENDIANNESS (0xf << 8) /* endianness swap etop channels */
269 + #define DMA_WEIGHT (BIT(17) | BIT(16)) /* default channel wheight */
270 +
271 +@@ -216,7 +217,7 @@ ltq_dma_init(struct platform_device *pdev)
272 + {
273 + struct clk *clk;
274 + struct resource *res;
275 +- unsigned id;
276 ++ unsigned int id, nchannels;
277 + int i;
278 +
279 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
280 +@@ -232,21 +233,24 @@ ltq_dma_init(struct platform_device *pdev)
281 + clk_enable(clk);
282 + ltq_dma_w32_mask(0, DMA_RESET, LTQ_DMA_CTRL);
283 +
284 ++ usleep_range(1, 10);
285 ++
286 + /* disable all interrupts */
287 + ltq_dma_w32(0, LTQ_DMA_IRNEN);
288 +
289 + /* reset/configure each channel */
290 +- for (i = 0; i < DMA_MAX_CHANNEL; i++) {
291 ++ id = ltq_dma_r32(LTQ_DMA_ID);
292 ++ nchannels = ((id & DMA_ID_CHNR) >> 20);
293 ++ for (i = 0; i < nchannels; i++) {
294 + ltq_dma_w32(i, LTQ_DMA_CS);
295 + ltq_dma_w32(DMA_CHAN_RST, LTQ_DMA_CCTRL);
296 + ltq_dma_w32(DMA_POLL | DMA_CLK_DIV4, LTQ_DMA_CPOLL);
297 + ltq_dma_w32_mask(DMA_CHAN_ON, 0, LTQ_DMA_CCTRL);
298 + }
299 +
300 +- id = ltq_dma_r32(LTQ_DMA_ID);
301 + dev_info(&pdev->dev,
302 + "Init done - hw rev: %X, ports: %d, channels: %d\n",
303 +- id & 0x1f, (id >> 16) & 0xf, id >> 20);
304 ++ id & 0x1f, (id >> 16) & 0xf, nchannels);
305 +
306 + return 0;
307 + }
308 +diff --git a/arch/mips/sni/time.c b/arch/mips/sni/time.c
309 +index fb4b3520cdc61..d72dd0d2ff595 100644
310 +--- a/arch/mips/sni/time.c
311 ++++ b/arch/mips/sni/time.c
312 +@@ -18,14 +18,14 @@ static int a20r_set_periodic(struct clock_event_device *evt)
313 + {
314 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0x34;
315 + wmb();
316 +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV;
317 ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV & 0xff;
318 + wmb();
319 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 0) = SNI_COUNTER0_DIV >> 8;
320 + wmb();
321 +
322 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 12) = 0xb4;
323 + wmb();
324 +- *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV;
325 ++ *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV & 0xff;
326 + wmb();
327 + *(volatile u8 *)(A20R_PT_CLOCK_BASE + 8) = SNI_COUNTER2_DIV >> 8;
328 + wmb();
329 +diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
330 +index 3b7b022384a07..86e79e9df265e 100644
331 +--- a/arch/parisc/kernel/entry.S
332 ++++ b/arch/parisc/kernel/entry.S
333 +@@ -1849,8 +1849,8 @@ syscall_restore:
334 + LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
335 +
336 + /* Are we being ptraced? */
337 +- ldw TASK_FLAGS(%r1),%r19
338 +- ldi _TIF_SYSCALL_TRACE_MASK,%r2
339 ++ LDREG TI_FLAGS-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r19
340 ++ ldi _TIF_SINGLESTEP|_TIF_BLOCKSTEP,%r2
341 + and,COND(=) %r19,%r2,%r0
342 + b,n syscall_restore_rfi
343 +
344 +diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
345 +index 52e85973a283c..5a2c4771e9d1f 100644
346 +--- a/arch/parisc/kernel/smp.c
347 ++++ b/arch/parisc/kernel/smp.c
348 +@@ -32,6 +32,7 @@
349 + #include <linux/bitops.h>
350 + #include <linux/ftrace.h>
351 + #include <linux/cpu.h>
352 ++#include <linux/kgdb.h>
353 +
354 + #include <linux/atomic.h>
355 + #include <asm/current.h>
356 +@@ -74,7 +75,10 @@ enum ipi_message_type {
357 + IPI_CALL_FUNC,
358 + IPI_CPU_START,
359 + IPI_CPU_STOP,
360 +- IPI_CPU_TEST
361 ++ IPI_CPU_TEST,
362 ++#ifdef CONFIG_KGDB
363 ++ IPI_ENTER_KGDB,
364 ++#endif
365 + };
366 +
367 +
368 +@@ -170,7 +174,12 @@ ipi_interrupt(int irq, void *dev_id)
369 + case IPI_CPU_TEST:
370 + smp_debug(100, KERN_DEBUG "CPU%d is alive!\n", this_cpu);
371 + break;
372 +-
373 ++#ifdef CONFIG_KGDB
374 ++ case IPI_ENTER_KGDB:
375 ++ smp_debug(100, KERN_DEBUG "CPU%d ENTER_KGDB\n", this_cpu);
376 ++ kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
377 ++ break;
378 ++#endif
379 + default:
380 + printk(KERN_CRIT "Unknown IPI num on CPU%d: %lu\n",
381 + this_cpu, which);
382 +@@ -226,6 +235,12 @@ send_IPI_allbutself(enum ipi_message_type op)
383 + }
384 + }
385 +
386 ++#ifdef CONFIG_KGDB
387 ++void kgdb_roundup_cpus(void)
388 ++{
389 ++ send_IPI_allbutself(IPI_ENTER_KGDB);
390 ++}
391 ++#endif
392 +
393 + inline void
394 + smp_send_stop(void) { send_IPI_allbutself(IPI_CPU_STOP); }
395 +diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
396 +index d72f003106835..ad6545dafe039 100644
397 +--- a/arch/parisc/mm/init.c
398 ++++ b/arch/parisc/mm/init.c
399 +@@ -940,9 +940,9 @@ void flush_tlb_all(void)
400 + {
401 + int do_recycle;
402 +
403 +- __inc_irq_stat(irq_tlb_count);
404 + do_recycle = 0;
405 + spin_lock(&sid_lock);
406 ++ __inc_irq_stat(irq_tlb_count);
407 + if (dirty_space_ids > RECYCLE_THRESHOLD) {
408 + BUG_ON(recycle_inuse); /* FIXME: Use a semaphore/wait queue here */
409 + get_dirty_sids(&recycle_ndirty,recycle_dirty_array);
410 +@@ -961,8 +961,8 @@ void flush_tlb_all(void)
411 + #else
412 + void flush_tlb_all(void)
413 + {
414 +- __inc_irq_stat(irq_tlb_count);
415 + spin_lock(&sid_lock);
416 ++ __inc_irq_stat(irq_tlb_count);
417 + flush_tlb_all_local(NULL);
418 + recycle_sids();
419 + spin_unlock(&sid_lock);
420 +diff --git a/arch/powerpc/boot/dts/charon.dts b/arch/powerpc/boot/dts/charon.dts
421 +index 0e00e508eaa6a..1c8fe20752e6a 100644
422 +--- a/arch/powerpc/boot/dts/charon.dts
423 ++++ b/arch/powerpc/boot/dts/charon.dts
424 +@@ -39,7 +39,7 @@
425 + };
426 + };
427 +
428 +- memory {
429 ++ memory@0 {
430 + device_type = "memory";
431 + reg = <0x00000000 0x08000000>; // 128MB
432 + };
433 +diff --git a/arch/powerpc/boot/dts/digsy_mtc.dts b/arch/powerpc/boot/dts/digsy_mtc.dts
434 +index 955bff629df3c..bf511255f3ae8 100644
435 +--- a/arch/powerpc/boot/dts/digsy_mtc.dts
436 ++++ b/arch/powerpc/boot/dts/digsy_mtc.dts
437 +@@ -20,7 +20,7 @@
438 + model = "intercontrol,digsy-mtc";
439 + compatible = "intercontrol,digsy-mtc";
440 +
441 +- memory {
442 ++ memory@0 {
443 + reg = <0x00000000 0x02000000>; // 32MB
444 + };
445 +
446 +diff --git a/arch/powerpc/boot/dts/lite5200.dts b/arch/powerpc/boot/dts/lite5200.dts
447 +index 179a1785d6454..18d137a3393f0 100644
448 +--- a/arch/powerpc/boot/dts/lite5200.dts
449 ++++ b/arch/powerpc/boot/dts/lite5200.dts
450 +@@ -36,7 +36,7 @@
451 + };
452 + };
453 +
454 +- memory {
455 ++ memory@0 {
456 + device_type = "memory";
457 + reg = <0x00000000 0x04000000>; // 64MB
458 + };
459 +diff --git a/arch/powerpc/boot/dts/lite5200b.dts b/arch/powerpc/boot/dts/lite5200b.dts
460 +index 5abb46c5cc951..29419cf81e044 100644
461 +--- a/arch/powerpc/boot/dts/lite5200b.dts
462 ++++ b/arch/powerpc/boot/dts/lite5200b.dts
463 +@@ -35,7 +35,7 @@
464 + led4 { gpios = <&gpio_simple 2 1>; };
465 + };
466 +
467 +- memory {
468 ++ memory@0 {
469 + reg = <0x00000000 0x10000000>; // 256MB
470 + };
471 +
472 +diff --git a/arch/powerpc/boot/dts/media5200.dts b/arch/powerpc/boot/dts/media5200.dts
473 +index b5413cb85f134..3d57463bc49da 100644
474 +--- a/arch/powerpc/boot/dts/media5200.dts
475 ++++ b/arch/powerpc/boot/dts/media5200.dts
476 +@@ -36,7 +36,7 @@
477 + };
478 + };
479 +
480 +- memory {
481 ++ memory@0 {
482 + reg = <0x00000000 0x08000000>; // 128MB RAM
483 + };
484 +
485 +diff --git a/arch/powerpc/boot/dts/mpc5200b.dtsi b/arch/powerpc/boot/dts/mpc5200b.dtsi
486 +index 969b2200b2f97..ecfba675b5611 100644
487 +--- a/arch/powerpc/boot/dts/mpc5200b.dtsi
488 ++++ b/arch/powerpc/boot/dts/mpc5200b.dtsi
489 +@@ -37,7 +37,7 @@
490 + };
491 + };
492 +
493 +- memory: memory {
494 ++ memory: memory@0 {
495 + device_type = "memory";
496 + reg = <0x00000000 0x04000000>; // 64MB
497 + };
498 +diff --git a/arch/powerpc/boot/dts/o2d.dts b/arch/powerpc/boot/dts/o2d.dts
499 +index 9f6dd4d889b32..5a676e8141caf 100644
500 +--- a/arch/powerpc/boot/dts/o2d.dts
501 ++++ b/arch/powerpc/boot/dts/o2d.dts
502 +@@ -16,7 +16,7 @@
503 + model = "ifm,o2d";
504 + compatible = "ifm,o2d";
505 +
506 +- memory {
507 ++ memory@0 {
508 + reg = <0x00000000 0x08000000>; // 128MB
509 + };
510 +
511 +diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
512 +index cf073e693f24d..1b4df5f64b580 100644
513 +--- a/arch/powerpc/boot/dts/o2d.dtsi
514 ++++ b/arch/powerpc/boot/dts/o2d.dtsi
515 +@@ -23,7 +23,7 @@
516 + model = "ifm,o2d";
517 + compatible = "ifm,o2d";
518 +
519 +- memory {
520 ++ memory@0 {
521 + reg = <0x00000000 0x04000000>; // 64MB
522 + };
523 +
524 +diff --git a/arch/powerpc/boot/dts/o2dnt2.dts b/arch/powerpc/boot/dts/o2dnt2.dts
525 +index a0f5b97a4f06e..5184c461a205f 100644
526 +--- a/arch/powerpc/boot/dts/o2dnt2.dts
527 ++++ b/arch/powerpc/boot/dts/o2dnt2.dts
528 +@@ -16,7 +16,7 @@
529 + model = "ifm,o2dnt2";
530 + compatible = "ifm,o2d";
531 +
532 +- memory {
533 ++ memory@0 {
534 + reg = <0x00000000 0x08000000>; // 128MB
535 + };
536 +
537 +diff --git a/arch/powerpc/boot/dts/o3dnt.dts b/arch/powerpc/boot/dts/o3dnt.dts
538 +index acce49326491b..045b901719245 100644
539 +--- a/arch/powerpc/boot/dts/o3dnt.dts
540 ++++ b/arch/powerpc/boot/dts/o3dnt.dts
541 +@@ -16,7 +16,7 @@
542 + model = "ifm,o3dnt";
543 + compatible = "ifm,o2d";
544 +
545 +- memory {
546 ++ memory@0 {
547 + reg = <0x00000000 0x04000000>; // 64MB
548 + };
549 +
550 +diff --git a/arch/powerpc/boot/dts/pcm032.dts b/arch/powerpc/boot/dts/pcm032.dts
551 +index 96b139bf50e9c..ac3f53c1a1f5b 100644
552 +--- a/arch/powerpc/boot/dts/pcm032.dts
553 ++++ b/arch/powerpc/boot/dts/pcm032.dts
554 +@@ -26,7 +26,7 @@
555 + model = "phytec,pcm032";
556 + compatible = "phytec,pcm032";
557 +
558 +- memory {
559 ++ memory@0 {
560 + reg = <0x00000000 0x08000000>; // 128MB
561 + };
562 +
563 +diff --git a/arch/powerpc/boot/dts/tqm5200.dts b/arch/powerpc/boot/dts/tqm5200.dts
564 +index 1db07f6cf133c..68b9e8240fb5b 100644
565 +--- a/arch/powerpc/boot/dts/tqm5200.dts
566 ++++ b/arch/powerpc/boot/dts/tqm5200.dts
567 +@@ -36,7 +36,7 @@
568 + };
569 + };
570 +
571 +- memory {
572 ++ memory@0 {
573 + device_type = "memory";
574 + reg = <0x00000000 0x04000000>; // 64MB
575 + };
576 +diff --git a/arch/powerpc/sysdev/dcr-low.S b/arch/powerpc/sysdev/dcr-low.S
577 +index d3098ef1404a2..3943d19d5f63b 100644
578 +--- a/arch/powerpc/sysdev/dcr-low.S
579 ++++ b/arch/powerpc/sysdev/dcr-low.S
580 +@@ -14,7 +14,7 @@
581 + #include <asm/bug.h>
582 +
583 + #define DCR_ACCESS_PROLOG(table) \
584 +- cmpli cr0,r3,1024; \
585 ++ cmplwi cr0,r3,1024; \
586 + rlwinm r3,r3,4,18,27; \
587 + lis r5,table@h; \
588 + ori r5,r5,table@l; \
589 +diff --git a/arch/sh/Kconfig.debug b/arch/sh/Kconfig.debug
590 +index 5f2bb4242c0f7..c50c397cbcf75 100644
591 +--- a/arch/sh/Kconfig.debug
592 ++++ b/arch/sh/Kconfig.debug
593 +@@ -60,6 +60,7 @@ config DUMP_CODE
594 +
595 + config DWARF_UNWINDER
596 + bool "Enable the DWARF unwinder for stacktraces"
597 ++ depends on DEBUG_KERNEL
598 + select FRAME_POINTER
599 + depends on SUPERH32
600 + default n
601 +diff --git a/arch/sh/include/asm/sfp-machine.h b/arch/sh/include/asm/sfp-machine.h
602 +index d3c548443f2a6..dd195c6f3b9d8 100644
603 +--- a/arch/sh/include/asm/sfp-machine.h
604 ++++ b/arch/sh/include/asm/sfp-machine.h
605 +@@ -25,6 +25,14 @@
606 + #ifndef _SFP_MACHINE_H
607 + #define _SFP_MACHINE_H
608 +
609 ++#ifdef __BIG_ENDIAN__
610 ++#define __BYTE_ORDER __BIG_ENDIAN
611 ++#define __LITTLE_ENDIAN 0
612 ++#else
613 ++#define __BYTE_ORDER __LITTLE_ENDIAN
614 ++#define __BIG_ENDIAN 0
615 ++#endif
616 ++
617 + #define _FP_W_TYPE_SIZE 32
618 + #define _FP_W_TYPE unsigned long
619 + #define _FP_WS_TYPE signed long
620 +diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
621 +index 4a298808789c4..4a1cee5da2dc5 100644
622 +--- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
623 ++++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
624 +@@ -78,8 +78,9 @@ static void shx3_prepare_cpus(unsigned int max_cpus)
625 + BUILD_BUG_ON(SMP_MSG_NR >= 8);
626 +
627 + for (i = 0; i < SMP_MSG_NR; i++)
628 +- request_irq(104 + i, ipi_interrupt_handler,
629 +- IRQF_PERCPU, "IPI", (void *)(long)i);
630 ++ if (request_irq(104 + i, ipi_interrupt_handler,
631 ++ IRQF_PERCPU, "IPI", (void *)(long)i))
632 ++ pr_err("Failed to request irq %d\n", i);
633 +
634 + for (i = 0; i < max_cpus; i++)
635 + set_cpu_present(i, true);
636 +diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
637 +index fb1251946b45e..67a140d77f336 100644
638 +--- a/arch/x86/include/asm/page_64_types.h
639 ++++ b/arch/x86/include/asm/page_64_types.h
640 +@@ -15,7 +15,7 @@
641 + #define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
642 + #define CURRENT_MASK (~(THREAD_SIZE - 1))
643 +
644 +-#define EXCEPTION_STACK_ORDER (0 + KASAN_STACK_ORDER)
645 ++#define EXCEPTION_STACK_ORDER (1 + KASAN_STACK_ORDER)
646 + #define EXCEPTION_STKSZ (PAGE_SIZE << EXCEPTION_STACK_ORDER)
647 +
648 + #define DEBUG_STACK_ORDER (EXCEPTION_STACK_ORDER + 1)
649 +diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
650 +index 9f669fdd20106..2a53a63f1e70f 100644
651 +--- a/arch/x86/kernel/irq.c
652 ++++ b/arch/x86/kernel/irq.c
653 +@@ -283,8 +283,10 @@ void kvm_set_posted_intr_wakeup_handler(void (*handler)(void))
654 + {
655 + if (handler)
656 + kvm_posted_intr_wakeup_handler = handler;
657 +- else
658 ++ else {
659 + kvm_posted_intr_wakeup_handler = dummy_handler;
660 ++ synchronize_rcu();
661 ++ }
662 + }
663 + EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler);
664 +
665 +diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
666 +index 85082574c5154..62e11835f220e 100644
667 +--- a/crypto/pcrypt.c
668 ++++ b/crypto/pcrypt.c
669 +@@ -138,12 +138,14 @@ static void pcrypt_aead_enc(struct padata_priv *padata)
670 + {
671 + struct pcrypt_request *preq = pcrypt_padata_request(padata);
672 + struct aead_request *req = pcrypt_request_ctx(preq);
673 ++ int ret;
674 +
675 +- padata->info = crypto_aead_encrypt(req);
676 ++ ret = crypto_aead_encrypt(req);
677 +
678 +- if (padata->info == -EINPROGRESS)
679 ++ if (ret == -EINPROGRESS)
680 + return;
681 +
682 ++ padata->info = ret;
683 + padata_do_serial(padata);
684 + }
685 +
686 +@@ -180,12 +182,14 @@ static void pcrypt_aead_dec(struct padata_priv *padata)
687 + {
688 + struct pcrypt_request *preq = pcrypt_padata_request(padata);
689 + struct aead_request *req = pcrypt_request_ctx(preq);
690 ++ int ret;
691 +
692 +- padata->info = crypto_aead_decrypt(req);
693 ++ ret = crypto_aead_decrypt(req);
694 +
695 +- if (padata->info == -EINPROGRESS)
696 ++ if (ret == -EINPROGRESS)
697 + return;
698 +
699 ++ padata->info = ret;
700 + padata_do_serial(padata);
701 + }
702 +
703 +diff --git a/drivers/acpi/acpica/acglobal.h b/drivers/acpi/acpica/acglobal.h
704 +index faa97604d878e..f178d11597c09 100644
705 +--- a/drivers/acpi/acpica/acglobal.h
706 ++++ b/drivers/acpi/acpica/acglobal.h
707 +@@ -256,6 +256,8 @@ extern struct acpi_bit_register_info
708 +
709 + ACPI_GLOBAL(u8, acpi_gbl_sleep_type_a);
710 + ACPI_GLOBAL(u8, acpi_gbl_sleep_type_b);
711 ++ACPI_GLOBAL(u8, acpi_gbl_sleep_type_a_s0);
712 ++ACPI_GLOBAL(u8, acpi_gbl_sleep_type_b_s0);
713 +
714 + /*****************************************************************************
715 + *
716 +diff --git a/drivers/acpi/acpica/hwesleep.c b/drivers/acpi/acpica/hwesleep.c
717 +index e5599f6108083..e4998cc0ce283 100644
718 +--- a/drivers/acpi/acpica/hwesleep.c
719 ++++ b/drivers/acpi/acpica/hwesleep.c
720 +@@ -184,17 +184,13 @@ acpi_status acpi_hw_extended_sleep(u8 sleep_state)
721 +
722 + acpi_status acpi_hw_extended_wake_prep(u8 sleep_state)
723 + {
724 +- acpi_status status;
725 + u8 sleep_type_value;
726 +
727 + ACPI_FUNCTION_TRACE(hw_extended_wake_prep);
728 +
729 +- status = acpi_get_sleep_type_data(ACPI_STATE_S0,
730 +- &acpi_gbl_sleep_type_a,
731 +- &acpi_gbl_sleep_type_b);
732 +- if (ACPI_SUCCESS(status)) {
733 ++ if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
734 + sleep_type_value =
735 +- ((acpi_gbl_sleep_type_a << ACPI_X_SLEEP_TYPE_POSITION) &
736 ++ ((acpi_gbl_sleep_type_a_s0 << ACPI_X_SLEEP_TYPE_POSITION) &
737 + ACPI_X_SLEEP_TYPE_MASK);
738 +
739 + (void)acpi_write((u64)(sleep_type_value | ACPI_X_SLEEP_ENABLE),
740 +diff --git a/drivers/acpi/acpica/hwsleep.c b/drivers/acpi/acpica/hwsleep.c
741 +index 7d21cae6d6028..7e44ba8c6a1ab 100644
742 +--- a/drivers/acpi/acpica/hwsleep.c
743 ++++ b/drivers/acpi/acpica/hwsleep.c
744 +@@ -217,7 +217,7 @@ acpi_status acpi_hw_legacy_sleep(u8 sleep_state)
745 +
746 + acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
747 + {
748 +- acpi_status status;
749 ++ acpi_status status = AE_OK;
750 + struct acpi_bit_register_info *sleep_type_reg_info;
751 + struct acpi_bit_register_info *sleep_enable_reg_info;
752 + u32 pm1a_control;
753 +@@ -230,10 +230,7 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
754 + * This is unclear from the ACPI Spec, but it is required
755 + * by some machines.
756 + */
757 +- status = acpi_get_sleep_type_data(ACPI_STATE_S0,
758 +- &acpi_gbl_sleep_type_a,
759 +- &acpi_gbl_sleep_type_b);
760 +- if (ACPI_SUCCESS(status)) {
761 ++ if (acpi_gbl_sleep_type_a_s0 != ACPI_SLEEP_TYPE_INVALID) {
762 + sleep_type_reg_info =
763 + acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
764 + sleep_enable_reg_info =
765 +@@ -254,9 +251,9 @@ acpi_status acpi_hw_legacy_wake_prep(u8 sleep_state)
766 +
767 + /* Insert the SLP_TYP bits */
768 +
769 +- pm1a_control |= (acpi_gbl_sleep_type_a <<
770 ++ pm1a_control |= (acpi_gbl_sleep_type_a_s0 <<
771 + sleep_type_reg_info->bit_position);
772 +- pm1b_control |= (acpi_gbl_sleep_type_b <<
773 ++ pm1b_control |= (acpi_gbl_sleep_type_b_s0 <<
774 + sleep_type_reg_info->bit_position);
775 +
776 + /* Write the control registers and ignore any errors */
777 +diff --git a/drivers/acpi/acpica/hwxfsleep.c b/drivers/acpi/acpica/hwxfsleep.c
778 +index d62a61612b3f1..b04e2b0f62246 100644
779 +--- a/drivers/acpi/acpica/hwxfsleep.c
780 ++++ b/drivers/acpi/acpica/hwxfsleep.c
781 +@@ -372,6 +372,13 @@ acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
782 + return_ACPI_STATUS(status);
783 + }
784 +
785 ++ status = acpi_get_sleep_type_data(ACPI_STATE_S0,
786 ++ &acpi_gbl_sleep_type_a_s0,
787 ++ &acpi_gbl_sleep_type_b_s0);
788 ++ if (ACPI_FAILURE(status)) {
789 ++ acpi_gbl_sleep_type_a_s0 = ACPI_SLEEP_TYPE_INVALID;
790 ++ }
791 ++
792 + /* Execute the _PTS method (Prepare To Sleep) */
793 +
794 + arg_list.count = 1;
795 +diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
796 +index b719ab3090bb2..e4f1cb67ba127 100644
797 +--- a/drivers/acpi/battery.c
798 ++++ b/drivers/acpi/battery.c
799 +@@ -187,7 +187,7 @@ static int acpi_battery_is_charged(struct acpi_battery *battery)
800 + return 1;
801 +
802 + /* fallback to using design values for broken batteries */
803 +- if (battery->design_capacity == battery->capacity_now)
804 ++ if (battery->design_capacity <= battery->capacity_now)
805 + return 1;
806 +
807 + /* we don't do any sort of metric based on percentages */
808 +diff --git a/drivers/android/binder.c b/drivers/android/binder.c
809 +index 3bc5a7caccbf1..f4454292f228e 100644
810 +--- a/drivers/android/binder.c
811 ++++ b/drivers/android/binder.c
812 +@@ -303,6 +303,7 @@ struct binder_proc {
813 + struct mm_struct *vma_vm_mm;
814 + struct task_struct *tsk;
815 + struct files_struct *files;
816 ++ const struct cred *cred;
817 + struct hlist_node deferred_work_node;
818 + int deferred_work;
819 + void *buffer;
820 +@@ -1419,8 +1420,8 @@ static void binder_transaction(struct binder_proc *proc,
821 + return_error = BR_FAILED_REPLY;
822 + goto err_invalid_target_handle;
823 + }
824 +- if (security_binder_transaction(proc->tsk,
825 +- target_proc->tsk) < 0) {
826 ++ if (security_binder_transaction(proc->cred,
827 ++ target_proc->cred) < 0) {
828 + return_error = BR_FAILED_REPLY;
829 + goto err_invalid_target_handle;
830 + }
831 +@@ -1493,7 +1494,7 @@ static void binder_transaction(struct binder_proc *proc,
832 + t->from = thread;
833 + else
834 + t->from = NULL;
835 +- t->sender_euid = task_euid(proc->tsk);
836 ++ t->sender_euid = proc->cred->euid;
837 + t->to_proc = target_proc;
838 + t->to_thread = target_thread;
839 + t->code = tr->code;
840 +@@ -1575,8 +1576,8 @@ static void binder_transaction(struct binder_proc *proc,
841 + return_error = BR_FAILED_REPLY;
842 + goto err_binder_get_ref_for_node_failed;
843 + }
844 +- if (security_binder_transfer_binder(proc->tsk,
845 +- target_proc->tsk)) {
846 ++ if (security_binder_transfer_binder(proc->cred,
847 ++ target_proc->cred)) {
848 + return_error = BR_FAILED_REPLY;
849 + goto err_binder_get_ref_for_node_failed;
850 + }
851 +@@ -1615,8 +1616,8 @@ static void binder_transaction(struct binder_proc *proc,
852 + return_error = BR_FAILED_REPLY;
853 + goto err_binder_get_ref_failed;
854 + }
855 +- if (security_binder_transfer_binder(proc->tsk,
856 +- target_proc->tsk)) {
857 ++ if (security_binder_transfer_binder(proc->cred,
858 ++ target_proc->cred)) {
859 + return_error = BR_FAILED_REPLY;
860 + goto err_binder_get_ref_failed;
861 + }
862 +@@ -1679,8 +1680,8 @@ static void binder_transaction(struct binder_proc *proc,
863 + return_error = BR_FAILED_REPLY;
864 + goto err_fget_failed;
865 + }
866 +- if (security_binder_transfer_file(proc->tsk,
867 +- target_proc->tsk,
868 ++ if (security_binder_transfer_file(proc->cred,
869 ++ target_proc->cred,
870 + file) < 0) {
871 + fput(file);
872 + return_error = BR_FAILED_REPLY;
873 +@@ -2762,7 +2763,7 @@ static int binder_ioctl_set_ctx_mgr(struct file *filp)
874 + ret = -EBUSY;
875 + goto out;
876 + }
877 +- ret = security_binder_set_context_mgr(proc->tsk);
878 ++ ret = security_binder_set_context_mgr(proc->cred);
879 + if (ret < 0)
880 + goto out;
881 + if (uid_valid(binder_context_mgr_uid)) {
882 +@@ -3015,6 +3016,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
883 + return -ENOMEM;
884 + get_task_struct(current->group_leader);
885 + proc->tsk = current->group_leader;
886 ++ proc->cred = get_cred(filp->f_cred);
887 + INIT_LIST_HEAD(&proc->todo);
888 + init_waitqueue_head(&proc->wait);
889 + proc->default_priority = task_nice(current);
890 +@@ -3220,6 +3222,7 @@ static void binder_deferred_release(struct binder_proc *proc)
891 + }
892 +
893 + put_task_struct(proc->tsk);
894 ++ put_cred(proc->cred);
895 +
896 + binder_debug(BINDER_DEBUG_OPEN_CLOSE,
897 + "%s: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n",
898 +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
899 +index 7db76b5c7ada3..23c8dd7dc9777 100644
900 +--- a/drivers/ata/libata-eh.c
901 ++++ b/drivers/ata/libata-eh.c
902 +@@ -114,6 +114,12 @@ static const unsigned long ata_eh_identify_timeouts[] = {
903 + ULONG_MAX,
904 + };
905 +
906 ++static const unsigned long ata_eh_revalidate_timeouts[] = {
907 ++ 15000, /* Some drives are slow to read log pages when waking-up */
908 ++ 15000, /* combined time till here is enough even for media access */
909 ++ ULONG_MAX,
910 ++};
911 ++
912 + static const unsigned long ata_eh_flush_timeouts[] = {
913 + 15000, /* be generous with flush */
914 + 15000, /* ditto */
915 +@@ -150,6 +156,8 @@ static const struct ata_eh_cmd_timeout_ent
916 + ata_eh_cmd_timeout_table[ATA_EH_CMD_TIMEOUT_TABLE_SIZE] = {
917 + { .commands = CMDS(ATA_CMD_ID_ATA, ATA_CMD_ID_ATAPI),
918 + .timeouts = ata_eh_identify_timeouts, },
919 ++ { .commands = CMDS(ATA_CMD_READ_LOG_EXT, ATA_CMD_READ_LOG_DMA_EXT),
920 ++ .timeouts = ata_eh_revalidate_timeouts, },
921 + { .commands = CMDS(ATA_CMD_READ_NATIVE_MAX, ATA_CMD_READ_NATIVE_MAX_EXT),
922 + .timeouts = ata_eh_other_timeouts, },
923 + { .commands = CMDS(ATA_CMD_SET_MAX, ATA_CMD_SET_MAX_EXT),
924 +diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
925 +index e7e92ed34f0c6..34c4a61a954fc 100644
926 +--- a/drivers/cpuidle/sysfs.c
927 ++++ b/drivers/cpuidle/sysfs.c
928 +@@ -413,6 +413,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device)
929 + &kdev->kobj, "state%d", i);
930 + if (ret) {
931 + kobject_put(&kobj->kobj);
932 ++ kfree(kobj);
933 + goto error_state;
934 + }
935 + kobject_uevent(&kobj->kobj, KOBJ_ADD);
936 +@@ -543,6 +544,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev)
937 + &kdev->kobj, "driver");
938 + if (ret) {
939 + kobject_put(&kdrv->kobj);
940 ++ kfree(kdrv);
941 + return ret;
942 + }
943 +
944 +@@ -629,7 +631,6 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
945 + if (!kdev)
946 + return -ENOMEM;
947 + kdev->dev = dev;
948 +- dev->kobj_dev = kdev;
949 +
950 + init_completion(&kdev->kobj_unregister);
951 +
952 +@@ -637,9 +638,11 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
953 + "cpuidle");
954 + if (error) {
955 + kobject_put(&kdev->kobj);
956 ++ kfree(kdev);
957 + return error;
958 + }
959 +
960 ++ dev->kobj_dev = kdev;
961 + kobject_uevent(&kdev->kobj, KOBJ_ADD);
962 +
963 + return 0;
964 +diff --git a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
965 +index 711706819b05d..7e45c21a61657 100644
966 +--- a/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
967 ++++ b/drivers/crypto/qat/qat_common/adf_pf2vf_msg.c
968 +@@ -218,6 +218,13 @@ static int __adf_iov_putmsg(struct adf_accel_dev *accel_dev, u32 msg, u8 vf_nr)
969 + val = ADF_CSR_RD(pmisc_bar_addr, pf2vf_offset);
970 + } while ((val & int_bit) && (count++ < ADF_IOV_MSG_ACK_MAX_RETRY));
971 +
972 ++ if (val != msg) {
973 ++ dev_dbg(&GET_DEV(accel_dev),
974 ++ "Collision - PFVF CSR overwritten by remote function\n");
975 ++ ret = -EIO;
976 ++ goto out;
977 ++ }
978 ++
979 + if (val & int_bit) {
980 + dev_dbg(&GET_DEV(accel_dev), "ACK not received from remote\n");
981 + val &= ~int_bit;
982 +diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
983 +index 8aa3ccf42e55a..2d87018069ca0 100644
984 +--- a/drivers/dma/at_xdmac.c
985 ++++ b/drivers/dma/at_xdmac.c
986 +@@ -156,7 +156,7 @@
987 + #define AT_XDMAC_CC_WRIP (0x1 << 23) /* Write in Progress (read only) */
988 + #define AT_XDMAC_CC_WRIP_DONE (0x0 << 23)
989 + #define AT_XDMAC_CC_WRIP_IN_PROGRESS (0x1 << 23)
990 +-#define AT_XDMAC_CC_PERID(i) (0x7f & (i) << 24) /* Channel Peripheral Identifier */
991 ++#define AT_XDMAC_CC_PERID(i) ((0x7f & (i)) << 24) /* Channel Peripheral Identifier */
992 + #define AT_XDMAC_CDS_MSP 0x2C /* Channel Data Stride Memory Set Pattern */
993 + #define AT_XDMAC_CSUS 0x30 /* Channel Source Microblock Stride */
994 + #define AT_XDMAC_CDUS 0x34 /* Channel Destination Microblock Stride */
995 +diff --git a/drivers/edac/sb_edac.c b/drivers/edac/sb_edac.c
996 +index a4e1f6939c395..a2ad988c9bdc6 100644
997 +--- a/drivers/edac/sb_edac.c
998 ++++ b/drivers/edac/sb_edac.c
999 +@@ -848,7 +848,7 @@ static u64 haswell_get_tohm(struct sbridge_pvt *pvt)
1000 + pci_read_config_dword(pvt->info.pci_vtd, HASWELL_TOHM_1, &reg);
1001 + rc = ((reg << 6) | rc) << 26;
1002 +
1003 +- return rc | 0x1ffffff;
1004 ++ return rc | 0x3ffffff;
1005 + }
1006 +
1007 + static u64 haswell_rir_limit(u32 reg)
1008 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1009 +index 1b3fda2331bee..e1d4115bd6732 100644
1010 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1011 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
1012 +@@ -835,6 +835,7 @@ static int amdgpu_connector_vga_get_modes(struct drm_connector *connector)
1013 +
1014 + amdgpu_connector_get_edid(connector);
1015 + ret = amdgpu_connector_ddc_get_modes(connector);
1016 ++ amdgpu_get_native_mode(connector);
1017 +
1018 + return ret;
1019 + }
1020 +diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
1021 +index 245070950e875..3fe5a49a9feeb 100644
1022 +--- a/drivers/gpu/drm/msm/msm_gem.c
1023 ++++ b/drivers/gpu/drm/msm/msm_gem.c
1024 +@@ -651,7 +651,7 @@ struct drm_gem_object *msm_gem_new(struct drm_device *dev,
1025 +
1026 + ret = msm_gem_new_impl(dev, size, flags, &obj);
1027 + if (ret)
1028 +- goto fail;
1029 ++ return ERR_PTR(ret);
1030 +
1031 + if (use_pages(obj)) {
1032 + ret = drm_gem_object_init(dev, obj, size);
1033 +@@ -687,7 +687,7 @@ struct drm_gem_object *msm_gem_import(struct drm_device *dev,
1034 +
1035 + ret = msm_gem_new_impl(dev, size, MSM_BO_WC, &obj);
1036 + if (ret)
1037 +- goto fail;
1038 ++ return ERR_PTR(ret);
1039 +
1040 + drm_gem_private_object_init(dev, obj, size);
1041 +
1042 +diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
1043 +index 0110d95522f32..cc811de31afa0 100644
1044 +--- a/drivers/gpu/drm/udl/udl_connector.c
1045 ++++ b/drivers/gpu/drm/udl/udl_connector.c
1046 +@@ -37,7 +37,7 @@ static u8 *udl_get_edid(struct udl_device *udl)
1047 + ret = usb_control_msg(udl->udev,
1048 + usb_rcvctrlpipe(udl->udev, 0), (0x02),
1049 + (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
1050 +- HZ);
1051 ++ 1000);
1052 + if (ret < 1) {
1053 + DRM_ERROR("Read EDID byte %d failed err %x\n", i, ret);
1054 + goto error;
1055 +diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
1056 +index 15e06493c53aa..4e7592addfe2b 100644
1057 +--- a/drivers/hv/hyperv_vmbus.h
1058 ++++ b/drivers/hv/hyperv_vmbus.h
1059 +@@ -26,6 +26,7 @@
1060 + #define _HYPERV_VMBUS_H
1061 +
1062 + #include <linux/list.h>
1063 ++#include <linux/bitops.h>
1064 + #include <asm/sync_bitops.h>
1065 + #include <linux/atomic.h>
1066 + #include <linux/hyperv.h>
1067 +diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c
1068 +index a3d912cd3b8d7..5081fd7e8fddc 100644
1069 +--- a/drivers/hwmon/pmbus/lm25066.c
1070 ++++ b/drivers/hwmon/pmbus/lm25066.c
1071 +@@ -69,22 +69,27 @@ static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = {
1072 + [lm25056] = {
1073 + [PSC_VOLTAGE_IN] = {
1074 + .m = 16296,
1075 ++ .b = 1343,
1076 + .R = -2,
1077 + },
1078 + [PSC_CURRENT_IN] = {
1079 + .m = 13797,
1080 ++ .b = -1833,
1081 + .R = -2,
1082 + },
1083 + [PSC_CURRENT_IN_L] = {
1084 + .m = 6726,
1085 ++ .b = -537,
1086 + .R = -2,
1087 + },
1088 + [PSC_POWER] = {
1089 + .m = 5501,
1090 ++ .b = -2908,
1091 + .R = -3,
1092 + },
1093 + [PSC_POWER_L] = {
1094 + .m = 26882,
1095 ++ .b = -5646,
1096 + .R = -4,
1097 + },
1098 + [PSC_TEMPERATURE] = {
1099 +@@ -96,26 +101,32 @@ static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = {
1100 + [lm25066] = {
1101 + [PSC_VOLTAGE_IN] = {
1102 + .m = 22070,
1103 ++ .b = -1800,
1104 + .R = -2,
1105 + },
1106 + [PSC_VOLTAGE_OUT] = {
1107 + .m = 22070,
1108 ++ .b = -1800,
1109 + .R = -2,
1110 + },
1111 + [PSC_CURRENT_IN] = {
1112 + .m = 13661,
1113 ++ .b = -5200,
1114 + .R = -2,
1115 + },
1116 + [PSC_CURRENT_IN_L] = {
1117 + .m = 6852,
1118 ++ .b = -3100,
1119 + .R = -2,
1120 + },
1121 + [PSC_POWER] = {
1122 + .m = 736,
1123 ++ .b = -3300,
1124 + .R = -2,
1125 + },
1126 + [PSC_POWER_L] = {
1127 + .m = 369,
1128 ++ .b = -1900,
1129 + .R = -2,
1130 + },
1131 + [PSC_TEMPERATURE] = {
1132 +@@ -155,26 +166,32 @@ static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = {
1133 + [lm5064] = {
1134 + [PSC_VOLTAGE_IN] = {
1135 + .m = 4611,
1136 ++ .b = -642,
1137 + .R = -2,
1138 + },
1139 + [PSC_VOLTAGE_OUT] = {
1140 + .m = 4621,
1141 ++ .b = 423,
1142 + .R = -2,
1143 + },
1144 + [PSC_CURRENT_IN] = {
1145 + .m = 10742,
1146 ++ .b = 1552,
1147 + .R = -2,
1148 + },
1149 + [PSC_CURRENT_IN_L] = {
1150 + .m = 5456,
1151 ++ .b = 2118,
1152 + .R = -2,
1153 + },
1154 + [PSC_POWER] = {
1155 + .m = 1204,
1156 ++ .b = 8524,
1157 + .R = -3,
1158 + },
1159 + [PSC_POWER_L] = {
1160 + .m = 612,
1161 ++ .b = 11202,
1162 + .R = -3,
1163 + },
1164 + [PSC_TEMPERATURE] = {
1165 +@@ -184,26 +201,32 @@ static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = {
1166 + [lm5066] = {
1167 + [PSC_VOLTAGE_IN] = {
1168 + .m = 4587,
1169 ++ .b = -1200,
1170 + .R = -2,
1171 + },
1172 + [PSC_VOLTAGE_OUT] = {
1173 + .m = 4587,
1174 ++ .b = -2400,
1175 + .R = -2,
1176 + },
1177 + [PSC_CURRENT_IN] = {
1178 + .m = 10753,
1179 ++ .b = -1200,
1180 + .R = -2,
1181 + },
1182 + [PSC_CURRENT_IN_L] = {
1183 + .m = 5405,
1184 ++ .b = -600,
1185 + .R = -2,
1186 + },
1187 + [PSC_POWER] = {
1188 + .m = 1204,
1189 ++ .b = -6000,
1190 + .R = -3,
1191 + },
1192 + [PSC_POWER_L] = {
1193 + .m = 605,
1194 ++ .b = -8000,
1195 + .R = -3,
1196 + },
1197 + [PSC_TEMPERATURE] = {
1198 +diff --git a/drivers/iio/dac/ad5446.c b/drivers/iio/dac/ad5446.c
1199 +index b555552a0d803..d3a3d62869d83 100644
1200 +--- a/drivers/iio/dac/ad5446.c
1201 ++++ b/drivers/iio/dac/ad5446.c
1202 +@@ -510,8 +510,15 @@ static int ad5622_write(struct ad5446_state *st, unsigned val)
1203 + {
1204 + struct i2c_client *client = to_i2c_client(st->dev);
1205 + __be16 data = cpu_to_be16(val);
1206 ++ int ret;
1207 ++
1208 ++ ret = i2c_master_send(client, (char *)&data, sizeof(data));
1209 ++ if (ret < 0)
1210 ++ return ret;
1211 ++ if (ret != sizeof(data))
1212 ++ return -EIO;
1213 +
1214 +- return i2c_master_send(client, (char *)&data, sizeof(data));
1215 ++ return 0;
1216 + }
1217 +
1218 + /**
1219 +diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
1220 +index ecd461ee6dbe2..a15beb161b64c 100644
1221 +--- a/drivers/infiniband/hw/mlx4/qp.c
1222 ++++ b/drivers/infiniband/hw/mlx4/qp.c
1223 +@@ -766,8 +766,10 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
1224 + if (dev->steering_support ==
1225 + MLX4_STEERING_MODE_DEVICE_MANAGED)
1226 + qp->flags |= MLX4_IB_QP_NETIF;
1227 +- else
1228 ++ else {
1229 ++ err = -EINVAL;
1230 + goto err;
1231 ++ }
1232 + }
1233 +
1234 + err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, qp);
1235 +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
1236 +index 7b942ee364b65..d5307b9273787 100644
1237 +--- a/drivers/input/mouse/elantech.c
1238 ++++ b/drivers/input/mouse/elantech.c
1239 +@@ -435,6 +435,19 @@ static void elantech_report_trackpoint(struct psmouse *psmouse,
1240 + case 0x16008020U:
1241 + case 0x26800010U:
1242 + case 0x36808000U:
1243 ++
1244 ++ /*
1245 ++ * This firmware misreport coordinates for trackpoint
1246 ++ * occasionally. Discard packets outside of [-127, 127] range
1247 ++ * to prevent cursor jumps.
1248 ++ */
1249 ++ if (packet[4] == 0x80 || packet[5] == 0x80 ||
1250 ++ packet[1] >> 7 == packet[4] >> 7 ||
1251 ++ packet[2] >> 7 == packet[5] >> 7) {
1252 ++ elantech_debug("discarding packet [%6ph]\n", packet);
1253 ++ break;
1254 ++
1255 ++ }
1256 + x = packet[4] - (int)((packet[1]^0x80) << 1);
1257 + y = (int)((packet[2]^0x80) << 1) - packet[5];
1258 +
1259 +diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
1260 +index 3049bccf24227..323b86b38b3a3 100644
1261 +--- a/drivers/input/serio/i8042-x86ia64io.h
1262 ++++ b/drivers/input/serio/i8042-x86ia64io.h
1263 +@@ -276,6 +276,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = {
1264 + DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
1265 + },
1266 + },
1267 ++ {
1268 ++ /* Fujitsu Lifebook T725 laptop */
1269 ++ .matches = {
1270 ++ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
1271 ++ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T725"),
1272 ++ },
1273 ++ },
1274 + {
1275 + /* Fujitsu Lifebook U745 */
1276 + .matches = {
1277 +@@ -916,6 +923,13 @@ static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
1278 + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
1279 + },
1280 + },
1281 ++ {
1282 ++ /* Fujitsu Lifebook T725 laptop */
1283 ++ .matches = {
1284 ++ DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
1285 ++ DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T725"),
1286 ++ },
1287 ++ },
1288 + {
1289 + /* Fujitsu U574 laptop */
1290 + /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
1291 +diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
1292 +index c71914e8f596c..cd7fdce98359f 100644
1293 +--- a/drivers/irqchip/irq-s3c24xx.c
1294 ++++ b/drivers/irqchip/irq-s3c24xx.c
1295 +@@ -368,11 +368,25 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
1296 + asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
1297 + {
1298 + do {
1299 +- if (likely(s3c_intc[0]))
1300 +- if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
1301 +- continue;
1302 ++ /*
1303 ++ * For platform based machines, neither ERR nor NULL can happen here.
1304 ++ * The s3c24xx_handle_irq() will be set as IRQ handler iff this succeeds:
1305 ++ *
1306 ++ * s3c_intc[0] = s3c24xx_init_intc()
1307 ++ *
1308 ++ * If this fails, the next calls to s3c24xx_init_intc() won't be executed.
1309 ++ *
1310 ++ * For DT machine, s3c_init_intc_of() could set the IRQ handler without
1311 ++ * setting s3c_intc[0] only if it was called with num_ctrl=0. There is no
1312 ++ * such code path, so again the s3c_intc[0] will have a valid pointer if
1313 ++ * set_handle_irq() is called.
1314 ++ *
1315 ++ * Therefore in s3c24xx_handle_irq(), the s3c_intc[0] is always something.
1316 ++ */
1317 ++ if (s3c24xx_handle_intc(s3c_intc[0], regs, 0))
1318 ++ continue;
1319 +
1320 +- if (s3c_intc[2])
1321 ++ if (!IS_ERR_OR_NULL(s3c_intc[2]))
1322 + if (s3c24xx_handle_intc(s3c_intc[2], regs, 64))
1323 + continue;
1324 +
1325 +diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
1326 +index 0db15f528ac1c..fb60c9f42cb60 100644
1327 +--- a/drivers/media/i2c/mt9p031.c
1328 ++++ b/drivers/media/i2c/mt9p031.c
1329 +@@ -81,7 +81,9 @@
1330 + #define MT9P031_PIXEL_CLOCK_INVERT (1 << 15)
1331 + #define MT9P031_PIXEL_CLOCK_SHIFT(n) ((n) << 8)
1332 + #define MT9P031_PIXEL_CLOCK_DIVIDE(n) ((n) << 0)
1333 +-#define MT9P031_FRAME_RESTART 0x0b
1334 ++#define MT9P031_RESTART 0x0b
1335 ++#define MT9P031_FRAME_PAUSE_RESTART (1 << 1)
1336 ++#define MT9P031_FRAME_RESTART (1 << 0)
1337 + #define MT9P031_SHUTTER_DELAY 0x0c
1338 + #define MT9P031_RST 0x0d
1339 + #define MT9P031_RST_ENABLE 1
1340 +@@ -448,9 +450,23 @@ static int mt9p031_set_params(struct mt9p031 *mt9p031)
1341 + static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
1342 + {
1343 + struct mt9p031 *mt9p031 = to_mt9p031(subdev);
1344 ++ struct i2c_client *client = v4l2_get_subdevdata(subdev);
1345 ++ int val;
1346 + int ret;
1347 +
1348 + if (!enable) {
1349 ++ /* enable pause restart */
1350 ++ val = MT9P031_FRAME_PAUSE_RESTART;
1351 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
1352 ++ if (ret < 0)
1353 ++ return ret;
1354 ++
1355 ++ /* enable restart + keep pause restart set */
1356 ++ val |= MT9P031_FRAME_RESTART;
1357 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
1358 ++ if (ret < 0)
1359 ++ return ret;
1360 ++
1361 + /* Stop sensor readout */
1362 + ret = mt9p031_set_output_control(mt9p031,
1363 + MT9P031_OUTPUT_CONTROL_CEN, 0);
1364 +@@ -470,6 +486,16 @@ static int mt9p031_s_stream(struct v4l2_subdev *subdev, int enable)
1365 + if (ret < 0)
1366 + return ret;
1367 +
1368 ++ /*
1369 ++ * - clear pause restart
1370 ++ * - don't clear restart as clearing restart manually can cause
1371 ++ * undefined behavior
1372 ++ */
1373 ++ val = MT9P031_FRAME_RESTART;
1374 ++ ret = mt9p031_write(client, MT9P031_RESTART, val);
1375 ++ if (ret < 0)
1376 ++ return ret;
1377 ++
1378 + return mt9p031_pll_enable(mt9p031);
1379 + }
1380 +
1381 +diff --git a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
1382 +index 3fdbd81b55806..a83ba068b8376 100644
1383 +--- a/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
1384 ++++ b/drivers/media/pci/netup_unidvb/netup_unidvb_core.c
1385 +@@ -253,19 +253,24 @@ static irqreturn_t netup_unidvb_isr(int irq, void *dev_id)
1386 + if ((reg40 & AVL_IRQ_ASSERTED) != 0) {
1387 + /* IRQ is being signaled */
1388 + reg_isr = readw(ndev->bmmio0 + REG_ISR);
1389 +- if (reg_isr & NETUP_UNIDVB_IRQ_I2C0) {
1390 +- iret = netup_i2c_interrupt(&ndev->i2c[0]);
1391 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_I2C1) {
1392 +- iret = netup_i2c_interrupt(&ndev->i2c[1]);
1393 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_SPI) {
1394 ++ if (reg_isr & NETUP_UNIDVB_IRQ_SPI)
1395 + iret = netup_spi_interrupt(ndev->spi);
1396 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA1) {
1397 +- iret = netup_dma_interrupt(&ndev->dma[0]);
1398 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA2) {
1399 +- iret = netup_dma_interrupt(&ndev->dma[1]);
1400 +- } else if (reg_isr & NETUP_UNIDVB_IRQ_CI) {
1401 +- iret = netup_ci_interrupt(ndev);
1402 ++ else if (!ndev->old_fw) {
1403 ++ if (reg_isr & NETUP_UNIDVB_IRQ_I2C0) {
1404 ++ iret = netup_i2c_interrupt(&ndev->i2c[0]);
1405 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_I2C1) {
1406 ++ iret = netup_i2c_interrupt(&ndev->i2c[1]);
1407 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA1) {
1408 ++ iret = netup_dma_interrupt(&ndev->dma[0]);
1409 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_DMA2) {
1410 ++ iret = netup_dma_interrupt(&ndev->dma[1]);
1411 ++ } else if (reg_isr & NETUP_UNIDVB_IRQ_CI) {
1412 ++ iret = netup_ci_interrupt(ndev);
1413 ++ } else {
1414 ++ goto err;
1415 ++ }
1416 + } else {
1417 ++err:
1418 + dev_err(&pci_dev->dev,
1419 + "%s(): unknown interrupt 0x%x\n",
1420 + __func__, reg_isr);
1421 +diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c
1422 +index 7727789dbda14..daa5b4dea092c 100644
1423 +--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
1424 ++++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
1425 +@@ -1102,7 +1102,7 @@ static int s5p_mfc_probe(struct platform_device *pdev)
1426 + spin_lock_init(&dev->condlock);
1427 + dev->plat_dev = pdev;
1428 + if (!dev->plat_dev) {
1429 +- dev_err(&pdev->dev, "No platform data specified\n");
1430 ++ mfc_err("No platform data specified\n");
1431 + return -ENODEV;
1432 + }
1433 +
1434 +diff --git a/drivers/media/radio/si470x/radio-si470x-i2c.c b/drivers/media/radio/si470x/radio-si470x-i2c.c
1435 +index 0836fa442d224..24804ce70f523 100644
1436 +--- a/drivers/media/radio/si470x/radio-si470x-i2c.c
1437 ++++ b/drivers/media/radio/si470x/radio-si470x-i2c.c
1438 +@@ -24,7 +24,7 @@
1439 +
1440 + /* driver definitions */
1441 + #define DRIVER_AUTHOR "Joonyoung Shim <jy0922.shim@×××××××.com>";
1442 +-#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
1443 ++#define DRIVER_CARD "Silicon Labs Si470x FM Radio"
1444 + #define DRIVER_DESC "I2C radio driver for Si470x FM Radio Receivers"
1445 + #define DRIVER_VERSION "1.0.2"
1446 +
1447 +diff --git a/drivers/media/radio/si470x/radio-si470x-usb.c b/drivers/media/radio/si470x/radio-si470x-usb.c
1448 +index c9347d5aac04f..6fd1e4f26f5f4 100644
1449 +--- a/drivers/media/radio/si470x/radio-si470x-usb.c
1450 ++++ b/drivers/media/radio/si470x/radio-si470x-usb.c
1451 +@@ -29,7 +29,7 @@
1452 +
1453 + /* driver definitions */
1454 + #define DRIVER_AUTHOR "Tobias Lorenz <tobias.lorenz@×××.net>"
1455 +-#define DRIVER_CARD "Silicon Labs Si470x FM Radio Receiver"
1456 ++#define DRIVER_CARD "Silicon Labs Si470x FM Radio"
1457 + #define DRIVER_DESC "USB radio driver for Si470x FM Radio Receivers"
1458 + #define DRIVER_VERSION "1.0.10"
1459 +
1460 +diff --git a/drivers/media/rc/ite-cir.c b/drivers/media/rc/ite-cir.c
1461 +index 7d3e50d94d86a..e8bc02ce9b2ff 100644
1462 +--- a/drivers/media/rc/ite-cir.c
1463 ++++ b/drivers/media/rc/ite-cir.c
1464 +@@ -299,7 +299,7 @@ static irqreturn_t ite_cir_isr(int irq, void *data)
1465 + }
1466 +
1467 + /* check for the receive interrupt */
1468 +- if (iflags & ITE_IRQ_RX_FIFO) {
1469 ++ if (iflags & (ITE_IRQ_RX_FIFO | ITE_IRQ_RX_FIFO_OVERRUN)) {
1470 + /* read the FIFO bytes */
1471 + rx_bytes =
1472 + dev->params.get_rx_bytes(dev, rx_buf,
1473 +diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c
1474 +index 0fba4a2c16028..7b9800d3446cf 100644
1475 +--- a/drivers/media/rc/mceusb.c
1476 ++++ b/drivers/media/rc/mceusb.c
1477 +@@ -1079,6 +1079,7 @@ static void mceusb_dev_recv(struct urb *urb)
1478 + case -ECONNRESET:
1479 + case -ENOENT:
1480 + case -EILSEQ:
1481 ++ case -EPROTO:
1482 + case -ESHUTDOWN:
1483 + usb_unlink_urb(urb);
1484 + return;
1485 +diff --git a/drivers/media/usb/dvb-usb/az6027.c b/drivers/media/usb/dvb-usb/az6027.c
1486 +index 92e47d6c3ee3e..c58fb74c3cd73 100644
1487 +--- a/drivers/media/usb/dvb-usb/az6027.c
1488 ++++ b/drivers/media/usb/dvb-usb/az6027.c
1489 +@@ -394,6 +394,7 @@ static struct rc_map_table rc_map_az6027_table[] = {
1490 + /* remote control stuff (does not work with my box) */
1491 + static int az6027_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
1492 + {
1493 ++ *state = REMOTE_NO_KEY_PRESSED;
1494 + return 0;
1495 + }
1496 +
1497 +diff --git a/drivers/media/usb/dvb-usb/dibusb-common.c b/drivers/media/usb/dvb-usb/dibusb-common.c
1498 +index 7b15aea2723d6..5a1dc0d465d26 100644
1499 +--- a/drivers/media/usb/dvb-usb/dibusb-common.c
1500 ++++ b/drivers/media/usb/dvb-usb/dibusb-common.c
1501 +@@ -182,7 +182,7 @@ int dibusb_read_eeprom_byte(struct dvb_usb_device *d, u8 offs, u8 *val)
1502 + u8 *buf;
1503 + int rc;
1504 +
1505 +- buf = kmalloc(2, GFP_KERNEL);
1506 ++ buf = kzalloc(2, GFP_KERNEL);
1507 + if (!buf)
1508 + return -ENOMEM;
1509 +
1510 +diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
1511 +index 049d664e94f07..8ac231f6b2d16 100644
1512 +--- a/drivers/media/usb/uvc/uvc_v4l2.c
1513 ++++ b/drivers/media/usb/uvc/uvc_v4l2.c
1514 +@@ -436,10 +436,13 @@ static int uvc_v4l2_set_streamparm(struct uvc_streaming *stream,
1515 + uvc_simplify_fraction(&timeperframe.numerator,
1516 + &timeperframe.denominator, 8, 333);
1517 +
1518 +- if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE)
1519 ++ if (parm->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
1520 + parm->parm.capture.timeperframe = timeperframe;
1521 +- else
1522 ++ parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME;
1523 ++ } else {
1524 + parm->parm.output.timeperframe = timeperframe;
1525 ++ parm->parm.output.capability = V4L2_CAP_TIMEPERFRAME;
1526 ++ }
1527 +
1528 + return 0;
1529 + }
1530 +diff --git a/drivers/memory/fsl_ifc.c b/drivers/memory/fsl_ifc.c
1531 +index 26b37ba4feda6..258d95b9c0adc 100644
1532 +--- a/drivers/memory/fsl_ifc.c
1533 ++++ b/drivers/memory/fsl_ifc.c
1534 +@@ -275,7 +275,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
1535 +
1536 + ret = fsl_ifc_ctrl_init(fsl_ifc_ctrl_dev);
1537 + if (ret < 0)
1538 +- goto err;
1539 ++ goto err_unmap_nandirq;
1540 +
1541 + init_waitqueue_head(&fsl_ifc_ctrl_dev->nand_wait);
1542 +
1543 +@@ -284,7 +284,7 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
1544 + if (ret != 0) {
1545 + dev_err(&dev->dev, "failed to install irq (%d)\n",
1546 + fsl_ifc_ctrl_dev->irq);
1547 +- goto err_irq;
1548 ++ goto err_unmap_nandirq;
1549 + }
1550 +
1551 + if (fsl_ifc_ctrl_dev->nand_irq) {
1552 +@@ -293,17 +293,16 @@ static int fsl_ifc_ctrl_probe(struct platform_device *dev)
1553 + if (ret != 0) {
1554 + dev_err(&dev->dev, "failed to install irq (%d)\n",
1555 + fsl_ifc_ctrl_dev->nand_irq);
1556 +- goto err_nandirq;
1557 ++ goto err_free_irq;
1558 + }
1559 + }
1560 +
1561 + return 0;
1562 +
1563 +-err_nandirq:
1564 +- free_irq(fsl_ifc_ctrl_dev->nand_irq, fsl_ifc_ctrl_dev);
1565 +- irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq);
1566 +-err_irq:
1567 ++err_free_irq:
1568 + free_irq(fsl_ifc_ctrl_dev->irq, fsl_ifc_ctrl_dev);
1569 ++err_unmap_nandirq:
1570 ++ irq_dispose_mapping(fsl_ifc_ctrl_dev->nand_irq);
1571 + irq_dispose_mapping(fsl_ifc_ctrl_dev->irq);
1572 + err:
1573 + return ret;
1574 +diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
1575 +index 24f2f8473deec..d0a4177f034a8 100644
1576 +--- a/drivers/memstick/core/ms_block.c
1577 ++++ b/drivers/memstick/core/ms_block.c
1578 +@@ -1730,7 +1730,7 @@ static int msb_init_card(struct memstick_dev *card)
1579 + msb->pages_in_block = boot_block->attr.block_size * 2;
1580 + msb->block_size = msb->page_size * msb->pages_in_block;
1581 +
1582 +- if (msb->page_size > PAGE_SIZE) {
1583 ++ if ((size_t)msb->page_size > PAGE_SIZE) {
1584 + /* this isn't supported by linux at all, anyway*/
1585 + dbg("device page %d size isn't supported", msb->page_size);
1586 + return -EINVAL;
1587 +diff --git a/drivers/memstick/host/jmb38x_ms.c b/drivers/memstick/host/jmb38x_ms.c
1588 +index 08fa6400d2558..ba6cd576e9979 100644
1589 +--- a/drivers/memstick/host/jmb38x_ms.c
1590 ++++ b/drivers/memstick/host/jmb38x_ms.c
1591 +@@ -905,7 +905,7 @@ static struct memstick_host *jmb38x_ms_alloc_host(struct jmb38x_ms *jm, int cnt)
1592 +
1593 + iounmap(host->addr);
1594 + err_out_free:
1595 +- kfree(msh);
1596 ++ memstick_free_host(msh);
1597 + return NULL;
1598 + }
1599 +
1600 +diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
1601 +index b3857445d6736..7779aaa6b9b81 100644
1602 +--- a/drivers/memstick/host/r592.c
1603 ++++ b/drivers/memstick/host/r592.c
1604 +@@ -842,15 +842,15 @@ static void r592_remove(struct pci_dev *pdev)
1605 + }
1606 + memstick_remove_host(dev->host);
1607 +
1608 ++ if (dev->dummy_dma_page)
1609 ++ dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
1610 ++ dev->dummy_dma_page_physical_address);
1611 ++
1612 + free_irq(dev->irq, dev);
1613 + iounmap(dev->mmio);
1614 + pci_release_regions(pdev);
1615 + pci_disable_device(pdev);
1616 + memstick_free_host(dev->host);
1617 +-
1618 +- if (dev->dummy_dma_page)
1619 +- dma_free_coherent(&pdev->dev, PAGE_SIZE, dev->dummy_dma_page,
1620 +- dev->dummy_dma_page_physical_address);
1621 + }
1622 +
1623 + #ifdef CONFIG_PM_SLEEP
1624 +diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
1625 +index 2e6d2fff1096a..fb1231a882e65 100644
1626 +--- a/drivers/mmc/host/Kconfig
1627 ++++ b/drivers/mmc/host/Kconfig
1628 +@@ -377,7 +377,7 @@ config MMC_OMAP_HS
1629 +
1630 + config MMC_WBSD
1631 + tristate "Winbond W83L51xD SD/MMC Card Interface support"
1632 +- depends on ISA_DMA_API
1633 ++ depends on ISA_DMA_API && !M68K
1634 + help
1635 + This selects the Winbond(R) W83L51xD Secure digital and
1636 + Multimedia card Interface.
1637 +diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
1638 +index 03ac8d5997632..4b5cca0226426 100644
1639 +--- a/drivers/mmc/host/dw_mmc.c
1640 ++++ b/drivers/mmc/host/dw_mmc.c
1641 +@@ -1763,7 +1763,8 @@ static void dw_mci_tasklet_func(unsigned long priv)
1642 + * delayed. Allowing the transfer to take place
1643 + * avoids races and keeps things simple.
1644 + */
1645 +- if (err != -ETIMEDOUT) {
1646 ++ if (err != -ETIMEDOUT &&
1647 ++ host->dir_status == DW_MCI_RECV_STATUS) {
1648 + state = STATE_SENDING_DATA;
1649 + continue;
1650 + }
1651 +diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c
1652 +index 68bbac4715c35..1e1e77a40f182 100644
1653 +--- a/drivers/net/bonding/bond_sysfs_slave.c
1654 ++++ b/drivers/net/bonding/bond_sysfs_slave.c
1655 +@@ -112,15 +112,15 @@ static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
1656 + }
1657 + static SLAVE_ATTR_RO(ad_partner_oper_port_state);
1658 +
1659 +-static const struct slave_attribute *slave_attrs[] = {
1660 +- &slave_attr_state,
1661 +- &slave_attr_mii_status,
1662 +- &slave_attr_link_failure_count,
1663 +- &slave_attr_perm_hwaddr,
1664 +- &slave_attr_queue_id,
1665 +- &slave_attr_ad_aggregator_id,
1666 +- &slave_attr_ad_actor_oper_port_state,
1667 +- &slave_attr_ad_partner_oper_port_state,
1668 ++static const struct attribute *slave_attrs[] = {
1669 ++ &slave_attr_state.attr,
1670 ++ &slave_attr_mii_status.attr,
1671 ++ &slave_attr_link_failure_count.attr,
1672 ++ &slave_attr_perm_hwaddr.attr,
1673 ++ &slave_attr_queue_id.attr,
1674 ++ &slave_attr_ad_aggregator_id.attr,
1675 ++ &slave_attr_ad_actor_oper_port_state.attr,
1676 ++ &slave_attr_ad_partner_oper_port_state.attr,
1677 + NULL
1678 + };
1679 +
1680 +@@ -141,24 +141,10 @@ const struct sysfs_ops slave_sysfs_ops = {
1681 +
1682 + int bond_sysfs_slave_add(struct slave *slave)
1683 + {
1684 +- const struct slave_attribute **a;
1685 +- int err;
1686 +-
1687 +- for (a = slave_attrs; *a; ++a) {
1688 +- err = sysfs_create_file(&slave->kobj, &((*a)->attr));
1689 +- if (err) {
1690 +- kobject_put(&slave->kobj);
1691 +- return err;
1692 +- }
1693 +- }
1694 +-
1695 +- return 0;
1696 ++ return sysfs_create_files(&slave->kobj, slave_attrs);
1697 + }
1698 +
1699 + void bond_sysfs_slave_del(struct slave *slave)
1700 + {
1701 +- const struct slave_attribute **a;
1702 +-
1703 +- for (a = slave_attrs; *a; ++a)
1704 +- sysfs_remove_file(&slave->kobj, &((*a)->attr));
1705 ++ sysfs_remove_files(&slave->kobj, slave_attrs);
1706 + }
1707 +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
1708 +index 1835d2e451c01..fc7fce642666c 100644
1709 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
1710 ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_init_ops.h
1711 +@@ -635,11 +635,13 @@ static int bnx2x_ilt_client_mem_op(struct bnx2x *bp, int cli_num,
1712 + {
1713 + int i, rc;
1714 + struct bnx2x_ilt *ilt = BP_ILT(bp);
1715 +- struct ilt_client_info *ilt_cli = &ilt->clients[cli_num];
1716 ++ struct ilt_client_info *ilt_cli;
1717 +
1718 + if (!ilt || !ilt->lines)
1719 + return -1;
1720 +
1721 ++ ilt_cli = &ilt->clients[cli_num];
1722 ++
1723 + if (ilt_cli->flags & (ILT_CLIENT_SKIP_INIT | ILT_CLIENT_SKIP_MEM))
1724 + return 0;
1725 +
1726 +diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
1727 +index e11f436b0726e..ac61d017a4b51 100644
1728 +--- a/drivers/net/ethernet/ti/davinci_emac.c
1729 ++++ b/drivers/net/ethernet/ti/davinci_emac.c
1730 +@@ -555,8 +555,20 @@ static int emac_set_coalesce(struct net_device *ndev,
1731 + u32 int_ctrl, num_interrupts = 0;
1732 + u32 prescale = 0, addnl_dvdr = 1, coal_intvl = 0;
1733 +
1734 +- if (!coal->rx_coalesce_usecs)
1735 +- return -EINVAL;
1736 ++ if (!coal->rx_coalesce_usecs) {
1737 ++ priv->coal_intvl = 0;
1738 ++
1739 ++ switch (priv->version) {
1740 ++ case EMAC_VERSION_2:
1741 ++ emac_ctrl_write(EMAC_DM646X_CMINTCTRL, 0);
1742 ++ break;
1743 ++ default:
1744 ++ emac_ctrl_write(EMAC_CTRL_EWINTTCNT, 0);
1745 ++ break;
1746 ++ }
1747 ++
1748 ++ return 0;
1749 ++ }
1750 +
1751 + coal_intvl = coal->rx_coalesce_usecs;
1752 +
1753 +diff --git a/drivers/net/tun.c b/drivers/net/tun.c
1754 +index 7622f390ef1a7..d4ce8b7360652 100644
1755 +--- a/drivers/net/tun.c
1756 ++++ b/drivers/net/tun.c
1757 +@@ -821,6 +821,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
1758 + {
1759 + struct tun_struct *tun = netdev_priv(dev);
1760 + int txq = skb->queue_mapping;
1761 ++ struct netdev_queue *queue;
1762 + struct tun_file *tfile;
1763 + u32 numqueues = 0;
1764 +
1765 +@@ -887,6 +888,10 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
1766 + /* Enqueue packet */
1767 + skb_queue_tail(&tfile->socket.sk->sk_receive_queue, skb);
1768 +
1769 ++ /* NETIF_F_LLTX requires to do our own update of trans_start */
1770 ++ queue = netdev_get_tx_queue(dev, txq);
1771 ++ queue->trans_start = jiffies;
1772 ++
1773 + /* Notify and wake up reader process */
1774 + if (tfile->flags & TUN_FASYNC)
1775 + kill_fasync(&tfile->fasync, SIGIO, POLL_IN);
1776 +diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
1777 +index 419c045d07527..474ee7e723d00 100644
1778 +--- a/drivers/net/vmxnet3/vmxnet3_drv.c
1779 ++++ b/drivers/net/vmxnet3/vmxnet3_drv.c
1780 +@@ -3389,7 +3389,6 @@ vmxnet3_suspend(struct device *device)
1781 + vmxnet3_free_intr_resources(adapter);
1782 +
1783 + netif_device_detach(netdev);
1784 +- netif_tx_stop_all_queues(netdev);
1785 +
1786 + /* Create wake-up filters. */
1787 + pmConf = adapter->pm_conf;
1788 +diff --git a/drivers/net/wireless/ath/ath6kl/usb.c b/drivers/net/wireless/ath/ath6kl/usb.c
1789 +index fc22c5f479276..3d0dfcf2c2462 100644
1790 +--- a/drivers/net/wireless/ath/ath6kl/usb.c
1791 ++++ b/drivers/net/wireless/ath/ath6kl/usb.c
1792 +@@ -340,6 +340,11 @@ static int ath6kl_usb_setup_pipe_resources(struct ath6kl_usb *ar_usb)
1793 + le16_to_cpu(endpoint->wMaxPacketSize),
1794 + endpoint->bInterval);
1795 + }
1796 ++
1797 ++ /* Ignore broken descriptors. */
1798 ++ if (usb_endpoint_maxp(endpoint) == 0)
1799 ++ continue;
1800 ++
1801 + urbcount = 0;
1802 +
1803 + pipe_num =
1804 +@@ -907,7 +912,7 @@ static int ath6kl_usb_submit_ctrl_in(struct ath6kl_usb *ar_usb,
1805 + req,
1806 + USB_DIR_IN | USB_TYPE_VENDOR |
1807 + USB_RECIP_DEVICE, value, index, buf,
1808 +- size, 2 * HZ);
1809 ++ size, 2000);
1810 +
1811 + if (ret < 0) {
1812 + ath6kl_warn("Failed to read usb control message: %d\n", ret);
1813 +diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
1814 +index 298c7957dd160..52906c080e0aa 100644
1815 +--- a/drivers/net/wireless/ath/ath9k/main.c
1816 ++++ b/drivers/net/wireless/ath/ath9k/main.c
1817 +@@ -528,8 +528,10 @@ irqreturn_t ath_isr(int irq, void *dev)
1818 + ath9k_debug_sync_cause(sc, sync_cause);
1819 + status &= ah->imask; /* discard unasked-for bits */
1820 +
1821 +- if (test_bit(ATH_OP_HW_RESET, &common->op_flags))
1822 ++ if (test_bit(ATH_OP_HW_RESET, &common->op_flags)) {
1823 ++ ath9k_hw_kill_interrupts(sc->sc_ah);
1824 + return IRQ_HANDLED;
1825 ++ }
1826 +
1827 + /*
1828 + * If there are no status bits set, then this interrupt was not
1829 +diff --git a/drivers/net/wireless/ath/dfs_pattern_detector.c b/drivers/net/wireless/ath/dfs_pattern_detector.c
1830 +index 0835828ffed77..2f4b79102a27a 100644
1831 +--- a/drivers/net/wireless/ath/dfs_pattern_detector.c
1832 ++++ b/drivers/net/wireless/ath/dfs_pattern_detector.c
1833 +@@ -182,10 +182,12 @@ static void channel_detector_exit(struct dfs_pattern_detector *dpd,
1834 + if (cd == NULL)
1835 + return;
1836 + list_del(&cd->head);
1837 +- for (i = 0; i < dpd->num_radar_types; i++) {
1838 +- struct pri_detector *de = cd->detectors[i];
1839 +- if (de != NULL)
1840 +- de->exit(de);
1841 ++ if (cd->detectors) {
1842 ++ for (i = 0; i < dpd->num_radar_types; i++) {
1843 ++ struct pri_detector *de = cd->detectors[i];
1844 ++ if (de != NULL)
1845 ++ de->exit(de);
1846 ++ }
1847 + }
1848 + kfree(cd->detectors);
1849 + kfree(cd);
1850 +diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c
1851 +index 274d114962e8a..52c2e81024a1f 100644
1852 +--- a/drivers/net/wireless/ath/wcn36xx/main.c
1853 ++++ b/drivers/net/wireless/ath/wcn36xx/main.c
1854 +@@ -127,7 +127,9 @@ static struct ieee80211_supported_band wcn_band_2ghz = {
1855 + .cap = IEEE80211_HT_CAP_GRN_FLD |
1856 + IEEE80211_HT_CAP_SGI_20 |
1857 + IEEE80211_HT_CAP_DSSSCCK40 |
1858 +- IEEE80211_HT_CAP_LSIG_TXOP_PROT,
1859 ++ IEEE80211_HT_CAP_LSIG_TXOP_PROT |
1860 ++ IEEE80211_HT_CAP_SGI_40 |
1861 ++ IEEE80211_HT_CAP_SUP_WIDTH_20_40,
1862 + .ht_supported = true,
1863 + .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
1864 + .ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
1865 +diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
1866 +index 462310e6e88fb..a706605cef9a8 100644
1867 +--- a/drivers/net/wireless/b43/phy_g.c
1868 ++++ b/drivers/net/wireless/b43/phy_g.c
1869 +@@ -2295,7 +2295,7 @@ static u8 b43_gphy_aci_scan(struct b43_wldev *dev)
1870 + b43_phy_mask(dev, B43_PHY_G_CRS, 0x7FFF);
1871 + b43_set_all_gains(dev, 3, 8, 1);
1872 +
1873 +- start = (channel - 5 > 0) ? channel - 5 : 1;
1874 ++ start = (channel > 5) ? channel - 5 : 1;
1875 + end = (channel + 5 < 14) ? channel + 5 : 13;
1876 +
1877 + for (i = start; i <= end; i++) {
1878 +diff --git a/drivers/net/wireless/b43legacy/radio.c b/drivers/net/wireless/b43legacy/radio.c
1879 +index 9501420340a91..5b1e8890305c1 100644
1880 +--- a/drivers/net/wireless/b43legacy/radio.c
1881 ++++ b/drivers/net/wireless/b43legacy/radio.c
1882 +@@ -299,7 +299,7 @@ u8 b43legacy_radio_aci_scan(struct b43legacy_wldev *dev)
1883 + & 0x7FFF);
1884 + b43legacy_set_all_gains(dev, 3, 8, 1);
1885 +
1886 +- start = (channel - 5 > 0) ? channel - 5 : 1;
1887 ++ start = (channel > 5) ? channel - 5 : 1;
1888 + end = (channel + 5 < 14) ? channel + 5 : 13;
1889 +
1890 + for (i = start; i <= end; i++) {
1891 +diff --git a/drivers/net/wireless/iwlwifi/mvm/utils.c b/drivers/net/wireless/iwlwifi/mvm/utils.c
1892 +index ad0f16909e2e2..3d089eb9dff51 100644
1893 +--- a/drivers/net/wireless/iwlwifi/mvm/utils.c
1894 ++++ b/drivers/net/wireless/iwlwifi/mvm/utils.c
1895 +@@ -923,6 +923,9 @@ bool iwl_mvm_rx_diversity_allowed(struct iwl_mvm *mvm)
1896 +
1897 + lockdep_assert_held(&mvm->mutex);
1898 +
1899 ++ if (iwlmvm_mod_params.power_scheme != IWL_POWER_SCHEME_CAM)
1900 ++ return false;
1901 ++
1902 + if (num_of_ant(iwl_mvm_get_valid_rx_ant(mvm)) == 1)
1903 + return false;
1904 +
1905 +diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c
1906 +index d271eaf1f9499..1793611a380c8 100644
1907 +--- a/drivers/net/wireless/libertas/if_usb.c
1908 ++++ b/drivers/net/wireless/libertas/if_usb.c
1909 +@@ -291,6 +291,7 @@ err_add_card:
1910 + if_usb_reset_device(cardp);
1911 + dealloc:
1912 + if_usb_free(cardp);
1913 ++ kfree(cardp);
1914 +
1915 + error:
1916 + return r;
1917 +@@ -317,6 +318,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
1918 +
1919 + /* Unlink and free urb */
1920 + if_usb_free(cardp);
1921 ++ kfree(cardp);
1922 +
1923 + usb_set_intfdata(intf, NULL);
1924 + usb_put_dev(interface_to_usbdev(intf));
1925 +diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c
1926 +index 799a2efe57937..193f8f70c4edb 100644
1927 +--- a/drivers/net/wireless/libertas_tf/if_usb.c
1928 ++++ b/drivers/net/wireless/libertas_tf/if_usb.c
1929 +@@ -240,6 +240,7 @@ static int if_usb_probe(struct usb_interface *intf,
1930 +
1931 + dealloc:
1932 + if_usb_free(cardp);
1933 ++ kfree(cardp);
1934 + error:
1935 + lbtf_deb_leave(LBTF_DEB_MAIN);
1936 + return -ENOMEM;
1937 +@@ -264,6 +265,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
1938 +
1939 + /* Unlink and free urb */
1940 + if_usb_free(cardp);
1941 ++ kfree(cardp);
1942 +
1943 + usb_set_intfdata(intf, NULL);
1944 + usb_put_dev(interface_to_usbdev(intf));
1945 +diff --git a/drivers/net/wireless/mwifiex/11n.c b/drivers/net/wireless/mwifiex/11n.c
1946 +index c174e79e6df2b..b70eac7d2dd79 100644
1947 +--- a/drivers/net/wireless/mwifiex/11n.c
1948 ++++ b/drivers/net/wireless/mwifiex/11n.c
1949 +@@ -630,14 +630,15 @@ int mwifiex_send_delba(struct mwifiex_private *priv, int tid, u8 *peer_mac,
1950 + uint16_t del_ba_param_set;
1951 +
1952 + memset(&delba, 0, sizeof(delba));
1953 +- delba.del_ba_param_set = cpu_to_le16(tid << DELBA_TID_POS);
1954 +
1955 +- del_ba_param_set = le16_to_cpu(delba.del_ba_param_set);
1956 ++ del_ba_param_set = tid << DELBA_TID_POS;
1957 ++
1958 + if (initiator)
1959 + del_ba_param_set |= IEEE80211_DELBA_PARAM_INITIATOR_MASK;
1960 + else
1961 + del_ba_param_set &= ~IEEE80211_DELBA_PARAM_INITIATOR_MASK;
1962 +
1963 ++ delba.del_ba_param_set = cpu_to_le16(del_ba_param_set);
1964 + memcpy(&delba.peer_mac_addr, peer_mac, ETH_ALEN);
1965 +
1966 + /* We don't wait for the response of this command */
1967 +diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
1968 +index c410ef92b084e..876c335c30693 100644
1969 +--- a/drivers/net/wireless/mwifiex/pcie.c
1970 ++++ b/drivers/net/wireless/mwifiex/pcie.c
1971 +@@ -1210,6 +1210,14 @@ mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb,
1972 + ret = -1;
1973 + goto done_unmap;
1974 + }
1975 ++
1976 ++ /* The firmware (latest version 15.68.19.p21) of the 88W8897 PCIe+USB card
1977 ++ * seems to crash randomly after setting the TX ring write pointer when
1978 ++ * ASPM powersaving is enabled. A workaround seems to be keeping the bus
1979 ++ * busy by reading a random register afterwards.
1980 ++ */
1981 ++ mwifiex_read_reg(adapter, PCI_VENDOR_ID, &rx_val);
1982 ++
1983 + if ((mwifiex_pcie_txbd_not_full(card)) &&
1984 + tx_param->next_pkt_len) {
1985 + /* have more packets and TxBD still can hold more */
1986 +diff --git a/drivers/net/wireless/mwifiex/usb.c b/drivers/net/wireless/mwifiex/usb.c
1987 +index 1a1b1de875835..1be7b219cb202 100644
1988 +--- a/drivers/net/wireless/mwifiex/usb.c
1989 ++++ b/drivers/net/wireless/mwifiex/usb.c
1990 +@@ -473,6 +473,22 @@ static int mwifiex_usb_probe(struct usb_interface *intf,
1991 + }
1992 + }
1993 +
1994 ++ switch (card->usb_boot_state) {
1995 ++ case USB8XXX_FW_DNLD:
1996 ++ /* Reject broken descriptors. */
1997 ++ if (!card->rx_cmd_ep || !card->tx_cmd_ep)
1998 ++ return -ENODEV;
1999 ++ if (card->bulk_out_maxpktsize == 0)
2000 ++ return -ENODEV;
2001 ++ break;
2002 ++ case USB8XXX_FW_READY:
2003 ++ /* Assume the driver can handle missing endpoints for now. */
2004 ++ break;
2005 ++ default:
2006 ++ WARN_ON(1);
2007 ++ return -ENODEV;
2008 ++ }
2009 ++
2010 + usb_set_intfdata(intf, card);
2011 +
2012 + ret = mwifiex_add_card(card, &add_remove_card_sem, &usb_ops,
2013 +diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
2014 +index d448480b84063..073968eccbc2b 100644
2015 +--- a/drivers/net/wireless/mwl8k.c
2016 ++++ b/drivers/net/wireless/mwl8k.c
2017 +@@ -5783,8 +5783,8 @@ static void mwl8k_fw_state_machine(const struct firmware *fw, void *context)
2018 + fail:
2019 + priv->fw_state = FW_STATE_ERROR;
2020 + complete(&priv->firmware_loading_complete);
2021 +- device_release_driver(&priv->pdev->dev);
2022 + mwl8k_release_firmware(priv);
2023 ++ device_release_driver(&priv->pdev->dev);
2024 + }
2025 +
2026 + #define MAX_RESTART_ATTEMPTS 1
2027 +diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
2028 +index 7d4c0c46a889d..6d4bf37c660f7 100644
2029 +--- a/drivers/net/xen-netfront.c
2030 ++++ b/drivers/net/xen-netfront.c
2031 +@@ -1454,6 +1454,10 @@ static int netfront_resume(struct xenbus_device *dev)
2032 +
2033 + dev_dbg(&dev->dev, "%s\n", dev->nodename);
2034 +
2035 ++ netif_tx_lock_bh(info->netdev);
2036 ++ netif_device_detach(info->netdev);
2037 ++ netif_tx_unlock_bh(info->netdev);
2038 ++
2039 + xennet_disconnect_backend(info);
2040 + return 0;
2041 + }
2042 +@@ -2014,6 +2018,10 @@ static int xennet_connect(struct net_device *dev)
2043 + * domain a kick because we've probably just requeued some
2044 + * packets.
2045 + */
2046 ++ netif_tx_lock_bh(np->netdev);
2047 ++ netif_device_attach(np->netdev);
2048 ++ netif_tx_unlock_bh(np->netdev);
2049 ++
2050 + netif_carrier_on(np->netdev);
2051 + for (j = 0; j < num_queues; ++j) {
2052 + queue = &np->queues[j];
2053 +diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
2054 +index 001c12867e430..9e0d74a08d584 100644
2055 +--- a/drivers/nfc/pn533.c
2056 ++++ b/drivers/nfc/pn533.c
2057 +@@ -2592,7 +2592,7 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
2058 + frag = pn533_alloc_skb(dev, frag_size);
2059 + if (!frag) {
2060 + skb_queue_purge(&dev->fragment_skb);
2061 +- break;
2062 ++ return -ENOMEM;
2063 + }
2064 +
2065 + if (!dev->tgt_mode) {
2066 +@@ -2662,7 +2662,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
2067 + /* jumbo frame ? */
2068 + if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
2069 + rc = pn533_fill_fragment_skbs(dev, skb);
2070 +- if (rc <= 0)
2071 ++ if (rc < 0)
2072 + goto error;
2073 +
2074 + skb = skb_dequeue(&dev->fragment_skb);
2075 +@@ -2734,7 +2734,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
2076 + /* let's split in multiple chunks if size's too big */
2077 + if (skb->len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
2078 + rc = pn533_fill_fragment_skbs(dev, skb);
2079 +- if (rc <= 0)
2080 ++ if (rc < 0)
2081 + goto error;
2082 +
2083 + /* get the first skb */
2084 +diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
2085 +index a635af3b9076c..534aa676bf551 100644
2086 +--- a/drivers/pci/msi.c
2087 ++++ b/drivers/pci/msi.c
2088 +@@ -390,18 +390,6 @@ static void free_msi_irqs(struct pci_dev *dev)
2089 + for (i = 0; i < entry->nvec_used; i++)
2090 + BUG_ON(irq_has_action(entry->irq + i));
2091 +
2092 +- pci_msi_teardown_msi_irqs(dev);
2093 +-
2094 +- list_for_each_entry_safe(entry, tmp, msi_list, list) {
2095 +- if (entry->msi_attrib.is_msix) {
2096 +- if (list_is_last(&entry->list, msi_list))
2097 +- iounmap(entry->mask_base);
2098 +- }
2099 +-
2100 +- list_del(&entry->list);
2101 +- kfree(entry);
2102 +- }
2103 +-
2104 + if (dev->msi_irq_groups) {
2105 + sysfs_remove_groups(&dev->dev.kobj, dev->msi_irq_groups);
2106 + msi_attrs = dev->msi_irq_groups[0]->attrs;
2107 +@@ -417,6 +405,18 @@ static void free_msi_irqs(struct pci_dev *dev)
2108 + kfree(dev->msi_irq_groups);
2109 + dev->msi_irq_groups = NULL;
2110 + }
2111 ++
2112 ++ pci_msi_teardown_msi_irqs(dev);
2113 ++
2114 ++ list_for_each_entry_safe(entry, tmp, msi_list, list) {
2115 ++ if (entry->msi_attrib.is_msix) {
2116 ++ if (list_is_last(&entry->list, msi_list))
2117 ++ iounmap(entry->mask_base);
2118 ++ }
2119 ++
2120 ++ list_del(&entry->list);
2121 ++ free_msi_entry(entry);
2122 ++ }
2123 + }
2124 +
2125 + static void pci_intx_for_msi(struct pci_dev *dev, int enable)
2126 +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
2127 +index f8f0849b9cdcb..8df369fac3dfb 100644
2128 +--- a/drivers/pci/quirks.c
2129 ++++ b/drivers/pci/quirks.c
2130 +@@ -3169,6 +3169,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0032, quirk_no_bus_reset);
2131 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003c, quirk_no_bus_reset);
2132 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0033, quirk_no_bus_reset);
2133 + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset);
2134 ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x003e, quirk_no_bus_reset);
2135 +
2136 + /*
2137 + * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS
2138 +diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
2139 +index a06262e91a933..411616e6cb744 100644
2140 +--- a/drivers/platform/x86/hp_accel.c
2141 ++++ b/drivers/platform/x86/hp_accel.c
2142 +@@ -377,9 +377,11 @@ static int lis3lv02d_add(struct acpi_device *device)
2143 + INIT_WORK(&hpled_led.work, delayed_set_status_worker);
2144 + ret = led_classdev_register(NULL, &hpled_led.led_classdev);
2145 + if (ret) {
2146 ++ i8042_remove_filter(hp_accel_i8042_filter);
2147 + lis3lv02d_joystick_disable(&lis3_dev);
2148 + lis3lv02d_poweroff(&lis3_dev);
2149 + flush_work(&hpled_led.work);
2150 ++ lis3lv02d_remove_fs(&lis3_dev);
2151 + return ret;
2152 + }
2153 +
2154 +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
2155 +index 20c588af33d88..f3954af14f52f 100644
2156 +--- a/drivers/platform/x86/thinkpad_acpi.c
2157 ++++ b/drivers/platform/x86/thinkpad_acpi.c
2158 +@@ -8606,7 +8606,7 @@ static int fan_write_cmd_level(const char *cmd, int *rc)
2159 +
2160 + if (strlencmp(cmd, "level auto") == 0)
2161 + level = TP_EC_FAN_AUTO;
2162 +- else if ((strlencmp(cmd, "level disengaged") == 0) |
2163 ++ else if ((strlencmp(cmd, "level disengaged") == 0) ||
2164 + (strlencmp(cmd, "level full-speed") == 0))
2165 + level = TP_EC_FAN_FULLSPEED;
2166 + else if (sscanf(cmd, "level %d", &level) != 1)
2167 +diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
2168 +index eb391a2818330..fb16c83900a02 100644
2169 +--- a/drivers/platform/x86/wmi.c
2170 ++++ b/drivers/platform/x86/wmi.c
2171 +@@ -367,7 +367,14 @@ struct acpi_buffer *out)
2172 + * the WQxx method failed - we should disable collection anyway.
2173 + */
2174 + if ((block->flags & ACPI_WMI_EXPENSIVE) && ACPI_SUCCESS(wc_status)) {
2175 +- status = acpi_execute_simple_method(handle, wc_method, 0);
2176 ++ /*
2177 ++ * Ignore whether this WCxx call succeeds or not since
2178 ++ * the previously executed WQxx method call might have
2179 ++ * succeeded, and returning the failing status code
2180 ++ * of this call would throw away the result of the WQxx
2181 ++ * call, potentially leaking memory.
2182 ++ */
2183 ++ acpi_execute_simple_method(handle, wc_method, 0);
2184 + }
2185 +
2186 + return status;
2187 +diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
2188 +index f18d845b3b92d..01ca03c809d05 100644
2189 +--- a/drivers/power/max17042_battery.c
2190 ++++ b/drivers/power/max17042_battery.c
2191 +@@ -246,7 +246,10 @@ static int max17042_get_property(struct power_supply *psy,
2192 + val->intval = data * 625 / 8;
2193 + break;
2194 + case POWER_SUPPLY_PROP_CAPACITY:
2195 +- ret = regmap_read(map, MAX17042_RepSOC, &data);
2196 ++ if (chip->pdata->enable_current_sense)
2197 ++ ret = regmap_read(map, MAX17042_RepSOC, &data);
2198 ++ else
2199 ++ ret = regmap_read(map, MAX17042_VFSOC, &data);
2200 + if (ret < 0)
2201 + return ret;
2202 +
2203 +@@ -752,7 +755,8 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)
2204 + regmap_read(map, MAX17042_RepSOC, &soc);
2205 + soc >>= 8;
2206 + soc_tr = (soc + off) << 8;
2207 +- soc_tr |= (soc - off);
2208 ++ if (off < soc)
2209 ++ soc_tr |= soc - off;
2210 + regmap_write(map, MAX17042_SALRT_Th, soc_tr);
2211 + }
2212 +
2213 +diff --git a/drivers/power/rt5033_battery.c b/drivers/power/rt5033_battery.c
2214 +index bcdd830484929..c9a58ed4dc9f1 100644
2215 +--- a/drivers/power/rt5033_battery.c
2216 ++++ b/drivers/power/rt5033_battery.c
2217 +@@ -63,7 +63,7 @@ static int rt5033_battery_get_watt_prop(struct i2c_client *client,
2218 + regmap_read(battery->regmap, regh, &msb);
2219 + regmap_read(battery->regmap, regl, &lsb);
2220 +
2221 +- ret = ((msb << 4) + (lsb >> 4)) * 1250 / 1000;
2222 ++ ret = ((msb << 4) + (lsb >> 4)) * 1250;
2223 +
2224 + return ret;
2225 + }
2226 +diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
2227 +index 24e57e770432b..6efd17692a55a 100644
2228 +--- a/drivers/scsi/advansys.c
2229 ++++ b/drivers/scsi/advansys.c
2230 +@@ -3370,8 +3370,8 @@ static void asc_prt_adv_board_info(struct seq_file *m, struct Scsi_Host *shost)
2231 + shost->host_no);
2232 +
2233 + seq_printf(m,
2234 +- " iop_base 0x%lx, cable_detect: %X, err_code %u\n",
2235 +- (unsigned long)v->iop_base,
2236 ++ " iop_base 0x%p, cable_detect: %X, err_code %u\n",
2237 ++ v->iop_base,
2238 + AdvReadWordRegister(iop_base,IOPW_SCSI_CFG1) & CABLE_DETECT,
2239 + v->err_code);
2240 +
2241 +diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
2242 +index 957767d383610..d1df694d9ed00 100644
2243 +--- a/drivers/scsi/csiostor/csio_lnode.c
2244 ++++ b/drivers/scsi/csiostor/csio_lnode.c
2245 +@@ -611,7 +611,7 @@ csio_ln_vnp_read_cbfn(struct csio_hw *hw, struct csio_mb *mbp)
2246 + struct fc_els_csp *csp;
2247 + struct fc_els_cssp *clsp;
2248 + enum fw_retval retval;
2249 +- __be32 nport_id;
2250 ++ __be32 nport_id = 0;
2251 +
2252 + retval = FW_CMD_RETVAL_G(ntohl(rsp->alloc_to_len16));
2253 + if (retval != FW_SUCCESS) {
2254 +diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
2255 +index 830b2d2dcf206..8490d0ff04ca7 100644
2256 +--- a/drivers/scsi/dc395x.c
2257 ++++ b/drivers/scsi/dc395x.c
2258 +@@ -4809,6 +4809,7 @@ static int dc395x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
2259 + /* initialise the adapter and everything we need */
2260 + if (adapter_init(acb, io_port_base, io_port_len, irq)) {
2261 + dprintkl(KERN_INFO, "adapter init failed\n");
2262 ++ acb = NULL;
2263 + goto fail;
2264 + }
2265 +
2266 +diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
2267 +index 9055a8fce3d4a..2087125922a11 100644
2268 +--- a/drivers/scsi/lpfc/lpfc_sli.c
2269 ++++ b/drivers/scsi/lpfc/lpfc_sli.c
2270 +@@ -17071,6 +17071,7 @@ lpfc_drain_txq(struct lpfc_hba *phba)
2271 + fail_msg,
2272 + piocbq->iotag, piocbq->sli4_xritag);
2273 + list_add_tail(&piocbq->list, &completions);
2274 ++ fail_msg = NULL;
2275 + }
2276 + spin_unlock_irqrestore(&pring->ring_lock, iflags);
2277 + }
2278 +diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
2279 +index 7686bfe9a4a9e..fb30329e60f0b 100644
2280 +--- a/drivers/scsi/qla2xxx/qla_gbl.h
2281 ++++ b/drivers/scsi/qla2xxx/qla_gbl.h
2282 +@@ -112,7 +112,6 @@ extern int ql2xasynctmfenable;
2283 + extern int ql2xgffidenable;
2284 + extern int ql2xenabledif;
2285 + extern int ql2xenablehba_err_chk;
2286 +-extern int ql2xtargetreset;
2287 + extern int ql2xdontresethba;
2288 + extern uint64_t ql2xmaxlun;
2289 + extern int ql2xmdcapmask;
2290 +@@ -643,7 +642,6 @@ extern void qlafx00_abort_iocb(srb_t *, struct abort_iocb_entry_fx00 *);
2291 + extern void qlafx00_fxdisc_iocb(srb_t *, struct fxdisc_entry_fx00 *);
2292 + extern void qlafx00_timer_routine(scsi_qla_host_t *);
2293 + extern int qlafx00_rescan_isp(scsi_qla_host_t *);
2294 +-extern int qlafx00_loop_reset(scsi_qla_host_t *vha);
2295 +
2296 + /* qla82xx related functions */
2297 +
2298 +diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
2299 +index b5029e543b918..4e75179e43687 100644
2300 +--- a/drivers/scsi/qla2xxx/qla_mr.c
2301 ++++ b/drivers/scsi/qla2xxx/qla_mr.c
2302 +@@ -737,29 +737,6 @@ qlafx00_lun_reset(fc_port_t *fcport, uint64_t l, int tag)
2303 + return qla2x00_async_tm_cmd(fcport, TCF_LUN_RESET, l, tag);
2304 + }
2305 +
2306 +-int
2307 +-qlafx00_loop_reset(scsi_qla_host_t *vha)
2308 +-{
2309 +- int ret;
2310 +- struct fc_port *fcport;
2311 +- struct qla_hw_data *ha = vha->hw;
2312 +-
2313 +- if (ql2xtargetreset) {
2314 +- list_for_each_entry(fcport, &vha->vp_fcports, list) {
2315 +- if (fcport->port_type != FCT_TARGET)
2316 +- continue;
2317 +-
2318 +- ret = ha->isp_ops->target_reset(fcport, 0, 0);
2319 +- if (ret != QLA_SUCCESS) {
2320 +- ql_dbg(ql_dbg_taskm, vha, 0x803d,
2321 +- "Bus Reset failed: Reset=%d "
2322 +- "d_id=%x.\n", ret, fcport->d_id.b24);
2323 +- }
2324 +- }
2325 +- }
2326 +- return QLA_SUCCESS;
2327 +-}
2328 +-
2329 + int
2330 + qlafx00_iospace_config(struct qla_hw_data *ha)
2331 + {
2332 +diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
2333 +index daafb60fa13e6..4fa0cd3c36634 100644
2334 +--- a/drivers/scsi/qla2xxx/qla_os.c
2335 ++++ b/drivers/scsi/qla2xxx/qla_os.c
2336 +@@ -177,12 +177,6 @@ MODULE_PARM_DESC(ql2xdbwr,
2337 + " 0 -- Regular doorbell.\n"
2338 + " 1 -- CAMRAM doorbell (faster).\n");
2339 +
2340 +-int ql2xtargetreset = 1;
2341 +-module_param(ql2xtargetreset, int, S_IRUGO);
2342 +-MODULE_PARM_DESC(ql2xtargetreset,
2343 +- "Enable target reset."
2344 +- "Default is 1 - use hw defaults.");
2345 +-
2346 + int ql2xgffidenable;
2347 + module_param(ql2xgffidenable, int, S_IRUGO);
2348 + MODULE_PARM_DESC(ql2xgffidenable,
2349 +@@ -1315,27 +1309,10 @@ int
2350 + qla2x00_loop_reset(scsi_qla_host_t *vha)
2351 + {
2352 + int ret;
2353 +- struct fc_port *fcport;
2354 + struct qla_hw_data *ha = vha->hw;
2355 +
2356 +- if (IS_QLAFX00(ha)) {
2357 +- return qlafx00_loop_reset(vha);
2358 +- }
2359 +-
2360 +- if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) {
2361 +- list_for_each_entry(fcport, &vha->vp_fcports, list) {
2362 +- if (fcport->port_type != FCT_TARGET)
2363 +- continue;
2364 +-
2365 +- ret = ha->isp_ops->target_reset(fcport, 0, 0);
2366 +- if (ret != QLA_SUCCESS) {
2367 +- ql_dbg(ql_dbg_taskm, vha, 0x802c,
2368 +- "Bus Reset failed: Reset=%d "
2369 +- "d_id=%x.\n", ret, fcport->d_id.b24);
2370 +- }
2371 +- }
2372 +- }
2373 +-
2374 ++ if (IS_QLAFX00(ha))
2375 ++ return QLA_SUCCESS;
2376 +
2377 + if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) {
2378 + atomic_set(&vha->loop_state, LOOP_DOWN);
2379 +diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c
2380 +index bec81c2404f78..1682fa3671bc3 100644
2381 +--- a/drivers/sh/maple/maple.c
2382 ++++ b/drivers/sh/maple/maple.c
2383 +@@ -835,8 +835,10 @@ static int __init maple_bus_init(void)
2384 +
2385 + maple_queue_cache = KMEM_CACHE(maple_buffer, SLAB_HWCACHE_ALIGN);
2386 +
2387 +- if (!maple_queue_cache)
2388 ++ if (!maple_queue_cache) {
2389 ++ retval = -ENOMEM;
2390 + goto cleanup_bothirqs;
2391 ++ }
2392 +
2393 + INIT_LIST_HEAD(&maple_waitq);
2394 + INIT_LIST_HEAD(&maple_sentq);
2395 +@@ -849,6 +851,7 @@ static int __init maple_bus_init(void)
2396 + if (!mdev[i]) {
2397 + while (i-- > 0)
2398 + maple_free_dev(mdev[i]);
2399 ++ retval = -ENOMEM;
2400 + goto cleanup_cache;
2401 + }
2402 + baseunits[i] = mdev[i];
2403 +diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
2404 +index 5e5fd77e27119..e294f21db2068 100644
2405 +--- a/drivers/spi/spi-pl022.c
2406 ++++ b/drivers/spi/spi-pl022.c
2407 +@@ -1710,12 +1710,13 @@ static int verify_controller_parameters(struct pl022 *pl022,
2408 + return -EINVAL;
2409 + }
2410 + } else {
2411 +- if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX)
2412 ++ if (chip_info->duplex != SSP_MICROWIRE_CHANNEL_FULL_DUPLEX) {
2413 + dev_err(&pl022->adev->dev,
2414 + "Microwire half duplex mode requested,"
2415 + " but this is only available in the"
2416 + " ST version of PL022\n");
2417 +- return -EINVAL;
2418 ++ return -EINVAL;
2419 ++ }
2420 + }
2421 + }
2422 + return 0;
2423 +diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
2424 +index 1fe782f9ee816..f1e09e7704afe 100644
2425 +--- a/drivers/target/target_core_alua.c
2426 ++++ b/drivers/target/target_core_alua.c
2427 +@@ -1735,7 +1735,6 @@ int core_alua_set_tg_pt_gp_id(
2428 + pr_err("Maximum ALUA alua_tg_pt_gps_count:"
2429 + " 0x0000ffff reached\n");
2430 + spin_unlock(&dev->t10_alua.tg_pt_gps_lock);
2431 +- kmem_cache_free(t10_alua_tg_pt_gp_cache, tg_pt_gp);
2432 + return -ENOSPC;
2433 + }
2434 + again:
2435 +diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
2436 +index 4198ed4ac6073..7a8da5758be8b 100644
2437 +--- a/drivers/target/target_core_device.c
2438 ++++ b/drivers/target/target_core_device.c
2439 +@@ -800,6 +800,8 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
2440 + INIT_LIST_HEAD(&dev->t10_alua.lba_map_list);
2441 + spin_lock_init(&dev->t10_alua.lba_map_lock);
2442 +
2443 ++ INIT_WORK(&dev->delayed_cmd_work, target_do_delayed_work);
2444 ++
2445 + dev->t10_wwn.t10_dev = dev;
2446 + dev->t10_alua.t10_dev = dev;
2447 +
2448 +diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
2449 +index 272e6f755322c..c0ee5e1f2b104 100644
2450 +--- a/drivers/target/target_core_internal.h
2451 ++++ b/drivers/target/target_core_internal.h
2452 +@@ -146,6 +146,7 @@ void transport_clear_lun_ref(struct se_lun *);
2453 + void transport_send_task_abort(struct se_cmd *);
2454 + sense_reason_t target_cmd_size_check(struct se_cmd *cmd, unsigned int size);
2455 + void target_qf_do_work(struct work_struct *work);
2456 ++void target_do_delayed_work(struct work_struct *work);
2457 + bool target_check_wce(struct se_device *dev);
2458 + bool target_check_fua(struct se_device *dev);
2459 + void __target_execute_cmd(struct se_cmd *, bool);
2460 +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
2461 +index 6c6aa23ced45f..75b29458c4da8 100644
2462 +--- a/drivers/target/target_core_transport.c
2463 ++++ b/drivers/target/target_core_transport.c
2464 +@@ -1877,32 +1877,35 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
2465 + */
2466 + switch (cmd->sam_task_attr) {
2467 + case TCM_HEAD_TAG:
2468 ++ atomic_inc_mb(&dev->non_ordered);
2469 + pr_debug("Added HEAD_OF_QUEUE for CDB: 0x%02x\n",
2470 + cmd->t_task_cdb[0]);
2471 + return false;
2472 + case TCM_ORDERED_TAG:
2473 +- atomic_inc_mb(&dev->dev_ordered_sync);
2474 ++ atomic_inc_mb(&dev->delayed_cmd_count);
2475 +
2476 + pr_debug("Added ORDERED for CDB: 0x%02x to ordered list\n",
2477 + cmd->t_task_cdb[0]);
2478 +-
2479 +- /*
2480 +- * Execute an ORDERED command if no other older commands
2481 +- * exist that need to be completed first.
2482 +- */
2483 +- if (!atomic_read(&dev->simple_cmds))
2484 +- return false;
2485 + break;
2486 + default:
2487 + /*
2488 + * For SIMPLE and UNTAGGED Task Attribute commands
2489 + */
2490 +- atomic_inc_mb(&dev->simple_cmds);
2491 ++ atomic_inc_mb(&dev->non_ordered);
2492 ++
2493 ++ if (atomic_read(&dev->delayed_cmd_count) == 0)
2494 ++ return false;
2495 + break;
2496 + }
2497 +
2498 +- if (atomic_read(&dev->dev_ordered_sync) == 0)
2499 +- return false;
2500 ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG) {
2501 ++ atomic_inc_mb(&dev->delayed_cmd_count);
2502 ++ /*
2503 ++ * We will account for this when we dequeue from the delayed
2504 ++ * list.
2505 ++ */
2506 ++ atomic_dec_mb(&dev->non_ordered);
2507 ++ }
2508 +
2509 + spin_lock(&dev->delayed_cmd_lock);
2510 + list_add_tail(&cmd->se_delayed_node, &dev->delayed_cmd_list);
2511 +@@ -1910,6 +1913,12 @@ static bool target_handle_task_attr(struct se_cmd *cmd)
2512 +
2513 + pr_debug("Added CDB: 0x%02x Task Attr: 0x%02x to delayed CMD listn",
2514 + cmd->t_task_cdb[0], cmd->sam_task_attr);
2515 ++ /*
2516 ++ * We may have no non ordered cmds when this function started or we
2517 ++ * could have raced with the last simple/head cmd completing, so kick
2518 ++ * the delayed handler here.
2519 ++ */
2520 ++ schedule_work(&dev->delayed_cmd_work);
2521 + return true;
2522 + }
2523 +
2524 +@@ -1960,29 +1969,48 @@ EXPORT_SYMBOL(target_execute_cmd);
2525 + * Process all commands up to the last received ORDERED task attribute which
2526 + * requires another blocking boundary
2527 + */
2528 +-static void target_restart_delayed_cmds(struct se_device *dev)
2529 ++void target_do_delayed_work(struct work_struct *work)
2530 + {
2531 +- for (;;) {
2532 ++ struct se_device *dev = container_of(work, struct se_device,
2533 ++ delayed_cmd_work);
2534 ++
2535 ++ spin_lock(&dev->delayed_cmd_lock);
2536 ++ while (!dev->ordered_sync_in_progress) {
2537 + struct se_cmd *cmd;
2538 +
2539 +- spin_lock(&dev->delayed_cmd_lock);
2540 +- if (list_empty(&dev->delayed_cmd_list)) {
2541 +- spin_unlock(&dev->delayed_cmd_lock);
2542 ++ if (list_empty(&dev->delayed_cmd_list))
2543 + break;
2544 +- }
2545 +
2546 + cmd = list_entry(dev->delayed_cmd_list.next,
2547 + struct se_cmd, se_delayed_node);
2548 ++
2549 ++ if (cmd->sam_task_attr == TCM_ORDERED_TAG) {
2550 ++ /*
2551 ++ * Check if we started with:
2552 ++ * [ordered] [simple] [ordered]
2553 ++ * and we are now at the last ordered so we have to wait
2554 ++ * for the simple cmd.
2555 ++ */
2556 ++ if (atomic_read(&dev->non_ordered) > 0)
2557 ++ break;
2558 ++
2559 ++ dev->ordered_sync_in_progress = true;
2560 ++ }
2561 ++
2562 + list_del(&cmd->se_delayed_node);
2563 ++ atomic_dec_mb(&dev->delayed_cmd_count);
2564 + spin_unlock(&dev->delayed_cmd_lock);
2565 +
2566 ++ if (cmd->sam_task_attr != TCM_ORDERED_TAG)
2567 ++ atomic_inc_mb(&dev->non_ordered);
2568 ++
2569 + cmd->transport_state |= CMD_T_SENT;
2570 +
2571 + __target_execute_cmd(cmd, true);
2572 +
2573 +- if (cmd->sam_task_attr == TCM_ORDERED_TAG)
2574 +- break;
2575 ++ spin_lock(&dev->delayed_cmd_lock);
2576 + }
2577 ++ spin_unlock(&dev->delayed_cmd_lock);
2578 + }
2579 +
2580 + /*
2581 +@@ -2000,16 +2028,19 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
2582 + goto restart;
2583 +
2584 + if (cmd->sam_task_attr == TCM_SIMPLE_TAG) {
2585 +- atomic_dec_mb(&dev->simple_cmds);
2586 ++ atomic_dec_mb(&dev->non_ordered);
2587 + dev->dev_cur_ordered_id++;
2588 + pr_debug("Incremented dev->dev_cur_ordered_id: %u for SIMPLE\n",
2589 + dev->dev_cur_ordered_id);
2590 + } else if (cmd->sam_task_attr == TCM_HEAD_TAG) {
2591 ++ atomic_dec_mb(&dev->non_ordered);
2592 + dev->dev_cur_ordered_id++;
2593 + pr_debug("Incremented dev_cur_ordered_id: %u for HEAD_OF_QUEUE\n",
2594 + dev->dev_cur_ordered_id);
2595 + } else if (cmd->sam_task_attr == TCM_ORDERED_TAG) {
2596 +- atomic_dec_mb(&dev->dev_ordered_sync);
2597 ++ spin_lock(&dev->delayed_cmd_lock);
2598 ++ dev->ordered_sync_in_progress = false;
2599 ++ spin_unlock(&dev->delayed_cmd_lock);
2600 +
2601 + dev->dev_cur_ordered_id++;
2602 + pr_debug("Incremented dev_cur_ordered_id: %u for ORDERED\n",
2603 +@@ -2018,7 +2049,8 @@ static void transport_complete_task_attr(struct se_cmd *cmd)
2604 + cmd->se_cmd_flags &= ~SCF_TASK_ATTR_SET;
2605 +
2606 + restart:
2607 +- target_restart_delayed_cmds(dev);
2608 ++ if (atomic_read(&dev->delayed_cmd_count) > 0)
2609 ++ schedule_work(&dev->delayed_cmd_work);
2610 + }
2611 +
2612 + static void transport_complete_qf(struct se_cmd *cmd)
2613 +diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
2614 +index 039837db65fcc..f3ed1eeaed4e1 100644
2615 +--- a/drivers/tty/serial/8250/8250_dw.c
2616 ++++ b/drivers/tty/serial/8250/8250_dw.c
2617 +@@ -607,7 +607,7 @@ static struct platform_driver dw8250_platform_driver = {
2618 + .name = "dw-apb-uart",
2619 + .pm = &dw8250_pm_ops,
2620 + .of_match_table = dw8250_of_match,
2621 +- .acpi_match_table = ACPI_PTR(dw8250_acpi_match),
2622 ++ .acpi_match_table = dw8250_acpi_match,
2623 + },
2624 + .probe = dw8250_probe,
2625 + .remove = dw8250_remove,
2626 +diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
2627 +index 4706df20191b1..832aec1f145f9 100644
2628 +--- a/drivers/tty/tty_buffer.c
2629 ++++ b/drivers/tty/tty_buffer.c
2630 +@@ -519,6 +519,9 @@ static void flush_to_ldisc(struct work_struct *work)
2631 + if (!count)
2632 + break;
2633 + head->read += count;
2634 ++
2635 ++ if (need_resched())
2636 ++ cond_resched();
2637 + }
2638 +
2639 + mutex_unlock(&buf->lock);
2640 +diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
2641 +index e104c99b3a1fc..9b3260a7cd2cc 100644
2642 +--- a/drivers/usb/chipidea/core.c
2643 ++++ b/drivers/usb/chipidea/core.c
2644 +@@ -518,7 +518,7 @@ int hw_device_reset(struct ci_hdrc *ci)
2645 + return 0;
2646 + }
2647 +
2648 +-static irqreturn_t ci_irq(int irq, void *data)
2649 ++static irqreturn_t ci_irq_handler(int irq, void *data)
2650 + {
2651 + struct ci_hdrc *ci = data;
2652 + irqreturn_t ret = IRQ_NONE;
2653 +@@ -571,6 +571,15 @@ static irqreturn_t ci_irq(int irq, void *data)
2654 + return ret;
2655 + }
2656 +
2657 ++static void ci_irq(struct ci_hdrc *ci)
2658 ++{
2659 ++ unsigned long flags;
2660 ++
2661 ++ local_irq_save(flags);
2662 ++ ci_irq_handler(ci->irq, ci);
2663 ++ local_irq_restore(flags);
2664 ++}
2665 ++
2666 + static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event,
2667 + void *ptr)
2668 + {
2669 +@@ -584,7 +593,7 @@ static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event,
2670 +
2671 + vbus->changed = true;
2672 +
2673 +- ci_irq(ci->irq, ci);
2674 ++ ci_irq(ci);
2675 + return NOTIFY_DONE;
2676 + }
2677 +
2678 +@@ -601,7 +610,7 @@ static int ci_id_notifier(struct notifier_block *nb, unsigned long event,
2679 +
2680 + id->changed = true;
2681 +
2682 +- ci_irq(ci->irq, ci);
2683 ++ ci_irq(ci);
2684 + return NOTIFY_DONE;
2685 + }
2686 +
2687 +@@ -1023,7 +1032,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
2688 + }
2689 +
2690 + platform_set_drvdata(pdev, ci);
2691 +- ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED,
2692 ++ ret = devm_request_irq(dev, ci->irq, ci_irq_handler, IRQF_SHARED,
2693 + ci->platdata->name, ci);
2694 + if (ret)
2695 + goto stop;
2696 +@@ -1138,11 +1147,11 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)
2697 +
2698 + if (!IS_ERR(cable_id->edev) && ci->is_otg &&
2699 + (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS))
2700 +- ci_irq(ci->irq, ci);
2701 ++ ci_irq(ci);
2702 +
2703 + if (!IS_ERR(cable_vbus->edev) && ci->is_otg &&
2704 + (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS))
2705 +- ci_irq(ci->irq, ci);
2706 ++ ci_irq(ci);
2707 + }
2708 +
2709 + static int ci_controller_resume(struct device *dev)
2710 +diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
2711 +index 97329ba5d3820..5cb3359cf126e 100644
2712 +--- a/drivers/usb/gadget/legacy/hid.c
2713 ++++ b/drivers/usb/gadget/legacy/hid.c
2714 +@@ -103,8 +103,10 @@ static int do_config(struct usb_configuration *c)
2715 +
2716 + list_for_each_entry(e, &hidg_func_list, node) {
2717 + e->f = usb_get_function(e->fi);
2718 +- if (IS_ERR(e->f))
2719 ++ if (IS_ERR(e->f)) {
2720 ++ status = PTR_ERR(e->f);
2721 + goto put;
2722 ++ }
2723 + status = usb_add_function(c, e->f);
2724 + if (status < 0) {
2725 + usb_put_function(e->f);
2726 +diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c
2727 +index 2f8a5fa28a802..f30e661129c29 100644
2728 +--- a/drivers/usb/host/max3421-hcd.c
2729 ++++ b/drivers/usb/host/max3421-hcd.c
2730 +@@ -121,8 +121,6 @@ struct max3421_hcd {
2731 +
2732 + struct task_struct *spi_thread;
2733 +
2734 +- struct max3421_hcd *next;
2735 +-
2736 + enum max3421_rh_state rh_state;
2737 + /* lower 16 bits contain port status, upper 16 bits the change mask: */
2738 + u32 port_status;
2739 +@@ -170,8 +168,6 @@ struct max3421_ep {
2740 + u8 retransmit; /* packet needs retransmission */
2741 + };
2742 +
2743 +-static struct max3421_hcd *max3421_hcd_list;
2744 +-
2745 + #define MAX3421_FIFO_SIZE 64
2746 +
2747 + #define MAX3421_SPI_DIR_RD 0 /* read register from MAX3421 */
2748 +@@ -1841,9 +1837,8 @@ max3421_probe(struct spi_device *spi)
2749 + }
2750 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
2751 + max3421_hcd = hcd_to_max3421(hcd);
2752 +- max3421_hcd->next = max3421_hcd_list;
2753 +- max3421_hcd_list = max3421_hcd;
2754 + INIT_LIST_HEAD(&max3421_hcd->ep_list);
2755 ++ spi_set_drvdata(spi, max3421_hcd);
2756 +
2757 + max3421_hcd->tx = kmalloc(sizeof(*max3421_hcd->tx), GFP_KERNEL);
2758 + if (!max3421_hcd->tx) {
2759 +@@ -1892,28 +1887,18 @@ error:
2760 + static int
2761 + max3421_remove(struct spi_device *spi)
2762 + {
2763 +- struct max3421_hcd *max3421_hcd = NULL, **prev;
2764 +- struct usb_hcd *hcd = NULL;
2765 ++ struct max3421_hcd *max3421_hcd;
2766 ++ struct usb_hcd *hcd;
2767 + unsigned long flags;
2768 +
2769 +- for (prev = &max3421_hcd_list; *prev; prev = &(*prev)->next) {
2770 +- max3421_hcd = *prev;
2771 +- hcd = max3421_to_hcd(max3421_hcd);
2772 +- if (hcd->self.controller == &spi->dev)
2773 +- break;
2774 +- }
2775 +- if (!max3421_hcd) {
2776 +- dev_err(&spi->dev, "no MAX3421 HCD found for SPI device %p\n",
2777 +- spi);
2778 +- return -ENODEV;
2779 +- }
2780 ++ max3421_hcd = spi_get_drvdata(spi);
2781 ++ hcd = max3421_to_hcd(max3421_hcd);
2782 +
2783 + usb_remove_hcd(hcd);
2784 +
2785 + spin_lock_irqsave(&max3421_hcd->lock, flags);
2786 +
2787 + kthread_stop(max3421_hcd->spi_thread);
2788 +- *prev = max3421_hcd->next;
2789 +
2790 + spin_unlock_irqrestore(&max3421_hcd->lock, flags);
2791 +
2792 +diff --git a/drivers/usb/host/ohci-tmio.c b/drivers/usb/host/ohci-tmio.c
2793 +index 9c9e97294c18d..4d42ae3b2fd6d 100644
2794 +--- a/drivers/usb/host/ohci-tmio.c
2795 ++++ b/drivers/usb/host/ohci-tmio.c
2796 +@@ -199,7 +199,7 @@ static int ohci_hcd_tmio_drv_probe(struct platform_device *dev)
2797 + if (usb_disabled())
2798 + return -ENODEV;
2799 +
2800 +- if (!cell)
2801 ++ if (!cell || !regs || !config || !sram)
2802 + return -EINVAL;
2803 +
2804 + if (irq < 0)
2805 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
2806 +index 6113b9da00c67..3ac5a4507aec2 100644
2807 +--- a/drivers/usb/host/xhci-hub.c
2808 ++++ b/drivers/usb/host/xhci-hub.c
2809 +@@ -156,7 +156,6 @@ static void xhci_common_hub_descriptor(struct xhci_hcd *xhci,
2810 + {
2811 + u16 temp;
2812 +
2813 +- desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.9 says 20ms max */
2814 + desc->bHubContrCurrent = 0;
2815 +
2816 + desc->bNbrPorts = ports;
2817 +@@ -190,6 +189,7 @@ static void xhci_usb2_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
2818 + desc->bDescriptorType = USB_DT_HUB;
2819 + temp = 1 + (ports / 8);
2820 + desc->bDescLength = USB_DT_HUB_NONVAR_SIZE + 2 * temp;
2821 ++ desc->bPwrOn2PwrGood = 10; /* xhci section 5.4.8 says 20ms */
2822 +
2823 + /* The Device Removable bits are reported on a byte granularity.
2824 + * If the port doesn't exist within that byte, the bit is set to 0.
2825 +@@ -240,6 +240,7 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
2826 + xhci_common_hub_descriptor(xhci, desc, ports);
2827 + desc->bDescriptorType = USB_DT_SS_HUB;
2828 + desc->bDescLength = USB_DT_SS_HUB_SIZE;
2829 ++ desc->bPwrOn2PwrGood = 50; /* usb 3.1 may fail if less than 100ms */
2830 +
2831 + /* header decode latency should be zero for roothubs,
2832 + * see section 4.23.5.2.
2833 +diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
2834 +index 83342e579233a..f4e9592c02d6c 100644
2835 +--- a/drivers/usb/misc/iowarrior.c
2836 ++++ b/drivers/usb/misc/iowarrior.c
2837 +@@ -96,10 +96,6 @@ struct iowarrior {
2838 + /* globals */
2839 + /*--------------*/
2840 +
2841 +-/*
2842 +- * USB spec identifies 5 second timeouts.
2843 +- */
2844 +-#define GET_TIMEOUT 5
2845 + #define USB_REQ_GET_REPORT 0x01
2846 + //#if 0
2847 + static int usb_get_report(struct usb_device *dev,
2848 +@@ -111,7 +107,7 @@ static int usb_get_report(struct usb_device *dev,
2849 + USB_DIR_IN | USB_TYPE_CLASS |
2850 + USB_RECIP_INTERFACE, (type << 8) + id,
2851 + inter->desc.bInterfaceNumber, buf, size,
2852 +- GET_TIMEOUT*HZ);
2853 ++ USB_CTRL_GET_TIMEOUT);
2854 + }
2855 + //#endif
2856 +
2857 +@@ -126,7 +122,7 @@ static int usb_set_report(struct usb_interface *intf, unsigned char type,
2858 + USB_TYPE_CLASS | USB_RECIP_INTERFACE,
2859 + (type << 8) + id,
2860 + intf->cur_altsetting->desc.bInterfaceNumber, buf,
2861 +- size, HZ);
2862 ++ size, 1000);
2863 + }
2864 +
2865 + /*---------------------*/
2866 +diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
2867 +index 85a57385958fd..f4297e5495958 100644
2868 +--- a/drivers/usb/musb/tusb6010.c
2869 ++++ b/drivers/usb/musb/tusb6010.c
2870 +@@ -1120,6 +1120,11 @@ static int tusb_musb_init(struct musb *musb)
2871 +
2872 + /* dma address for async dma */
2873 + mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2874 ++ if (!mem) {
2875 ++ pr_debug("no async dma resource?\n");
2876 ++ ret = -ENODEV;
2877 ++ goto done;
2878 ++ }
2879 + musb->async = mem->start;
2880 +
2881 + /* dma address for sync dma */
2882 +diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
2883 +index a79e9adf4e53b..b8f7dca97b984 100644
2884 +--- a/drivers/usb/serial/keyspan.c
2885 ++++ b/drivers/usb/serial/keyspan.c
2886 +@@ -2417,22 +2417,22 @@ static int keyspan_port_probe(struct usb_serial_port *port)
2887 + for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) {
2888 + p_priv->in_buffer[i] = kzalloc(IN_BUFLEN, GFP_KERNEL);
2889 + if (!p_priv->in_buffer[i])
2890 +- goto err_in_buffer;
2891 ++ goto err_free_in_buffer;
2892 + }
2893 +
2894 + for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) {
2895 + p_priv->out_buffer[i] = kzalloc(OUT_BUFLEN, GFP_KERNEL);
2896 + if (!p_priv->out_buffer[i])
2897 +- goto err_out_buffer;
2898 ++ goto err_free_out_buffer;
2899 + }
2900 +
2901 + p_priv->inack_buffer = kzalloc(INACK_BUFLEN, GFP_KERNEL);
2902 + if (!p_priv->inack_buffer)
2903 +- goto err_inack_buffer;
2904 ++ goto err_free_out_buffer;
2905 +
2906 + p_priv->outcont_buffer = kzalloc(OUTCONT_BUFLEN, GFP_KERNEL);
2907 + if (!p_priv->outcont_buffer)
2908 +- goto err_outcont_buffer;
2909 ++ goto err_free_inack_buffer;
2910 +
2911 + p_priv->device_details = d_details;
2912 +
2913 +@@ -2478,15 +2478,14 @@ static int keyspan_port_probe(struct usb_serial_port *port)
2914 +
2915 + return 0;
2916 +
2917 +-err_outcont_buffer:
2918 ++err_free_inack_buffer:
2919 + kfree(p_priv->inack_buffer);
2920 +-err_inack_buffer:
2921 ++err_free_out_buffer:
2922 + for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i)
2923 + kfree(p_priv->out_buffer[i]);
2924 +-err_out_buffer:
2925 ++err_free_in_buffer:
2926 + for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i)
2927 + kfree(p_priv->in_buffer[i]);
2928 +-err_in_buffer:
2929 + kfree(p_priv);
2930 +
2931 + return -ENOMEM;
2932 +diff --git a/drivers/video/console/sticon.c b/drivers/video/console/sticon.c
2933 +index 026fd12159332..9f856b4174628 100644
2934 +--- a/drivers/video/console/sticon.c
2935 ++++ b/drivers/video/console/sticon.c
2936 +@@ -316,13 +316,13 @@ static unsigned long sticon_getxy(struct vc_data *conp, unsigned long pos,
2937 + static u8 sticon_build_attr(struct vc_data *conp, u8 color, u8 intens,
2938 + u8 blink, u8 underline, u8 reverse, u8 italic)
2939 + {
2940 +- u8 attr = ((color & 0x70) >> 1) | ((color & 7));
2941 ++ u8 fg = color & 7;
2942 ++ u8 bg = (color & 0x70) >> 4;
2943 +
2944 +- if (reverse) {
2945 +- color = ((color >> 3) & 0x7) | ((color & 0x7) << 3);
2946 +- }
2947 +-
2948 +- return attr;
2949 ++ if (reverse)
2950 ++ return (fg << 3) | bg;
2951 ++ else
2952 ++ return (bg << 3) | fg;
2953 + }
2954 +
2955 + static void sticon_invert_region(struct vc_data *conp, u16 *p, int count)
2956 +diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
2957 +index 314b7eceb81c5..84a3778552eba 100644
2958 +--- a/drivers/video/fbdev/chipsfb.c
2959 ++++ b/drivers/video/fbdev/chipsfb.c
2960 +@@ -332,7 +332,7 @@ static struct fb_var_screeninfo chipsfb_var = {
2961 +
2962 + static void init_chips(struct fb_info *p, unsigned long addr)
2963 + {
2964 +- memset(p->screen_base, 0, 0x100000);
2965 ++ fb_memset(p->screen_base, 0, 0x100000);
2966 +
2967 + p->fix = chipsfb_fix;
2968 + p->fix.smem_start = addr;
2969 +diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
2970 +index 2b12ef019ae02..96bf71802eff5 100644
2971 +--- a/drivers/watchdog/f71808e_wdt.c
2972 ++++ b/drivers/watchdog/f71808e_wdt.c
2973 +@@ -225,15 +225,17 @@ static int watchdog_set_timeout(int timeout)
2974 +
2975 + mutex_lock(&watchdog.lock);
2976 +
2977 +- watchdog.timeout = timeout;
2978 + if (timeout > 0xff) {
2979 + watchdog.timer_val = DIV_ROUND_UP(timeout, 60);
2980 + watchdog.minutes_mode = true;
2981 ++ timeout = watchdog.timer_val * 60;
2982 + } else {
2983 + watchdog.timer_val = timeout;
2984 + watchdog.minutes_mode = false;
2985 + }
2986 +
2987 ++ watchdog.timeout = timeout;
2988 ++
2989 + mutex_unlock(&watchdog.lock);
2990 +
2991 + return 0;
2992 +diff --git a/drivers/xen/xen-pciback/conf_space_capability.c b/drivers/xen/xen-pciback/conf_space_capability.c
2993 +index b1a1d7de0894e..daa2e89a50fa3 100644
2994 +--- a/drivers/xen/xen-pciback/conf_space_capability.c
2995 ++++ b/drivers/xen/xen-pciback/conf_space_capability.c
2996 +@@ -159,7 +159,7 @@ static void *pm_ctrl_init(struct pci_dev *dev, int offset)
2997 + }
2998 +
2999 + out:
3000 +- return ERR_PTR(err);
3001 ++ return err ? ERR_PTR(err) : NULL;
3002 + }
3003 +
3004 + static const struct config_field caplist_pm[] = {
3005 +diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c
3006 +index 205d6b43cd7da..d096254d9acc7 100644
3007 +--- a/fs/btrfs/async-thread.c
3008 ++++ b/fs/btrfs/async-thread.c
3009 +@@ -261,6 +261,13 @@ static void run_ordered_work(struct __btrfs_workqueue *wq)
3010 + ordered_list);
3011 + if (!test_bit(WORK_DONE_BIT, &work->flags))
3012 + break;
3013 ++ /*
3014 ++ * Orders all subsequent loads after reading WORK_DONE_BIT,
3015 ++ * paired with the smp_mb__before_atomic in btrfs_work_helper
3016 ++ * this guarantees that the ordered function will see all
3017 ++ * updates from ordinary work function.
3018 ++ */
3019 ++ smp_rmb();
3020 +
3021 + /*
3022 + * we are going to call the ordered done function, but
3023 +@@ -310,6 +317,13 @@ static void normal_work_helper(struct btrfs_work *work)
3024 + thresh_exec_hook(wq);
3025 + work->func(work);
3026 + if (need_order) {
3027 ++ /*
3028 ++ * Ensures all memory accesses done in the work function are
3029 ++ * ordered before setting the WORK_DONE_BIT. Ensuring the thread
3030 ++ * which is going to executed the ordered work sees them.
3031 ++ * Pairs with the smp_rmb in run_ordered_work.
3032 ++ */
3033 ++ smp_mb__before_atomic();
3034 + set_bit(WORK_DONE_BIT, &work->flags);
3035 + run_ordered_work(wq);
3036 + }
3037 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
3038 +index ff4df17832196..51d432435e8a6 100644
3039 +--- a/fs/btrfs/tree-log.c
3040 ++++ b/fs/btrfs/tree-log.c
3041 +@@ -2207,7 +2207,9 @@ again:
3042 + else {
3043 + ret = find_dir_range(log, path, dirid, key_type,
3044 + &range_start, &range_end);
3045 +- if (ret != 0)
3046 ++ if (ret < 0)
3047 ++ goto out;
3048 ++ else if (ret > 0)
3049 + break;
3050 + }
3051 +
3052 +diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c
3053 +index 103788ecc28c1..0c2aabba1fdbb 100644
3054 +--- a/fs/jfs/jfs_mount.c
3055 ++++ b/fs/jfs/jfs_mount.c
3056 +@@ -93,14 +93,14 @@ int jfs_mount(struct super_block *sb)
3057 + * (initialize mount inode from the superblock)
3058 + */
3059 + if ((rc = chkSuper(sb))) {
3060 +- goto errout20;
3061 ++ goto out;
3062 + }
3063 +
3064 + ipaimap = diReadSpecial(sb, AGGREGATE_I, 0);
3065 + if (ipaimap == NULL) {
3066 + jfs_err("jfs_mount: Failed to read AGGREGATE_I");
3067 + rc = -EIO;
3068 +- goto errout20;
3069 ++ goto out;
3070 + }
3071 + sbi->ipaimap = ipaimap;
3072 +
3073 +@@ -111,7 +111,7 @@ int jfs_mount(struct super_block *sb)
3074 + */
3075 + if ((rc = diMount(ipaimap))) {
3076 + jfs_err("jfs_mount: diMount(ipaimap) failed w/rc = %d", rc);
3077 +- goto errout21;
3078 ++ goto err_ipaimap;
3079 + }
3080 +
3081 + /*
3082 +@@ -120,7 +120,7 @@ int jfs_mount(struct super_block *sb)
3083 + ipbmap = diReadSpecial(sb, BMAP_I, 0);
3084 + if (ipbmap == NULL) {
3085 + rc = -EIO;
3086 +- goto errout22;
3087 ++ goto err_umount_ipaimap;
3088 + }
3089 +
3090 + jfs_info("jfs_mount: ipbmap:0x%p", ipbmap);
3091 +@@ -132,7 +132,7 @@ int jfs_mount(struct super_block *sb)
3092 + */
3093 + if ((rc = dbMount(ipbmap))) {
3094 + jfs_err("jfs_mount: dbMount failed w/rc = %d", rc);
3095 +- goto errout22;
3096 ++ goto err_ipbmap;
3097 + }
3098 +
3099 + /*
3100 +@@ -151,7 +151,7 @@ int jfs_mount(struct super_block *sb)
3101 + if (!ipaimap2) {
3102 + jfs_err("jfs_mount: Failed to read AGGREGATE_I");
3103 + rc = -EIO;
3104 +- goto errout35;
3105 ++ goto err_umount_ipbmap;
3106 + }
3107 + sbi->ipaimap2 = ipaimap2;
3108 +
3109 +@@ -163,7 +163,7 @@ int jfs_mount(struct super_block *sb)
3110 + if ((rc = diMount(ipaimap2))) {
3111 + jfs_err("jfs_mount: diMount(ipaimap2) failed, rc = %d",
3112 + rc);
3113 +- goto errout35;
3114 ++ goto err_ipaimap2;
3115 + }
3116 + } else
3117 + /* Secondary aggregate inode table is not valid */
3118 +@@ -180,7 +180,7 @@ int jfs_mount(struct super_block *sb)
3119 + jfs_err("jfs_mount: Failed to read FILESYSTEM_I");
3120 + /* open fileset secondary inode allocation map */
3121 + rc = -EIO;
3122 +- goto errout40;
3123 ++ goto err_umount_ipaimap2;
3124 + }
3125 + jfs_info("jfs_mount: ipimap:0x%p", ipimap);
3126 +
3127 +@@ -190,41 +190,34 @@ int jfs_mount(struct super_block *sb)
3128 + /* initialize fileset inode allocation map */
3129 + if ((rc = diMount(ipimap))) {
3130 + jfs_err("jfs_mount: diMount failed w/rc = %d", rc);
3131 +- goto errout41;
3132 ++ goto err_ipimap;
3133 + }
3134 +
3135 +- goto out;
3136 ++ return rc;
3137 +
3138 + /*
3139 + * unwind on error
3140 + */
3141 +- errout41: /* close fileset inode allocation map inode */
3142 ++err_ipimap:
3143 ++ /* close fileset inode allocation map inode */
3144 + diFreeSpecial(ipimap);
3145 +-
3146 +- errout40: /* fileset closed */
3147 +-
3148 ++err_umount_ipaimap2:
3149 + /* close secondary aggregate inode allocation map */
3150 +- if (ipaimap2) {
3151 ++ if (ipaimap2)
3152 + diUnmount(ipaimap2, 1);
3153 ++err_ipaimap2:
3154 ++ /* close aggregate inodes */
3155 ++ if (ipaimap2)
3156 + diFreeSpecial(ipaimap2);
3157 +- }
3158 +-
3159 +- errout35:
3160 +-
3161 +- /* close aggregate block allocation map */
3162 ++err_umount_ipbmap: /* close aggregate block allocation map */
3163 + dbUnmount(ipbmap, 1);
3164 ++err_ipbmap: /* close aggregate inodes */
3165 + diFreeSpecial(ipbmap);
3166 +-
3167 +- errout22: /* close aggregate inode allocation map */
3168 +-
3169 ++err_umount_ipaimap: /* close aggregate inode allocation map */
3170 + diUnmount(ipaimap, 1);
3171 +-
3172 +- errout21: /* close aggregate inodes */
3173 ++err_ipaimap: /* close aggregate inodes */
3174 + diFreeSpecial(ipaimap);
3175 +- errout20: /* aggregate closed */
3176 +-
3177 +- out:
3178 +-
3179 ++out:
3180 + if (rc)
3181 + jfs_err("Mount JFS Failure: %d", rc);
3182 +
3183 +diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
3184 +index 0de92ad0ba79d..73c12b13fc3ee 100644
3185 +--- a/fs/ocfs2/file.c
3186 ++++ b/fs/ocfs2/file.c
3187 +@@ -490,10 +490,11 @@ int ocfs2_truncate_file(struct inode *inode,
3188 + * greater than page size, so we have to truncate them
3189 + * anyway.
3190 + */
3191 +- unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
3192 +- truncate_inode_pages(inode->i_mapping, new_i_size);
3193 +
3194 + if (OCFS2_I(inode)->ip_dyn_features & OCFS2_INLINE_DATA_FL) {
3195 ++ unmap_mapping_range(inode->i_mapping,
3196 ++ new_i_size + PAGE_SIZE - 1, 0, 1);
3197 ++ truncate_inode_pages(inode->i_mapping, new_i_size);
3198 + status = ocfs2_truncate_inline(inode, di_bh, new_i_size,
3199 + i_size_read(inode), 1);
3200 + if (status)
3201 +@@ -512,6 +513,9 @@ int ocfs2_truncate_file(struct inode *inode,
3202 + goto bail_unlock_sem;
3203 + }
3204 +
3205 ++ unmap_mapping_range(inode->i_mapping, new_i_size + PAGE_SIZE - 1, 0, 1);
3206 ++ truncate_inode_pages(inode->i_mapping, new_i_size);
3207 ++
3208 + status = ocfs2_commit_truncate(osb, inode, di_bh);
3209 + if (status < 0) {
3210 + mlog_errno(status);
3211 +diff --git a/fs/quota/quota_tree.c b/fs/quota/quota_tree.c
3212 +index 3069b11867194..4f21724a212bd 100644
3213 +--- a/fs/quota/quota_tree.c
3214 ++++ b/fs/quota/quota_tree.c
3215 +@@ -416,6 +416,7 @@ static int free_dqentry(struct qtree_mem_dqinfo *info, struct dquot *dquot,
3216 + quota_error(dquot->dq_sb, "Quota structure has offset to "
3217 + "other block (%u) than it should (%u)", blk,
3218 + (uint)(dquot->dq_off >> info->dqi_blocksize_bits));
3219 ++ ret = -EIO;
3220 + goto out_buf;
3221 + }
3222 + ret = read_blk(info, blk, buf);
3223 +@@ -481,6 +482,13 @@ static int remove_tree(struct qtree_mem_dqinfo *info, struct dquot *dquot,
3224 + goto out_buf;
3225 + }
3226 + newblk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
3227 ++ if (newblk < QT_TREEOFF || newblk >= info->dqi_blocks) {
3228 ++ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
3229 ++ newblk, info->dqi_blocks);
3230 ++ ret = -EUCLEAN;
3231 ++ goto out_buf;
3232 ++ }
3233 ++
3234 + if (depth == info->dqi_qtree_depth - 1) {
3235 + ret = free_dqentry(info, dquot, newblk);
3236 + newblk = 0;
3237 +@@ -580,6 +588,13 @@ static loff_t find_tree_dqentry(struct qtree_mem_dqinfo *info,
3238 + blk = le32_to_cpu(ref[get_index(info, dquot->dq_id, depth)]);
3239 + if (!blk) /* No reference? */
3240 + goto out_buf;
3241 ++ if (blk < QT_TREEOFF || blk >= info->dqi_blocks) {
3242 ++ quota_error(dquot->dq_sb, "Getting block too big (%u >= %u)",
3243 ++ blk, info->dqi_blocks);
3244 ++ ret = -EUCLEAN;
3245 ++ goto out_buf;
3246 ++ }
3247 ++
3248 + if (depth < info->dqi_qtree_depth - 1)
3249 + ret = find_tree_dqentry(info, dquot, blk, depth+1);
3250 + else
3251 +diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
3252 +index c66f2423e1f5c..6ccfd47157d37 100644
3253 +--- a/fs/tracefs/inode.c
3254 ++++ b/fs/tracefs/inode.c
3255 +@@ -429,7 +429,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
3256 + if (unlikely(!inode))
3257 + return failed_creating(dentry);
3258 +
3259 +- inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
3260 ++ /* Do not set bits for OTH */
3261 ++ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
3262 + inode->i_op = ops;
3263 + inode->i_fop = &simple_dir_operations;
3264 +
3265 +diff --git a/include/linux/libata.h b/include/linux/libata.h
3266 +index ae4a5a1ae3814..b8c06ef833315 100644
3267 +--- a/include/linux/libata.h
3268 ++++ b/include/linux/libata.h
3269 +@@ -406,7 +406,7 @@ enum {
3270 + /* This should match the actual table size of
3271 + * ata_eh_cmd_timeout_table in libata-eh.c.
3272 + */
3273 +- ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 6,
3274 ++ ATA_EH_CMD_TIMEOUT_TABLE_SIZE = 7,
3275 +
3276 + /* Horkage types. May be set by libata or controller on drives
3277 + (some horkage may be drive/controller pair dependent */
3278 +diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
3279 +index ec3a6bab29de3..169f4be3ce565 100644
3280 +--- a/include/linux/lsm_hooks.h
3281 ++++ b/include/linux/lsm_hooks.h
3282 +@@ -1121,22 +1121,22 @@
3283 + *
3284 + * @binder_set_context_mgr
3285 + * Check whether @mgr is allowed to be the binder context manager.
3286 +- * @mgr contains the task_struct for the task being registered.
3287 ++ * @mgr contains the struct cred for the current binder process.
3288 + * Return 0 if permission is granted.
3289 + * @binder_transaction
3290 + * Check whether @from is allowed to invoke a binder transaction call
3291 + * to @to.
3292 +- * @from contains the task_struct for the sending task.
3293 +- * @to contains the task_struct for the receiving task.
3294 +- * @binder_transfer_binder
3295 ++ * @from contains the struct cred for the sending process.
3296 ++ * @to contains the struct cred for the receiving process.
3297 ++ * @binder_transfer_binder:
3298 + * Check whether @from is allowed to transfer a binder reference to @to.
3299 +- * @from contains the task_struct for the sending task.
3300 +- * @to contains the task_struct for the receiving task.
3301 +- * @binder_transfer_file
3302 ++ * @from contains the struct cred for the sending process.
3303 ++ * @to contains the struct cred for the receiving process.
3304 ++ * @binder_transfer_file:
3305 + * Check whether @from is allowed to transfer @file to @to.
3306 +- * @from contains the task_struct for the sending task.
3307 ++ * @from contains the struct cred for the sending process.
3308 + * @file contains the struct file being transferred.
3309 +- * @to contains the task_struct for the receiving task.
3310 ++ * @to contains the struct cred for the receiving process.
3311 + *
3312 + * @ptrace_access_check:
3313 + * Check permission before allowing the current process to trace the
3314 +@@ -1301,13 +1301,13 @@
3315 + */
3316 +
3317 + union security_list_options {
3318 +- int (*binder_set_context_mgr)(struct task_struct *mgr);
3319 +- int (*binder_transaction)(struct task_struct *from,
3320 +- struct task_struct *to);
3321 +- int (*binder_transfer_binder)(struct task_struct *from,
3322 +- struct task_struct *to);
3323 +- int (*binder_transfer_file)(struct task_struct *from,
3324 +- struct task_struct *to,
3325 ++ int (*binder_set_context_mgr)(const struct cred *mgr);
3326 ++ int (*binder_transaction)(const struct cred *from,
3327 ++ const struct cred *to);
3328 ++ int (*binder_transfer_binder)(const struct cred *from,
3329 ++ const struct cred *to);
3330 ++ int (*binder_transfer_file)(const struct cred *from,
3331 ++ const struct cred *to,
3332 + struct file *file);
3333 +
3334 + int (*ptrace_access_check)(struct task_struct *child,
3335 +diff --git a/include/linux/security.h b/include/linux/security.h
3336 +index 2f4c1f7aa7db7..846c6d44d6bea 100644
3337 +--- a/include/linux/security.h
3338 ++++ b/include/linux/security.h
3339 +@@ -182,13 +182,13 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
3340 + extern int security_init(void);
3341 +
3342 + /* Security operations */
3343 +-int security_binder_set_context_mgr(struct task_struct *mgr);
3344 +-int security_binder_transaction(struct task_struct *from,
3345 +- struct task_struct *to);
3346 +-int security_binder_transfer_binder(struct task_struct *from,
3347 +- struct task_struct *to);
3348 +-int security_binder_transfer_file(struct task_struct *from,
3349 +- struct task_struct *to, struct file *file);
3350 ++int security_binder_set_context_mgr(const struct cred *mgr);
3351 ++int security_binder_transaction(const struct cred *from,
3352 ++ const struct cred *to);
3353 ++int security_binder_transfer_binder(const struct cred *from,
3354 ++ const struct cred *to);
3355 ++int security_binder_transfer_file(const struct cred *from,
3356 ++ const struct cred *to, struct file *file);
3357 + int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
3358 + int security_ptrace_traceme(struct task_struct *parent);
3359 + int security_capget(struct task_struct *target,
3360 +@@ -378,25 +378,25 @@ static inline int security_init(void)
3361 + return 0;
3362 + }
3363 +
3364 +-static inline int security_binder_set_context_mgr(struct task_struct *mgr)
3365 ++static inline int security_binder_set_context_mgr(const struct cred *mgr)
3366 + {
3367 + return 0;
3368 + }
3369 +
3370 +-static inline int security_binder_transaction(struct task_struct *from,
3371 +- struct task_struct *to)
3372 ++static inline int security_binder_transaction(const struct cred *from,
3373 ++ const struct cred *to)
3374 + {
3375 + return 0;
3376 + }
3377 +
3378 +-static inline int security_binder_transfer_binder(struct task_struct *from,
3379 +- struct task_struct *to)
3380 ++static inline int security_binder_transfer_binder(const struct cred *from,
3381 ++ const struct cred *to)
3382 + {
3383 + return 0;
3384 + }
3385 +
3386 +-static inline int security_binder_transfer_file(struct task_struct *from,
3387 +- struct task_struct *to,
3388 ++static inline int security_binder_transfer_file(const struct cred *from,
3389 ++ const struct cred *to,
3390 + struct file *file)
3391 + {
3392 + return 0;
3393 +diff --git a/include/net/llc.h b/include/net/llc.h
3394 +index 95e5ced4c1339..18dfd3e49a69f 100644
3395 +--- a/include/net/llc.h
3396 ++++ b/include/net/llc.h
3397 +@@ -72,7 +72,9 @@ struct llc_sap {
3398 + static inline
3399 + struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex)
3400 + {
3401 +- return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES];
3402 ++ u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS);
3403 ++
3404 ++ return &sap->sk_dev_hash[bucket];
3405 + }
3406 +
3407 + static inline
3408 +diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
3409 +index 5aa8e0e62e309..7b08d0c5b6624 100644
3410 +--- a/include/target/target_core_base.h
3411 ++++ b/include/target/target_core_base.h
3412 +@@ -787,8 +787,9 @@ struct se_device {
3413 + atomic_long_t read_bytes;
3414 + atomic_long_t write_bytes;
3415 + /* Active commands on this virtual SE device */
3416 +- atomic_t simple_cmds;
3417 +- atomic_t dev_ordered_sync;
3418 ++ atomic_t non_ordered;
3419 ++ bool ordered_sync_in_progress;
3420 ++ atomic_t delayed_cmd_count;
3421 + atomic_t dev_qf_count;
3422 + u32 export_count;
3423 + spinlock_t delayed_cmd_lock;
3424 +@@ -811,6 +812,7 @@ struct se_device {
3425 + struct list_head dev_tmr_list;
3426 + struct workqueue_struct *tmr_wq;
3427 + struct work_struct qf_work_queue;
3428 ++ struct work_struct delayed_cmd_work;
3429 + struct list_head delayed_cmd_list;
3430 + struct list_head state_list;
3431 + struct list_head qf_cmd_list;
3432 +diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
3433 +index eb3c786afa707..04bd75b0f1f29 100644
3434 +--- a/include/uapi/linux/pci_regs.h
3435 ++++ b/include/uapi/linux/pci_regs.h
3436 +@@ -488,6 +488,12 @@
3437 + #define PCI_EXP_DEVCTL_URRE 0x0008 /* Unsupported Request Reporting En. */
3438 + #define PCI_EXP_DEVCTL_RELAX_EN 0x0010 /* Enable relaxed ordering */
3439 + #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0 /* Max_Payload_Size */
3440 ++#define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000 /* 128 Bytes */
3441 ++#define PCI_EXP_DEVCTL_PAYLOAD_256B 0x0020 /* 256 Bytes */
3442 ++#define PCI_EXP_DEVCTL_PAYLOAD_512B 0x0040 /* 512 Bytes */
3443 ++#define PCI_EXP_DEVCTL_PAYLOAD_1024B 0x0060 /* 1024 Bytes */
3444 ++#define PCI_EXP_DEVCTL_PAYLOAD_2048B 0x0080 /* 2048 Bytes */
3445 ++#define PCI_EXP_DEVCTL_PAYLOAD_4096B 0x00a0 /* 4096 Bytes */
3446 + #define PCI_EXP_DEVCTL_EXT_TAG 0x0100 /* Extended Tag Field Enable */
3447 + #define PCI_EXP_DEVCTL_PHANTOM 0x0200 /* Phantom Functions Enable */
3448 + #define PCI_EXP_DEVCTL_AUX_PME 0x0400 /* Auxiliary Power PM Enable */
3449 +diff --git a/kernel/power/swap.c b/kernel/power/swap.c
3450 +index 160e1006640d5..a7630e7b22a5d 100644
3451 +--- a/kernel/power/swap.c
3452 ++++ b/kernel/power/swap.c
3453 +@@ -1519,9 +1519,10 @@ end:
3454 + int swsusp_check(void)
3455 + {
3456 + int error;
3457 ++ void *holder;
3458 +
3459 + hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device,
3460 +- FMODE_READ, NULL);
3461 ++ FMODE_READ | FMODE_EXCL, &holder);
3462 + if (!IS_ERR(hib_resume_bdev)) {
3463 + set_blocksize(hib_resume_bdev, PAGE_SIZE);
3464 + clear_page(swsusp_header);
3465 +@@ -1541,7 +1542,7 @@ int swsusp_check(void)
3466 +
3467 + put:
3468 + if (error)
3469 +- blkdev_put(hib_resume_bdev, FMODE_READ);
3470 ++ blkdev_put(hib_resume_bdev, FMODE_READ | FMODE_EXCL);
3471 + else
3472 + pr_debug("PM: Image signature found, resuming\n");
3473 + } else {
3474 +diff --git a/kernel/sched/core.c b/kernel/sched/core.c
3475 +index 4a0a754f24c87..69c6c740da11b 100644
3476 +--- a/kernel/sched/core.c
3477 ++++ b/kernel/sched/core.c
3478 +@@ -1885,6 +1885,9 @@ out:
3479 +
3480 + bool cpus_share_cache(int this_cpu, int that_cpu)
3481 + {
3482 ++ if (this_cpu == that_cpu)
3483 ++ return true;
3484 ++
3485 + return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
3486 + }
3487 + #endif /* CONFIG_SMP */
3488 +diff --git a/kernel/signal.c b/kernel/signal.c
3489 +index 6aa9ca45ebb1d..a699055ebfe8d 100644
3490 +--- a/kernel/signal.c
3491 ++++ b/kernel/signal.c
3492 +@@ -1823,16 +1823,6 @@ static inline int may_ptrace_stop(void)
3493 + return 1;
3494 + }
3495 +
3496 +-/*
3497 +- * Return non-zero if there is a SIGKILL that should be waking us up.
3498 +- * Called with the siglock held.
3499 +- */
3500 +-static int sigkill_pending(struct task_struct *tsk)
3501 +-{
3502 +- return sigismember(&tsk->pending.signal, SIGKILL) ||
3503 +- sigismember(&tsk->signal->shared_pending.signal, SIGKILL);
3504 +-}
3505 +-
3506 + /*
3507 + * This must be called with current->sighand->siglock held.
3508 + *
3509 +@@ -1858,15 +1848,10 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
3510 + * calling arch_ptrace_stop, so we must release it now.
3511 + * To preserve proper semantics, we must do this before
3512 + * any signal bookkeeping like checking group_stop_count.
3513 +- * Meanwhile, a SIGKILL could come in before we retake the
3514 +- * siglock. That must prevent us from sleeping in TASK_TRACED.
3515 +- * So after regaining the lock, we must check for SIGKILL.
3516 + */
3517 + spin_unlock_irq(&current->sighand->siglock);
3518 + arch_ptrace_stop(exit_code, info);
3519 + spin_lock_irq(&current->sighand->siglock);
3520 +- if (sigkill_pending(current))
3521 +- return;
3522 + }
3523 +
3524 + /*
3525 +@@ -1875,6 +1860,8 @@ static void ptrace_stop(int exit_code, int why, int clear_code, siginfo_t *info)
3526 + * Also, transition to TRACED and updates to ->jobctl should be
3527 + * atomic with respect to siglock and should be done after the arch
3528 + * hook as siglock is released and regrabbed across it.
3529 ++ * schedule() will not sleep if there is a pending signal that
3530 ++ * can awaken the task.
3531 + */
3532 + set_current_state(TASK_TRACED);
3533 +
3534 +diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
3535 +index 25d59a95bd668..abea25310ac73 100644
3536 +--- a/lib/decompress_unxz.c
3537 ++++ b/lib/decompress_unxz.c
3538 +@@ -167,7 +167,7 @@
3539 + * memeq and memzero are not used much and any remotely sane implementation
3540 + * is fast enough. memcpy/memmove speed matters in multi-call mode, but
3541 + * the kernel image is decompressed in single-call mode, in which only
3542 +- * memcpy speed can matter and only if there is a lot of uncompressible data
3543 ++ * memmove speed can matter and only if there is a lot of uncompressible data
3544 + * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the
3545 + * functions below should just be kept small; it's probably not worth
3546 + * optimizing for speed.
3547 +diff --git a/lib/xz/xz_dec_lzma2.c b/lib/xz/xz_dec_lzma2.c
3548 +index 08c3c80499983..2c5197d6b944d 100644
3549 +--- a/lib/xz/xz_dec_lzma2.c
3550 ++++ b/lib/xz/xz_dec_lzma2.c
3551 +@@ -387,7 +387,14 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
3552 +
3553 + *left -= copy_size;
3554 +
3555 +- memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
3556 ++ /*
3557 ++ * If doing in-place decompression in single-call mode and the
3558 ++ * uncompressed size of the file is larger than the caller
3559 ++ * thought (i.e. it is invalid input!), the buffers below may
3560 ++ * overlap and cause undefined behavior with memcpy().
3561 ++ * With valid inputs memcpy() would be fine here.
3562 ++ */
3563 ++ memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
3564 + dict->pos += copy_size;
3565 +
3566 + if (dict->full < dict->pos)
3567 +@@ -397,7 +404,11 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
3568 + if (dict->pos == dict->end)
3569 + dict->pos = 0;
3570 +
3571 +- memcpy(b->out + b->out_pos, b->in + b->in_pos,
3572 ++ /*
3573 ++ * Like above but for multi-call mode: use memmove()
3574 ++ * to avoid undefined behavior with invalid input.
3575 ++ */
3576 ++ memmove(b->out + b->out_pos, b->in + b->in_pos,
3577 + copy_size);
3578 + }
3579 +
3580 +@@ -421,6 +432,12 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
3581 + if (dict->pos == dict->end)
3582 + dict->pos = 0;
3583 +
3584 ++ /*
3585 ++ * These buffers cannot overlap even if doing in-place
3586 ++ * decompression because in multi-call mode dict->buf
3587 ++ * has been allocated by us in this file; it's not
3588 ++ * provided by the caller like in single-call mode.
3589 ++ */
3590 + memcpy(b->out + b->out_pos, dict->buf + dict->start,
3591 + copy_size);
3592 + }
3593 +diff --git a/lib/xz/xz_dec_stream.c b/lib/xz/xz_dec_stream.c
3594 +index ac809b1e64f78..9e5b9ab537fea 100644
3595 +--- a/lib/xz/xz_dec_stream.c
3596 ++++ b/lib/xz/xz_dec_stream.c
3597 +@@ -402,12 +402,12 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)
3598 + * we will accept other check types too, but then the check won't
3599 + * be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given.
3600 + */
3601 ++ if (s->temp.buf[HEADER_MAGIC_SIZE + 1] > XZ_CHECK_MAX)
3602 ++ return XZ_OPTIONS_ERROR;
3603 ++
3604 + s->check_type = s->temp.buf[HEADER_MAGIC_SIZE + 1];
3605 +
3606 + #ifdef XZ_DEC_ANY_CHECK
3607 +- if (s->check_type > XZ_CHECK_MAX)
3608 +- return XZ_OPTIONS_ERROR;
3609 +-
3610 + if (s->check_type > XZ_CHECK_CRC32)
3611 + return XZ_UNSUPPORTED_CHECK;
3612 + #else
3613 +diff --git a/mm/oom_kill.c b/mm/oom_kill.c
3614 +index bc781cdc0d044..a35729ef93d39 100644
3615 +--- a/mm/oom_kill.c
3616 ++++ b/mm/oom_kill.c
3617 +@@ -761,6 +761,9 @@ void pagefault_out_of_memory(void)
3618 + if (mem_cgroup_oom_synchronize(true))
3619 + return;
3620 +
3621 ++ if (fatal_signal_pending(current))
3622 ++ return;
3623 ++
3624 + if (!mutex_trylock(&oom_lock))
3625 + return;
3626 +
3627 +diff --git a/mm/slab.h b/mm/slab.h
3628 +index 7b60871979976..b0131504b7ee3 100644
3629 +--- a/mm/slab.h
3630 ++++ b/mm/slab.h
3631 +@@ -133,7 +133,7 @@ static inline unsigned long kmem_cache_flags(unsigned long object_size,
3632 + #define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE | SLAB_RECLAIM_ACCOUNT | \
3633 + SLAB_TEMPORARY | SLAB_NOTRACK)
3634 + #else
3635 +-#define SLAB_CACHE_FLAGS (0)
3636 ++#define SLAB_CACHE_FLAGS (SLAB_NOLEAKTRACE)
3637 + #endif
3638 +
3639 + #define CACHE_CREATE_MASK (SLAB_CORE_FLAGS | SLAB_DEBUG_FLAGS | SLAB_CACHE_FLAGS)
3640 +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
3641 +index caea5bb38d4b0..6f8d2fe114f65 100644
3642 +--- a/net/batman-adv/bat_iv_ogm.c
3643 ++++ b/net/batman-adv/bat_iv_ogm.c
3644 +@@ -526,8 +526,10 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet)
3645 + if (WARN_ON(!forw_packet->if_outgoing))
3646 + goto out;
3647 +
3648 +- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface))
3649 ++ if (forw_packet->if_outgoing->soft_iface != soft_iface) {
3650 ++ pr_warn("%s: soft interface switch for queued OGM\n", __func__);
3651 + goto out;
3652 ++ }
3653 +
3654 + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE)
3655 + goto out;
3656 +diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
3657 +index 1267cbb1a329a..355a18d373e66 100644
3658 +--- a/net/batman-adv/bridge_loop_avoidance.c
3659 ++++ b/net/batman-adv/bridge_loop_avoidance.c
3660 +@@ -1346,10 +1346,14 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
3661 + return 0;
3662 +
3663 + bat_priv->bla.claim_hash = batadv_hash_new(128);
3664 +- bat_priv->bla.backbone_hash = batadv_hash_new(32);
3665 ++ if (!bat_priv->bla.claim_hash)
3666 ++ return -ENOMEM;
3667 +
3668 +- if (!bat_priv->bla.claim_hash || !bat_priv->bla.backbone_hash)
3669 ++ bat_priv->bla.backbone_hash = batadv_hash_new(32);
3670 ++ if (!bat_priv->bla.backbone_hash) {
3671 ++ batadv_hash_destroy(bat_priv->bla.claim_hash);
3672 + return -ENOMEM;
3673 ++ }
3674 +
3675 + batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
3676 + &batadv_claim_hash_lock_class_key);
3677 +@@ -1366,31 +1370,32 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
3678 + }
3679 +
3680 + /**
3681 +- * batadv_bla_check_bcast_duplist
3682 ++ * batadv_bla_check_duplist() - Check if a frame is in the broadcast dup.
3683 + * @bat_priv: the bat priv with all the soft interface information
3684 +- * @skb: contains the bcast_packet to be checked
3685 ++ * @skb: contains the multicast packet to be checked
3686 ++ * @payload_ptr: pointer to position inside the head buffer of the skb
3687 ++ * marking the start of the data to be CRC'ed
3688 ++ * @orig: originator mac address, NULL if unknown
3689 + *
3690 +- * check if it is on our broadcast list. Another gateway might
3691 +- * have sent the same packet because it is connected to the same backbone,
3692 +- * so we have to remove this duplicate.
3693 ++ * Check if it is on our broadcast list. Another gateway might have sent the
3694 ++ * same packet because it is connected to the same backbone, so we have to
3695 ++ * remove this duplicate.
3696 + *
3697 + * This is performed by checking the CRC, which will tell us
3698 + * with a good chance that it is the same packet. If it is furthermore
3699 + * sent by another host, drop it. We allow equal packets from
3700 + * the same host however as this might be intended.
3701 + */
3702 +-int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
3703 +- struct sk_buff *skb)
3704 ++static int batadv_bla_check_duplist(struct batadv_priv *bat_priv,
3705 ++ struct sk_buff *skb, u8 *payload_ptr,
3706 ++ const u8 *orig)
3707 + {
3708 + int i, curr, ret = 0;
3709 + __be32 crc;
3710 +- struct batadv_bcast_packet *bcast_packet;
3711 + struct batadv_bcast_duplist_entry *entry;
3712 +
3713 +- bcast_packet = (struct batadv_bcast_packet *)skb->data;
3714 +-
3715 + /* calculate the crc ... */
3716 +- crc = batadv_skb_crc32(skb, (u8 *)(bcast_packet + 1));
3717 ++ crc = batadv_skb_crc32(skb, payload_ptr);
3718 +
3719 + spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
3720 +
3721 +@@ -1409,8 +1414,21 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
3722 + if (entry->crc != crc)
3723 + continue;
3724 +
3725 +- if (batadv_compare_eth(entry->orig, bcast_packet->orig))
3726 +- continue;
3727 ++ /* are the originators both known and not anonymous? */
3728 ++ if (orig && !is_zero_ether_addr(orig) &&
3729 ++ !is_zero_ether_addr(entry->orig)) {
3730 ++ /* If known, check if the new frame came from
3731 ++ * the same originator:
3732 ++ * We are safe to take identical frames from the
3733 ++ * same orig, if known, as multiplications in
3734 ++ * the mesh are detected via the (orig, seqno) pair.
3735 ++ * So we can be a bit more liberal here and allow
3736 ++ * identical frames from the same orig which the source
3737 ++ * host might have sent multiple times on purpose.
3738 ++ */
3739 ++ if (batadv_compare_eth(entry->orig, orig))
3740 ++ continue;
3741 ++ }
3742 +
3743 + /* this entry seems to match: same crc, not too old,
3744 + * and from another gw. therefore return 1 to forbid it.
3745 +@@ -1426,7 +1444,14 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
3746 + entry = &bat_priv->bla.bcast_duplist[curr];
3747 + entry->crc = crc;
3748 + entry->entrytime = jiffies;
3749 +- ether_addr_copy(entry->orig, bcast_packet->orig);
3750 ++
3751 ++ /* known originator */
3752 ++ if (orig)
3753 ++ ether_addr_copy(entry->orig, orig);
3754 ++ /* anonymous originator */
3755 ++ else
3756 ++ eth_zero_addr(entry->orig);
3757 ++
3758 + bat_priv->bla.bcast_duplist_curr = curr;
3759 +
3760 + out:
3761 +@@ -1435,6 +1460,48 @@ out:
3762 + return ret;
3763 + }
3764 +
3765 ++/**
3766 ++ * batadv_bla_check_ucast_duplist() - Check if a frame is in the broadcast dup.
3767 ++ * @bat_priv: the bat priv with all the soft interface information
3768 ++ * @skb: contains the multicast packet to be checked, decapsulated from a
3769 ++ * unicast_packet
3770 ++ *
3771 ++ * Check if it is on our broadcast list. Another gateway might have sent the
3772 ++ * same packet because it is connected to the same backbone, so we have to
3773 ++ * remove this duplicate.
3774 ++ *
3775 ++ * Return: true if a packet is in the duplicate list, false otherwise.
3776 ++ */
3777 ++static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv,
3778 ++ struct sk_buff *skb)
3779 ++{
3780 ++ return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, NULL);
3781 ++}
3782 ++
3783 ++/**
3784 ++ * batadv_bla_check_bcast_duplist() - Check if a frame is in the broadcast dup.
3785 ++ * @bat_priv: the bat priv with all the soft interface information
3786 ++ * @skb: contains the bcast_packet to be checked
3787 ++ *
3788 ++ * Check if it is on our broadcast list. Another gateway might have sent the
3789 ++ * same packet because it is connected to the same backbone, so we have to
3790 ++ * remove this duplicate.
3791 ++ *
3792 ++ * Return: true if a packet is in the duplicate list, false otherwise.
3793 ++ */
3794 ++int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
3795 ++ struct sk_buff *skb)
3796 ++{
3797 ++ struct batadv_bcast_packet *bcast_packet;
3798 ++ u8 *payload_ptr;
3799 ++
3800 ++ bcast_packet = (struct batadv_bcast_packet *)skb->data;
3801 ++ payload_ptr = (u8 *)(bcast_packet + 1);
3802 ++
3803 ++ return batadv_bla_check_duplist(bat_priv, skb, payload_ptr,
3804 ++ bcast_packet->orig);
3805 ++}
3806 ++
3807 + /**
3808 + * batadv_bla_is_backbone_gw_orig
3809 + * @bat_priv: the bat priv with all the soft interface information
3810 +@@ -1538,7 +1605,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
3811 + * @bat_priv: the bat priv with all the soft interface information
3812 + * @skb: the frame to be checked
3813 + * @vid: the VLAN ID of the frame
3814 +- * @is_bcast: the packet came in a broadcast packet type.
3815 ++ * @packet_type: the batman packet type this frame came in
3816 + *
3817 + * bla_rx avoidance checks if:
3818 + * * we have to race for a claim
3819 +@@ -1549,7 +1616,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv)
3820 + * process the skb.
3821 + */
3822 + int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
3823 +- unsigned short vid, bool is_bcast)
3824 ++ unsigned short vid, int packet_type)
3825 + {
3826 + struct batadv_bla_backbone_gw *backbone_gw;
3827 + struct ethhdr *ethhdr;
3828 +@@ -1568,9 +1635,32 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
3829 + goto allow;
3830 +
3831 + if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
3832 +- /* don't allow broadcasts while requests are in flight */
3833 +- if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast)
3834 +- goto handled;
3835 ++ /* don't allow multicast packets while requests are in flight */
3836 ++ if (is_multicast_ether_addr(ethhdr->h_dest))
3837 ++ /* Both broadcast flooding or multicast-via-unicasts
3838 ++ * delivery might send to multiple backbone gateways
3839 ++ * sharing the same LAN and therefore need to coordinate
3840 ++ * which backbone gateway forwards into the LAN,
3841 ++ * by claiming the payload source address.
3842 ++ *
3843 ++ * Broadcast flooding and multicast-via-unicasts
3844 ++ * delivery use the following two batman packet types.
3845 ++ * Note: explicitly exclude BATADV_UNICAST_4ADDR,
3846 ++ * as the DHCP gateway feature will send explicitly
3847 ++ * to only one BLA gateway, so the claiming process
3848 ++ * should be avoided there.
3849 ++ */
3850 ++ if (packet_type == BATADV_BCAST ||
3851 ++ packet_type == BATADV_UNICAST)
3852 ++ goto handled;
3853 ++
3854 ++ /* potential duplicates from foreign BLA backbone gateways via
3855 ++ * multicast-in-unicast packets
3856 ++ */
3857 ++ if (is_multicast_ether_addr(ethhdr->h_dest) &&
3858 ++ packet_type == BATADV_UNICAST &&
3859 ++ batadv_bla_check_ucast_duplist(bat_priv, skb))
3860 ++ goto handled;
3861 +
3862 + ether_addr_copy(search_claim.addr, ethhdr->h_source);
3863 + search_claim.vid = vid;
3864 +@@ -1598,13 +1688,14 @@ int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
3865 + goto allow;
3866 + }
3867 +
3868 +- /* if it is a broadcast ... */
3869 +- if (is_multicast_ether_addr(ethhdr->h_dest) && is_bcast) {
3870 ++ /* if it is a multicast ... */
3871 ++ if (is_multicast_ether_addr(ethhdr->h_dest) &&
3872 ++ (packet_type == BATADV_BCAST || packet_type == BATADV_UNICAST)) {
3873 + /* ... drop it. the responsible gateway is in charge.
3874 + *
3875 +- * We need to check is_bcast because with the gateway
3876 ++ * We need to check packet type because with the gateway
3877 + * feature, broadcasts (like DHCP requests) may be sent
3878 +- * using a unicast packet type.
3879 ++ * using a unicast 4 address packet type. See comment above.
3880 + */
3881 + goto handled;
3882 + } else {
3883 +diff --git a/net/batman-adv/bridge_loop_avoidance.h b/net/batman-adv/bridge_loop_avoidance.h
3884 +index 025152b342823..d1553c46df8c7 100644
3885 +--- a/net/batman-adv/bridge_loop_avoidance.h
3886 ++++ b/net/batman-adv/bridge_loop_avoidance.h
3887 +@@ -27,7 +27,7 @@ struct sk_buff;
3888 +
3889 + #ifdef CONFIG_BATMAN_ADV_BLA
3890 + int batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
3891 +- unsigned short vid, bool is_bcast);
3892 ++ unsigned short vid, int packet_type);
3893 + int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
3894 + unsigned short vid);
3895 + int batadv_bla_is_backbone_gw(struct sk_buff *skb,
3896 +@@ -50,7 +50,7 @@ void batadv_bla_free(struct batadv_priv *bat_priv);
3897 +
3898 + static inline int batadv_bla_rx(struct batadv_priv *bat_priv,
3899 + struct sk_buff *skb, unsigned short vid,
3900 +- bool is_bcast)
3901 ++ int packet_type)
3902 + {
3903 + return 0;
3904 + }
3905 +diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c
3906 +index b2ef03a3a2d49..b905763dc2e74 100644
3907 +--- a/net/batman-adv/debugfs.c
3908 ++++ b/net/batman-adv/debugfs.c
3909 +@@ -214,6 +214,7 @@ static const struct file_operations batadv_log_fops = {
3910 + .read = batadv_log_read,
3911 + .poll = batadv_log_poll,
3912 + .llseek = no_llseek,
3913 ++ .owner = THIS_MODULE,
3914 + };
3915 +
3916 + static int batadv_debug_log_setup(struct batadv_priv *bat_priv)
3917 +diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
3918 +index 9751b207b01f6..371f50804fc2a 100644
3919 +--- a/net/batman-adv/fragmentation.c
3920 ++++ b/net/batman-adv/fragmentation.c
3921 +@@ -394,9 +394,10 @@ out:
3922 +
3923 + /**
3924 + * batadv_frag_create - create a fragment from skb
3925 ++ * @net_dev: outgoing device for fragment
3926 + * @skb: skb to create fragment from
3927 + * @frag_head: header to use in new fragment
3928 +- * @mtu: size of new fragment
3929 ++ * @fragment_size: size of new fragment
3930 + *
3931 + * Split the passed skb into two fragments: A new one with size matching the
3932 + * passed mtu and the old one with the rest. The new skb contains data from the
3933 +@@ -404,22 +405,25 @@ out:
3934 + *
3935 + * Returns the new fragment, NULL on error.
3936 + */
3937 +-static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
3938 ++static struct sk_buff *batadv_frag_create(struct net_device *net_dev,
3939 ++ struct sk_buff *skb,
3940 + struct batadv_frag_packet *frag_head,
3941 +- unsigned int mtu)
3942 ++ unsigned int fragment_size)
3943 + {
3944 ++ unsigned int ll_reserved = LL_RESERVED_SPACE(net_dev);
3945 ++ unsigned int tailroom = net_dev->needed_tailroom;
3946 + struct sk_buff *skb_fragment;
3947 + unsigned header_size = sizeof(*frag_head);
3948 +- unsigned fragment_size = mtu - header_size;
3949 ++ unsigned mtu = fragment_size + header_size;
3950 +
3951 +- skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN);
3952 ++ skb_fragment = dev_alloc_skb(ll_reserved + mtu + tailroom);
3953 + if (!skb_fragment)
3954 + goto err;
3955 +
3956 + skb->priority = TC_PRIO_CONTROL;
3957 +
3958 + /* Eat the last mtu-bytes of the skb */
3959 +- skb_reserve(skb_fragment, header_size + ETH_HLEN);
3960 ++ skb_reserve(skb_fragment, ll_reserved + header_size);
3961 + skb_split(skb, skb_fragment, skb->len - fragment_size);
3962 +
3963 + /* Add the header */
3964 +@@ -442,13 +446,14 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
3965 + struct batadv_orig_node *orig_node,
3966 + struct batadv_neigh_node *neigh_node)
3967 + {
3968 ++ struct net_device *net_dev = neigh_node->if_incoming->net_dev;
3969 + struct batadv_priv *bat_priv;
3970 + struct batadv_hard_iface *primary_if = NULL;
3971 + struct batadv_frag_packet frag_header;
3972 + struct sk_buff *skb_fragment;
3973 +- unsigned mtu = neigh_node->if_incoming->net_dev->mtu;
3974 ++ unsigned mtu = net_dev->mtu;
3975 + unsigned header_size = sizeof(frag_header);
3976 +- unsigned max_fragment_size, max_packet_size;
3977 ++ unsigned max_fragment_size, num_fragments;
3978 + bool ret = false;
3979 +
3980 + /* To avoid merge and refragmentation at next-hops we never send
3981 +@@ -456,10 +461,15 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
3982 + */
3983 + mtu = min_t(unsigned, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
3984 + max_fragment_size = mtu - header_size;
3985 +- max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS;
3986 ++
3987 ++ if (skb->len == 0 || max_fragment_size == 0)
3988 ++ goto out_err;
3989 ++
3990 ++ num_fragments = (skb->len - 1) / max_fragment_size + 1;
3991 ++ max_fragment_size = (skb->len - 1) / num_fragments + 1;
3992 +
3993 + /* Don't even try to fragment, if we need more than 16 fragments */
3994 +- if (skb->len > max_packet_size)
3995 ++ if (num_fragments > BATADV_FRAG_MAX_FRAGMENTS)
3996 + goto out_err;
3997 +
3998 + bat_priv = orig_node->bat_priv;
3999 +@@ -484,7 +494,8 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
4000 + if (frag_header.no == BATADV_FRAG_MAX_FRAGMENTS - 1)
4001 + goto out_err;
4002 +
4003 +- skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
4004 ++ skb_fragment = batadv_frag_create(net_dev, skb, &frag_header,
4005 ++ max_fragment_size);
4006 + if (!skb_fragment)
4007 + goto out_err;
4008 +
4009 +@@ -496,11 +507,13 @@ bool batadv_frag_send_packet(struct sk_buff *skb,
4010 + frag_header.no++;
4011 + }
4012 +
4013 +- /* Make room for the fragment header. */
4014 +- if (batadv_skb_head_push(skb, header_size) < 0 ||
4015 +- pskb_expand_head(skb, header_size + ETH_HLEN, 0, GFP_ATOMIC) < 0)
4016 ++ /* make sure that there is at least enough head for the fragmentation
4017 ++ * and ethernet headers
4018 ++ */
4019 ++ if (skb_cow_head(skb, ETH_HLEN + header_size) < 0)
4020 + goto out_err;
4021 +
4022 ++ skb_push(skb, header_size);
4023 + memcpy(skb->data, &frag_header, header_size);
4024 +
4025 + /* Send the last fragment */
4026 +diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
4027 +index c59bbc3277632..0bd7c9e6c9a0d 100644
4028 +--- a/net/batman-adv/hard-interface.c
4029 ++++ b/net/batman-adv/hard-interface.c
4030 +@@ -316,6 +316,9 @@ static void batadv_hardif_recalc_extra_skbroom(struct net_device *soft_iface)
4031 + needed_headroom = lower_headroom + (lower_header_len - ETH_HLEN);
4032 + needed_headroom += batadv_max_header_len();
4033 +
4034 ++ /* fragmentation headers don't strip the unicast/... header */
4035 ++ needed_headroom += sizeof(struct batadv_frag_packet);
4036 ++
4037 + soft_iface->needed_headroom = needed_headroom;
4038 + soft_iface->needed_tailroom = lower_tailroom;
4039 + }
4040 +diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c
4041 +index 88cea5154113d..8ba7b86579d42 100644
4042 +--- a/net/batman-adv/main.c
4043 ++++ b/net/batman-adv/main.c
4044 +@@ -159,24 +159,34 @@ int batadv_mesh_init(struct net_device *soft_iface)
4045 + INIT_HLIST_HEAD(&bat_priv->softif_vlan_list);
4046 +
4047 + ret = batadv_originator_init(bat_priv);
4048 +- if (ret < 0)
4049 +- goto err;
4050 ++ if (ret < 0) {
4051 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
4052 ++ goto err_orig;
4053 ++ }
4054 +
4055 + ret = batadv_tt_init(bat_priv);
4056 +- if (ret < 0)
4057 +- goto err;
4058 ++ if (ret < 0) {
4059 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
4060 ++ goto err_tt;
4061 ++ }
4062 +
4063 + ret = batadv_bla_init(bat_priv);
4064 +- if (ret < 0)
4065 +- goto err;
4066 ++ if (ret < 0) {
4067 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
4068 ++ goto err_bla;
4069 ++ }
4070 +
4071 + ret = batadv_dat_init(bat_priv);
4072 +- if (ret < 0)
4073 +- goto err;
4074 ++ if (ret < 0) {
4075 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
4076 ++ goto err_dat;
4077 ++ }
4078 +
4079 + ret = batadv_nc_mesh_init(bat_priv);
4080 +- if (ret < 0)
4081 +- goto err;
4082 ++ if (ret < 0) {
4083 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
4084 ++ goto err_nc;
4085 ++ }
4086 +
4087 + batadv_gw_init(bat_priv);
4088 + batadv_mcast_init(bat_priv);
4089 +@@ -186,8 +196,18 @@ int batadv_mesh_init(struct net_device *soft_iface)
4090 +
4091 + return 0;
4092 +
4093 +-err:
4094 +- batadv_mesh_free(soft_iface);
4095 ++err_nc:
4096 ++ batadv_dat_free(bat_priv);
4097 ++err_dat:
4098 ++ batadv_bla_free(bat_priv);
4099 ++err_bla:
4100 ++ batadv_tt_free(bat_priv);
4101 ++err_tt:
4102 ++ batadv_originator_free(bat_priv);
4103 ++err_orig:
4104 ++ batadv_purge_outstanding_packets(bat_priv, NULL);
4105 ++ atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
4106 ++
4107 + return ret;
4108 + }
4109 +
4110 +diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c
4111 +index 8aa2d65df86f3..44965f71ad739 100644
4112 +--- a/net/batman-adv/multicast.c
4113 ++++ b/net/batman-adv/multicast.c
4114 +@@ -44,7 +44,9 @@
4115 + #include <net/addrconf.h>
4116 + #include <net/ipv6.h>
4117 +
4118 ++#include "bridge_loop_avoidance.h"
4119 + #include "packet.h"
4120 ++#include "send.h"
4121 + #include "translation-table.h"
4122 +
4123 + /**
4124 +@@ -805,6 +807,35 @@ void batadv_mcast_free(struct batadv_priv *bat_priv)
4125 + batadv_mcast_mla_tt_retract(bat_priv, NULL);
4126 + }
4127 +
4128 ++/**
4129 ++ * batadv_mcast_forw_send_orig() - send a multicast packet to an originator
4130 ++ * @bat_priv: the bat priv with all the soft interface information
4131 ++ * @skb: the multicast packet to send
4132 ++ * @vid: the vlan identifier
4133 ++ * @orig_node: the originator to send the packet to
4134 ++ *
4135 ++ * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
4136 ++ */
4137 ++int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
4138 ++ struct sk_buff *skb,
4139 ++ unsigned short vid,
4140 ++ struct batadv_orig_node *orig_node)
4141 ++{
4142 ++ /* Avoid sending multicast-in-unicast packets to other BLA
4143 ++ * gateways - they already got the frame from the LAN side
4144 ++ * we share with them.
4145 ++ * TODO: Refactor to take BLA into account earlier, to avoid
4146 ++ * reducing the mcast_fanout count.
4147 ++ */
4148 ++ if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig, vid)) {
4149 ++ dev_kfree_skb(skb);
4150 ++ return NET_XMIT_SUCCESS;
4151 ++ }
4152 ++
4153 ++ return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST, 0,
4154 ++ orig_node, vid);
4155 ++}
4156 ++
4157 + /**
4158 + * batadv_mcast_purge_orig - reset originator global mcast state modifications
4159 + * @orig: the originator which is going to get purged
4160 +diff --git a/net/batman-adv/multicast.h b/net/batman-adv/multicast.h
4161 +index 8f3cb04b9f13f..dd83ef07e2f27 100644
4162 +--- a/net/batman-adv/multicast.h
4163 ++++ b/net/batman-adv/multicast.h
4164 +@@ -44,6 +44,11 @@ enum batadv_forw_mode
4165 + batadv_mcast_forw_mode(struct batadv_priv *bat_priv, struct sk_buff *skb,
4166 + struct batadv_orig_node **mcast_single_orig);
4167 +
4168 ++int batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
4169 ++ struct sk_buff *skb,
4170 ++ unsigned short vid,
4171 ++ struct batadv_orig_node *orig_node);
4172 ++
4173 + void batadv_mcast_init(struct batadv_priv *bat_priv);
4174 +
4175 + void batadv_mcast_free(struct batadv_priv *bat_priv);
4176 +@@ -68,6 +73,16 @@ static inline int batadv_mcast_init(struct batadv_priv *bat_priv)
4177 + return 0;
4178 + }
4179 +
4180 ++static inline int
4181 ++batadv_mcast_forw_send_orig(struct batadv_priv *bat_priv,
4182 ++ struct sk_buff *skb,
4183 ++ unsigned short vid,
4184 ++ struct batadv_orig_node *orig_node)
4185 ++{
4186 ++ kfree_skb(skb);
4187 ++ return NET_XMIT_DROP;
4188 ++}
4189 ++
4190 + static inline void batadv_mcast_free(struct batadv_priv *bat_priv)
4191 + {
4192 + }
4193 +diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c
4194 +index 91de807a8f03a..9317d872b9c0c 100644
4195 +--- a/net/batman-adv/network-coding.c
4196 ++++ b/net/batman-adv/network-coding.c
4197 +@@ -159,8 +159,10 @@ int batadv_nc_mesh_init(struct batadv_priv *bat_priv)
4198 + &batadv_nc_coding_hash_lock_class_key);
4199 +
4200 + bat_priv->nc.decoding_hash = batadv_hash_new(128);
4201 +- if (!bat_priv->nc.decoding_hash)
4202 ++ if (!bat_priv->nc.decoding_hash) {
4203 ++ batadv_hash_destroy(bat_priv->nc.coding_hash);
4204 + goto err;
4205 ++ }
4206 +
4207 + batadv_hash_set_lock_class(bat_priv->nc.decoding_hash,
4208 + &batadv_nc_decoding_hash_lock_class_key);
4209 +diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
4210 +index ff693887ea822..5105e860d3aa8 100644
4211 +--- a/net/batman-adv/soft-interface.c
4212 ++++ b/net/batman-adv/soft-interface.c
4213 +@@ -353,9 +353,8 @@ send:
4214 + goto dropped;
4215 + ret = batadv_send_skb_via_gw(bat_priv, skb, vid);
4216 + } else if (mcast_single_orig) {
4217 +- ret = batadv_send_skb_unicast(bat_priv, skb,
4218 +- BATADV_UNICAST, 0,
4219 +- mcast_single_orig, vid);
4220 ++ ret = batadv_mcast_forw_send_orig(bat_priv, skb, vid,
4221 ++ mcast_single_orig);
4222 + } else {
4223 + if (batadv_dat_snoop_outgoing_arp_request(bat_priv,
4224 + skb))
4225 +@@ -394,10 +393,10 @@ void batadv_interface_rx(struct net_device *soft_iface,
4226 + struct vlan_ethhdr *vhdr;
4227 + struct ethhdr *ethhdr;
4228 + unsigned short vid;
4229 +- bool is_bcast;
4230 ++ int packet_type;
4231 +
4232 + batadv_bcast_packet = (struct batadv_bcast_packet *)skb->data;
4233 +- is_bcast = (batadv_bcast_packet->packet_type == BATADV_BCAST);
4234 ++ packet_type = batadv_bcast_packet->packet_type;
4235 +
4236 + /* check if enough space is available for pulling, and pull */
4237 + if (!pskb_may_pull(skb, hdr_size))
4238 +@@ -445,7 +444,7 @@ void batadv_interface_rx(struct net_device *soft_iface,
4239 + /* Let the bridge loop avoidance check the packet. If will
4240 + * not handle it, we can safely push it up.
4241 + */
4242 +- if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
4243 ++ if (batadv_bla_rx(bat_priv, skb, vid, packet_type))
4244 + goto out;
4245 +
4246 + if (orig_node)
4247 +@@ -539,15 +538,20 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
4248 + struct batadv_softif_vlan *vlan;
4249 + int err;
4250 +
4251 ++ spin_lock_bh(&bat_priv->softif_vlan_list_lock);
4252 ++
4253 + vlan = batadv_softif_vlan_get(bat_priv, vid);
4254 + if (vlan) {
4255 + batadv_softif_vlan_free_ref(vlan);
4256 ++ spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
4257 + return -EEXIST;
4258 + }
4259 +
4260 + vlan = kzalloc(sizeof(*vlan), GFP_ATOMIC);
4261 +- if (!vlan)
4262 ++ if (!vlan) {
4263 ++ spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
4264 + return -ENOMEM;
4265 ++ }
4266 +
4267 + vlan->bat_priv = bat_priv;
4268 + vlan->vid = vid;
4269 +@@ -555,16 +559,19 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid)
4270 +
4271 + atomic_set(&vlan->ap_isolation, 0);
4272 +
4273 ++ hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list);
4274 ++ spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
4275 ++
4276 ++ /* batadv_sysfs_add_vlan cannot be in the spinlock section due to the
4277 ++ * sleeping behavior of the sysfs functions and the fs_reclaim lock
4278 ++ */
4279 + err = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan);
4280 + if (err) {
4281 +- kfree(vlan);
4282 ++ /* ref for the list */
4283 ++ batadv_softif_vlan_free_ref(vlan);
4284 + return err;
4285 + }
4286 +
4287 +- spin_lock_bh(&bat_priv->softif_vlan_list_lock);
4288 +- hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list);
4289 +- spin_unlock_bh(&bat_priv->softif_vlan_list_lock);
4290 +-
4291 + /* add a new TT local entry. This one will be marked with the NOPURGE
4292 + * flag
4293 + */
4294 +diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
4295 +index 5f976485e8c64..1e71e0c9b47b2 100644
4296 +--- a/net/batman-adv/translation-table.c
4297 ++++ b/net/batman-adv/translation-table.c
4298 +@@ -1426,7 +1426,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
4299 + ether_addr_copy(common->addr, tt_addr);
4300 + common->vid = vid;
4301 +
4302 +- common->flags = flags & (~BATADV_TT_SYNC_MASK);
4303 ++ if (!is_multicast_ether_addr(common->addr))
4304 ++ common->flags = flags & (~BATADV_TT_SYNC_MASK);
4305 +
4306 + tt_global_entry->roam_at = 0;
4307 + /* node must store current time in case of roaming. This is
4308 +@@ -1489,7 +1490,8 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
4309 + * TT_CLIENT_WIFI, therefore they have to be copied in the
4310 + * client entry
4311 + */
4312 +- tt_global_entry->common.flags |= flags & (~BATADV_TT_SYNC_MASK);
4313 ++ if (!is_multicast_ether_addr(common->addr))
4314 ++ tt_global_entry->common.flags |= flags & (~BATADV_TT_SYNC_MASK);
4315 +
4316 + /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
4317 + * one originator left in the list and we previously received a
4318 +@@ -3833,8 +3835,10 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
4319 + return ret;
4320 +
4321 + ret = batadv_tt_global_init(bat_priv);
4322 +- if (ret < 0)
4323 ++ if (ret < 0) {
4324 ++ batadv_tt_local_table_free(bat_priv);
4325 + return ret;
4326 ++ }
4327 +
4328 + batadv_tvlv_handler_register(bat_priv, batadv_tt_tvlv_ogm_handler_v1,
4329 + batadv_tt_tvlv_unicast_handler_v1,
4330 +diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
4331 +index 30731ce390ba0..eddf67a3dbdcb 100644
4332 +--- a/net/bluetooth/l2cap_sock.c
4333 ++++ b/net/bluetooth/l2cap_sock.c
4334 +@@ -1309,6 +1309,9 @@ static void l2cap_sock_close_cb(struct l2cap_chan *chan)
4335 + {
4336 + struct sock *sk = chan->data;
4337 +
4338 ++ if (!sk)
4339 ++ return;
4340 ++
4341 + l2cap_sock_kill(sk);
4342 + }
4343 +
4344 +@@ -1317,6 +1320,9 @@ static void l2cap_sock_teardown_cb(struct l2cap_chan *chan, int err)
4345 + struct sock *sk = chan->data;
4346 + struct sock *parent;
4347 +
4348 ++ if (!sk)
4349 ++ return;
4350 ++
4351 + BT_DBG("chan %p state %s", chan, state_to_string(chan->state));
4352 +
4353 + /* This callback can be called both for server (BT_LISTEN)
4354 +@@ -1486,8 +1492,10 @@ static void l2cap_sock_destruct(struct sock *sk)
4355 + {
4356 + BT_DBG("sk %p", sk);
4357 +
4358 +- if (l2cap_pi(sk)->chan)
4359 ++ if (l2cap_pi(sk)->chan) {
4360 ++ l2cap_pi(sk)->chan->data = NULL;
4361 + l2cap_chan_put(l2cap_pi(sk)->chan);
4362 ++ }
4363 +
4364 + if (l2cap_pi(sk)->rx_busy_skb) {
4365 + kfree_skb(l2cap_pi(sk)->rx_busy_skb);
4366 +diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
4367 +index 701d230fb9cf6..b9d0d1d6a4be1 100644
4368 +--- a/net/bluetooth/sco.c
4369 ++++ b/net/bluetooth/sco.c
4370 +@@ -269,7 +269,8 @@ done:
4371 + return err;
4372 + }
4373 +
4374 +-static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
4375 ++static int sco_send_frame(struct sock *sk, void *buf, int len,
4376 ++ unsigned int msg_flags)
4377 + {
4378 + struct sco_conn *conn = sco_pi(sk)->conn;
4379 + struct sk_buff *skb;
4380 +@@ -281,15 +282,11 @@ static int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
4381 +
4382 + BT_DBG("sk %p len %d", sk, len);
4383 +
4384 +- skb = bt_skb_send_alloc(sk, len, msg->msg_flags & MSG_DONTWAIT, &err);
4385 ++ skb = bt_skb_send_alloc(sk, len, msg_flags & MSG_DONTWAIT, &err);
4386 + if (!skb)
4387 + return err;
4388 +
4389 +- if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
4390 +- kfree_skb(skb);
4391 +- return -EFAULT;
4392 +- }
4393 +-
4394 ++ memcpy(skb_put(skb, len), buf, len);
4395 + hci_send_sco(conn->hcon, skb);
4396 +
4397 + return len;
4398 +@@ -700,6 +697,7 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
4399 + size_t len)
4400 + {
4401 + struct sock *sk = sock->sk;
4402 ++ void *buf;
4403 + int err;
4404 +
4405 + BT_DBG("sock %p, sk %p", sock, sk);
4406 +@@ -711,14 +709,24 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
4407 + if (msg->msg_flags & MSG_OOB)
4408 + return -EOPNOTSUPP;
4409 +
4410 ++ buf = kmalloc(len, GFP_KERNEL);
4411 ++ if (!buf)
4412 ++ return -ENOMEM;
4413 ++
4414 ++ if (memcpy_from_msg(buf, msg, len)) {
4415 ++ kfree(buf);
4416 ++ return -EFAULT;
4417 ++ }
4418 ++
4419 + lock_sock(sk);
4420 +
4421 + if (sk->sk_state == BT_CONNECTED)
4422 +- err = sco_send_frame(sk, msg, len);
4423 ++ err = sco_send_frame(sk, buf, len, msg->msg_flags);
4424 + else
4425 + err = -ENOTCONN;
4426 +
4427 + release_sock(sk);
4428 ++ kfree(buf);
4429 + return err;
4430 + }
4431 +
4432 +diff --git a/net/core/stream.c b/net/core/stream.c
4433 +index 3089b014bb538..2c50c71cb806f 100644
4434 +--- a/net/core/stream.c
4435 ++++ b/net/core/stream.c
4436 +@@ -194,9 +194,6 @@ void sk_stream_kill_queues(struct sock *sk)
4437 + /* First the read buffer. */
4438 + __skb_queue_purge(&sk->sk_receive_queue);
4439 +
4440 +- /* Next, the error queue. */
4441 +- __skb_queue_purge(&sk->sk_error_queue);
4442 +-
4443 + /* Next, the write queue. */
4444 + WARN_ON(!skb_queue_empty(&sk->sk_write_queue));
4445 +
4446 +diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
4447 +index 54cde78c27183..ebce25080f7ff 100644
4448 +--- a/net/netfilter/nfnetlink_queue.c
4449 ++++ b/net/netfilter/nfnetlink_queue.c
4450 +@@ -486,7 +486,7 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,
4451 + goto nla_put_failure;
4452 +
4453 + if (indev && entskb->dev &&
4454 +- entskb->mac_header != entskb->network_header) {
4455 ++ skb_mac_header_was_set(entskb)) {
4456 + struct nfqnl_msg_packet_hw phw;
4457 + int len;
4458 +
4459 +diff --git a/net/nfc/core.c b/net/nfc/core.c
4460 +index 1471e4b0aa2c6..8c7f221e1d125 100644
4461 +--- a/net/nfc/core.c
4462 ++++ b/net/nfc/core.c
4463 +@@ -106,13 +106,13 @@ int nfc_dev_up(struct nfc_dev *dev)
4464 +
4465 + device_lock(&dev->dev);
4466 +
4467 +- if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
4468 +- rc = -ERFKILL;
4469 ++ if (!device_is_registered(&dev->dev)) {
4470 ++ rc = -ENODEV;
4471 + goto error;
4472 + }
4473 +
4474 +- if (!device_is_registered(&dev->dev)) {
4475 +- rc = -ENODEV;
4476 ++ if (dev->rfkill && rfkill_blocked(dev->rfkill)) {
4477 ++ rc = -ERFKILL;
4478 + goto error;
4479 + }
4480 +
4481 +@@ -1120,11 +1120,7 @@ int nfc_register_device(struct nfc_dev *dev)
4482 + if (rc)
4483 + pr_err("Could not register llcp device\n");
4484 +
4485 +- rc = nfc_genl_device_added(dev);
4486 +- if (rc)
4487 +- pr_debug("The userspace won't be notified that the device %s was added\n",
4488 +- dev_name(&dev->dev));
4489 +-
4490 ++ device_lock(&dev->dev);
4491 + dev->rfkill = rfkill_alloc(dev_name(&dev->dev), &dev->dev,
4492 + RFKILL_TYPE_NFC, &nfc_rfkill_ops, dev);
4493 + if (dev->rfkill) {
4494 +@@ -1133,6 +1129,12 @@ int nfc_register_device(struct nfc_dev *dev)
4495 + dev->rfkill = NULL;
4496 + }
4497 + }
4498 ++ device_unlock(&dev->dev);
4499 ++
4500 ++ rc = nfc_genl_device_added(dev);
4501 ++ if (rc)
4502 ++ pr_debug("The userspace won't be notified that the device %s was added\n",
4503 ++ dev_name(&dev->dev));
4504 +
4505 + return 0;
4506 + }
4507 +@@ -1149,10 +1151,17 @@ void nfc_unregister_device(struct nfc_dev *dev)
4508 +
4509 + pr_debug("dev_name=%s\n", dev_name(&dev->dev));
4510 +
4511 ++ rc = nfc_genl_device_removed(dev);
4512 ++ if (rc)
4513 ++ pr_debug("The userspace won't be notified that the device %s "
4514 ++ "was removed\n", dev_name(&dev->dev));
4515 ++
4516 ++ device_lock(&dev->dev);
4517 + if (dev->rfkill) {
4518 + rfkill_unregister(dev->rfkill);
4519 + rfkill_destroy(dev->rfkill);
4520 + }
4521 ++ device_unlock(&dev->dev);
4522 +
4523 + if (dev->ops->check_presence) {
4524 + device_lock(&dev->dev);
4525 +@@ -1162,11 +1171,6 @@ void nfc_unregister_device(struct nfc_dev *dev)
4526 + cancel_work_sync(&dev->check_pres_work);
4527 + }
4528 +
4529 +- rc = nfc_genl_device_removed(dev);
4530 +- if (rc)
4531 +- pr_debug("The userspace won't be notified that the device %s "
4532 +- "was removed\n", dev_name(&dev->dev));
4533 +-
4534 + nfc_llcp_unregister_device(dev);
4535 +
4536 + mutex_lock(&nfc_devlist_mutex);
4537 +diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
4538 +index 35cc290389c8a..27df5a5d69e80 100644
4539 +--- a/net/nfc/nci/core.c
4540 ++++ b/net/nfc/nci/core.c
4541 +@@ -149,12 +149,15 @@ inline int nci_request(struct nci_dev *ndev,
4542 + {
4543 + int rc;
4544 +
4545 +- if (!test_bit(NCI_UP, &ndev->flags))
4546 +- return -ENETDOWN;
4547 +-
4548 + /* Serialize all requests */
4549 + mutex_lock(&ndev->req_lock);
4550 +- rc = __nci_request(ndev, req, opt, timeout);
4551 ++ /* check the state after obtaing the lock against any races
4552 ++ * from nci_close_device when the device gets removed.
4553 ++ */
4554 ++ if (test_bit(NCI_UP, &ndev->flags))
4555 ++ rc = __nci_request(ndev, req, opt, timeout);
4556 ++ else
4557 ++ rc = -ENETDOWN;
4558 + mutex_unlock(&ndev->req_lock);
4559 +
4560 + return rc;
4561 +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
4562 +index 8f5fec0956bd9..537d57558c216 100644
4563 +--- a/net/vmw_vsock/af_vsock.c
4564 ++++ b/net/vmw_vsock/af_vsock.c
4565 +@@ -1152,6 +1152,8 @@ static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr,
4566 + * non-blocking call.
4567 + */
4568 + err = -EALREADY;
4569 ++ if (flags & O_NONBLOCK)
4570 ++ goto out;
4571 + break;
4572 + default:
4573 + if ((sk->sk_state == VSOCK_SS_LISTEN) ||
4574 +diff --git a/net/wireless/util.c b/net/wireless/util.c
4575 +index 73c361fd4a16f..5e1c791d4cb92 100644
4576 +--- a/net/wireless/util.c
4577 ++++ b/net/wireless/util.c
4578 +@@ -963,6 +963,7 @@ int cfg80211_change_iface(struct cfg80211_registered_device *rdev,
4579 +
4580 + switch (otype) {
4581 + case NL80211_IFTYPE_AP:
4582 ++ case NL80211_IFTYPE_P2P_GO:
4583 + cfg80211_stop_ap(rdev, dev, true);
4584 + break;
4585 + case NL80211_IFTYPE_ADHOC:
4586 +diff --git a/security/security.c b/security/security.c
4587 +index 0dde287db5c5d..b81a709ff331e 100644
4588 +--- a/security/security.c
4589 ++++ b/security/security.c
4590 +@@ -130,25 +130,25 @@ int __init security_module_enable(const char *module)
4591 +
4592 + /* Security operations */
4593 +
4594 +-int security_binder_set_context_mgr(struct task_struct *mgr)
4595 ++int security_binder_set_context_mgr(const struct cred *mgr)
4596 + {
4597 + return call_int_hook(binder_set_context_mgr, 0, mgr);
4598 + }
4599 +
4600 +-int security_binder_transaction(struct task_struct *from,
4601 +- struct task_struct *to)
4602 ++int security_binder_transaction(const struct cred *from,
4603 ++ const struct cred *to)
4604 + {
4605 + return call_int_hook(binder_transaction, 0, from, to);
4606 + }
4607 +
4608 +-int security_binder_transfer_binder(struct task_struct *from,
4609 +- struct task_struct *to)
4610 ++int security_binder_transfer_binder(const struct cred *from,
4611 ++ const struct cred *to)
4612 + {
4613 + return call_int_hook(binder_transfer_binder, 0, from, to);
4614 + }
4615 +
4616 +-int security_binder_transfer_file(struct task_struct *from,
4617 +- struct task_struct *to, struct file *file)
4618 ++int security_binder_transfer_file(const struct cred *from,
4619 ++ const struct cred *to, struct file *file)
4620 + {
4621 + return call_int_hook(binder_transfer_file, 0, from, to, file);
4622 + }
4623 +diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
4624 +index 055bf769408e6..44f4495e3fbd9 100644
4625 +--- a/security/selinux/hooks.c
4626 ++++ b/security/selinux/hooks.c
4627 +@@ -1974,21 +1974,18 @@ static inline u32 open_file_to_av(struct file *file)
4628 +
4629 + /* Hook functions begin here. */
4630 +
4631 +-static int selinux_binder_set_context_mgr(struct task_struct *mgr)
4632 ++static int selinux_binder_set_context_mgr(const struct cred *mgr)
4633 + {
4634 +- u32 mysid = current_sid();
4635 +- u32 mgrsid = task_sid(mgr);
4636 +-
4637 +- return avc_has_perm(mysid, mgrsid, SECCLASS_BINDER,
4638 ++ return avc_has_perm(current_sid(), cred_sid(mgr), SECCLASS_BINDER,
4639 + BINDER__SET_CONTEXT_MGR, NULL);
4640 + }
4641 +
4642 +-static int selinux_binder_transaction(struct task_struct *from,
4643 +- struct task_struct *to)
4644 ++static int selinux_binder_transaction(const struct cred *from,
4645 ++ const struct cred *to)
4646 + {
4647 + u32 mysid = current_sid();
4648 +- u32 fromsid = task_sid(from);
4649 +- u32 tosid = task_sid(to);
4650 ++ u32 fromsid = cred_sid(from);
4651 ++ u32 tosid = cred_sid(to);
4652 + int rc;
4653 +
4654 + if (mysid != fromsid) {
4655 +@@ -2002,21 +1999,19 @@ static int selinux_binder_transaction(struct task_struct *from,
4656 + NULL);
4657 + }
4658 +
4659 +-static int selinux_binder_transfer_binder(struct task_struct *from,
4660 +- struct task_struct *to)
4661 ++static int selinux_binder_transfer_binder(const struct cred *from,
4662 ++ const struct cred *to)
4663 + {
4664 +- u32 fromsid = task_sid(from);
4665 +- u32 tosid = task_sid(to);
4666 +-
4667 +- return avc_has_perm(fromsid, tosid, SECCLASS_BINDER, BINDER__TRANSFER,
4668 ++ return avc_has_perm(cred_sid(from), cred_sid(to),
4669 ++ SECCLASS_BINDER, BINDER__TRANSFER,
4670 + NULL);
4671 + }
4672 +
4673 +-static int selinux_binder_transfer_file(struct task_struct *from,
4674 +- struct task_struct *to,
4675 ++static int selinux_binder_transfer_file(const struct cred *from,
4676 ++ const struct cred *to,
4677 + struct file *file)
4678 + {
4679 +- u32 sid = task_sid(to);
4680 ++ u32 sid = cred_sid(to);
4681 + struct file_security_struct *fsec = file->f_security;
4682 + struct inode *inode = d_backing_inode(file->f_path.dentry);
4683 + struct inode_security_struct *isec = inode->i_security;
4684 +diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
4685 +index df082648eb0aa..ce30b61c56171 100644
4686 +--- a/security/smack/smackfs.c
4687 ++++ b/security/smack/smackfs.c
4688 +@@ -721,9 +721,7 @@ static void smk_cipso_doi(void)
4689 + printk(KERN_WARNING "%s:%d remove rc = %d\n",
4690 + __func__, __LINE__, rc);
4691 +
4692 +- doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
4693 +- if (doip == NULL)
4694 +- panic("smack: Failed to initialize cipso DOI.\n");
4695 ++ doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL);
4696 + doip->map.std = NULL;
4697 + doip->doi = smk_cipso_doi_value;
4698 + doip->type = CIPSO_V4_MAP_PASS;
4699 +@@ -742,7 +740,7 @@ static void smk_cipso_doi(void)
4700 + if (rc != 0) {
4701 + printk(KERN_WARNING "%s:%d map add rc = %d\n",
4702 + __func__, __LINE__, rc);
4703 +- kfree(doip);
4704 ++ netlbl_cfg_cipsov4_del(doip->doi, &nai);
4705 + return;
4706 + }
4707 + }
4708 +@@ -859,6 +857,7 @@ static int smk_open_cipso(struct inode *inode, struct file *file)
4709 + static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
4710 + size_t count, loff_t *ppos, int format)
4711 + {
4712 ++ struct netlbl_lsm_catmap *old_cat;
4713 + struct smack_known *skp;
4714 + struct netlbl_lsm_secattr ncats;
4715 + char mapcatset[SMK_CIPSOLEN];
4716 +@@ -952,9 +951,11 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
4717 +
4718 + rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
4719 + if (rc >= 0) {
4720 +- netlbl_catmap_free(skp->smk_netlabel.attr.mls.cat);
4721 ++ old_cat = skp->smk_netlabel.attr.mls.cat;
4722 + skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat;
4723 + skp->smk_netlabel.attr.mls.lvl = ncats.attr.mls.lvl;
4724 ++ synchronize_rcu();
4725 ++ netlbl_catmap_free(old_cat);
4726 + rc = count;
4727 + }
4728 +
4729 +diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
4730 +index 7a8c79dd97340..903fbf03559e5 100644
4731 +--- a/sound/core/oss/mixer_oss.c
4732 ++++ b/sound/core/oss/mixer_oss.c
4733 +@@ -144,11 +144,13 @@ static int snd_mixer_oss_devmask(struct snd_mixer_oss_file *fmixer)
4734 +
4735 + if (mixer == NULL)
4736 + return -EIO;
4737 ++ mutex_lock(&mixer->reg_mutex);
4738 + for (chn = 0; chn < 31; chn++) {
4739 + pslot = &mixer->slots[chn];
4740 + if (pslot->put_volume || pslot->put_recsrc)
4741 + result |= 1 << chn;
4742 + }
4743 ++ mutex_unlock(&mixer->reg_mutex);
4744 + return result;
4745 + }
4746 +
4747 +@@ -160,11 +162,13 @@ static int snd_mixer_oss_stereodevs(struct snd_mixer_oss_file *fmixer)
4748 +
4749 + if (mixer == NULL)
4750 + return -EIO;
4751 ++ mutex_lock(&mixer->reg_mutex);
4752 + for (chn = 0; chn < 31; chn++) {
4753 + pslot = &mixer->slots[chn];
4754 + if (pslot->put_volume && pslot->stereo)
4755 + result |= 1 << chn;
4756 + }
4757 ++ mutex_unlock(&mixer->reg_mutex);
4758 + return result;
4759 + }
4760 +
4761 +@@ -175,6 +179,7 @@ static int snd_mixer_oss_recmask(struct snd_mixer_oss_file *fmixer)
4762 +
4763 + if (mixer == NULL)
4764 + return -EIO;
4765 ++ mutex_lock(&mixer->reg_mutex);
4766 + if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
4767 + result = mixer->mask_recsrc;
4768 + } else {
4769 +@@ -186,6 +191,7 @@ static int snd_mixer_oss_recmask(struct snd_mixer_oss_file *fmixer)
4770 + result |= 1 << chn;
4771 + }
4772 + }
4773 ++ mutex_unlock(&mixer->reg_mutex);
4774 + return result;
4775 + }
4776 +
4777 +@@ -196,11 +202,12 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
4778 +
4779 + if (mixer == NULL)
4780 + return -EIO;
4781 ++ mutex_lock(&mixer->reg_mutex);
4782 + if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
4783 +- int err;
4784 + unsigned int index;
4785 +- if ((err = mixer->get_recsrc(fmixer, &index)) < 0)
4786 +- return err;
4787 ++ result = mixer->get_recsrc(fmixer, &index);
4788 ++ if (result < 0)
4789 ++ goto unlock;
4790 + result = 1 << index;
4791 + } else {
4792 + struct snd_mixer_oss_slot *pslot;
4793 +@@ -215,7 +222,10 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
4794 + }
4795 + }
4796 + }
4797 +- return mixer->oss_recsrc = result;
4798 ++ mixer->oss_recsrc = result;
4799 ++ unlock:
4800 ++ mutex_unlock(&mixer->reg_mutex);
4801 ++ return result;
4802 + }
4803 +
4804 + static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsrc)
4805 +@@ -228,6 +238,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
4806 +
4807 + if (mixer == NULL)
4808 + return -EIO;
4809 ++ mutex_lock(&mixer->reg_mutex);
4810 + if (mixer->get_recsrc && mixer->put_recsrc) { /* exclusive input */
4811 + if (recsrc & ~mixer->oss_recsrc)
4812 + recsrc &= ~mixer->oss_recsrc;
4813 +@@ -253,6 +264,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
4814 + }
4815 + }
4816 + }
4817 ++ mutex_unlock(&mixer->reg_mutex);
4818 + return result;
4819 + }
4820 +
4821 +@@ -264,6 +276,7 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot)
4822 +
4823 + if (mixer == NULL || slot > 30)
4824 + return -EIO;
4825 ++ mutex_lock(&mixer->reg_mutex);
4826 + pslot = &mixer->slots[slot];
4827 + left = pslot->volume[0];
4828 + right = pslot->volume[1];
4829 +@@ -271,15 +284,21 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot)
4830 + result = pslot->get_volume(fmixer, pslot, &left, &right);
4831 + if (!pslot->stereo)
4832 + right = left;
4833 +- if (snd_BUG_ON(left < 0 || left > 100))
4834 +- return -EIO;
4835 +- if (snd_BUG_ON(right < 0 || right > 100))
4836 +- return -EIO;
4837 ++ if (snd_BUG_ON(left < 0 || left > 100)) {
4838 ++ result = -EIO;
4839 ++ goto unlock;
4840 ++ }
4841 ++ if (snd_BUG_ON(right < 0 || right > 100)) {
4842 ++ result = -EIO;
4843 ++ goto unlock;
4844 ++ }
4845 + if (result >= 0) {
4846 + pslot->volume[0] = left;
4847 + pslot->volume[1] = right;
4848 + result = (left & 0xff) | ((right & 0xff) << 8);
4849 + }
4850 ++ unlock:
4851 ++ mutex_unlock(&mixer->reg_mutex);
4852 + return result;
4853 + }
4854 +
4855 +@@ -292,6 +311,7 @@ static int snd_mixer_oss_set_volume(struct snd_mixer_oss_file *fmixer,
4856 +
4857 + if (mixer == NULL || slot > 30)
4858 + return -EIO;
4859 ++ mutex_lock(&mixer->reg_mutex);
4860 + pslot = &mixer->slots[slot];
4861 + if (left > 100)
4862 + left = 100;
4863 +@@ -302,10 +322,13 @@ static int snd_mixer_oss_set_volume(struct snd_mixer_oss_file *fmixer,
4864 + if (pslot->put_volume)
4865 + result = pslot->put_volume(fmixer, pslot, left, right);
4866 + if (result < 0)
4867 +- return result;
4868 ++ goto unlock;
4869 + pslot->volume[0] = left;
4870 + pslot->volume[1] = right;
4871 +- return (left & 0xff) | ((right & 0xff) << 8);
4872 ++ result = (left & 0xff) | ((right & 0xff) << 8);
4873 ++ unlock:
4874 ++ mutex_unlock(&mixer->reg_mutex);
4875 ++ return result;
4876 + }
4877 +
4878 + static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int cmd, unsigned long arg)
4879 +diff --git a/sound/core/timer.c b/sound/core/timer.c
4880 +index 7e4509de01c47..90ad22e24a71e 100644
4881 +--- a/sound/core/timer.c
4882 ++++ b/sound/core/timer.c
4883 +@@ -525,13 +525,13 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
4884 + if (!timer)
4885 + return -EINVAL;
4886 + spin_lock_irqsave(&timer->lock, flags);
4887 ++ list_del_init(&timeri->ack_list);
4888 ++ list_del_init(&timeri->active_list);
4889 + if (!(timeri->flags & (SNDRV_TIMER_IFLG_RUNNING |
4890 + SNDRV_TIMER_IFLG_START))) {
4891 + result = -EBUSY;
4892 + goto unlock;
4893 + }
4894 +- list_del_init(&timeri->ack_list);
4895 +- list_del_init(&timeri->active_list);
4896 + if (timer->card && timer->card->shutdown)
4897 + goto unlock;
4898 + if (stop) {
4899 +@@ -566,23 +566,22 @@ static int snd_timer_stop1(struct snd_timer_instance *timeri, bool stop)
4900 + static int snd_timer_stop_slave(struct snd_timer_instance *timeri, bool stop)
4901 + {
4902 + unsigned long flags;
4903 ++ bool running;
4904 +
4905 + spin_lock_irqsave(&slave_active_lock, flags);
4906 +- if (!(timeri->flags & SNDRV_TIMER_IFLG_RUNNING)) {
4907 +- spin_unlock_irqrestore(&slave_active_lock, flags);
4908 +- return -EBUSY;
4909 +- }
4910 ++ running = timeri->flags & SNDRV_TIMER_IFLG_RUNNING;
4911 + timeri->flags &= ~SNDRV_TIMER_IFLG_RUNNING;
4912 + if (timeri->timer) {
4913 + spin_lock(&timeri->timer->lock);
4914 + list_del_init(&timeri->ack_list);
4915 + list_del_init(&timeri->active_list);
4916 +- snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
4917 +- SNDRV_TIMER_EVENT_PAUSE);
4918 ++ if (running)
4919 ++ snd_timer_notify1(timeri, stop ? SNDRV_TIMER_EVENT_STOP :
4920 ++ SNDRV_TIMER_EVENT_PAUSE);
4921 + spin_unlock(&timeri->timer->lock);
4922 + }
4923 + spin_unlock_irqrestore(&slave_active_lock, flags);
4924 +- return 0;
4925 ++ return running ? 0 : -EBUSY;
4926 + }
4927 +
4928 + /*
4929 +diff --git a/sound/isa/gus/gus_dma.c b/sound/isa/gus/gus_dma.c
4930 +index 36c27c8323601..2e27cd3427c87 100644
4931 +--- a/sound/isa/gus/gus_dma.c
4932 ++++ b/sound/isa/gus/gus_dma.c
4933 +@@ -141,6 +141,8 @@ static void snd_gf1_dma_interrupt(struct snd_gus_card * gus)
4934 + }
4935 + block = snd_gf1_dma_next_block(gus);
4936 + spin_unlock(&gus->dma_lock);
4937 ++ if (!block)
4938 ++ return;
4939 + snd_gf1_dma_program(gus, block->addr, block->buf_addr, block->count, (unsigned short) block->cmd);
4940 + kfree(block);
4941 + #if 0
4942 +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
4943 +index 551377fab0d03..5aea9f703b8c0 100644
4944 +--- a/sound/soc/soc-dapm.c
4945 ++++ b/sound/soc/soc-dapm.c
4946 +@@ -2373,8 +2373,13 @@ static struct snd_soc_dapm_widget *dapm_find_widget(
4947 + return NULL;
4948 + }
4949 +
4950 +-static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
4951 +- const char *pin, int status)
4952 ++/*
4953 ++ * set the DAPM pin status:
4954 ++ * returns 1 when the value has been updated, 0 when unchanged, or a negative
4955 ++ * error code; called from kcontrol put callback
4956 ++ */
4957 ++static int __snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
4958 ++ const char *pin, int status)
4959 + {
4960 + struct snd_soc_dapm_widget *w = dapm_find_widget(dapm, pin, true);
4961 + int ret = 0;
4962 +@@ -2400,6 +2405,18 @@ static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
4963 + return ret;
4964 + }
4965 +
4966 ++/*
4967 ++ * similar as __snd_soc_dapm_set_pin(), but returns 0 when successful;
4968 ++ * called from several API functions below
4969 ++ */
4970 ++static int snd_soc_dapm_set_pin(struct snd_soc_dapm_context *dapm,
4971 ++ const char *pin, int status)
4972 ++{
4973 ++ int ret = __snd_soc_dapm_set_pin(dapm, pin, status);
4974 ++
4975 ++ return ret < 0 ? ret : 0;
4976 ++}
4977 ++
4978 + /**
4979 + * snd_soc_dapm_sync_unlocked - scan and power dapm paths
4980 + * @dapm: DAPM context
4981 +@@ -3294,10 +3311,10 @@ int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
4982 + const char *pin = (const char *)kcontrol->private_value;
4983 + int ret;
4984 +
4985 +- if (ucontrol->value.integer.value[0])
4986 +- ret = snd_soc_dapm_enable_pin(&card->dapm, pin);
4987 +- else
4988 +- ret = snd_soc_dapm_disable_pin(&card->dapm, pin);
4989 ++ mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
4990 ++ ret = __snd_soc_dapm_set_pin(&card->dapm, pin,
4991 ++ !!ucontrol->value.integer.value[0]);
4992 ++ mutex_unlock(&card->dapm_mutex);
4993 +
4994 + snd_soc_dapm_sync(&card->dapm);
4995 + return ret;
4996 +diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
4997 +index 9312cd8a6fdd1..c5c6d360843aa 100644
4998 +--- a/sound/synth/emux/emux.c
4999 ++++ b/sound/synth/emux/emux.c
5000 +@@ -101,7 +101,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
5001 + emu->name = kstrdup(name, GFP_KERNEL);
5002 + emu->voices = kcalloc(emu->max_voices, sizeof(struct snd_emux_voice),
5003 + GFP_KERNEL);
5004 +- if (emu->voices == NULL)
5005 ++ if (emu->name == NULL || emu->voices == NULL)
5006 + return -ENOMEM;
5007 +
5008 + /* create soundfont list */
5009 +diff --git a/sound/usb/6fire/comm.c b/sound/usb/6fire/comm.c
5010 +index 161215d78d952..f29c115b9d564 100644
5011 +--- a/sound/usb/6fire/comm.c
5012 ++++ b/sound/usb/6fire/comm.c
5013 +@@ -99,7 +99,7 @@ static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
5014 + int actual_len;
5015 +
5016 + ret = usb_interrupt_msg(dev, usb_sndintpipe(dev, COMM_EP),
5017 +- buffer, buffer[1] + 2, &actual_len, HZ);
5018 ++ buffer, buffer[1] + 2, &actual_len, 1000);
5019 + if (ret < 0)
5020 + return ret;
5021 + else if (actual_len != buffer[1] + 2)
5022 +diff --git a/sound/usb/6fire/firmware.c b/sound/usb/6fire/firmware.c
5023 +index 62c25e74f0e52..2809ba257fa4e 100644
5024 +--- a/sound/usb/6fire/firmware.c
5025 ++++ b/sound/usb/6fire/firmware.c
5026 +@@ -166,7 +166,7 @@ static int usb6fire_fw_ezusb_write(struct usb_device *device,
5027 +
5028 + ret = usb_control_msg(device, usb_sndctrlpipe(device, 0), type,
5029 + USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
5030 +- value, 0, data, len, HZ);
5031 ++ value, 0, data, len, 1000);
5032 + if (ret < 0)
5033 + return ret;
5034 + else if (ret != len)
5035 +@@ -179,7 +179,7 @@ static int usb6fire_fw_ezusb_read(struct usb_device *device,
5036 + {
5037 + int ret = usb_control_msg(device, usb_rcvctrlpipe(device, 0), type,
5038 + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, value,
5039 +- 0, data, len, HZ);
5040 ++ 0, data, len, 1000);
5041 + if (ret < 0)
5042 + return ret;
5043 + else if (ret != len)
5044 +@@ -194,7 +194,7 @@ static int usb6fire_fw_fpga_write(struct usb_device *device,
5045 + int ret;
5046 +
5047 + ret = usb_bulk_msg(device, usb_sndbulkpipe(device, FPGA_EP), data, len,
5048 +- &actual_len, HZ);
5049 ++ &actual_len, 1000);
5050 + if (ret < 0)
5051 + return ret;
5052 + else if (actual_len != len)
5053 +diff --git a/sound/usb/line6/driver.c b/sound/usb/line6/driver.c
5054 +index ae2c35918002e..898fba45f1b64 100644
5055 +--- a/sound/usb/line6/driver.c
5056 ++++ b/sound/usb/line6/driver.c
5057 +@@ -101,7 +101,7 @@ static int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
5058 + usb_sndintpipe(line6->usbdev,
5059 + line6->properties->ep_ctrl_w),
5060 + (char *)frag_buf, frag_size,
5061 +- &partial, LINE6_TIMEOUT * HZ);
5062 ++ &partial, LINE6_TIMEOUT);
5063 +
5064 + if (retval) {
5065 + dev_err(line6->ifcdev,
5066 +@@ -321,7 +321,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
5067 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
5068 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
5069 + (datalen << 8) | 0x21, address,
5070 +- NULL, 0, LINE6_TIMEOUT * HZ);
5071 ++ NULL, 0, LINE6_TIMEOUT);
5072 +
5073 + if (ret < 0) {
5074 + dev_err(line6->ifcdev, "read request failed (error %d)\n", ret);
5075 +@@ -336,7 +336,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
5076 + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
5077 + USB_DIR_IN,
5078 + 0x0012, 0x0000, len, 1,
5079 +- LINE6_TIMEOUT * HZ);
5080 ++ LINE6_TIMEOUT);
5081 + if (ret < 0) {
5082 + dev_err(line6->ifcdev,
5083 + "receive length failed (error %d)\n", ret);
5084 +@@ -364,7 +364,7 @@ int line6_read_data(struct usb_line6 *line6, unsigned address, void *data,
5085 + ret = usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), 0x67,
5086 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
5087 + 0x0013, 0x0000, data, datalen,
5088 +- LINE6_TIMEOUT * HZ);
5089 ++ LINE6_TIMEOUT);
5090 +
5091 + if (ret < 0)
5092 + dev_err(line6->ifcdev, "read failed (error %d)\n", ret);
5093 +@@ -396,7 +396,7 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data,
5094 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
5095 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
5096 + 0x0022, address, data, datalen,
5097 +- LINE6_TIMEOUT * HZ);
5098 ++ LINE6_TIMEOUT);
5099 +
5100 + if (ret < 0) {
5101 + dev_err(line6->ifcdev,
5102 +@@ -412,7 +412,7 @@ int line6_write_data(struct usb_line6 *line6, unsigned address, void *data,
5103 + USB_TYPE_VENDOR | USB_RECIP_DEVICE |
5104 + USB_DIR_IN,
5105 + 0x0012, 0x0000,
5106 +- status, 1, LINE6_TIMEOUT * HZ);
5107 ++ status, 1, LINE6_TIMEOUT);
5108 +
5109 + if (ret < 0) {
5110 + dev_err(line6->ifcdev,
5111 +diff --git a/sound/usb/line6/driver.h b/sound/usb/line6/driver.h
5112 +index 7da643e79e3b5..ad845d488d497 100644
5113 +--- a/sound/usb/line6/driver.h
5114 ++++ b/sound/usb/line6/driver.h
5115 +@@ -24,7 +24,7 @@
5116 + #define LINE6_FALLBACK_INTERVAL 10
5117 + #define LINE6_FALLBACK_MAXPACKETSIZE 16
5118 +
5119 +-#define LINE6_TIMEOUT 1
5120 ++#define LINE6_TIMEOUT 1000
5121 + #define LINE6_BUFSIZE_LISTEN 32
5122 + #define LINE6_MESSAGE_MAXLEN 256
5123 +
5124 +diff --git a/sound/usb/line6/toneport.c b/sound/usb/line6/toneport.c
5125 +index 5512b3d532e71..9cc512d7f3e16 100644
5126 +--- a/sound/usb/line6/toneport.c
5127 ++++ b/sound/usb/line6/toneport.c
5128 +@@ -133,7 +133,7 @@ static int toneport_send_cmd(struct usb_device *usbdev, int cmd1, int cmd2)
5129 +
5130 + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), 0x67,
5131 + USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
5132 +- cmd1, cmd2, NULL, 0, LINE6_TIMEOUT * HZ);
5133 ++ cmd1, cmd2, NULL, 0, LINE6_TIMEOUT);
5134 +
5135 + if (ret < 0) {
5136 + dev_err(&usbdev->dev, "send failed (error %d)\n", ret);
5137 +diff --git a/sound/usb/misc/ua101.c b/sound/usb/misc/ua101.c
5138 +index 9581089c28c5e..3ba5d0afa9476 100644
5139 +--- a/sound/usb/misc/ua101.c
5140 ++++ b/sound/usb/misc/ua101.c
5141 +@@ -1032,7 +1032,7 @@ static int detect_usb_format(struct ua101 *ua)
5142 + fmt_playback->bSubframeSize * ua->playback.channels;
5143 +
5144 + epd = &ua->intf[INTF_CAPTURE]->altsetting[1].endpoint[0].desc;
5145 +- if (!usb_endpoint_is_isoc_in(epd)) {
5146 ++ if (!usb_endpoint_is_isoc_in(epd) || usb_endpoint_maxp(epd) == 0) {
5147 + dev_err(&ua->dev->dev, "invalid capture endpoint\n");
5148 + return -ENXIO;
5149 + }
5150 +@@ -1040,7 +1040,7 @@ static int detect_usb_format(struct ua101 *ua)
5151 + ua->capture.max_packet_bytes = le16_to_cpu(epd->wMaxPacketSize);
5152 +
5153 + epd = &ua->intf[INTF_PLAYBACK]->altsetting[1].endpoint[0].desc;
5154 +- if (!usb_endpoint_is_isoc_out(epd)) {
5155 ++ if (!usb_endpoint_is_isoc_out(epd) || usb_endpoint_maxp(epd) == 0) {
5156 + dev_err(&ua->dev->dev, "invalid playback endpoint\n");
5157 + return -ENXIO;
5158 + }