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, 31 Jul 2020 16:10:40
Message-Id: 1596211797.7c177a07d1e81782612e663c6ae00a036454afac.mpagano@gentoo
1 commit: 7c177a07d1e81782612e663c6ae00a036454afac
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 31 16:09:57 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 31 16:09:57 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=7c177a07
7
8 Linux patch 4.4.232
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1231_linux-4.4.232.patch | 1689 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 1693 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 3d3ab8d..16b1510 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -967,6 +967,10 @@ Patch: 1230_linux-4.4.231.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.4.231
23
24 +Patch: 1231_linux-4.4.232.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.4.232
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/1231_linux-4.4.232.patch b/1231_linux-4.4.232.patch
33 new file mode 100644
34 index 0000000..21c6229
35 --- /dev/null
36 +++ b/1231_linux-4.4.232.patch
37 @@ -0,0 +1,1689 @@
38 +diff --git a/Makefile b/Makefile
39 +index 46178c83906c..47a0a6c8272b 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 4
45 +-SUBLEVEL = 231
46 ++SUBLEVEL = 232
47 + EXTRAVERSION =
48 + NAME = Blurry Fish Butt
49 +
50 +@@ -607,7 +607,7 @@ ifeq ($(cc-name),clang)
51 + ifneq ($(CROSS_COMPILE),)
52 + CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
53 + GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit))
54 +-CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)
55 ++CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE))
56 + GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..)
57 + endif
58 + ifneq ($(GCC_TOOLCHAIN),)
59 +diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
60 +index 8e7675e5ce4a..77fbcabcd9e3 100644
61 +--- a/arch/arm64/kernel/debug-monitors.c
62 ++++ b/arch/arm64/kernel/debug-monitors.c
63 +@@ -387,13 +387,13 @@ void user_rewind_single_step(struct task_struct *task)
64 + * If single step is active for this thread, then set SPSR.SS
65 + * to 1 to avoid returning to the active-pending state.
66 + */
67 +- if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP))
68 ++ if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
69 + set_regs_spsr_ss(task_pt_regs(task));
70 + }
71 +
72 + void user_fastforward_single_step(struct task_struct *task)
73 + {
74 +- if (test_ti_thread_flag(task_thread_info(task), TIF_SINGLESTEP))
75 ++ if (test_tsk_thread_flag(task, TIF_SINGLESTEP))
76 + clear_regs_spsr_ss(task_pt_regs(task));
77 + }
78 +
79 +diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
80 +index 1d109990a022..cb2590821707 100644
81 +--- a/arch/parisc/include/asm/atomic.h
82 ++++ b/arch/parisc/include/asm/atomic.h
83 +@@ -208,6 +208,8 @@ atomic64_set(atomic64_t *v, s64 i)
84 + _atomic_spin_unlock_irqrestore(v, flags);
85 + }
86 +
87 ++#define atomic64_set_release(v, i) atomic64_set((v), (i))
88 ++
89 + static __inline__ s64
90 + atomic64_read(const atomic64_t *v)
91 + {
92 +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
93 +index 31fad2cbd734..8fc842dae3b3 100644
94 +--- a/arch/x86/kernel/fpu/signal.c
95 ++++ b/arch/x86/kernel/fpu/signal.c
96 +@@ -317,10 +317,10 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
97 + sanitize_restored_xstate(tsk, &env, xfeatures, fx_only);
98 + }
99 +
100 ++ local_bh_disable();
101 + fpu->fpstate_active = 1;
102 +- preempt_disable();
103 + fpu__restore(fpu);
104 +- preempt_enable();
105 ++ local_bh_enable();
106 +
107 + return err;
108 + } else {
109 +diff --git a/arch/x86/math-emu/wm_sqrt.S b/arch/x86/math-emu/wm_sqrt.S
110 +index d258f59564e1..3b40c98bbbd4 100644
111 +--- a/arch/x86/math-emu/wm_sqrt.S
112 ++++ b/arch/x86/math-emu/wm_sqrt.S
113 +@@ -208,7 +208,7 @@ sqrt_stage_2_finish:
114 +
115 + #ifdef PARANOID
116 + /* It should be possible to get here only if the arg is ffff....ffff */
117 +- cmp $0xffffffff,FPU_fsqrt_arg_1
118 ++ cmpl $0xffffffff,FPU_fsqrt_arg_1
119 + jnz sqrt_stage_2_error
120 + #endif /* PARANOID */
121 +
122 +diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
123 +index 49ccbd9022f6..92f5a259e251 100644
124 +--- a/arch/xtensa/kernel/setup.c
125 ++++ b/arch/xtensa/kernel/setup.c
126 +@@ -716,7 +716,8 @@ c_start(struct seq_file *f, loff_t *pos)
127 + static void *
128 + c_next(struct seq_file *f, void *v, loff_t *pos)
129 + {
130 +- return NULL;
131 ++ ++*pos;
132 ++ return c_start(f, pos);
133 + }
134 +
135 + static void
136 +diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
137 +index e2dd9109df63..00f17b5ec9c9 100644
138 +--- a/arch/xtensa/kernel/xtensa_ksyms.c
139 ++++ b/arch/xtensa/kernel/xtensa_ksyms.c
140 +@@ -82,13 +82,13 @@ void __xtensa_libgcc_window_spill(void)
141 + }
142 + EXPORT_SYMBOL(__xtensa_libgcc_window_spill);
143 +
144 +-unsigned long __sync_fetch_and_and_4(unsigned long *p, unsigned long v)
145 ++unsigned int __sync_fetch_and_and_4(volatile void *p, unsigned int v)
146 + {
147 + BUG();
148 + }
149 + EXPORT_SYMBOL(__sync_fetch_and_and_4);
150 +
151 +-unsigned long __sync_fetch_and_or_4(unsigned long *p, unsigned long v)
152 ++unsigned int __sync_fetch_and_or_4(volatile void *p, unsigned int v)
153 + {
154 + BUG();
155 + }
156 +diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c
157 +index 3f0a7e262d69..ad5712f68c3e 100644
158 +--- a/drivers/base/regmap/regmap-debugfs.c
159 ++++ b/drivers/base/regmap/regmap-debugfs.c
160 +@@ -194,6 +194,9 @@ static ssize_t regmap_read_debugfs(struct regmap *map, unsigned int from,
161 + if (*ppos < 0 || !count)
162 + return -EINVAL;
163 +
164 ++ if (count > (PAGE_SIZE << (MAX_ORDER - 1)))
165 ++ count = PAGE_SIZE << (MAX_ORDER - 1);
166 ++
167 + buf = kmalloc(count, GFP_KERNEL);
168 + if (!buf)
169 + return -ENOMEM;
170 +@@ -342,6 +345,9 @@ static ssize_t regmap_reg_ranges_read_file(struct file *file,
171 + if (*ppos < 0 || !count)
172 + return -EINVAL;
173 +
174 ++ if (count > (PAGE_SIZE << (MAX_ORDER - 1)))
175 ++ count = PAGE_SIZE << (MAX_ORDER - 1);
176 ++
177 + buf = kmalloc(count, GFP_KERNEL);
178 + if (!buf)
179 + return -ENOMEM;
180 +diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
181 +index 77cabde977ed..4a4efc6f54b5 100644
182 +--- a/drivers/base/regmap/regmap.c
183 ++++ b/drivers/base/regmap/regmap.c
184 +@@ -1106,7 +1106,7 @@ static int dev_get_regmap_match(struct device *dev, void *res, void *data)
185 +
186 + /* If the user didn't specify a name match any */
187 + if (data)
188 +- return (*r)->name == data;
189 ++ return !strcmp((*r)->name, data);
190 + else
191 + return 1;
192 + }
193 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c
194 +index 954f5b76bfcf..d44965f805fe 100644
195 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c
196 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxg94.c
197 +@@ -118,10 +118,10 @@ g94_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
198 + if (retries)
199 + udelay(400);
200 +
201 +- /* transaction request, wait up to 1ms for it to complete */
202 ++ /* transaction request, wait up to 2ms for it to complete */
203 + nvkm_wr32(device, 0x00e4e4 + base, 0x00010000 | ctrl);
204 +
205 +- timeout = 1000;
206 ++ timeout = 2000;
207 + do {
208 + ctrl = nvkm_rd32(device, 0x00e4e4 + base);
209 + udelay(1);
210 +diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
211 +index bed231b56dbd..7cac8fe372b6 100644
212 +--- a/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
213 ++++ b/drivers/gpu/drm/nouveau/nvkm/subdev/i2c/auxgm204.c
214 +@@ -118,10 +118,10 @@ gm204_i2c_aux_xfer(struct nvkm_i2c_aux *obj, bool retry,
215 + if (retries)
216 + udelay(400);
217 +
218 +- /* transaction request, wait up to 1ms for it to complete */
219 ++ /* transaction request, wait up to 2ms for it to complete */
220 + nvkm_wr32(device, 0x00d954 + base, 0x00010000 | ctrl);
221 +
222 +- timeout = 1000;
223 ++ timeout = 2000;
224 + do {
225 + ctrl = nvkm_rd32(device, 0x00d954 + base);
226 + udelay(1);
227 +diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
228 +index 8ba9eadc2079..3fb9cbdac3bf 100644
229 +--- a/drivers/net/ethernet/marvell/sky2.c
230 ++++ b/drivers/net/ethernet/marvell/sky2.c
231 +@@ -215,7 +215,7 @@ io_error:
232 +
233 + static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
234 + {
235 +- u16 v;
236 ++ u16 v = 0;
237 + __gm_phy_read(hw, port, reg, &v);
238 + return v;
239 + }
240 +diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
241 +index 7405f537beca..8531a7201968 100644
242 +--- a/drivers/net/ethernet/smsc/smc91x.c
243 ++++ b/drivers/net/ethernet/smsc/smc91x.c
244 +@@ -2289,7 +2289,7 @@ static int smc_drv_probe(struct platform_device *pdev)
245 + ret = try_toggle_control_gpio(&pdev->dev, &lp->power_gpio,
246 + "power", 0, 0, 100);
247 + if (ret)
248 +- return ret;
249 ++ goto out_free_netdev;
250 +
251 + /*
252 + * Optional reset GPIO configured? Minimum 100 ns reset needed
253 +@@ -2298,7 +2298,7 @@ static int smc_drv_probe(struct platform_device *pdev)
254 + ret = try_toggle_control_gpio(&pdev->dev, &lp->reset_gpio,
255 + "reset", 0, 0, 100);
256 + if (ret)
257 +- return ret;
258 ++ goto out_free_netdev;
259 +
260 + /*
261 + * Need to wait for optional EEPROM to load, max 750 us according
262 +diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
263 +index 313e006f74fe..6f3519123eb6 100644
264 +--- a/drivers/net/hippi/rrunner.c
265 ++++ b/drivers/net/hippi/rrunner.c
266 +@@ -1250,7 +1250,7 @@ static int rr_open(struct net_device *dev)
267 + rrpriv->info = NULL;
268 + }
269 + if (rrpriv->rx_ctrl) {
270 +- pci_free_consistent(pdev, sizeof(struct ring_ctrl),
271 ++ pci_free_consistent(pdev, 256 * sizeof(struct ring_ctrl),
272 + rrpriv->rx_ctrl, rrpriv->rx_ctrl_dma);
273 + rrpriv->rx_ctrl = NULL;
274 + }
275 +diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
276 +index 847c9fc10f9a..0da80adc545a 100644
277 +--- a/drivers/net/phy/dp83640.c
278 ++++ b/drivers/net/phy/dp83640.c
279 +@@ -1335,6 +1335,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
280 + dp83640->hwts_rx_en = 1;
281 + dp83640->layer = PTP_CLASS_L4;
282 + dp83640->version = PTP_CLASS_V1;
283 ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
284 + break;
285 + case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
286 + case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
287 +@@ -1342,6 +1343,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
288 + dp83640->hwts_rx_en = 1;
289 + dp83640->layer = PTP_CLASS_L4;
290 + dp83640->version = PTP_CLASS_V2;
291 ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L4_EVENT;
292 + break;
293 + case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
294 + case HWTSTAMP_FILTER_PTP_V2_L2_SYNC:
295 +@@ -1349,6 +1351,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
296 + dp83640->hwts_rx_en = 1;
297 + dp83640->layer = PTP_CLASS_L2;
298 + dp83640->version = PTP_CLASS_V2;
299 ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
300 + break;
301 + case HWTSTAMP_FILTER_PTP_V2_EVENT:
302 + case HWTSTAMP_FILTER_PTP_V2_SYNC:
303 +@@ -1356,6 +1359,7 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
304 + dp83640->hwts_rx_en = 1;
305 + dp83640->layer = PTP_CLASS_L4 | PTP_CLASS_L2;
306 + dp83640->version = PTP_CLASS_V2;
307 ++ cfg.rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
308 + break;
309 + default:
310 + return -ERANGE;
311 +diff --git a/drivers/net/usb/ax88172a.c b/drivers/net/usb/ax88172a.c
312 +index 6b1d03b73eeb..6b734c7ffec3 100644
313 +--- a/drivers/net/usb/ax88172a.c
314 ++++ b/drivers/net/usb/ax88172a.c
315 +@@ -245,6 +245,7 @@ static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf)
316 + ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf);
317 + if (ret < ETH_ALEN) {
318 + netdev_err(dev->net, "Failed to read MAC address: %d\n", ret);
319 ++ ret = -EIO;
320 + goto free;
321 + }
322 + memcpy(dev->net->dev_addr, buf, ETH_ALEN);
323 +diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
324 +index 6676607164d6..f5657783fad4 100644
325 +--- a/drivers/net/wan/lapbether.c
326 ++++ b/drivers/net/wan/lapbether.c
327 +@@ -308,7 +308,6 @@ static void lapbeth_setup(struct net_device *dev)
328 + dev->netdev_ops = &lapbeth_netdev_ops;
329 + dev->destructor = free_netdev;
330 + dev->type = ARPHRD_X25;
331 +- dev->hard_header_len = 3;
332 + dev->mtu = 1000;
333 + dev->addr_len = 0;
334 + }
335 +@@ -329,6 +328,14 @@ static int lapbeth_new_device(struct net_device *dev)
336 + if (!ndev)
337 + goto out;
338 +
339 ++ /* When transmitting data:
340 ++ * first this driver removes a pseudo header of 1 byte,
341 ++ * then the lapb module prepends an LAPB header of at most 3 bytes,
342 ++ * then this driver prepends a length field of 2 bytes,
343 ++ * then the underlying Ethernet device prepends its own header.
344 ++ */
345 ++ ndev->hard_header_len = -1 + 3 + 2 + dev->hard_header_len;
346 ++
347 + lapbeth = netdev_priv(ndev);
348 + lapbeth->axdev = ndev;
349 +
350 +diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
351 +index cd39025d2abf..022487d90aa3 100644
352 +--- a/drivers/net/wan/x25_asy.c
353 ++++ b/drivers/net/wan/x25_asy.c
354 +@@ -186,7 +186,7 @@ static inline void x25_asy_unlock(struct x25_asy *sl)
355 + netif_wake_queue(sl->dev);
356 + }
357 +
358 +-/* Send one completely decapsulated IP datagram to the IP layer. */
359 ++/* Send an LAPB frame to the LAPB module to process. */
360 +
361 + static void x25_asy_bump(struct x25_asy *sl)
362 + {
363 +@@ -198,13 +198,12 @@ static void x25_asy_bump(struct x25_asy *sl)
364 + count = sl->rcount;
365 + dev->stats.rx_bytes += count;
366 +
367 +- skb = dev_alloc_skb(count+1);
368 ++ skb = dev_alloc_skb(count);
369 + if (skb == NULL) {
370 + netdev_warn(sl->dev, "memory squeeze, dropping packet\n");
371 + dev->stats.rx_dropped++;
372 + return;
373 + }
374 +- skb_push(skb, 1); /* LAPB internal control */
375 + memcpy(skb_put(skb, count), sl->rbuff, count);
376 + skb->protocol = x25_type_trans(skb, sl->dev);
377 + err = lapb_data_received(skb->dev, skb);
378 +@@ -212,7 +211,6 @@ static void x25_asy_bump(struct x25_asy *sl)
379 + kfree_skb(skb);
380 + printk(KERN_DEBUG "x25_asy: data received err - %d\n", err);
381 + } else {
382 +- netif_rx(skb);
383 + dev->stats.rx_packets++;
384 + }
385 + }
386 +@@ -358,12 +356,21 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
387 + */
388 +
389 + /*
390 +- * Called when I frame data arrives. We did the work above - throw it
391 +- * at the net layer.
392 ++ * Called when I frame data arrive. We add a pseudo header for upper
393 ++ * layers and pass it to upper layers.
394 + */
395 +
396 + static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb)
397 + {
398 ++ if (skb_cow(skb, 1)) {
399 ++ kfree_skb(skb);
400 ++ return NET_RX_DROP;
401 ++ }
402 ++ skb_push(skb, 1);
403 ++ skb->data[0] = X25_IFACE_DATA;
404 ++
405 ++ skb->protocol = x25_type_trans(skb, dev);
406 ++
407 + return netif_rx(skb);
408 + }
409 +
410 +@@ -655,7 +662,7 @@ static void x25_asy_unesc(struct x25_asy *sl, unsigned char s)
411 + switch (s) {
412 + case X25_END:
413 + if (!test_and_clear_bit(SLF_ERROR, &sl->flags) &&
414 +- sl->rcount > 2)
415 ++ sl->rcount >= 2)
416 + x25_asy_bump(sl);
417 + clear_bit(SLF_ESCAPE, &sl->flags);
418 + sl->rcount = 0;
419 +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
420 +index e2ed30b03af5..76d91859cfde 100644
421 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
422 ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
423 +@@ -639,9 +639,9 @@ err:
424 +
425 + static void ath9k_hif_usb_rx_cb(struct urb *urb)
426 + {
427 +- struct sk_buff *skb = (struct sk_buff *) urb->context;
428 +- struct hif_device_usb *hif_dev =
429 +- usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
430 ++ struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
431 ++ struct hif_device_usb *hif_dev = rx_buf->hif_dev;
432 ++ struct sk_buff *skb = rx_buf->skb;
433 + int ret;
434 +
435 + if (!skb)
436 +@@ -681,14 +681,15 @@ resubmit:
437 + return;
438 + free:
439 + kfree_skb(skb);
440 ++ kfree(rx_buf);
441 + }
442 +
443 + static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
444 + {
445 +- struct sk_buff *skb = (struct sk_buff *) urb->context;
446 ++ struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
447 ++ struct hif_device_usb *hif_dev = rx_buf->hif_dev;
448 ++ struct sk_buff *skb = rx_buf->skb;
449 + struct sk_buff *nskb;
450 +- struct hif_device_usb *hif_dev =
451 +- usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
452 + int ret;
453 +
454 + if (!skb)
455 +@@ -728,11 +729,13 @@ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
456 + return;
457 + }
458 +
459 ++ rx_buf->skb = nskb;
460 ++
461 + usb_fill_int_urb(urb, hif_dev->udev,
462 + usb_rcvintpipe(hif_dev->udev,
463 + USB_REG_IN_PIPE),
464 + nskb->data, MAX_REG_IN_BUF_SIZE,
465 +- ath9k_hif_usb_reg_in_cb, nskb, 1);
466 ++ ath9k_hif_usb_reg_in_cb, rx_buf, 1);
467 + }
468 +
469 + resubmit:
470 +@@ -746,6 +749,7 @@ resubmit:
471 + return;
472 + free:
473 + kfree_skb(skb);
474 ++ kfree(rx_buf);
475 + urb->context = NULL;
476 + }
477 +
478 +@@ -791,7 +795,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
479 + init_usb_anchor(&hif_dev->mgmt_submitted);
480 +
481 + for (i = 0; i < MAX_TX_URB_NUM; i++) {
482 +- tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
483 ++ tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL);
484 + if (!tx_buf)
485 + goto err;
486 +
487 +@@ -828,8 +832,9 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct hif_device_usb *hif_dev)
488 +
489 + static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
490 + {
491 +- struct urb *urb = NULL;
492 ++ struct rx_buf *rx_buf = NULL;
493 + struct sk_buff *skb = NULL;
494 ++ struct urb *urb = NULL;
495 + int i, ret;
496 +
497 + init_usb_anchor(&hif_dev->rx_submitted);
498 +@@ -837,6 +842,12 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
499 +
500 + for (i = 0; i < MAX_RX_URB_NUM; i++) {
501 +
502 ++ rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
503 ++ if (!rx_buf) {
504 ++ ret = -ENOMEM;
505 ++ goto err_rxb;
506 ++ }
507 ++
508 + /* Allocate URB */
509 + urb = usb_alloc_urb(0, GFP_KERNEL);
510 + if (urb == NULL) {
511 +@@ -851,11 +862,14 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
512 + goto err_skb;
513 + }
514 +
515 ++ rx_buf->hif_dev = hif_dev;
516 ++ rx_buf->skb = skb;
517 ++
518 + usb_fill_bulk_urb(urb, hif_dev->udev,
519 + usb_rcvbulkpipe(hif_dev->udev,
520 + USB_WLAN_RX_PIPE),
521 + skb->data, MAX_RX_BUF_SIZE,
522 +- ath9k_hif_usb_rx_cb, skb);
523 ++ ath9k_hif_usb_rx_cb, rx_buf);
524 +
525 + /* Anchor URB */
526 + usb_anchor_urb(urb, &hif_dev->rx_submitted);
527 +@@ -881,6 +895,8 @@ err_submit:
528 + err_skb:
529 + usb_free_urb(urb);
530 + err_urb:
531 ++ kfree(rx_buf);
532 ++err_rxb:
533 + ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
534 + return ret;
535 + }
536 +@@ -892,14 +908,21 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct hif_device_usb *hif_dev)
537 +
538 + static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
539 + {
540 +- struct urb *urb = NULL;
541 ++ struct rx_buf *rx_buf = NULL;
542 + struct sk_buff *skb = NULL;
543 ++ struct urb *urb = NULL;
544 + int i, ret;
545 +
546 + init_usb_anchor(&hif_dev->reg_in_submitted);
547 +
548 + for (i = 0; i < MAX_REG_IN_URB_NUM; i++) {
549 +
550 ++ rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
551 ++ if (!rx_buf) {
552 ++ ret = -ENOMEM;
553 ++ goto err_rxb;
554 ++ }
555 ++
556 + /* Allocate URB */
557 + urb = usb_alloc_urb(0, GFP_KERNEL);
558 + if (urb == NULL) {
559 +@@ -914,11 +937,14 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
560 + goto err_skb;
561 + }
562 +
563 ++ rx_buf->hif_dev = hif_dev;
564 ++ rx_buf->skb = skb;
565 ++
566 + usb_fill_int_urb(urb, hif_dev->udev,
567 + usb_rcvintpipe(hif_dev->udev,
568 + USB_REG_IN_PIPE),
569 + skb->data, MAX_REG_IN_BUF_SIZE,
570 +- ath9k_hif_usb_reg_in_cb, skb, 1);
571 ++ ath9k_hif_usb_reg_in_cb, rx_buf, 1);
572 +
573 + /* Anchor URB */
574 + usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
575 +@@ -944,6 +970,8 @@ err_submit:
576 + err_skb:
577 + usb_free_urb(urb);
578 + err_urb:
579 ++ kfree(rx_buf);
580 ++err_rxb:
581 + ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
582 + return ret;
583 + }
584 +diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h b/drivers/net/wireless/ath/ath9k/hif_usb.h
585 +index a95cdf562611..835264c36595 100644
586 +--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
587 ++++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
588 +@@ -84,6 +84,11 @@ struct tx_buf {
589 + struct list_head list;
590 + };
591 +
592 ++struct rx_buf {
593 ++ struct sk_buff *skb;
594 ++ struct hif_device_usb *hif_dev;
595 ++};
596 ++
597 + #define HIF_USB_TX_STOP BIT(0)
598 + #define HIF_USB_TX_FLUSH BIT(1)
599 +
600 +diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h
601 +index 7bfea47dbb47..f63417197a62 100644
602 +--- a/drivers/pinctrl/pinctrl-amd.h
603 ++++ b/drivers/pinctrl/pinctrl-amd.h
604 +@@ -249,7 +249,7 @@ static const struct amd_pingroup kerncz_groups[] = {
605 + {
606 + .name = "uart0",
607 + .pins = uart0_pins,
608 +- .npins = 9,
609 ++ .npins = 5,
610 + },
611 + {
612 + .name = "uart1",
613 +diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
614 +index 319868f3f674..083cd11ce7d7 100644
615 +--- a/drivers/scsi/scsi_transport_spi.c
616 ++++ b/drivers/scsi/scsi_transport_spi.c
617 +@@ -353,7 +353,7 @@ store_spi_transport_##field(struct device *dev, \
618 + struct spi_transport_attrs *tp \
619 + = (struct spi_transport_attrs *)&starget->starget_data; \
620 + \
621 +- if (i->f->set_##field) \
622 ++ if (!i->f->set_##field) \
623 + return -EINVAL; \
624 + val = simple_strtoul(buf, NULL, 0); \
625 + if (val > tp->max_##field) \
626 +diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c
627 +index ccd1a91290bf..536a135cd00b 100644
628 +--- a/drivers/staging/comedi/drivers/addi_apci_1032.c
629 ++++ b/drivers/staging/comedi/drivers/addi_apci_1032.c
630 +@@ -115,14 +115,22 @@ static int apci1032_cos_insn_config(struct comedi_device *dev,
631 + unsigned int *data)
632 + {
633 + struct apci1032_private *devpriv = dev->private;
634 +- unsigned int shift, oldmask;
635 ++ unsigned int shift, oldmask, himask, lomask;
636 +
637 + switch (data[0]) {
638 + case INSN_CONFIG_DIGITAL_TRIG:
639 + if (data[1] != 0)
640 + return -EINVAL;
641 + shift = data[3];
642 +- oldmask = (1U << shift) - 1;
643 ++ if (shift < 32) {
644 ++ oldmask = (1U << shift) - 1;
645 ++ himask = data[4] << shift;
646 ++ lomask = data[5] << shift;
647 ++ } else {
648 ++ oldmask = 0xffffffffu;
649 ++ himask = 0;
650 ++ lomask = 0;
651 ++ }
652 + switch (data[2]) {
653 + case COMEDI_DIGITAL_TRIG_DISABLE:
654 + devpriv->ctrl = 0;
655 +@@ -145,8 +153,8 @@ static int apci1032_cos_insn_config(struct comedi_device *dev,
656 + devpriv->mode2 &= oldmask;
657 + }
658 + /* configure specified channels */
659 +- devpriv->mode1 |= data[4] << shift;
660 +- devpriv->mode2 |= data[5] << shift;
661 ++ devpriv->mode1 |= himask;
662 ++ devpriv->mode2 |= lomask;
663 + break;
664 + case COMEDI_DIGITAL_TRIG_ENABLE_LEVELS:
665 + if (devpriv->ctrl != (APCI1032_CTRL_INT_ENA |
666 +@@ -163,8 +171,8 @@ static int apci1032_cos_insn_config(struct comedi_device *dev,
667 + devpriv->mode2 &= oldmask;
668 + }
669 + /* configure specified channels */
670 +- devpriv->mode1 |= data[4] << shift;
671 +- devpriv->mode2 |= data[5] << shift;
672 ++ devpriv->mode1 |= himask;
673 ++ devpriv->mode2 |= lomask;
674 + break;
675 + default:
676 + return -EINVAL;
677 +diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c
678 +index 79a8799b1262..c4e36fb6df9d 100644
679 +--- a/drivers/staging/comedi/drivers/addi_apci_1500.c
680 ++++ b/drivers/staging/comedi/drivers/addi_apci_1500.c
681 +@@ -461,13 +461,14 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
682 + struct apci1500_private *devpriv = dev->private;
683 + unsigned int trig = data[1];
684 + unsigned int shift = data[3];
685 +- unsigned int hi_mask = data[4] << shift;
686 +- unsigned int lo_mask = data[5] << shift;
687 +- unsigned int chan_mask = hi_mask | lo_mask;
688 +- unsigned int old_mask = (1 << shift) - 1;
689 ++ unsigned int hi_mask;
690 ++ unsigned int lo_mask;
691 ++ unsigned int chan_mask;
692 ++ unsigned int old_mask;
693 + unsigned int pm;
694 + unsigned int pt;
695 + unsigned int pp;
696 ++ unsigned int invalid_chan;
697 +
698 + if (trig > 1) {
699 + dev_dbg(dev->class_dev,
700 +@@ -475,7 +476,20 @@ static int apci1500_di_cfg_trig(struct comedi_device *dev,
701 + return -EINVAL;
702 + }
703 +
704 +- if (chan_mask > 0xffff) {
705 ++ if (shift <= 16) {
706 ++ hi_mask = data[4] << shift;
707 ++ lo_mask = data[5] << shift;
708 ++ old_mask = (1U << shift) - 1;
709 ++ invalid_chan = (data[4] | data[5]) >> (16 - shift);
710 ++ } else {
711 ++ hi_mask = 0;
712 ++ lo_mask = 0;
713 ++ old_mask = 0xffff;
714 ++ invalid_chan = data[4] | data[5];
715 ++ }
716 ++ chan_mask = hi_mask | lo_mask;
717 ++
718 ++ if (invalid_chan) {
719 + dev_dbg(dev->class_dev, "invalid digital trigger channel\n");
720 + return -EINVAL;
721 + }
722 +diff --git a/drivers/staging/comedi/drivers/addi_apci_1564.c b/drivers/staging/comedi/drivers/addi_apci_1564.c
723 +index f1ccfbd4c578..340e55c69263 100644
724 +--- a/drivers/staging/comedi/drivers/addi_apci_1564.c
725 ++++ b/drivers/staging/comedi/drivers/addi_apci_1564.c
726 +@@ -288,14 +288,22 @@ static int apci1564_cos_insn_config(struct comedi_device *dev,
727 + unsigned int *data)
728 + {
729 + struct apci1564_private *devpriv = dev->private;
730 +- unsigned int shift, oldmask;
731 ++ unsigned int shift, oldmask, himask, lomask;
732 +
733 + switch (data[0]) {
734 + case INSN_CONFIG_DIGITAL_TRIG:
735 + if (data[1] != 0)
736 + return -EINVAL;
737 + shift = data[3];
738 +- oldmask = (1U << shift) - 1;
739 ++ if (shift < 32) {
740 ++ oldmask = (1U << shift) - 1;
741 ++ himask = data[4] << shift;
742 ++ lomask = data[5] << shift;
743 ++ } else {
744 ++ oldmask = 0xffffffffu;
745 ++ himask = 0;
746 ++ lomask = 0;
747 ++ }
748 + switch (data[2]) {
749 + case COMEDI_DIGITAL_TRIG_DISABLE:
750 + devpriv->ctrl = 0;
751 +@@ -319,8 +327,8 @@ static int apci1564_cos_insn_config(struct comedi_device *dev,
752 + devpriv->mode2 &= oldmask;
753 + }
754 + /* configure specified channels */
755 +- devpriv->mode1 |= data[4] << shift;
756 +- devpriv->mode2 |= data[5] << shift;
757 ++ devpriv->mode1 |= himask;
758 ++ devpriv->mode2 |= lomask;
759 + break;
760 + case COMEDI_DIGITAL_TRIG_ENABLE_LEVELS:
761 + if (devpriv->ctrl != (APCI1564_DI_IRQ_ENA |
762 +@@ -337,8 +345,8 @@ static int apci1564_cos_insn_config(struct comedi_device *dev,
763 + devpriv->mode2 &= oldmask;
764 + }
765 + /* configure specified channels */
766 +- devpriv->mode1 |= data[4] << shift;
767 +- devpriv->mode2 |= data[5] << shift;
768 ++ devpriv->mode1 |= himask;
769 ++ devpriv->mode2 |= lomask;
770 + break;
771 + default:
772 + return -EINVAL;
773 +diff --git a/drivers/staging/comedi/drivers/ni_6527.c b/drivers/staging/comedi/drivers/ni_6527.c
774 +index 62a817e4cd64..5b904cf07bd1 100644
775 +--- a/drivers/staging/comedi/drivers/ni_6527.c
776 ++++ b/drivers/staging/comedi/drivers/ni_6527.c
777 +@@ -341,7 +341,7 @@ static int ni6527_intr_insn_config(struct comedi_device *dev,
778 + case COMEDI_DIGITAL_TRIG_ENABLE_EDGES:
779 + /* check shift amount */
780 + shift = data[3];
781 +- if (shift >= s->n_chan) {
782 ++ if (shift >= 32) {
783 + mask = 0;
784 + rising = 0;
785 + falling = 0;
786 +diff --git a/drivers/staging/wlan-ng/prism2usb.c b/drivers/staging/wlan-ng/prism2usb.c
787 +index 8abf3f87a2d5..6da5c66bb3d5 100644
788 +--- a/drivers/staging/wlan-ng/prism2usb.c
789 ++++ b/drivers/staging/wlan-ng/prism2usb.c
790 +@@ -60,11 +60,25 @@ static int prism2sta_probe_usb(struct usb_interface *interface,
791 + const struct usb_device_id *id)
792 + {
793 + struct usb_device *dev;
794 +-
795 ++ const struct usb_endpoint_descriptor *epd;
796 ++ const struct usb_host_interface *iface_desc = interface->cur_altsetting;
797 + wlandevice_t *wlandev = NULL;
798 + hfa384x_t *hw = NULL;
799 + int result = 0;
800 +
801 ++ if (iface_desc->desc.bNumEndpoints != 2) {
802 ++ result = -ENODEV;
803 ++ goto failed;
804 ++ }
805 ++
806 ++ result = -EINVAL;
807 ++ epd = &iface_desc->endpoint[1].desc;
808 ++ if (!usb_endpoint_is_bulk_in(epd))
809 ++ goto failed;
810 ++ epd = &iface_desc->endpoint[2].desc;
811 ++ if (!usb_endpoint_is_bulk_out(epd))
812 ++ goto failed;
813 ++
814 + dev = interface_to_usbdev(interface);
815 + wlandev = create_wlan();
816 + if (wlandev == NULL) {
817 +diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
818 +index 39126460c1f5..e9ea9005a984 100644
819 +--- a/drivers/tty/serial/8250/8250_core.c
820 ++++ b/drivers/tty/serial/8250/8250_core.c
821 +@@ -530,6 +530,7 @@ static void __init serial8250_isa_init_ports(void)
822 + */
823 + up->mcr_mask = ~ALPHA_KLUDGE_MCR;
824 + up->mcr_force = ALPHA_KLUDGE_MCR;
825 ++ serial8250_set_defaults(up);
826 + }
827 +
828 + /* chain base port ops to support Remote Supervisor Adapter */
829 +@@ -553,7 +554,6 @@ static void __init serial8250_isa_init_ports(void)
830 + port->membase = old_serial_port[i].iomem_base;
831 + port->iotype = old_serial_port[i].io_type;
832 + port->regshift = old_serial_port[i].iomem_reg_shift;
833 +- serial8250_set_defaults(up);
834 +
835 + port->irqflags |= irqflag;
836 + if (serial8250_isa_config != NULL)
837 +diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
838 +index 035810bbcd02..470ccf729d59 100644
839 +--- a/drivers/tty/serial/8250/8250_mtk.c
840 ++++ b/drivers/tty/serial/8250/8250_mtk.c
841 +@@ -47,8 +47,21 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
842 + struct uart_8250_port *up =
843 + container_of(port, struct uart_8250_port, port);
844 +
845 ++ /*
846 ++ * Store the requested baud rate before calling the generic 8250
847 ++ * set_termios method. Standard 8250 port expects bauds to be
848 ++ * no higher than (uartclk / 16) so the baud will be clamped if it
849 ++ * gets out of that bound. Mediatek 8250 port supports speed
850 ++ * higher than that, therefore we'll get original baud rate back
851 ++ * after calling the generic set_termios method and recalculate
852 ++ * the speed later in this method.
853 ++ */
854 ++ baud = tty_termios_baud_rate(termios);
855 ++
856 + serial8250_do_set_termios(port, termios, old);
857 +
858 ++ tty_termios_encode_baud_rate(termios, baud, baud);
859 ++
860 + /*
861 + * Mediatek UARTs use an extra highspeed register (UART_MTK_HIGHS)
862 + *
863 +@@ -91,6 +104,11 @@ mtk8250_set_termios(struct uart_port *port, struct ktermios *termios,
864 + */
865 + spin_lock_irqsave(&port->lock, flags);
866 +
867 ++ /*
868 ++ * Update the per-port timeout.
869 ++ */
870 ++ uart_update_timeout(port, termios->c_cflag, baud);
871 ++
872 + /* set DLAB we have cval saved in up->lcr from the call to the core */
873 + serial_port_out(port, UART_LCR, up->lcr | UART_LCR_DLAB);
874 + serial_dl_write(up, quot);
875 +diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c
876 +index 594639e5cbf8..78168e1827b5 100644
877 +--- a/drivers/usb/gadget/udc/gr_udc.c
878 ++++ b/drivers/usb/gadget/udc/gr_udc.c
879 +@@ -2001,9 +2001,12 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit)
880 +
881 + if (num == 0) {
882 + _req = gr_alloc_request(&ep->ep, GFP_ATOMIC);
883 ++ if (!_req)
884 ++ return -ENOMEM;
885 ++
886 + buf = devm_kzalloc(dev->dev, PAGE_SIZE, GFP_DMA | GFP_ATOMIC);
887 +- if (!_req || !buf) {
888 +- /* possible _req freed by gr_probe via gr_remove */
889 ++ if (!buf) {
890 ++ gr_free_request(&ep->ep, _req);
891 + return -ENOMEM;
892 + }
893 +
894 +diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
895 +index 81c5d07a2af1..228bfa19b745 100644
896 +--- a/fs/btrfs/backref.c
897 ++++ b/fs/btrfs/backref.c
898 +@@ -1221,6 +1221,7 @@ static int __btrfs_find_all_roots(struct btrfs_trans_handle *trans,
899 + if (ret < 0 && ret != -ENOENT) {
900 + ulist_free(tmp);
901 + ulist_free(*roots);
902 ++ *roots = NULL;
903 + return ret;
904 + }
905 + node = ulist_next(tmp, &uiter);
906 +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
907 +index 55ce6543050d..dcae0cf4924b 100644
908 +--- a/fs/btrfs/volumes.c
909 ++++ b/fs/btrfs/volumes.c
910 +@@ -6693,6 +6693,14 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
911 + mutex_lock(&uuid_mutex);
912 + lock_chunks(root);
913 +
914 ++ /*
915 ++ * It is possible for mount and umount to race in such a way that
916 ++ * we execute this code path, but open_fs_devices failed to clear
917 ++ * total_rw_bytes. We certainly want it cleared before reading the
918 ++ * device items, so clear it here.
919 ++ */
920 ++ root->fs_info->fs_devices->total_rw_bytes = 0;
921 ++
922 + /*
923 + * Read all device items, and then all the chunk items. All
924 + * device items are found before any chunk item (their object id
925 +diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
926 +index a002e289a544..c18c26a78453 100644
927 +--- a/fs/cifs/inode.c
928 ++++ b/fs/cifs/inode.c
929 +@@ -1737,7 +1737,6 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
930 + FILE_UNIX_BASIC_INFO *info_buf_target;
931 + unsigned int xid;
932 + int rc, tmprc;
933 +- bool new_target = d_really_is_negative(target_dentry);
934 +
935 + if (flags & ~RENAME_NOREPLACE)
936 + return -EINVAL;
937 +@@ -1814,13 +1813,8 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
938 + */
939 +
940 + unlink_target:
941 +- /*
942 +- * If the target dentry was created during the rename, try
943 +- * unlinking it if it's not negative
944 +- */
945 +- if (new_target &&
946 +- d_really_is_positive(target_dentry) &&
947 +- (rc == -EACCES || rc == -EEXIST)) {
948 ++ /* Try unlinking the target dentry if it's not negative */
949 ++ if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) {
950 + if (d_is_dir(target_dentry))
951 + tmprc = cifs_rmdir(target_dir, target_dentry);
952 + else
953 +diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
954 +index 4d76e9a97538..7789f0b9b999 100644
955 +--- a/fs/nfs/direct.c
956 ++++ b/fs/nfs/direct.c
957 +@@ -385,6 +385,8 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
958 + if (write)
959 + nfs_zap_mapping(inode, inode->i_mapping);
960 +
961 ++ inode_dio_end(inode);
962 ++
963 + if (dreq->iocb) {
964 + long res = (long) dreq->error;
965 + if (!res)
966 +@@ -394,10 +396,7 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
967 +
968 + complete_all(&dreq->completion);
969 +
970 +- igrab(inode);
971 + nfs_direct_req_release(dreq);
972 +- inode_dio_end(inode);
973 +- iput(inode);
974 + }
975 +
976 + static void nfs_direct_readpage_release(struct nfs_page *req)
977 +@@ -538,10 +537,8 @@ static ssize_t nfs_direct_read_schedule_iovec(struct nfs_direct_req *dreq,
978 + * generic layer handle the completion.
979 + */
980 + if (requested_bytes == 0) {
981 +- igrab(inode);
982 +- nfs_direct_req_release(dreq);
983 + inode_dio_end(inode);
984 +- iput(inode);
985 ++ nfs_direct_req_release(dreq);
986 + return result < 0 ? result : -EIO;
987 + }
988 +
989 +@@ -942,10 +939,8 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq,
990 + * generic layer handle the completion.
991 + */
992 + if (requested_bytes == 0) {
993 +- igrab(inode);
994 +- nfs_direct_req_release(dreq);
995 + inode_dio_end(inode);
996 +- iput(inode);
997 ++ nfs_direct_req_release(dreq);
998 + return result < 0 ? result : -EIO;
999 + }
1000 +
1001 +diff --git a/fs/nfs/file.c b/fs/nfs/file.c
1002 +index eaa6697d256e..dc875cd0e11d 100644
1003 +--- a/fs/nfs/file.c
1004 ++++ b/fs/nfs/file.c
1005 +@@ -82,7 +82,6 @@ nfs_file_release(struct inode *inode, struct file *filp)
1006 + dprintk("NFS: release(%pD2)\n", filp);
1007 +
1008 + nfs_inc_stats(inode, NFSIOS_VFSRELEASE);
1009 +- inode_dio_wait(inode);
1010 + nfs_file_clear_open_context(filp);
1011 + return 0;
1012 + }
1013 +diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
1014 +index d98ba57ef01a..c167bdaafc50 100644
1015 +--- a/fs/xfs/libxfs/xfs_bmap.c
1016 ++++ b/fs/xfs/libxfs/xfs_bmap.c
1017 +@@ -793,6 +793,8 @@ xfs_bmap_extents_to_btree(
1018 + *logflagsp = 0;
1019 + if ((error = xfs_alloc_vextent(&args))) {
1020 + xfs_iroot_realloc(ip, -1, whichfork);
1021 ++ ASSERT(ifp->if_broot == NULL);
1022 ++ XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS);
1023 + xfs_btree_del_cursor(cur, XFS_BTREE_ERROR);
1024 + return error;
1025 + }
1026 +diff --git a/include/linux/tcp.h b/include/linux/tcp.h
1027 +index 085da1707cea..b9e591582be9 100644
1028 +--- a/include/linux/tcp.h
1029 ++++ b/include/linux/tcp.h
1030 +@@ -211,7 +211,8 @@ struct tcp_sock {
1031 + u8 reord; /* reordering detected */
1032 + } rack;
1033 + u16 advmss; /* Advertised MSS */
1034 +- u8 unused;
1035 ++ u8 tlp_retrans:1, /* TLP is a retransmission */
1036 ++ unused_1:7;
1037 + u8 nonagle : 4,/* Disable Nagle algorithm? */
1038 + thin_lto : 1,/* Use linear timeouts for thin streams */
1039 + thin_dupack : 1,/* Fast retransmit on first dupack */
1040 +@@ -225,7 +226,7 @@ struct tcp_sock {
1041 + syn_data_acked:1,/* data in SYN is acked by SYN-ACK */
1042 + save_syn:1, /* Save headers of SYN packet */
1043 + is_cwnd_limited:1;/* forward progress limited by snd_cwnd? */
1044 +- u32 tlp_high_seq; /* snd_nxt at the time of TLP retransmit. */
1045 ++ u32 tlp_high_seq; /* snd_nxt at the time of TLP */
1046 +
1047 + /* RTT measurement */
1048 + u32 srtt_us; /* smoothed round trip time << 3 in usecs */
1049 +diff --git a/kernel/events/core.c b/kernel/events/core.c
1050 +index feff3ba98cc9..388ce03155b4 100644
1051 +--- a/kernel/events/core.c
1052 ++++ b/kernel/events/core.c
1053 +@@ -3940,7 +3940,9 @@ EXPORT_SYMBOL_GPL(perf_event_read_value);
1054 + static int __perf_read_group_add(struct perf_event *leader,
1055 + u64 read_format, u64 *values)
1056 + {
1057 ++ struct perf_event_context *ctx = leader->ctx;
1058 + struct perf_event *sub;
1059 ++ unsigned long flags;
1060 + int n = 1; /* skip @nr */
1061 + int ret;
1062 +
1063 +@@ -3970,12 +3972,15 @@ static int __perf_read_group_add(struct perf_event *leader,
1064 + if (read_format & PERF_FORMAT_ID)
1065 + values[n++] = primary_event_id(leader);
1066 +
1067 ++ raw_spin_lock_irqsave(&ctx->lock, flags);
1068 ++
1069 + list_for_each_entry(sub, &leader->sibling_list, group_entry) {
1070 + values[n++] += perf_event_count(sub);
1071 + if (read_format & PERF_FORMAT_ID)
1072 + values[n++] = primary_event_id(sub);
1073 + }
1074 +
1075 ++ raw_spin_unlock_irqrestore(&ctx->lock, flags);
1076 + return 0;
1077 + }
1078 +
1079 +diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
1080 +index e7dabb254404..d937fbbc3642 100644
1081 +--- a/kernel/events/uprobes.c
1082 ++++ b/kernel/events/uprobes.c
1083 +@@ -1875,7 +1875,7 @@ static void handle_swbp(struct pt_regs *regs)
1084 + if (!uprobe) {
1085 + if (is_swbp > 0) {
1086 + /* No matching uprobe; signal SIGTRAP. */
1087 +- send_sig(SIGTRAP, current, 0);
1088 ++ force_sig(SIGTRAP, current);
1089 + } else {
1090 + /*
1091 + * Either we raced with uprobe_unregister() or we can't
1092 +diff --git a/mm/memcontrol.c b/mm/memcontrol.c
1093 +index cb98a1889c8c..617feca8d094 100644
1094 +--- a/mm/memcontrol.c
1095 ++++ b/mm/memcontrol.c
1096 +@@ -4889,7 +4889,6 @@ static void __mem_cgroup_clear_mc(void)
1097 + if (!mem_cgroup_is_root(mc.to))
1098 + page_counter_uncharge(&mc.to->memory, mc.moved_swap);
1099 +
1100 +- mem_cgroup_id_get_many(mc.to, mc.moved_swap);
1101 + css_put_many(&mc.to->css, mc.moved_swap);
1102 +
1103 + mc.moved_swap = 0;
1104 +@@ -5067,7 +5066,8 @@ put: /* get_mctgt_type() gets the page */
1105 + ent = target.ent;
1106 + if (!mem_cgroup_move_swap_account(ent, mc.from, mc.to)) {
1107 + mc.precharge--;
1108 +- /* we fixup refcnts and charges later. */
1109 ++ mem_cgroup_id_get_many(mc.to, 1);
1110 ++ /* we fixup other refcnts and charges later. */
1111 + mc.moved_swap++;
1112 + }
1113 + break;
1114 +diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
1115 +index 02be8ee23271..64fede18aa33 100644
1116 +--- a/net/ax25/af_ax25.c
1117 ++++ b/net/ax25/af_ax25.c
1118 +@@ -1191,7 +1191,10 @@ static int __must_check ax25_connect(struct socket *sock,
1119 + if (addr_len > sizeof(struct sockaddr_ax25) &&
1120 + fsa->fsa_ax25.sax25_ndigis != 0) {
1121 + /* Valid number of digipeaters ? */
1122 +- if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) {
1123 ++ if (fsa->fsa_ax25.sax25_ndigis < 1 ||
1124 ++ fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS ||
1125 ++ addr_len < sizeof(struct sockaddr_ax25) +
1126 ++ sizeof(ax25_address) * fsa->fsa_ax25.sax25_ndigis) {
1127 + err = -EINVAL;
1128 + goto out_release;
1129 + }
1130 +@@ -1510,7 +1513,10 @@ static int ax25_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
1131 + struct full_sockaddr_ax25 *fsa = (struct full_sockaddr_ax25 *)usax;
1132 +
1133 + /* Valid number of digipeaters ? */
1134 +- if (usax->sax25_ndigis < 1 || usax->sax25_ndigis > AX25_MAX_DIGIS) {
1135 ++ if (usax->sax25_ndigis < 1 ||
1136 ++ usax->sax25_ndigis > AX25_MAX_DIGIS ||
1137 ++ addr_len < sizeof(struct sockaddr_ax25) +
1138 ++ sizeof(ax25_address) * usax->sax25_ndigis) {
1139 + err = -EINVAL;
1140 + goto out;
1141 + }
1142 +diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
1143 +index 579d351f6ddd..c976fd132c3b 100644
1144 +--- a/net/core/net-sysfs.c
1145 ++++ b/net/core/net-sysfs.c
1146 +@@ -999,7 +999,7 @@ static ssize_t show_trans_timeout(struct netdev_queue *queue,
1147 + trans_timeout = queue->trans_timeout;
1148 + spin_unlock_irq(&queue->_xmit_lock);
1149 +
1150 +- return sprintf(buf, "%lu", trans_timeout);
1151 ++ return sprintf(buf, fmt_ulong, trans_timeout);
1152 + }
1153 +
1154 + #ifdef CONFIG_XPS
1155 +diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
1156 +index e2066f2f19b4..9215ee1de494 100644
1157 +--- a/net/ipv4/tcp_input.c
1158 ++++ b/net/ipv4/tcp_input.c
1159 +@@ -3517,10 +3517,8 @@ static void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq)
1160 + }
1161 + }
1162 +
1163 +-/* This routine deals with acks during a TLP episode.
1164 +- * We mark the end of a TLP episode on receiving TLP dupack or when
1165 +- * ack is after tlp_high_seq.
1166 +- * Ref: loss detection algorithm in draft-dukkipati-tcpm-tcp-loss-probe.
1167 ++/* This routine deals with acks during a TLP episode and ends an episode by
1168 ++ * resetting tlp_high_seq. Ref: TLP algorithm in draft-ietf-tcpm-rack
1169 + */
1170 + static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag)
1171 + {
1172 +@@ -3529,7 +3527,10 @@ static void tcp_process_tlp_ack(struct sock *sk, u32 ack, int flag)
1173 + if (before(ack, tp->tlp_high_seq))
1174 + return;
1175 +
1176 +- if (flag & FLAG_DSACKING_ACK) {
1177 ++ if (!tp->tlp_retrans) {
1178 ++ /* TLP of new data has been acknowledged */
1179 ++ tp->tlp_high_seq = 0;
1180 ++ } else if (flag & FLAG_DSACKING_ACK) {
1181 + /* This DSACK means original and TLP probe arrived; no loss */
1182 + tp->tlp_high_seq = 0;
1183 + } else if (after(ack, tp->tlp_high_seq)) {
1184 +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
1185 +index 6c8966dcf612..b218138874cc 100644
1186 +--- a/net/ipv4/tcp_output.c
1187 ++++ b/net/ipv4/tcp_output.c
1188 +@@ -2271,6 +2271,11 @@ void tcp_send_loss_probe(struct sock *sk)
1189 + int pcount;
1190 + int mss = tcp_current_mss(sk);
1191 +
1192 ++ /* At most one outstanding TLP */
1193 ++ if (tp->tlp_high_seq)
1194 ++ goto rearm_timer;
1195 ++
1196 ++ tp->tlp_retrans = 0;
1197 + skb = tcp_send_head(sk);
1198 + if (skb) {
1199 + if (tcp_snd_wnd_test(tp, skb, mss)) {
1200 +@@ -2293,10 +2298,6 @@ void tcp_send_loss_probe(struct sock *sk)
1201 + return;
1202 + }
1203 +
1204 +- /* At most one outstanding TLP retransmission. */
1205 +- if (tp->tlp_high_seq)
1206 +- goto rearm_timer;
1207 +-
1208 + if (skb_still_in_host_queue(sk, skb))
1209 + goto rearm_timer;
1210 +
1211 +@@ -2317,10 +2318,12 @@ void tcp_send_loss_probe(struct sock *sk)
1212 + if (__tcp_retransmit_skb(sk, skb))
1213 + goto rearm_timer;
1214 +
1215 ++ tp->tlp_retrans = 1;
1216 ++
1217 ++probe_sent:
1218 + /* Record snd_nxt for loss detection. */
1219 + tp->tlp_high_seq = tp->snd_nxt;
1220 +
1221 +-probe_sent:
1222 + NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPLOSSPROBES);
1223 + /* Reset s.t. tcp_rearm_rto will restart timer from now */
1224 + inet_csk(sk)->icsk_pending = 0;
1225 +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
1226 +index bb306996c15e..5464fd210230 100644
1227 +--- a/net/ipv4/udp.c
1228 ++++ b/net/ipv4/udp.c
1229 +@@ -1558,7 +1558,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1230 + /*
1231 + * UDP-Lite specific tests, ignored on UDP sockets
1232 + */
1233 +- if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
1234 ++ if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
1235 +
1236 + /*
1237 + * MIB statistics other than incrementing the error count are
1238 +diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
1239 +index 546172bfaba1..6efe6b101d3f 100644
1240 +--- a/net/ipv6/ip6_gre.c
1241 ++++ b/net/ipv6/ip6_gre.c
1242 +@@ -1355,15 +1355,16 @@ static void ip6gre_destroy_tunnels(struct net *net, struct list_head *head)
1243 + static int __net_init ip6gre_init_net(struct net *net)
1244 + {
1245 + struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
1246 ++ struct net_device *ndev;
1247 + int err;
1248 +
1249 +- ign->fb_tunnel_dev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
1250 +- NET_NAME_UNKNOWN,
1251 +- ip6gre_tunnel_setup);
1252 +- if (!ign->fb_tunnel_dev) {
1253 ++ ndev = alloc_netdev(sizeof(struct ip6_tnl), "ip6gre0",
1254 ++ NET_NAME_UNKNOWN, ip6gre_tunnel_setup);
1255 ++ if (!ndev) {
1256 + err = -ENOMEM;
1257 + goto err_alloc_dev;
1258 + }
1259 ++ ign->fb_tunnel_dev = ndev;
1260 + dev_net_set(ign->fb_tunnel_dev, net);
1261 + /* FB netdevice is special: we have one, and only one per netns.
1262 + * Allowing to move it to another netns is clearly unsafe.
1263 +@@ -1383,7 +1384,7 @@ static int __net_init ip6gre_init_net(struct net *net)
1264 + return 0;
1265 +
1266 + err_reg_dev:
1267 +- ip6gre_dev_free(ign->fb_tunnel_dev);
1268 ++ ip6gre_dev_free(ndev);
1269 + err_alloc_dev:
1270 + return err;
1271 + }
1272 +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
1273 +index 73f111206e36..79c583004575 100644
1274 +--- a/net/ipv6/udp.c
1275 ++++ b/net/ipv6/udp.c
1276 +@@ -672,7 +672,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
1277 + /*
1278 + * UDP-Lite specific tests, ignored on UDP sockets (see net/ipv4/udp.c).
1279 + */
1280 +- if ((is_udplite & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
1281 ++ if ((up->pcflag & UDPLITE_RECV_CC) && UDP_SKB_CB(skb)->partial_cov) {
1282 +
1283 + if (up->pcrlen == 0) { /* full coverage was set */
1284 + net_dbg_ratelimited("UDPLITE6: partial coverage %d while full coverage %d requested\n",
1285 +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
1286 +index a74a6ff18f91..886dce84e70c 100644
1287 +--- a/net/mac80211/rx.c
1288 ++++ b/net/mac80211/rx.c
1289 +@@ -1963,6 +1963,7 @@ static int ieee80211_802_1x_port_control(struct ieee80211_rx_data *rx)
1290 +
1291 + static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc)
1292 + {
1293 ++ struct ieee80211_hdr *hdr = (void *)rx->skb->data;
1294 + struct sk_buff *skb = rx->skb;
1295 + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
1296 +
1297 +@@ -1973,6 +1974,31 @@ static int ieee80211_drop_unencrypted(struct ieee80211_rx_data *rx, __le16 fc)
1298 + if (status->flag & RX_FLAG_DECRYPTED)
1299 + return 0;
1300 +
1301 ++ /* check mesh EAPOL frames first */
1302 ++ if (unlikely(rx->sta && ieee80211_vif_is_mesh(&rx->sdata->vif) &&
1303 ++ ieee80211_is_data(fc))) {
1304 ++ struct ieee80211s_hdr *mesh_hdr;
1305 ++ u16 hdr_len = ieee80211_hdrlen(fc);
1306 ++ u16 ethertype_offset;
1307 ++ __be16 ethertype;
1308 ++
1309 ++ if (!ether_addr_equal(hdr->addr1, rx->sdata->vif.addr))
1310 ++ goto drop_check;
1311 ++
1312 ++ /* make sure fixed part of mesh header is there, also checks skb len */
1313 ++ if (!pskb_may_pull(rx->skb, hdr_len + 6))
1314 ++ goto drop_check;
1315 ++
1316 ++ mesh_hdr = (struct ieee80211s_hdr *)(skb->data + hdr_len);
1317 ++ ethertype_offset = hdr_len + ieee80211_get_mesh_hdrlen(mesh_hdr) +
1318 ++ sizeof(rfc1042_header);
1319 ++
1320 ++ if (skb_copy_bits(rx->skb, ethertype_offset, &ethertype, 2) == 0 &&
1321 ++ ethertype == rx->sdata->control_port_protocol)
1322 ++ return 0;
1323 ++ }
1324 ++
1325 ++drop_check:
1326 + /* Drop unencrypted frames if key is set. */
1327 + if (unlikely(!ieee80211_has_protected(fc) &&
1328 + !ieee80211_is_any_nullfunc(fc) &&
1329 +diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
1330 +index 14c4e12c47b0..a1997f9a447a 100644
1331 +--- a/net/rxrpc/ar-output.c
1332 ++++ b/net/rxrpc/ar-output.c
1333 +@@ -533,7 +533,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
1334 + /* this should be in poll */
1335 + sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
1336 +
1337 +- if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
1338 ++ if (sk->sk_shutdown & SEND_SHUTDOWN)
1339 + return -EPIPE;
1340 +
1341 + more = msg->msg_flags & MSG_MORE;
1342 +diff --git a/net/rxrpc/ar-recvmsg.c b/net/rxrpc/ar-recvmsg.c
1343 +index b92beded7459..cb9affdb1e87 100644
1344 +--- a/net/rxrpc/ar-recvmsg.c
1345 ++++ b/net/rxrpc/ar-recvmsg.c
1346 +@@ -78,7 +78,7 @@ int rxrpc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
1347 + release_sock(&rx->sk);
1348 + if (continue_call)
1349 + rxrpc_put_call(continue_call);
1350 +- return -ENODATA;
1351 ++ return -EAGAIN;
1352 + }
1353 + }
1354 +
1355 +diff --git a/scripts/decode_stacktrace.sh b/scripts/decode_stacktrace.sh
1356 +index 4f5e76f76b9d..003968cb04d4 100755
1357 +--- a/scripts/decode_stacktrace.sh
1358 ++++ b/scripts/decode_stacktrace.sh
1359 +@@ -63,8 +63,8 @@ parse_symbol() {
1360 + return
1361 + fi
1362 +
1363 +- # Strip out the base of the path
1364 +- code=${code#$basepath/}
1365 ++ # Strip out the base of the path on each line
1366 ++ code=$(while read -r line; do echo "${line#$basepath/}"; done <<< "$code")
1367 +
1368 + # In the case of inlines, move everything to same line
1369 + code=${code//$'\n'/' '}
1370 +diff --git a/sound/core/info.c b/sound/core/info.c
1371 +index 358a6947342d..8a6fa8fd0aab 100644
1372 +--- a/sound/core/info.c
1373 ++++ b/sound/core/info.c
1374 +@@ -634,7 +634,9 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
1375 + {
1376 + int c = -1;
1377 +
1378 +- if (snd_BUG_ON(!buffer || !buffer->buffer))
1379 ++ if (snd_BUG_ON(!buffer))
1380 ++ return 1;
1381 ++ if (!buffer->buffer)
1382 + return 1;
1383 + if (len <= 0 || buffer->stop || buffer->error)
1384 + return 1;
1385 +diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h
1386 +index 3f1b0f1df809..e4e31e82311d 100644
1387 +--- a/sound/soc/codecs/rt5670.h
1388 ++++ b/sound/soc/codecs/rt5670.h
1389 +@@ -760,7 +760,7 @@
1390 + #define RT5670_PWR_VREF2_BIT 4
1391 + #define RT5670_PWR_FV2 (0x1 << 3)
1392 + #define RT5670_PWR_FV2_BIT 3
1393 +-#define RT5670_LDO_SEL_MASK (0x3)
1394 ++#define RT5670_LDO_SEL_MASK (0x7)
1395 + #define RT5670_LDO_SEL_SFT 0
1396 +
1397 + /* Power Management for Analog 2 (0x64) */
1398 +diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
1399 +index 20f0e27918dd..acd460303d1a 100644
1400 +--- a/tools/perf/builtin-script.c
1401 ++++ b/tools/perf/builtin-script.c
1402 +@@ -1245,7 +1245,7 @@ static int is_directory(const char *base_path, const struct dirent *dent)
1403 + char path[PATH_MAX];
1404 + struct stat st;
1405 +
1406 +- sprintf(path, "%s/%s", base_path, dent->d_name);
1407 ++ scnprintf(path, PATH_MAX, "%s/%s", base_path, dent->d_name);
1408 + if (stat(path, &st))
1409 + return 0;
1410 +
1411 +@@ -1426,8 +1426,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1412 + return -1;
1413 +
1414 + for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1415 +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1416 +- lang_dirent->d_name);
1417 ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1418 ++ lang_dirent->d_name);
1419 + lang_dir = opendir(lang_path);
1420 + if (!lang_dir)
1421 + continue;
1422 +@@ -1436,8 +1436,8 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1423 + script_root = get_script_root(script_dirent, REPORT_SUFFIX);
1424 + if (script_root) {
1425 + desc = script_desc__findnew(script_root);
1426 +- snprintf(script_path, MAXPATHLEN, "%s/%s",
1427 +- lang_path, script_dirent->d_name);
1428 ++ scnprintf(script_path, MAXPATHLEN, "%s/%s",
1429 ++ lang_path, script_dirent->d_name);
1430 + read_script_info(desc, script_path);
1431 + free(script_root);
1432 + }
1433 +@@ -1473,7 +1473,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
1434 + int match, len;
1435 + FILE *fp;
1436 +
1437 +- sprintf(filename, "%s/bin/%s-record", dir_name, scriptname);
1438 ++ scnprintf(filename, MAXPATHLEN, "%s/bin/%s-record", dir_name, scriptname);
1439 +
1440 + fp = fopen(filename, "r");
1441 + if (!fp)
1442 +@@ -1549,8 +1549,8 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1443 + }
1444 +
1445 + for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1446 +- snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
1447 +- lang_dirent->d_name);
1448 ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
1449 ++ lang_dirent->d_name);
1450 + #ifdef NO_LIBPERL
1451 + if (strstr(lang_path, "perl"))
1452 + continue;
1453 +@@ -1605,8 +1605,8 @@ static char *get_script_path(const char *script_root, const char *suffix)
1454 + return NULL;
1455 +
1456 + for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1457 +- snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1458 +- lang_dirent->d_name);
1459 ++ scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1460 ++ lang_dirent->d_name);
1461 + lang_dir = opendir(lang_path);
1462 + if (!lang_dir)
1463 + continue;
1464 +@@ -1617,8 +1617,8 @@ static char *get_script_path(const char *script_root, const char *suffix)
1465 + free(__script_root);
1466 + closedir(lang_dir);
1467 + closedir(scripts_dir);
1468 +- snprintf(script_path, MAXPATHLEN, "%s/%s",
1469 +- lang_path, script_dirent->d_name);
1470 ++ scnprintf(script_path, MAXPATHLEN, "%s/%s",
1471 ++ lang_path, script_dirent->d_name);
1472 + return strdup(script_path);
1473 + }
1474 + free(__script_root);
1475 +diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c
1476 +index 79547c225c14..9c81fbfb16d2 100644
1477 +--- a/tools/perf/tests/attr.c
1478 ++++ b/tools/perf/tests/attr.c
1479 +@@ -147,8 +147,8 @@ static int run_dir(const char *d, const char *perf)
1480 + if (verbose)
1481 + vcnt++;
1482 +
1483 +- snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
1484 +- d, d, perf, vcnt, v);
1485 ++ scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
1486 ++ d, d, perf, vcnt, v);
1487 +
1488 + return system(cmd) ? TEST_FAIL : TEST_OK;
1489 + }
1490 +diff --git a/tools/perf/tests/pmu.c b/tools/perf/tests/pmu.c
1491 +index faa04e9d5d5f..b776831ceeea 100644
1492 +--- a/tools/perf/tests/pmu.c
1493 ++++ b/tools/perf/tests/pmu.c
1494 +@@ -95,7 +95,7 @@ static char *test_format_dir_get(void)
1495 + struct test_format *format = &test_formats[i];
1496 + FILE *file;
1497 +
1498 +- snprintf(name, PATH_MAX, "%s/%s", dir, format->name);
1499 ++ scnprintf(name, PATH_MAX, "%s/%s", dir, format->name);
1500 +
1501 + file = fopen(name, "w");
1502 + if (!file)
1503 +diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
1504 +index 1dd1949b0e79..1e1c37a17355 100644
1505 +--- a/tools/perf/util/annotate.c
1506 ++++ b/tools/perf/util/annotate.c
1507 +@@ -1077,7 +1077,7 @@ int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize)
1508 + struct dso *dso = map->dso;
1509 + char *filename = dso__build_id_filename(dso, NULL, 0);
1510 + bool free_filename = true;
1511 +- char command[PATH_MAX * 2];
1512 ++ char *command;
1513 + FILE *file;
1514 + int err = 0;
1515 + char symfs_filename[PATH_MAX];
1516 +@@ -1192,7 +1192,7 @@ fallback:
1517 + strcpy(symfs_filename, tmp);
1518 + }
1519 +
1520 +- snprintf(command, sizeof(command),
1521 ++ err = asprintf(&command,
1522 + "%s %s%s --start-address=0x%016" PRIx64
1523 + " --stop-address=0x%016" PRIx64
1524 + " -l -d %s %s -C %s 2>/dev/null|grep -v %s|expand",
1525 +@@ -1205,6 +1205,11 @@ fallback:
1526 + symbol_conf.annotate_src ? "-S" : "",
1527 + symfs_filename, filename);
1528 +
1529 ++ if (err < 0) {
1530 ++ pr_err("Failure allocating memory for the command to run\n");
1531 ++ goto out_remove_tmp;
1532 ++ }
1533 ++
1534 + pr_debug("Executing: %s\n", command);
1535 +
1536 + file = popen(command, "r");
1537 +@@ -1214,7 +1219,7 @@ fallback:
1538 + * If we were using debug info should retry with
1539 + * original binary.
1540 + */
1541 +- goto out_remove_tmp;
1542 ++ goto out_free_command;
1543 + }
1544 +
1545 + nline = 0;
1546 +@@ -1237,6 +1242,9 @@ fallback:
1547 +
1548 + pclose(file);
1549 +
1550 ++out_free_command:
1551 ++ free(command);
1552 ++
1553 + out_remove_tmp:
1554 + if (dso__needs_decompress(dso))
1555 + unlink(symfs_filename);
1556 +diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
1557 +index 32e12ecfe9c5..a32f0b34e3ed 100644
1558 +--- a/tools/perf/util/cgroup.c
1559 ++++ b/tools/perf/util/cgroup.c
1560 +@@ -64,7 +64,7 @@ static int open_cgroup(char *name)
1561 + if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1))
1562 + return -1;
1563 +
1564 +- snprintf(path, PATH_MAX, "%s/%s", mnt, name);
1565 ++ scnprintf(path, PATH_MAX, "%s/%s", mnt, name);
1566 +
1567 + fd = open(path, O_RDONLY);
1568 + if (fd == -1)
1569 +diff --git a/tools/perf/util/pager.c b/tools/perf/util/pager.c
1570 +index 53ef006a951c..b301d779c4af 100644
1571 +--- a/tools/perf/util/pager.c
1572 ++++ b/tools/perf/util/pager.c
1573 +@@ -16,10 +16,13 @@ static void pager_preexec(void)
1574 + * have real input
1575 + */
1576 + fd_set in;
1577 ++ fd_set exception;
1578 +
1579 + FD_ZERO(&in);
1580 ++ FD_ZERO(&exception);
1581 + FD_SET(0, &in);
1582 +- select(1, &in, NULL, &in, NULL);
1583 ++ FD_SET(0, &exception);
1584 ++ select(1, &in, NULL, &exception, NULL);
1585 +
1586 + setenv("LESS", "FRSX", 0);
1587 + }
1588 +diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
1589 +index 9351738df703..849ad278dd5d 100644
1590 +--- a/tools/perf/util/parse-events.c
1591 ++++ b/tools/perf/util/parse-events.c
1592 +@@ -194,8 +194,8 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
1593 +
1594 + for_each_event(sys_dirent, evt_dir, evt_dirent) {
1595 +
1596 +- snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
1597 +- evt_dirent->d_name);
1598 ++ scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
1599 ++ evt_dirent->d_name);
1600 + fd = open(evt_path, O_RDONLY);
1601 + if (fd < 0)
1602 + continue;
1603 +diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
1604 +index 4f650ebd564a..5245fbd09106 100644
1605 +--- a/tools/perf/util/pmu.c
1606 ++++ b/tools/perf/util/pmu.c
1607 +@@ -302,7 +302,7 @@ static int pmu_aliases_parse(char *dir, struct list_head *head)
1608 + if (pmu_alias_info_file(name))
1609 + continue;
1610 +
1611 +- snprintf(path, PATH_MAX, "%s/%s", dir, name);
1612 ++ scnprintf(path, PATH_MAX, "%s/%s", dir, name);
1613 +
1614 + file = fopen(path, "r");
1615 + if (!file) {
1616 +diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
1617 +index 0195b7e8c54a..4f05424096b6 100644
1618 +--- a/tools/perf/util/probe-event.c
1619 ++++ b/tools/perf/util/probe-event.c
1620 +@@ -122,7 +122,7 @@ static struct symbol *__find_kernel_function(u64 addr, struct map **mapp)
1621 + return machine__find_kernel_function(host_machine, addr, mapp, NULL);
1622 + }
1623 +
1624 +-static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void)
1625 ++static struct ref_reloc_sym *kernel_get_ref_reloc_sym(struct map **pmap)
1626 + {
1627 + /* kmap->ref_reloc_sym should be set if host_machine is initialized */
1628 + struct kmap *kmap;
1629 +@@ -134,6 +134,10 @@ static struct ref_reloc_sym *kernel_get_ref_reloc_sym(void)
1630 + kmap = map__kmap(map);
1631 + if (!kmap)
1632 + return NULL;
1633 ++
1634 ++ if (pmap)
1635 ++ *pmap = map;
1636 ++
1637 + return kmap->ref_reloc_sym;
1638 + }
1639 +
1640 +@@ -145,7 +149,7 @@ static int kernel_get_symbol_address_by_name(const char *name, u64 *addr,
1641 + struct map *map;
1642 +
1643 + /* ref_reloc_sym is just a label. Need a special fix*/
1644 +- reloc_sym = kernel_get_ref_reloc_sym();
1645 ++ reloc_sym = kernel_get_ref_reloc_sym(NULL);
1646 + if (reloc_sym && strcmp(name, reloc_sym->name) == 0)
1647 + *addr = (reloc) ? reloc_sym->addr : reloc_sym->unrelocated_addr;
1648 + else {
1649 +@@ -618,6 +622,7 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
1650 + bool uprobe)
1651 + {
1652 + struct ref_reloc_sym *reloc_sym;
1653 ++ struct map *map;
1654 + char *tmp;
1655 + int i, skipped = 0;
1656 +
1657 +@@ -628,7 +633,7 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
1658 + if (module)
1659 + return add_module_to_probe_trace_events(tevs, ntevs, module);
1660 +
1661 +- reloc_sym = kernel_get_ref_reloc_sym();
1662 ++ reloc_sym = kernel_get_ref_reloc_sym(&map);
1663 + if (!reloc_sym) {
1664 + pr_warning("Relocated base symbol is not found!\n");
1665 + return -EINVAL;
1666 +@@ -637,9 +642,13 @@ static int post_process_probe_trace_events(struct probe_trace_event *tevs,
1667 + for (i = 0; i < ntevs; i++) {
1668 + if (!tevs[i].point.address || tevs[i].point.retprobe)
1669 + continue;
1670 +- /* If we found a wrong one, mark it by NULL symbol */
1671 ++ /*
1672 ++ * If we found a wrong one, mark it by NULL symbol.
1673 ++ * Since addresses in debuginfo is same as objdump, we need
1674 ++ * to convert it to addresses on memory.
1675 ++ */
1676 + if (kprobe_warn_out_range(tevs[i].point.symbol,
1677 +- tevs[i].point.address)) {
1678 ++ map__objdump_2mem(map, tevs[i].point.address))) {
1679 + tmp = NULL;
1680 + skipped++;
1681 + } else {
1682 +@@ -2553,7 +2562,7 @@ static int find_probe_trace_events_from_map(struct perf_probe_event *pev,
1683 +
1684 + /* Note that the symbols in the kmodule are not relocated */
1685 + if (!pev->uprobes && !pp->retprobe && !pev->target) {
1686 +- reloc_sym = kernel_get_ref_reloc_sym();
1687 ++ reloc_sym = kernel_get_ref_reloc_sym(NULL);
1688 + if (!reloc_sym) {
1689 + pr_warning("Relocated base symbol is not found!\n");
1690 + ret = -EINVAL;
1691 +diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
1692 +index b4db3f48e3b0..2853d4728ab9 100644
1693 +--- a/tools/perf/util/srcline.c
1694 ++++ b/tools/perf/util/srcline.c
1695 +@@ -86,16 +86,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
1696 + bfd_vma pc, vma;
1697 + bfd_size_type size;
1698 + struct a2l_data *a2l = data;
1699 ++ flagword flags;
1700 +
1701 + if (a2l->found)
1702 + return;
1703 +
1704 +- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
1705 ++#ifdef bfd_get_section_flags
1706 ++ flags = bfd_get_section_flags(abfd, section);
1707 ++#else
1708 ++ flags = bfd_section_flags(section);
1709 ++#endif
1710 ++ if ((flags & SEC_ALLOC) == 0)
1711 + return;
1712 +
1713 + pc = a2l->addr;
1714 ++#ifdef bfd_get_section_vma
1715 + vma = bfd_get_section_vma(abfd, section);
1716 ++#else
1717 ++ vma = bfd_section_vma(section);
1718 ++#endif
1719 ++#ifdef bfd_get_section_size
1720 + size = bfd_get_section_size(section);
1721 ++#else
1722 ++ size = bfd_section_size(section);
1723 ++#endif
1724 +
1725 + if (pc < vma || pc >= vma + size)
1726 + return;