Gentoo Archives: gentoo-commits

From: Mike Pagano <mpagano@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:4.9 commit in: /
Date: Thu, 03 Sep 2020 11:34:13
Message-Id: 1599132809.37bc4861ef87ec59933ff9864d90d34777175f19.mpagano@gentoo
1 commit: 37bc4861ef87ec59933ff9864d90d34777175f19
2 Author: Mike Pagano <mpagano <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 3 11:33:29 2020 +0000
4 Commit: Mike Pagano <mpagano <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 3 11:33:29 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=37bc4861
7
8 Linux patch 4.9.235
9
10 Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>
11
12 0000_README | 4 +
13 1234_linux-4.9.235.patch | 2855 ++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 2859 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index 595b0b0..52a8bef 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -979,6 +979,10 @@ Patch: 1233_linux-4.9.234.patch
21 From: http://www.kernel.org
22 Desc: Linux 4.9.234
23
24 +Patch: 1234_linux-4.9.235.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 4.9.235
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/1234_linux-4.9.235.patch b/1234_linux-4.9.235.patch
33 new file mode 100644
34 index 0000000..b00210d
35 --- /dev/null
36 +++ b/1234_linux-4.9.235.patch
37 @@ -0,0 +1,2855 @@
38 +diff --git a/Makefile b/Makefile
39 +index e5a6f33e95de6..d21084a36bd4d 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,6 +1,6 @@
43 + VERSION = 4
44 + PATCHLEVEL = 9
45 +-SUBLEVEL = 234
46 ++SUBLEVEL = 235
47 + EXTRAVERSION =
48 + NAME = Roaring Lionus
49 +
50 +diff --git a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
51 +index fabc0cebe2aa2..1f9ff2cea2151 100644
52 +--- a/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
53 ++++ b/arch/arm64/boot/dts/qcom/msm8916-pins.dtsi
54 +@@ -555,7 +555,7 @@
55 + pins = "gpio63", "gpio64", "gpio65", "gpio66",
56 + "gpio67", "gpio68";
57 + drive-strength = <2>;
58 +- bias-disable;
59 ++ bias-pull-down;
60 + };
61 + };
62 + };
63 +diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c
64 +index 115b0955715f3..ed7e3a288b4e5 100644
65 +--- a/arch/arm64/kvm/hyp/switch.c
66 ++++ b/arch/arm64/kvm/hyp/switch.c
67 +@@ -412,7 +412,7 @@ static void __hyp_text __hyp_call_panic_nvhe(u64 spsr, u64 elr, u64 par,
68 + * making sure it is a kernel address and not a PC-relative
69 + * reference.
70 + */
71 +- asm volatile("ldr %0, =__hyp_panic_string" : "=r" (str_va));
72 ++ asm volatile("ldr %0, =%1" : "=r" (str_va) : "S" (__hyp_panic_string));
73 +
74 + __hyp_do_panic(str_va,
75 + spsr, elr,
76 +diff --git a/arch/mips/vdso/genvdso.c b/arch/mips/vdso/genvdso.c
77 +index 530a36f465ced..afcc86726448e 100644
78 +--- a/arch/mips/vdso/genvdso.c
79 ++++ b/arch/mips/vdso/genvdso.c
80 +@@ -126,6 +126,7 @@ static void *map_vdso(const char *path, size_t *_size)
81 + if (fstat(fd, &stat) != 0) {
82 + fprintf(stderr, "%s: Failed to stat '%s': %s\n", program_name,
83 + path, strerror(errno));
84 ++ close(fd);
85 + return NULL;
86 + }
87 +
88 +@@ -134,6 +135,7 @@ static void *map_vdso(const char *path, size_t *_size)
89 + if (addr == MAP_FAILED) {
90 + fprintf(stderr, "%s: Failed to map '%s': %s\n", program_name,
91 + path, strerror(errno));
92 ++ close(fd);
93 + return NULL;
94 + }
95 +
96 +@@ -143,6 +145,7 @@ static void *map_vdso(const char *path, size_t *_size)
97 + if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) != 0) {
98 + fprintf(stderr, "%s: '%s' is not an ELF file\n", program_name,
99 + path);
100 ++ close(fd);
101 + return NULL;
102 + }
103 +
104 +@@ -154,6 +157,7 @@ static void *map_vdso(const char *path, size_t *_size)
105 + default:
106 + fprintf(stderr, "%s: '%s' has invalid ELF class\n",
107 + program_name, path);
108 ++ close(fd);
109 + return NULL;
110 + }
111 +
112 +@@ -165,6 +169,7 @@ static void *map_vdso(const char *path, size_t *_size)
113 + default:
114 + fprintf(stderr, "%s: '%s' has invalid ELF data order\n",
115 + program_name, path);
116 ++ close(fd);
117 + return NULL;
118 + }
119 +
120 +@@ -172,15 +177,18 @@ static void *map_vdso(const char *path, size_t *_size)
121 + fprintf(stderr,
122 + "%s: '%s' has invalid ELF machine (expected EM_MIPS)\n",
123 + program_name, path);
124 ++ close(fd);
125 + return NULL;
126 + } else if (swap_uint16(ehdr->e_type) != ET_DYN) {
127 + fprintf(stderr,
128 + "%s: '%s' has invalid ELF type (expected ET_DYN)\n",
129 + program_name, path);
130 ++ close(fd);
131 + return NULL;
132 + }
133 +
134 + *_size = stat.st_size;
135 ++ close(fd);
136 + return addr;
137 + }
138 +
139 +@@ -284,10 +292,12 @@ int main(int argc, char **argv)
140 + /* Calculate and write symbol offsets to <output file> */
141 + if (!get_symbols(dbg_vdso_path, dbg_vdso)) {
142 + unlink(out_path);
143 ++ fclose(out_file);
144 + return EXIT_FAILURE;
145 + }
146 +
147 + fprintf(out_file, "};\n");
148 ++ fclose(out_file);
149 +
150 + return EXIT_SUCCESS;
151 + }
152 +diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
153 +index ba49ae6625f1b..a10b67df83bae 100644
154 +--- a/arch/powerpc/perf/core-book3s.c
155 ++++ b/arch/powerpc/perf/core-book3s.c
156 +@@ -2042,6 +2042,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val,
157 +
158 + if (perf_event_overflow(event, &data, regs))
159 + power_pmu_stop(event, 0);
160 ++ } else if (period) {
161 ++ /* Account for interrupt in case of invalid SIAR */
162 ++ if (perf_event_account_interrupt(event))
163 ++ power_pmu_stop(event, 0);
164 + }
165 + }
166 +
167 +diff --git a/arch/powerpc/platforms/cell/Kconfig b/arch/powerpc/platforms/cell/Kconfig
168 +index d9088f0b8fcc5..621be43433303 100644
169 +--- a/arch/powerpc/platforms/cell/Kconfig
170 ++++ b/arch/powerpc/platforms/cell/Kconfig
171 +@@ -45,6 +45,7 @@ config SPU_FS
172 + tristate "SPU file system"
173 + default m
174 + depends on PPC_CELL
175 ++ depends on COREDUMP
176 + select SPU_BASE
177 + select MEMORY_HOTPLUG
178 + help
179 +diff --git a/drivers/base/core.c b/drivers/base/core.c
180 +index 69a71074dc65b..fe9f2aea84bd4 100644
181 +--- a/drivers/base/core.c
182 ++++ b/drivers/base/core.c
183 +@@ -2348,9 +2348,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
184 + */
185 + void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
186 + {
187 +- if (fwnode) {
188 +- struct fwnode_handle *fn = dev->fwnode;
189 ++ struct fwnode_handle *fn = dev->fwnode;
190 +
191 ++ if (fwnode) {
192 + if (fwnode_is_primary(fn))
193 + fn = fn->secondary;
194 +
195 +@@ -2360,8 +2360,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
196 + }
197 + dev->fwnode = fwnode;
198 + } else {
199 +- dev->fwnode = fwnode_is_primary(dev->fwnode) ?
200 +- dev->fwnode->secondary : NULL;
201 ++ if (fwnode_is_primary(fn)) {
202 ++ dev->fwnode = fn->secondary;
203 ++ fn->secondary = NULL;
204 ++ } else {
205 ++ dev->fwnode = NULL;
206 ++ }
207 + }
208 + }
209 + EXPORT_SYMBOL_GPL(set_primary_fwnode);
210 +diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
211 +index a2714890fe431..d707cd16ed014 100644
212 +--- a/drivers/base/power/main.c
213 ++++ b/drivers/base/power/main.c
214 +@@ -1366,13 +1366,17 @@ static int __device_suspend(struct device *dev, pm_message_t state, bool async)
215 + }
216 +
217 + /*
218 +- * If a device configured to wake up the system from sleep states
219 +- * has been suspended at run time and there's a resume request pending
220 +- * for it, this is equivalent to the device signaling wakeup, so the
221 +- * system suspend operation should be aborted.
222 ++ * Wait for possible runtime PM transitions of the device in progress
223 ++ * to complete and if there's a runtime resume request pending for it,
224 ++ * resume it before proceeding with invoking the system-wide suspend
225 ++ * callbacks for it.
226 ++ *
227 ++ * If the system-wide suspend callbacks below change the configuration
228 ++ * of the device, they must disable runtime PM for it or otherwise
229 ++ * ensure that its runtime-resume callbacks will not be confused by that
230 ++ * change in case they are invoked going forward.
231 + */
232 +- if (pm_runtime_barrier(dev) && device_may_wakeup(dev))
233 +- pm_wakeup_event(dev, 0);
234 ++ pm_runtime_barrier(dev);
235 +
236 + if (pm_wakeup_pending()) {
237 + dev->power.direct_complete = false;
238 +diff --git a/drivers/edac/ie31200_edac.c b/drivers/edac/ie31200_edac.c
239 +index 1c88d97074951..3438b98e60948 100644
240 +--- a/drivers/edac/ie31200_edac.c
241 ++++ b/drivers/edac/ie31200_edac.c
242 +@@ -145,6 +145,8 @@
243 + (n << (28 + (2 * skl) - PAGE_SHIFT))
244 +
245 + static int nr_channels;
246 ++static struct pci_dev *mci_pdev;
247 ++static int ie31200_registered = 1;
248 +
249 + struct ie31200_priv {
250 + void __iomem *window;
251 +@@ -512,12 +514,16 @@ fail_free:
252 + static int ie31200_init_one(struct pci_dev *pdev,
253 + const struct pci_device_id *ent)
254 + {
255 +- edac_dbg(0, "MC:\n");
256 ++ int rc;
257 +
258 ++ edac_dbg(0, "MC:\n");
259 + if (pci_enable_device(pdev) < 0)
260 + return -EIO;
261 ++ rc = ie31200_probe1(pdev, ent->driver_data);
262 ++ if (rc == 0 && !mci_pdev)
263 ++ mci_pdev = pci_dev_get(pdev);
264 +
265 +- return ie31200_probe1(pdev, ent->driver_data);
266 ++ return rc;
267 + }
268 +
269 + static void ie31200_remove_one(struct pci_dev *pdev)
270 +@@ -526,6 +532,8 @@ static void ie31200_remove_one(struct pci_dev *pdev)
271 + struct ie31200_priv *priv;
272 +
273 + edac_dbg(0, "\n");
274 ++ pci_dev_put(mci_pdev);
275 ++ mci_pdev = NULL;
276 + mci = edac_mc_del_mc(&pdev->dev);
277 + if (!mci)
278 + return;
279 +@@ -574,17 +582,53 @@ static struct pci_driver ie31200_driver = {
280 +
281 + static int __init ie31200_init(void)
282 + {
283 ++ int pci_rc, i;
284 ++
285 + edac_dbg(3, "MC:\n");
286 + /* Ensure that the OPSTATE is set correctly for POLL or NMI */
287 + opstate_init();
288 +
289 +- return pci_register_driver(&ie31200_driver);
290 ++ pci_rc = pci_register_driver(&ie31200_driver);
291 ++ if (pci_rc < 0)
292 ++ goto fail0;
293 ++
294 ++ if (!mci_pdev) {
295 ++ ie31200_registered = 0;
296 ++ for (i = 0; ie31200_pci_tbl[i].vendor != 0; i++) {
297 ++ mci_pdev = pci_get_device(ie31200_pci_tbl[i].vendor,
298 ++ ie31200_pci_tbl[i].device,
299 ++ NULL);
300 ++ if (mci_pdev)
301 ++ break;
302 ++ }
303 ++ if (!mci_pdev) {
304 ++ edac_dbg(0, "ie31200 pci_get_device fail\n");
305 ++ pci_rc = -ENODEV;
306 ++ goto fail1;
307 ++ }
308 ++ pci_rc = ie31200_init_one(mci_pdev, &ie31200_pci_tbl[i]);
309 ++ if (pci_rc < 0) {
310 ++ edac_dbg(0, "ie31200 init fail\n");
311 ++ pci_rc = -ENODEV;
312 ++ goto fail1;
313 ++ }
314 ++ }
315 ++ return 0;
316 ++
317 ++fail1:
318 ++ pci_unregister_driver(&ie31200_driver);
319 ++fail0:
320 ++ pci_dev_put(mci_pdev);
321 ++
322 ++ return pci_rc;
323 + }
324 +
325 + static void __exit ie31200_exit(void)
326 + {
327 + edac_dbg(3, "MC:\n");
328 + pci_unregister_driver(&ie31200_driver);
329 ++ if (!ie31200_registered)
330 ++ ie31200_remove_one(mci_pdev);
331 + }
332 +
333 + module_init(ie31200_init);
334 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
335 +index e9311eb7b8d9f..694f631d9c90d 100644
336 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
337 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
338 +@@ -734,8 +734,10 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)
339 +
340 + if (!drm_kms_helper_is_poll_worker()) {
341 + r = pm_runtime_get_sync(connector->dev->dev);
342 +- if (r < 0)
343 ++ if (r < 0) {
344 ++ pm_runtime_put_autosuspend(connector->dev->dev);
345 + return connector_status_disconnected;
346 ++ }
347 + }
348 +
349 + if (encoder) {
350 +@@ -872,8 +874,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
351 +
352 + if (!drm_kms_helper_is_poll_worker()) {
353 + r = pm_runtime_get_sync(connector->dev->dev);
354 +- if (r < 0)
355 ++ if (r < 0) {
356 ++ pm_runtime_put_autosuspend(connector->dev->dev);
357 + return connector_status_disconnected;
358 ++ }
359 + }
360 +
361 + encoder = amdgpu_connector_best_single_encoder(connector);
362 +@@ -996,8 +1000,10 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
363 +
364 + if (!drm_kms_helper_is_poll_worker()) {
365 + r = pm_runtime_get_sync(connector->dev->dev);
366 +- if (r < 0)
367 ++ if (r < 0) {
368 ++ pm_runtime_put_autosuspend(connector->dev->dev);
369 + return connector_status_disconnected;
370 ++ }
371 + }
372 +
373 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
374 +@@ -1371,8 +1377,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
375 +
376 + if (!drm_kms_helper_is_poll_worker()) {
377 + r = pm_runtime_get_sync(connector->dev->dev);
378 +- if (r < 0)
379 ++ if (r < 0) {
380 ++ pm_runtime_put_autosuspend(connector->dev->dev);
381 + return connector_status_disconnected;
382 ++ }
383 + }
384 +
385 + if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
386 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
387 +index 15a2d8f3725d5..fdf7a18058881 100644
388 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
389 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
390 +@@ -268,7 +268,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
391 +
392 + ret = pm_runtime_get_sync(dev->dev);
393 + if (ret < 0)
394 +- return ret;
395 ++ goto out;
396 +
397 + ret = drm_crtc_helper_set_config(set);
398 +
399 +@@ -283,7 +283,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
400 + take the current one */
401 + if (active && !adev->have_disp_power_ref) {
402 + adev->have_disp_power_ref = true;
403 +- return ret;
404 ++ goto out;
405 + }
406 + /* if we have no active crtcs, then drop the power ref
407 + we got before */
408 +@@ -292,6 +292,7 @@ int amdgpu_crtc_set_config(struct drm_mode_set *set)
409 + adev->have_disp_power_ref = false;
410 + }
411 +
412 ++out:
413 + /* drop the power reference we got coming in here */
414 + pm_runtime_put_autosuspend(dev->dev);
415 + return ret;
416 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
417 +index e0890deccb2fe..7cae10fec78de 100644
418 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
419 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
420 +@@ -633,11 +633,12 @@ long amdgpu_drm_ioctl(struct file *filp,
421 + dev = file_priv->minor->dev;
422 + ret = pm_runtime_get_sync(dev->dev);
423 + if (ret < 0)
424 +- return ret;
425 ++ goto out;
426 +
427 + ret = drm_ioctl(filp, cmd, arg);
428 +
429 + pm_runtime_mark_last_busy(dev->dev);
430 ++out:
431 + pm_runtime_put_autosuspend(dev->dev);
432 + return ret;
433 + }
434 +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
435 +index ab5134d920d96..96fc1566f28e5 100644
436 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
437 ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
438 +@@ -543,7 +543,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
439 +
440 + r = pm_runtime_get_sync(dev->dev);
441 + if (r < 0)
442 +- return r;
443 ++ goto pm_put;
444 +
445 + fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
446 + if (unlikely(!fpriv)) {
447 +@@ -566,6 +566,7 @@ int amdgpu_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
448 +
449 + out_suspend:
450 + pm_runtime_mark_last_busy(dev->dev);
451 ++pm_put:
452 + pm_runtime_put_autosuspend(dev->dev);
453 +
454 + return r;
455 +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
456 +index 8c6e47c5507fb..74221e096855d 100644
457 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
458 ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
459 +@@ -841,8 +841,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
460 +
461 + ret = kobject_init_and_add(dev->kobj_node, &node_type,
462 + sys_props.kobj_nodes, "%d", id);
463 +- if (ret < 0)
464 ++ if (ret < 0) {
465 ++ kobject_put(dev->kobj_node);
466 + return ret;
467 ++ }
468 +
469 + dev->kobj_mem = kobject_create_and_add("mem_banks", dev->kobj_node);
470 + if (!dev->kobj_mem)
471 +@@ -885,8 +887,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
472 + return -ENOMEM;
473 + ret = kobject_init_and_add(mem->kobj, &mem_type,
474 + dev->kobj_mem, "%d", i);
475 +- if (ret < 0)
476 ++ if (ret < 0) {
477 ++ kobject_put(mem->kobj);
478 + return ret;
479 ++ }
480 +
481 + mem->attr.name = "properties";
482 + mem->attr.mode = KFD_SYSFS_FILE_MODE;
483 +@@ -904,8 +908,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
484 + return -ENOMEM;
485 + ret = kobject_init_and_add(cache->kobj, &cache_type,
486 + dev->kobj_cache, "%d", i);
487 +- if (ret < 0)
488 ++ if (ret < 0) {
489 ++ kobject_put(cache->kobj);
490 + return ret;
491 ++ }
492 +
493 + cache->attr.name = "properties";
494 + cache->attr.mode = KFD_SYSFS_FILE_MODE;
495 +@@ -923,8 +929,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
496 + return -ENOMEM;
497 + ret = kobject_init_and_add(iolink->kobj, &iolink_type,
498 + dev->kobj_iolink, "%d", i);
499 +- if (ret < 0)
500 ++ if (ret < 0) {
501 ++ kobject_put(iolink->kobj);
502 + return ret;
503 ++ }
504 +
505 + iolink->attr.name = "properties";
506 + iolink->attr.mode = KFD_SYSFS_FILE_MODE;
507 +@@ -976,8 +984,10 @@ static int kfd_topology_update_sysfs(void)
508 + ret = kobject_init_and_add(sys_props.kobj_topology,
509 + &sysprops_type, &kfd_device->kobj,
510 + "topology");
511 +- if (ret < 0)
512 ++ if (ret < 0) {
513 ++ kobject_put(sys_props.kobj_topology);
514 + return ret;
515 ++ }
516 +
517 + sys_props.kobj_nodes = kobject_create_and_add("nodes",
518 + sys_props.kobj_topology);
519 +diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
520 +index 5bfae1f972c74..0061deca290a4 100644
521 +--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
522 ++++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
523 +@@ -281,8 +281,10 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
524 + pm_runtime_get_noresume(dev->dev);
525 + } else {
526 + ret = pm_runtime_get_sync(dev->dev);
527 +- if (ret < 0 && ret != -EACCES)
528 ++ if (ret < 0 && ret != -EACCES) {
529 ++ pm_runtime_put_autosuspend(dev->dev);
530 + return conn_status;
531 ++ }
532 + }
533 +
534 + nv_encoder = nouveau_connector_ddc_detect(connector);
535 +diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
536 +index 275abc424ce25..40da9143f7220 100644
537 +--- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c
538 ++++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c
539 +@@ -183,8 +183,10 @@ nouveau_fbcon_open(struct fb_info *info, int user)
540 + struct nouveau_fbdev *fbcon = info->par;
541 + struct nouveau_drm *drm = nouveau_drm(fbcon->dev);
542 + int ret = pm_runtime_get_sync(drm->dev->dev);
543 +- if (ret < 0 && ret != -EACCES)
544 ++ if (ret < 0 && ret != -EACCES) {
545 ++ pm_runtime_put(drm->dev->dev);
546 + return ret;
547 ++ }
548 + return 0;
549 + }
550 +
551 +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
552 +index efa875120071a..9e6c2be0cc7d4 100644
553 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c
554 ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c
555 +@@ -892,8 +892,10 @@ radeon_lvds_detect(struct drm_connector *connector, bool force)
556 +
557 + if (!drm_kms_helper_is_poll_worker()) {
558 + r = pm_runtime_get_sync(connector->dev->dev);
559 +- if (r < 0)
560 ++ if (r < 0) {
561 ++ pm_runtime_put_autosuspend(connector->dev->dev);
562 + return connector_status_disconnected;
563 ++ }
564 + }
565 +
566 + if (encoder) {
567 +@@ -1038,8 +1040,10 @@ radeon_vga_detect(struct drm_connector *connector, bool force)
568 +
569 + if (!drm_kms_helper_is_poll_worker()) {
570 + r = pm_runtime_get_sync(connector->dev->dev);
571 +- if (r < 0)
572 ++ if (r < 0) {
573 ++ pm_runtime_put_autosuspend(connector->dev->dev);
574 + return connector_status_disconnected;
575 ++ }
576 + }
577 +
578 + encoder = radeon_best_single_encoder(connector);
579 +@@ -1176,8 +1180,10 @@ radeon_tv_detect(struct drm_connector *connector, bool force)
580 +
581 + if (!drm_kms_helper_is_poll_worker()) {
582 + r = pm_runtime_get_sync(connector->dev->dev);
583 +- if (r < 0)
584 ++ if (r < 0) {
585 ++ pm_runtime_put_autosuspend(connector->dev->dev);
586 + return connector_status_disconnected;
587 ++ }
588 + }
589 +
590 + encoder = radeon_best_single_encoder(connector);
591 +@@ -1260,8 +1266,10 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
592 +
593 + if (!drm_kms_helper_is_poll_worker()) {
594 + r = pm_runtime_get_sync(connector->dev->dev);
595 +- if (r < 0)
596 ++ if (r < 0) {
597 ++ pm_runtime_put_autosuspend(connector->dev->dev);
598 + return connector_status_disconnected;
599 ++ }
600 + }
601 +
602 + if (radeon_connector->detected_hpd_without_ddc) {
603 +@@ -1701,8 +1709,10 @@ radeon_dp_detect(struct drm_connector *connector, bool force)
604 +
605 + if (!drm_kms_helper_is_poll_worker()) {
606 + r = pm_runtime_get_sync(connector->dev->dev);
607 +- if (r < 0)
608 ++ if (r < 0) {
609 ++ pm_runtime_put_autosuspend(connector->dev->dev);
610 + return connector_status_disconnected;
611 ++ }
612 + }
613 +
614 + if (!force && radeon_check_hpd_status_unchanged(connector)) {
615 +diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
616 +index 850527d5fab1b..606fd875740c0 100644
617 +--- a/drivers/hid/i2c-hid/i2c-hid-core.c
618 ++++ b/drivers/hid/i2c-hid/i2c-hid-core.c
619 +@@ -407,6 +407,19 @@ static int i2c_hid_set_power(struct i2c_client *client, int power_state)
620 + dev_err(&client->dev, "failed to change power setting.\n");
621 +
622 + set_pwr_exit:
623 ++
624 ++ /*
625 ++ * The HID over I2C specification states that if a DEVICE needs time
626 ++ * after the PWR_ON request, it should utilise CLOCK stretching.
627 ++ * However, it has been observered that the Windows driver provides a
628 ++ * 1ms sleep between the PWR_ON and RESET requests.
629 ++ * According to Goodix Windows even waits 60 ms after (other?)
630 ++ * PWR_ON requests. Testing has confirmed that several devices
631 ++ * will not work properly without a delay after a PWR_ON request.
632 ++ */
633 ++ if (!ret && power_state == I2C_HID_PWR_ON)
634 ++ msleep(60);
635 ++
636 + return ret;
637 + }
638 +
639 +@@ -428,15 +441,6 @@ static int i2c_hid_hwreset(struct i2c_client *client)
640 + if (ret)
641 + goto out_unlock;
642 +
643 +- /*
644 +- * The HID over I2C specification states that if a DEVICE needs time
645 +- * after the PWR_ON request, it should utilise CLOCK stretching.
646 +- * However, it has been observered that the Windows driver provides a
647 +- * 1ms sleep between the PWR_ON and RESET requests and that some devices
648 +- * rely on this.
649 +- */
650 +- usleep_range(1000, 5000);
651 +-
652 + i2c_hid_dbg(ihid, "resetting...\n");
653 +
654 + ret = i2c_hid_command(client, &hid_reset_cmd, NULL, 0);
655 +diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
656 +index dbdd265075daf..7bce23a43907e 100644
657 +--- a/drivers/hid/usbhid/hiddev.c
658 ++++ b/drivers/hid/usbhid/hiddev.c
659 +@@ -554,12 +554,16 @@ static noinline int hiddev_ioctl_usage(struct hiddev *hiddev, unsigned int cmd,
660 +
661 + switch (cmd) {
662 + case HIDIOCGUSAGE:
663 ++ if (uref->usage_index >= field->report_count)
664 ++ goto inval;
665 + uref->value = field->value[uref->usage_index];
666 + if (copy_to_user(user_arg, uref, sizeof(*uref)))
667 + goto fault;
668 + goto goodreturn;
669 +
670 + case HIDIOCSUSAGE:
671 ++ if (uref->usage_index >= field->report_count)
672 ++ goto inval;
673 + field->value[uref->usage_index] = uref->value;
674 + goto goodreturn;
675 +
676 +diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
677 +index 4231673435e7b..6be02da2ccc46 100644
678 +--- a/drivers/i2c/busses/i2c-rcar.c
679 ++++ b/drivers/i2c/busses/i2c-rcar.c
680 +@@ -534,6 +534,7 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv)
681 + /* master sent stop */
682 + if (ssr_filtered & SSR) {
683 + i2c_slave_event(priv->slave, I2C_SLAVE_STOP, &value);
684 ++ rcar_i2c_write(priv, ICSCR, SIE | SDBS); /* clear our NACK */
685 + rcar_i2c_write(priv, ICSIER, SAR);
686 + rcar_i2c_write(priv, ICSSR, ~SSR & 0xff);
687 + }
688 +diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
689 +index f106fd9782bfb..99c36a5438a75 100644
690 +--- a/drivers/iommu/iova.c
691 ++++ b/drivers/iommu/iova.c
692 +@@ -676,7 +676,9 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad)
693 + for (i = 0 ; i < mag->size; ++i) {
694 + struct iova *iova = private_find_iova(iovad, mag->pfns[i]);
695 +
696 +- BUG_ON(!iova);
697 ++ if (WARN_ON(!iova))
698 ++ continue;
699 ++
700 + private_free_iova(iovad, iova);
701 + }
702 +
703 +diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
704 +index 29deda7aed040..2d3ff028f50c9 100644
705 +--- a/drivers/md/dm-table.c
706 ++++ b/drivers/md/dm-table.c
707 +@@ -510,14 +510,14 @@ static int adjoin(struct dm_table *table, struct dm_target *ti)
708 + * On the other hand, dm-switch needs to process bulk data using messages and
709 + * excessive use of GFP_NOIO could cause trouble.
710 + */
711 +-static char **realloc_argv(unsigned *array_size, char **old_argv)
712 ++static char **realloc_argv(unsigned *size, char **old_argv)
713 + {
714 + char **argv;
715 + unsigned new_size;
716 + gfp_t gfp;
717 +
718 +- if (*array_size) {
719 +- new_size = *array_size * 2;
720 ++ if (*size) {
721 ++ new_size = *size * 2;
722 + gfp = GFP_KERNEL;
723 + } else {
724 + new_size = 8;
725 +@@ -525,8 +525,8 @@ static char **realloc_argv(unsigned *array_size, char **old_argv)
726 + }
727 + argv = kmalloc(new_size * sizeof(*argv), gfp);
728 + if (argv) {
729 +- memcpy(argv, old_argv, *array_size * sizeof(*argv));
730 +- *array_size = new_size;
731 ++ memcpy(argv, old_argv, *size * sizeof(*argv));
732 ++ *size = new_size;
733 + }
734 +
735 + kfree(old_argv);
736 +diff --git a/drivers/media/pci/ttpci/av7110.c b/drivers/media/pci/ttpci/av7110.c
737 +index 382caf200ba16..c313f51688f44 100644
738 +--- a/drivers/media/pci/ttpci/av7110.c
739 ++++ b/drivers/media/pci/ttpci/av7110.c
740 +@@ -426,14 +426,15 @@ static void debiirq(unsigned long cookie)
741 + case DATA_CI_GET:
742 + {
743 + u8 *data = av7110->debi_virt;
744 ++ u8 data_0 = data[0];
745 +
746 +- if ((data[0] < 2) && data[2] == 0xff) {
747 ++ if (data_0 < 2 && data[2] == 0xff) {
748 + int flags = 0;
749 + if (data[5] > 0)
750 + flags |= CA_CI_MODULE_PRESENT;
751 + if (data[5] > 5)
752 + flags |= CA_CI_MODULE_READY;
753 +- av7110->ci_slot[data[0]].flags = flags;
754 ++ av7110->ci_slot[data_0].flags = flags;
755 + } else
756 + ci_get_data(&av7110->ci_rbuffer,
757 + av7110->debi_virt,
758 +diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c
759 +index 5104cc0ee40e3..a3c4cc025ed6f 100644
760 +--- a/drivers/media/platform/davinci/vpif_capture.c
761 ++++ b/drivers/media/platform/davinci/vpif_capture.c
762 +@@ -1408,8 +1408,6 @@ probe_out:
763 + /* Unregister video device */
764 + video_unregister_device(&ch->video_dev);
765 + }
766 +- kfree(vpif_obj.sd);
767 +- v4l2_device_unregister(&vpif_obj.v4l2_dev);
768 +
769 + return err;
770 + }
771 +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
772 +index d52fd842ef1fe..8322129c3f987 100644
773 +--- a/drivers/net/bonding/bond_main.c
774 ++++ b/drivers/net/bonding/bond_main.c
775 +@@ -1985,7 +1985,8 @@ static int bond_release_and_destroy(struct net_device *bond_dev,
776 + int ret;
777 +
778 + ret = bond_release(bond_dev, slave_dev);
779 +- if (ret == 0 && !bond_has_slaves(bond)) {
780 ++ if (ret == 0 && !bond_has_slaves(bond) &&
781 ++ bond_dev->reg_state != NETREG_UNREGISTERING) {
782 + bond_dev->priv_flags |= IFF_DISABLE_NETPOLL;
783 + netdev_info(bond_dev, "Destroying bond %s\n",
784 + bond_dev->name);
785 +@@ -4131,13 +4132,23 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev)
786 + return ret;
787 + }
788 +
789 ++static u32 bond_mode_bcast_speed(struct slave *slave, u32 speed)
790 ++{
791 ++ if (speed == 0 || speed == SPEED_UNKNOWN)
792 ++ speed = slave->speed;
793 ++ else
794 ++ speed = min(speed, slave->speed);
795 ++
796 ++ return speed;
797 ++}
798 ++
799 + static int bond_ethtool_get_settings(struct net_device *bond_dev,
800 + struct ethtool_cmd *ecmd)
801 + {
802 + struct bonding *bond = netdev_priv(bond_dev);
803 +- unsigned long speed = 0;
804 + struct list_head *iter;
805 + struct slave *slave;
806 ++ u32 speed = 0;
807 +
808 + ecmd->duplex = DUPLEX_UNKNOWN;
809 + ecmd->port = PORT_OTHER;
810 +@@ -4149,8 +4160,13 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev,
811 + */
812 + bond_for_each_slave(bond, slave, iter) {
813 + if (bond_slave_can_tx(slave)) {
814 +- if (slave->speed != SPEED_UNKNOWN)
815 +- speed += slave->speed;
816 ++ if (slave->speed != SPEED_UNKNOWN) {
817 ++ if (BOND_MODE(bond) == BOND_MODE_BROADCAST)
818 ++ speed = bond_mode_bcast_speed(slave,
819 ++ speed);
820 ++ else
821 ++ speed += slave->speed;
822 ++ }
823 + if (ecmd->duplex == DUPLEX_UNKNOWN &&
824 + slave->duplex != DUPLEX_UNKNOWN)
825 + ecmd->duplex = slave->duplex;
826 +diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
827 +index b665d27f8e299..95ab44aa0eeab 100644
828 +--- a/drivers/net/ethernet/freescale/gianfar.c
829 ++++ b/drivers/net/ethernet/freescale/gianfar.c
830 +@@ -844,8 +844,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
831 + continue;
832 +
833 + err = gfar_parse_group(child, priv, model);
834 +- if (err)
835 ++ if (err) {
836 ++ of_node_put(child);
837 + goto err_grp_init;
838 ++ }
839 + }
840 + } else { /* SQ_SG_MODE */
841 + err = gfar_parse_group(np, priv, model);
842 +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
843 +index 72f37e546ed24..ac757819cadb5 100644
844 +--- a/drivers/net/ipvlan/ipvlan_main.c
845 ++++ b/drivers/net/ipvlan/ipvlan_main.c
846 +@@ -168,12 +168,21 @@ static void ipvlan_port_destroy(struct net_device *dev)
847 + kfree_rcu(port, rcu);
848 + }
849 +
850 ++#define IPVLAN_ALWAYS_ON_OFLOADS \
851 ++ (NETIF_F_SG | NETIF_F_HW_CSUM | \
852 ++ NETIF_F_GSO_ROBUST | NETIF_F_GSO_SOFTWARE | NETIF_F_GSO_ENCAP_ALL)
853 ++
854 ++#define IPVLAN_ALWAYS_ON \
855 ++ (IPVLAN_ALWAYS_ON_OFLOADS | NETIF_F_LLTX | NETIF_F_VLAN_CHALLENGED)
856 ++
857 + #define IPVLAN_FEATURES \
858 + (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \
859 + NETIF_F_GSO | NETIF_F_TSO | NETIF_F_UFO | NETIF_F_GSO_ROBUST | \
860 + NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \
861 + NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER)
862 +
863 ++ /* NETIF_F_GSO_ENCAP_ALL NETIF_F_GSO_SOFTWARE Newly added */
864 ++
865 + #define IPVLAN_STATE_MASK \
866 + ((1<<__LINK_STATE_NOCARRIER) | (1<<__LINK_STATE_DORMANT))
867 +
868 +@@ -186,7 +195,9 @@ static int ipvlan_init(struct net_device *dev)
869 + dev->state = (dev->state & ~IPVLAN_STATE_MASK) |
870 + (phy_dev->state & IPVLAN_STATE_MASK);
871 + dev->features = phy_dev->features & IPVLAN_FEATURES;
872 +- dev->features |= NETIF_F_LLTX;
873 ++ dev->features |= IPVLAN_ALWAYS_ON;
874 ++ dev->vlan_features = phy_dev->vlan_features & IPVLAN_FEATURES;
875 ++ dev->vlan_features |= IPVLAN_ALWAYS_ON_OFLOADS;
876 + dev->gso_max_size = phy_dev->gso_max_size;
877 + dev->gso_max_segs = phy_dev->gso_max_segs;
878 + dev->hard_header_len = phy_dev->hard_header_len;
879 +@@ -274,7 +285,14 @@ static netdev_features_t ipvlan_fix_features(struct net_device *dev,
880 + {
881 + struct ipvl_dev *ipvlan = netdev_priv(dev);
882 +
883 +- return features & (ipvlan->sfeatures | ~IPVLAN_FEATURES);
884 ++ features |= NETIF_F_ALL_FOR_ALL;
885 ++ features &= (ipvlan->sfeatures | ~IPVLAN_FEATURES);
886 ++ features = netdev_increment_features(ipvlan->phy_dev->features,
887 ++ features, features);
888 ++ features |= IPVLAN_ALWAYS_ON;
889 ++ features &= (IPVLAN_FEATURES | IPVLAN_ALWAYS_ON);
890 ++
891 ++ return features;
892 + }
893 +
894 + static void ipvlan_change_rx_flags(struct net_device *dev, int change)
895 +@@ -675,10 +693,9 @@ static int ipvlan_device_event(struct notifier_block *unused,
896 +
897 + case NETDEV_FEAT_CHANGE:
898 + list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
899 +- ipvlan->dev->features = dev->features & IPVLAN_FEATURES;
900 + ipvlan->dev->gso_max_size = dev->gso_max_size;
901 + ipvlan->dev->gso_max_segs = dev->gso_max_segs;
902 +- netdev_features_change(ipvlan->dev);
903 ++ netdev_update_features(ipvlan->dev);
904 + }
905 + break;
906 +
907 +diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h
908 +index 6038b7486f1db..e04e0260035ad 100644
909 +--- a/drivers/net/wireless/ath/ath10k/hw.h
910 ++++ b/drivers/net/wireless/ath/ath10k/hw.h
911 +@@ -558,7 +558,7 @@ ath10k_rx_desc_get_l3_pad_bytes(struct ath10k_hw_params *hw,
912 +
913 + #define TARGET_10_4_TX_DBG_LOG_SIZE 1024
914 + #define TARGET_10_4_NUM_WDS_ENTRIES 32
915 +-#define TARGET_10_4_DMA_BURST_SIZE 0
916 ++#define TARGET_10_4_DMA_BURST_SIZE 1
917 + #define TARGET_10_4_MAC_AGGR_DELIM 0
918 + #define TARGET_10_4_RX_SKIP_DEFRAG_TIMEOUT_DUP_DETECTION_CHECK 1
919 + #define TARGET_10_4_VOW_CONFIG 0
920 +diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c
921 +index 93b22a5b6878e..e524573aa8a09 100644
922 +--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
923 ++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
924 +@@ -752,8 +752,11 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
925 +
926 + usb_anchor_urb(urb, &rtlusb->rx_submitted);
927 + err = usb_submit_urb(urb, GFP_KERNEL);
928 +- if (err)
929 ++ if (err) {
930 ++ usb_unanchor_urb(urb);
931 ++ usb_free_urb(urb);
932 + goto err_out;
933 ++ }
934 + usb_free_urb(urb);
935 + }
936 + return 0;
937 +diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
938 +index 429d34c348b9f..01a343ad7155c 100644
939 +--- a/drivers/pci/slot.c
940 ++++ b/drivers/pci/slot.c
941 +@@ -303,13 +303,16 @@ placeholder:
942 + slot_name = make_slot_name(name);
943 + if (!slot_name) {
944 + err = -ENOMEM;
945 ++ kfree(slot);
946 + goto err;
947 + }
948 +
949 + err = kobject_init_and_add(&slot->kobj, &pci_slot_ktype, NULL,
950 + "%s", slot_name);
951 +- if (err)
952 ++ if (err) {
953 ++ kobject_put(&slot->kobj);
954 + goto err;
955 ++ }
956 +
957 + INIT_LIST_HEAD(&slot->list);
958 + list_add(&slot->list, &parent->slots);
959 +@@ -328,7 +331,6 @@ out:
960 + mutex_unlock(&pci_slot_mutex);
961 + return slot;
962 + err:
963 +- kfree(slot);
964 + slot = ERR_PTR(err);
965 + goto out;
966 + }
967 +diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
968 +index 39a2b0cde9e42..d81fdcd6a1fe0 100644
969 +--- a/drivers/s390/cio/css.c
970 ++++ b/drivers/s390/cio/css.c
971 +@@ -529,6 +529,11 @@ static int slow_eval_known_fn(struct subchannel *sch, void *data)
972 + rc = css_evaluate_known_subchannel(sch, 1);
973 + if (rc == -EAGAIN)
974 + css_schedule_eval(sch->schid);
975 ++ /*
976 ++ * The loop might take long time for platforms with lots of
977 ++ * known devices. Allow scheduling here.
978 ++ */
979 ++ cond_resched();
980 + }
981 + return 0;
982 + }
983 +diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
984 +index 3c2f34db937b6..f5f3a8113bc55 100644
985 +--- a/drivers/scsi/fcoe/fcoe_ctlr.c
986 ++++ b/drivers/scsi/fcoe/fcoe_ctlr.c
987 +@@ -267,9 +267,9 @@ static void fcoe_sysfs_fcf_del(struct fcoe_fcf *new)
988 + WARN_ON(!fcf_dev);
989 + new->fcf_dev = NULL;
990 + fcoe_fcf_device_delete(fcf_dev);
991 +- kfree(new);
992 + mutex_unlock(&cdev->lock);
993 + }
994 ++ kfree(new);
995 + }
996 +
997 + /**
998 +diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c
999 +index e18bbc66e83b1..77cb16d8dfd35 100644
1000 +--- a/drivers/scsi/lpfc/lpfc_vport.c
1001 ++++ b/drivers/scsi/lpfc/lpfc_vport.c
1002 +@@ -624,27 +624,16 @@ lpfc_vport_delete(struct fc_vport *fc_vport)
1003 + vport->port_state < LPFC_VPORT_READY)
1004 + return -EAGAIN;
1005 + }
1006 ++
1007 + /*
1008 +- * This is a bit of a mess. We want to ensure the shost doesn't get
1009 +- * torn down until we're done with the embedded lpfc_vport structure.
1010 +- *
1011 +- * Beyond holding a reference for this function, we also need a
1012 +- * reference for outstanding I/O requests we schedule during delete
1013 +- * processing. But once we scsi_remove_host() we can no longer obtain
1014 +- * a reference through scsi_host_get().
1015 +- *
1016 +- * So we take two references here. We release one reference at the
1017 +- * bottom of the function -- after delinking the vport. And we
1018 +- * release the other at the completion of the unreg_vpi that get's
1019 +- * initiated after we've disposed of all other resources associated
1020 +- * with the port.
1021 ++ * Take early refcount for outstanding I/O requests we schedule during
1022 ++ * delete processing for unreg_vpi. Always keep this before
1023 ++ * scsi_remove_host() as we can no longer obtain a reference through
1024 ++ * scsi_host_get() after scsi_host_remove as shost is set to SHOST_DEL.
1025 + */
1026 + if (!scsi_host_get(shost))
1027 + return VPORT_INVAL;
1028 +- if (!scsi_host_get(shost)) {
1029 +- scsi_host_put(shost);
1030 +- return VPORT_INVAL;
1031 +- }
1032 ++
1033 + lpfc_free_sysfs_attr(vport);
1034 +
1035 + lpfc_debugfs_terminate(vport);
1036 +@@ -792,8 +781,9 @@ skip_logo:
1037 + if (!(vport->vpi_state & LPFC_VPI_REGISTERED) ||
1038 + lpfc_mbx_unreg_vpi(vport))
1039 + scsi_host_put(shost);
1040 +- } else
1041 ++ } else {
1042 + scsi_host_put(shost);
1043 ++ }
1044 +
1045 + lpfc_free_vpi(phba, vport->vpi);
1046 + vport->work_port_events = 0;
1047 +diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
1048 +index 42b97f1196232..c2bce3f6eaace 100644
1049 +--- a/drivers/scsi/scsi_transport_iscsi.c
1050 ++++ b/drivers/scsi/scsi_transport_iscsi.c
1051 +@@ -3191,7 +3191,7 @@ static int iscsi_set_flashnode_param(struct iscsi_transport *transport,
1052 + pr_err("%s could not find host no %u\n",
1053 + __func__, ev->u.set_flashnode.host_no);
1054 + err = -ENODEV;
1055 +- goto put_host;
1056 ++ goto exit_set_fnode;
1057 + }
1058 +
1059 + idx = ev->u.set_flashnode.flashnode_idx;
1060 +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
1061 +index a7f520581cb0f..ad5f2e2b4cbaf 100644
1062 +--- a/drivers/scsi/ufs/ufshcd.c
1063 ++++ b/drivers/scsi/ufs/ufshcd.c
1064 +@@ -659,6 +659,7 @@ unblock_reqs:
1065 + int ufshcd_hold(struct ufs_hba *hba, bool async)
1066 + {
1067 + int rc = 0;
1068 ++ bool flush_result;
1069 + unsigned long flags;
1070 +
1071 + if (!ufshcd_is_clkgating_allowed(hba))
1072 +@@ -690,7 +691,9 @@ start:
1073 + break;
1074 + }
1075 + spin_unlock_irqrestore(hba->host->host_lock, flags);
1076 +- flush_work(&hba->clk_gating.ungate_work);
1077 ++ flush_result = flush_work(&hba->clk_gating.ungate_work);
1078 ++ if (hba->clk_gating.is_suspended && !flush_result)
1079 ++ goto out;
1080 + spin_lock_irqsave(hba->host->host_lock, flags);
1081 + goto start;
1082 + }
1083 +@@ -4397,7 +4400,7 @@ static void ufshcd_sl_intr(struct ufs_hba *hba, u32 intr_status)
1084 + */
1085 + static irqreturn_t ufshcd_intr(int irq, void *__hba)
1086 + {
1087 +- u32 intr_status, enabled_intr_status;
1088 ++ u32 intr_status, enabled_intr_status = 0;
1089 + irqreturn_t retval = IRQ_NONE;
1090 + struct ufs_hba *hba = __hba;
1091 + int retries = hba->nutrs;
1092 +@@ -4411,7 +4414,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
1093 + * read, make sure we handle them by checking the interrupt status
1094 + * again in a loop until we process all of the reqs before returning.
1095 + */
1096 +- do {
1097 ++ while (intr_status && retries--) {
1098 + enabled_intr_status =
1099 + intr_status & ufshcd_readl(hba, REG_INTERRUPT_ENABLE);
1100 + if (intr_status)
1101 +@@ -4422,7 +4425,7 @@ static irqreturn_t ufshcd_intr(int irq, void *__hba)
1102 + }
1103 +
1104 + intr_status = ufshcd_readl(hba, REG_INTERRUPT_STATUS);
1105 +- } while (intr_status && --retries);
1106 ++ }
1107 +
1108 + spin_unlock(hba->host->host_lock);
1109 + return retval;
1110 +diff --git a/drivers/staging/media/cec/cec-api.c b/drivers/staging/media/cec/cec-api.c
1111 +index e274e2f223986..264bb7d1efcb8 100644
1112 +--- a/drivers/staging/media/cec/cec-api.c
1113 ++++ b/drivers/staging/media/cec/cec-api.c
1114 +@@ -141,7 +141,13 @@ static long cec_adap_g_log_addrs(struct cec_adapter *adap,
1115 + struct cec_log_addrs log_addrs;
1116 +
1117 + mutex_lock(&adap->lock);
1118 +- log_addrs = adap->log_addrs;
1119 ++ /*
1120 ++ * We use memcpy here instead of assignment since there is a
1121 ++ * hole at the end of struct cec_log_addrs that an assignment
1122 ++ * might ignore. So when we do copy_to_user() we could leak
1123 ++ * one byte of memory.
1124 ++ */
1125 ++ memcpy(&log_addrs, &adap->log_addrs, sizeof(log_addrs));
1126 + if (!adap->is_configured)
1127 + memset(log_addrs.log_addr, CEC_LOG_ADDR_INVALID,
1128 + sizeof(log_addrs.log_addr));
1129 +diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
1130 +index 1a83456a65a00..693fbb2858404 100644
1131 +--- a/drivers/target/target_core_user.c
1132 ++++ b/drivers/target/target_core_user.c
1133 +@@ -666,7 +666,14 @@ static unsigned int tcmu_handle_completions(struct tcmu_dev *udev)
1134 + struct tcmu_cmd_entry *entry = (void *) mb + CMDR_OFF + udev->cmdr_last_cleaned;
1135 + struct tcmu_cmd *cmd;
1136 +
1137 +- tcmu_flush_dcache_range(entry, sizeof(*entry));
1138 ++ /*
1139 ++ * Flush max. up to end of cmd ring since current entry might
1140 ++ * be a padding that is shorter than sizeof(*entry)
1141 ++ */
1142 ++ size_t ring_left = head_to_end(udev->cmdr_last_cleaned,
1143 ++ udev->cmdr_size);
1144 ++ tcmu_flush_dcache_range(entry, ring_left < sizeof(*entry) ?
1145 ++ ring_left : sizeof(*entry));
1146 +
1147 + if (tcmu_hdr_get_op(entry->hdr.len_op) == TCMU_OP_PAD) {
1148 + UPDATE_HEAD(udev->cmdr_last_cleaned,
1149 +diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
1150 +index c7a7574172fae..5641b877dca53 100644
1151 +--- a/drivers/tty/serial/8250/8250_port.c
1152 ++++ b/drivers/tty/serial/8250/8250_port.c
1153 +@@ -2205,6 +2205,10 @@ int serial8250_do_startup(struct uart_port *port)
1154 +
1155 + if (port->irq) {
1156 + unsigned char iir1;
1157 ++
1158 ++ if (port->irqflags & IRQF_SHARED)
1159 ++ disable_irq_nosync(port->irq);
1160 ++
1161 + /*
1162 + * Test for UARTs that do not reassert THRE when the
1163 + * transmitter is idle and the interrupt has already
1164 +@@ -2214,8 +2218,6 @@ int serial8250_do_startup(struct uart_port *port)
1165 + * allow register changes to become visible.
1166 + */
1167 + spin_lock_irqsave(&port->lock, flags);
1168 +- if (up->port.irqflags & IRQF_SHARED)
1169 +- disable_irq_nosync(port->irq);
1170 +
1171 + wait_for_xmitr(up, UART_LSR_THRE);
1172 + serial_port_out_sync(port, UART_IER, UART_IER_THRI);
1173 +@@ -2227,9 +2229,10 @@ int serial8250_do_startup(struct uart_port *port)
1174 + iir = serial_port_in(port, UART_IIR);
1175 + serial_port_out(port, UART_IER, 0);
1176 +
1177 ++ spin_unlock_irqrestore(&port->lock, flags);
1178 ++
1179 + if (port->irqflags & IRQF_SHARED)
1180 + enable_irq(port->irq);
1181 +- spin_unlock_irqrestore(&port->lock, flags);
1182 +
1183 + /*
1184 + * If the interrupt is not reasserted, or we otherwise
1185 +diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
1186 +index b3b9b3d2cddf9..6e27dee3876a4 100644
1187 +--- a/drivers/tty/serial/amba-pl011.c
1188 ++++ b/drivers/tty/serial/amba-pl011.c
1189 +@@ -2249,9 +2249,8 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
1190 + clk_disable(uap->clk);
1191 + }
1192 +
1193 +-static void __init
1194 +-pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1195 +- int *parity, int *bits)
1196 ++static void pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1197 ++ int *parity, int *bits)
1198 + {
1199 + if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) {
1200 + unsigned int lcr_h, ibrd, fbrd;
1201 +@@ -2284,7 +2283,7 @@ pl011_console_get_options(struct uart_amba_port *uap, int *baud,
1202 + }
1203 + }
1204 +
1205 +-static int __init pl011_console_setup(struct console *co, char *options)
1206 ++static int pl011_console_setup(struct console *co, char *options)
1207 + {
1208 + struct uart_amba_port *uap;
1209 + int baud = 38400;
1210 +@@ -2352,8 +2351,8 @@ static int __init pl011_console_setup(struct console *co, char *options)
1211 + *
1212 + * Returns 0 if console matches; otherwise non-zero to use default matching
1213 + */
1214 +-static int __init pl011_console_match(struct console *co, char *name, int idx,
1215 +- char *options)
1216 ++static int pl011_console_match(struct console *co, char *name, int idx,
1217 ++ char *options)
1218 + {
1219 + unsigned char iotype;
1220 + resource_size_t addr;
1221 +@@ -2533,7 +2532,7 @@ static int pl011_setup_port(struct device *dev, struct uart_amba_port *uap,
1222 +
1223 + static int pl011_register_port(struct uart_amba_port *uap)
1224 + {
1225 +- int ret;
1226 ++ int ret, i;
1227 +
1228 + /* Ensure interrupts from this UART are masked and cleared */
1229 + pl011_write(0, uap, REG_IMSC);
1230 +@@ -2544,6 +2543,9 @@ static int pl011_register_port(struct uart_amba_port *uap)
1231 + if (ret < 0) {
1232 + dev_err(uap->port.dev,
1233 + "Failed to register AMBA-PL011 driver\n");
1234 ++ for (i = 0; i < ARRAY_SIZE(amba_ports); i++)
1235 ++ if (amba_ports[i] == uap)
1236 ++ amba_ports[i] = NULL;
1237 + return ret;
1238 + }
1239 + }
1240 +diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
1241 +index 01ff8ec780237..4dfdb59061bea 100644
1242 +--- a/drivers/tty/serial/samsung.c
1243 ++++ b/drivers/tty/serial/samsung.c
1244 +@@ -1725,9 +1725,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1245 + ourport->tx_irq = ret + 1;
1246 + }
1247 +
1248 +- ret = platform_get_irq(platdev, 1);
1249 +- if (ret > 0)
1250 +- ourport->tx_irq = ret;
1251 ++ if (!s3c24xx_serial_has_interrupt_mask(port)) {
1252 ++ ret = platform_get_irq(platdev, 1);
1253 ++ if (ret > 0)
1254 ++ ourport->tx_irq = ret;
1255 ++ }
1256 + /*
1257 + * DMA is currently supported only on DT platforms, if DMA properties
1258 + * are specified.
1259 +diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
1260 +index 3e5a3614fad03..1f00f42213c27 100644
1261 +--- a/drivers/tty/vt/vt.c
1262 ++++ b/drivers/tty/vt/vt.c
1263 +@@ -868,7 +868,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1264 + unsigned int old_rows, old_row_size;
1265 + unsigned int new_cols, new_rows, new_row_size, new_screen_size;
1266 + unsigned int user;
1267 +- unsigned short *newscreen;
1268 ++ unsigned short *oldscreen, *newscreen;
1269 +
1270 + WARN_CONSOLE_UNLOCKED();
1271 +
1272 +@@ -950,10 +950,11 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
1273 + if (new_scr_end > new_origin)
1274 + scr_memsetw((void *)new_origin, vc->vc_video_erase_char,
1275 + new_scr_end - new_origin);
1276 +- kfree(vc->vc_screenbuf);
1277 ++ oldscreen = vc->vc_screenbuf;
1278 + vc->vc_screenbuf = newscreen;
1279 + vc->vc_screenbuf_size = new_screen_size;
1280 + set_origin(vc);
1281 ++ kfree(oldscreen);
1282 +
1283 + /* do part of a reset_terminal() */
1284 + vc->vc_top = 0;
1285 +diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c
1286 +index 4ed0d77e59181..78a3b969cae71 100644
1287 +--- a/drivers/tty/vt/vt_ioctl.c
1288 ++++ b/drivers/tty/vt/vt_ioctl.c
1289 +@@ -896,12 +896,22 @@ int vt_ioctl(struct tty_struct *tty,
1290 + console_lock();
1291 + vcp = vc_cons[i].d;
1292 + if (vcp) {
1293 ++ int ret;
1294 ++ int save_scan_lines = vcp->vc_scan_lines;
1295 ++ int save_font_height = vcp->vc_font.height;
1296 ++
1297 + if (v.v_vlin)
1298 + vcp->vc_scan_lines = v.v_vlin;
1299 + if (v.v_clin)
1300 + vcp->vc_font.height = v.v_clin;
1301 + vcp->vc_resize_user = 1;
1302 +- vc_resize(vcp, v.v_cols, v.v_rows);
1303 ++ ret = vc_resize(vcp, v.v_cols, v.v_rows);
1304 ++ if (ret) {
1305 ++ vcp->vc_scan_lines = save_scan_lines;
1306 ++ vcp->vc_font.height = save_font_height;
1307 ++ console_unlock();
1308 ++ return ret;
1309 ++ }
1310 + }
1311 + console_unlock();
1312 + }
1313 +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1314 +index e6e0f786547bf..eed7c8d8e3d4f 100644
1315 +--- a/drivers/usb/core/quirks.c
1316 ++++ b/drivers/usb/core/quirks.c
1317 +@@ -299,6 +299,8 @@ static const struct usb_device_id usb_quirk_list[] = {
1318 +
1319 + { USB_DEVICE(0x2386, 0x3119), .driver_info = USB_QUIRK_NO_LPM },
1320 +
1321 ++ { USB_DEVICE(0x2386, 0x350e), .driver_info = USB_QUIRK_NO_LPM },
1322 ++
1323 + /* DJI CineSSD */
1324 + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM },
1325 +
1326 +diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
1327 +index 6399923239e78..b69747367bd75 100644
1328 +--- a/drivers/usb/gadget/function/f_ncm.c
1329 ++++ b/drivers/usb/gadget/function/f_ncm.c
1330 +@@ -1209,12 +1209,15 @@ static int ncm_unwrap_ntb(struct gether *port,
1331 + int ndp_index;
1332 + unsigned dg_len, dg_len2;
1333 + unsigned ndp_len;
1334 ++ unsigned block_len;
1335 + struct sk_buff *skb2;
1336 + int ret = -EINVAL;
1337 +- unsigned max_size = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
1338 ++ unsigned ntb_max = le32_to_cpu(ntb_parameters.dwNtbOutMaxSize);
1339 ++ unsigned frame_max = le16_to_cpu(ecm_desc.wMaxSegmentSize);
1340 + const struct ndp_parser_opts *opts = ncm->parser_opts;
1341 + unsigned crc_len = ncm->is_crc ? sizeof(uint32_t) : 0;
1342 + int dgram_counter;
1343 ++ bool ndp_after_header;
1344 +
1345 + /* dwSignature */
1346 + if (get_unaligned_le32(tmp) != opts->nth_sign) {
1347 +@@ -1233,25 +1236,37 @@ static int ncm_unwrap_ntb(struct gether *port,
1348 + }
1349 + tmp++; /* skip wSequence */
1350 +
1351 ++ block_len = get_ncm(&tmp, opts->block_length);
1352 + /* (d)wBlockLength */
1353 +- if (get_ncm(&tmp, opts->block_length) > max_size) {
1354 ++ if (block_len > ntb_max) {
1355 + INFO(port->func.config->cdev, "OUT size exceeded\n");
1356 + goto err;
1357 + }
1358 +
1359 + ndp_index = get_ncm(&tmp, opts->ndp_index);
1360 ++ ndp_after_header = false;
1361 +
1362 + /* Run through all the NDP's in the NTB */
1363 + do {
1364 +- /* NCM 3.2 */
1365 +- if (((ndp_index % 4) != 0) &&
1366 +- (ndp_index < opts->nth_size)) {
1367 ++ /*
1368 ++ * NCM 3.2
1369 ++ * dwNdpIndex
1370 ++ */
1371 ++ if (((ndp_index % 4) != 0) ||
1372 ++ (ndp_index < opts->nth_size) ||
1373 ++ (ndp_index > (block_len -
1374 ++ opts->ndp_size))) {
1375 + INFO(port->func.config->cdev, "Bad index: %#X\n",
1376 + ndp_index);
1377 + goto err;
1378 + }
1379 ++ if (ndp_index == opts->nth_size)
1380 ++ ndp_after_header = true;
1381 +
1382 +- /* walk through NDP */
1383 ++ /*
1384 ++ * walk through NDP
1385 ++ * dwSignature
1386 ++ */
1387 + tmp = (void *)(skb->data + ndp_index);
1388 + if (get_unaligned_le32(tmp) != ncm->ndp_sign) {
1389 + INFO(port->func.config->cdev, "Wrong NDP SIGN\n");
1390 +@@ -1262,14 +1277,15 @@ static int ncm_unwrap_ntb(struct gether *port,
1391 + ndp_len = get_unaligned_le16(tmp++);
1392 + /*
1393 + * NCM 3.3.1
1394 ++ * wLength
1395 + * entry is 2 items
1396 + * item size is 16/32 bits, opts->dgram_item_len * 2 bytes
1397 + * minimal: struct usb_cdc_ncm_ndpX + normal entry + zero entry
1398 + * Each entry is a dgram index and a dgram length.
1399 + */
1400 + if ((ndp_len < opts->ndp_size
1401 +- + 2 * 2 * (opts->dgram_item_len * 2))
1402 +- || (ndp_len % opts->ndplen_align != 0)) {
1403 ++ + 2 * 2 * (opts->dgram_item_len * 2)) ||
1404 ++ (ndp_len % opts->ndplen_align != 0)) {
1405 + INFO(port->func.config->cdev, "Bad NDP length: %#X\n",
1406 + ndp_len);
1407 + goto err;
1408 +@@ -1286,8 +1302,21 @@ static int ncm_unwrap_ntb(struct gether *port,
1409 +
1410 + do {
1411 + index = index2;
1412 ++ /* wDatagramIndex[0] */
1413 ++ if ((index < opts->nth_size) ||
1414 ++ (index > block_len - opts->dpe_size)) {
1415 ++ INFO(port->func.config->cdev,
1416 ++ "Bad index: %#X\n", index);
1417 ++ goto err;
1418 ++ }
1419 ++
1420 + dg_len = dg_len2;
1421 +- if (dg_len < 14 + crc_len) { /* ethernet hdr + crc */
1422 ++ /*
1423 ++ * wDatagramLength[0]
1424 ++ * ethernet hdr + crc or larger than max frame size
1425 ++ */
1426 ++ if ((dg_len < 14 + crc_len) ||
1427 ++ (dg_len > frame_max)) {
1428 + INFO(port->func.config->cdev,
1429 + "Bad dgram length: %#X\n", dg_len);
1430 + goto err;
1431 +@@ -1311,6 +1340,37 @@ static int ncm_unwrap_ntb(struct gether *port,
1432 + index2 = get_ncm(&tmp, opts->dgram_item_len);
1433 + dg_len2 = get_ncm(&tmp, opts->dgram_item_len);
1434 +
1435 ++ if (index2 == 0 || dg_len2 == 0)
1436 ++ break;
1437 ++
1438 ++ /* wDatagramIndex[1] */
1439 ++ if (ndp_after_header) {
1440 ++ if (index2 < opts->nth_size + opts->ndp_size) {
1441 ++ INFO(port->func.config->cdev,
1442 ++ "Bad index: %#X\n", index2);
1443 ++ goto err;
1444 ++ }
1445 ++ } else {
1446 ++ if (index2 < opts->nth_size + opts->dpe_size) {
1447 ++ INFO(port->func.config->cdev,
1448 ++ "Bad index: %#X\n", index2);
1449 ++ goto err;
1450 ++ }
1451 ++ }
1452 ++ if (index2 > block_len - opts->dpe_size) {
1453 ++ INFO(port->func.config->cdev,
1454 ++ "Bad index: %#X\n", index2);
1455 ++ goto err;
1456 ++ }
1457 ++
1458 ++ /* wDatagramLength[1] */
1459 ++ if ((dg_len2 < 14 + crc_len) ||
1460 ++ (dg_len2 > frame_max)) {
1461 ++ INFO(port->func.config->cdev,
1462 ++ "Bad dgram length: %#X\n", dg_len);
1463 ++ goto err;
1464 ++ }
1465 ++
1466 + /*
1467 + * Copy the data into a new skb.
1468 + * This ensures the truesize is correct
1469 +@@ -1327,9 +1387,6 @@ static int ncm_unwrap_ntb(struct gether *port,
1470 + ndp_len -= 2 * (opts->dgram_item_len * 2);
1471 +
1472 + dgram_counter++;
1473 +-
1474 +- if (index2 == 0 || dg_len2 == 0)
1475 +- break;
1476 + } while (ndp_len > 2 * (opts->dgram_item_len * 2));
1477 + } while (ndp_index);
1478 +
1479 +diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
1480 +index d2351139342f6..7e8e262b36297 100644
1481 +--- a/drivers/usb/gadget/function/f_tcm.c
1482 ++++ b/drivers/usb/gadget/function/f_tcm.c
1483 +@@ -751,12 +751,13 @@ static int uasp_alloc_stream_res(struct f_uas *fu, struct uas_stream *stream)
1484 + goto err_sts;
1485 +
1486 + return 0;
1487 ++
1488 + err_sts:
1489 +- usb_ep_free_request(fu->ep_status, stream->req_status);
1490 +- stream->req_status = NULL;
1491 +-err_out:
1492 + usb_ep_free_request(fu->ep_out, stream->req_out);
1493 + stream->req_out = NULL;
1494 ++err_out:
1495 ++ usb_ep_free_request(fu->ep_in, stream->req_in);
1496 ++ stream->req_in = NULL;
1497 + out:
1498 + return -ENOMEM;
1499 + }
1500 +diff --git a/drivers/usb/gadget/u_f.h b/drivers/usb/gadget/u_f.h
1501 +index 2f03334c68741..d150a6795f481 100644
1502 +--- a/drivers/usb/gadget/u_f.h
1503 ++++ b/drivers/usb/gadget/u_f.h
1504 +@@ -17,6 +17,7 @@
1505 + #define __U_F_H__
1506 +
1507 + #include <linux/usb/gadget.h>
1508 ++#include <linux/overflow.h>
1509 +
1510 + /* Variable Length Array Macros **********************************************/
1511 + #define vla_group(groupname) size_t groupname##__next = 0
1512 +@@ -24,21 +25,36 @@
1513 +
1514 + #define vla_item(groupname, type, name, n) \
1515 + size_t groupname##_##name##__offset = ({ \
1516 +- size_t align_mask = __alignof__(type) - 1; \
1517 +- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
1518 +- size_t size = (n) * sizeof(type); \
1519 +- groupname##__next = offset + size; \
1520 ++ size_t offset = 0; \
1521 ++ if (groupname##__next != SIZE_MAX) { \
1522 ++ size_t align_mask = __alignof__(type) - 1; \
1523 ++ size_t size = array_size(n, sizeof(type)); \
1524 ++ offset = (groupname##__next + align_mask) & \
1525 ++ ~align_mask; \
1526 ++ if (check_add_overflow(offset, size, \
1527 ++ &groupname##__next)) { \
1528 ++ groupname##__next = SIZE_MAX; \
1529 ++ offset = 0; \
1530 ++ } \
1531 ++ } \
1532 + offset; \
1533 + })
1534 +
1535 + #define vla_item_with_sz(groupname, type, name, n) \
1536 +- size_t groupname##_##name##__sz = (n) * sizeof(type); \
1537 +- size_t groupname##_##name##__offset = ({ \
1538 +- size_t align_mask = __alignof__(type) - 1; \
1539 +- size_t offset = (groupname##__next + align_mask) & ~align_mask;\
1540 +- size_t size = groupname##_##name##__sz; \
1541 +- groupname##__next = offset + size; \
1542 +- offset; \
1543 ++ size_t groupname##_##name##__sz = array_size(n, sizeof(type)); \
1544 ++ size_t groupname##_##name##__offset = ({ \
1545 ++ size_t offset = 0; \
1546 ++ if (groupname##__next != SIZE_MAX) { \
1547 ++ size_t align_mask = __alignof__(type) - 1; \
1548 ++ offset = (groupname##__next + align_mask) & \
1549 ++ ~align_mask; \
1550 ++ if (check_add_overflow(offset, groupname##_##name##__sz,\
1551 ++ &groupname##__next)) { \
1552 ++ groupname##__next = SIZE_MAX; \
1553 ++ offset = 0; \
1554 ++ } \
1555 ++ } \
1556 ++ offset; \
1557 + })
1558 +
1559 + #define vla_ptr(ptr, groupname, name) \
1560 +diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
1561 +index 6865b919403f7..2ed062a2e93b4 100644
1562 +--- a/drivers/usb/host/ohci-exynos.c
1563 ++++ b/drivers/usb/host/ohci-exynos.c
1564 +@@ -166,9 +166,8 @@ skip_phy:
1565 + hcd->rsrc_len = resource_size(res);
1566 +
1567 + irq = platform_get_irq(pdev, 0);
1568 +- if (!irq) {
1569 +- dev_err(&pdev->dev, "Failed to get IRQ\n");
1570 +- err = -ENODEV;
1571 ++ if (irq < 0) {
1572 ++ err = irq;
1573 + goto fail_io;
1574 + }
1575 +
1576 +diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
1577 +index 04d36fa607342..194ea29d7a57e 100644
1578 +--- a/drivers/usb/host/xhci-hub.c
1579 ++++ b/drivers/usb/host/xhci-hub.c
1580 +@@ -623,15 +623,6 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
1581 + {
1582 + u32 pls = status_reg & PORT_PLS_MASK;
1583 +
1584 +- /* resume state is a xHCI internal state.
1585 +- * Do not report it to usb core, instead, pretend to be U3,
1586 +- * thus usb core knows it's not ready for transfer
1587 +- */
1588 +- if (pls == XDEV_RESUME) {
1589 +- *status |= USB_SS_PORT_LS_U3;
1590 +- return;
1591 +- }
1592 +-
1593 + /* When the CAS bit is set then warm reset
1594 + * should be performed on port
1595 + */
1596 +@@ -653,6 +644,16 @@ static void xhci_hub_report_usb3_link_state(struct xhci_hcd *xhci,
1597 + */
1598 + pls |= USB_PORT_STAT_CONNECTION;
1599 + } else {
1600 ++ /*
1601 ++ * Resume state is an xHCI internal state. Do not report it to
1602 ++ * usb core, instead, pretend to be U3, thus usb core knows
1603 ++ * it's not ready for transfer.
1604 ++ */
1605 ++ if (pls == XDEV_RESUME) {
1606 ++ *status |= USB_SS_PORT_LS_U3;
1607 ++ return;
1608 ++ }
1609 ++
1610 + /*
1611 + * If CAS bit isn't set but the Port is already at
1612 + * Compliance Mode, fake a connection so the USB core
1613 +diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c
1614 +index bd6e06ef88acd..5dfc58ac97f30 100644
1615 +--- a/drivers/usb/misc/lvstest.c
1616 ++++ b/drivers/usb/misc/lvstest.c
1617 +@@ -392,7 +392,7 @@ static int lvs_rh_probe(struct usb_interface *intf,
1618 + USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT);
1619 + if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) {
1620 + dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret);
1621 +- return ret;
1622 ++ return ret < 0 ? ret : -EINVAL;
1623 + }
1624 +
1625 + /* submit urb to poll interrupt endpoint */
1626 +diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
1627 +index 895e8c0288cf9..30b3bdc4e6761 100644
1628 +--- a/drivers/usb/misc/sisusbvga/sisusb.c
1629 ++++ b/drivers/usb/misc/sisusbvga/sisusb.c
1630 +@@ -762,7 +762,7 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
1631 + u8 swap8, fromkern = kernbuffer ? 1 : 0;
1632 + u16 swap16;
1633 + u32 swap32, flag = (length >> 28) & 1;
1634 +- char buf[4];
1635 ++ u8 buf[4];
1636 +
1637 + /* if neither kernbuffer not userbuffer are given, assume
1638 + * data in obuf
1639 +diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
1640 +index 2350502f90540..1be1fa1b73770 100644
1641 +--- a/drivers/usb/misc/yurex.c
1642 ++++ b/drivers/usb/misc/yurex.c
1643 +@@ -502,7 +502,7 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
1644 + prepare_to_wait(&dev->waitq, &wait, TASK_INTERRUPTIBLE);
1645 + dev_dbg(&dev->interface->dev, "%s - submit %c\n", __func__,
1646 + dev->cntl_buffer[0]);
1647 +- retval = usb_submit_urb(dev->cntl_urb, GFP_KERNEL);
1648 ++ retval = usb_submit_urb(dev->cntl_urb, GFP_ATOMIC);
1649 + if (retval >= 0)
1650 + timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
1651 + finish_wait(&dev->waitq, &wait);
1652 +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
1653 +index 46079468df426..4a94effb64f77 100644
1654 +--- a/drivers/usb/storage/unusual_devs.h
1655 ++++ b/drivers/usb/storage/unusual_devs.h
1656 +@@ -2347,7 +2347,7 @@ UNUSUAL_DEV( 0x357d, 0x7788, 0x0114, 0x0114,
1657 + "JMicron",
1658 + "USB to ATA/ATAPI Bridge",
1659 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1660 +- US_FL_BROKEN_FUA ),
1661 ++ US_FL_BROKEN_FUA | US_FL_IGNORE_UAS ),
1662 +
1663 + /* Reported by Andrey Rahmatullin <wrar@××××××××.org> */
1664 + UNUSUAL_DEV( 0x4102, 0x1020, 0x0100, 0x0100,
1665 +diff --git a/drivers/usb/storage/unusual_uas.h b/drivers/usb/storage/unusual_uas.h
1666 +index 4df15faa66d71..018b0663d6109 100644
1667 +--- a/drivers/usb/storage/unusual_uas.h
1668 ++++ b/drivers/usb/storage/unusual_uas.h
1669 +@@ -41,6 +41,13 @@
1670 + * and don't forget to CC: the USB development list <linux-usb@×××××××××××.org>
1671 + */
1672 +
1673 ++/* Reported-by: Till Dörges <doerges@×××××××××.de> */
1674 ++UNUSUAL_DEV(0x054c, 0x087d, 0x0000, 0x9999,
1675 ++ "Sony",
1676 ++ "PSZ-HA*",
1677 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1678 ++ US_FL_NO_REPORT_OPCODES),
1679 ++
1680 + /* Reported-by: Julian Groß <julian.g@××××××.de> */
1681 + UNUSUAL_DEV(0x059f, 0x105f, 0x0000, 0x9999,
1682 + "LaCie",
1683 +@@ -156,6 +163,13 @@ UNUSUAL_DEV(0x152d, 0x0578, 0x0000, 0x9999,
1684 + USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1685 + US_FL_BROKEN_FUA),
1686 +
1687 ++/* Reported-by: Thinh Nguyen <thinhn@××××××××.com> */
1688 ++UNUSUAL_DEV(0x154b, 0xf00d, 0x0000, 0x9999,
1689 ++ "PNY",
1690 ++ "Pro Elite SSD",
1691 ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL,
1692 ++ US_FL_NO_ATA_1X),
1693 ++
1694 + /* Reported-by: Hans de Goede <hdegoede@××××××.com> */
1695 + UNUSUAL_DEV(0x2109, 0x0711, 0x0000, 0x9999,
1696 + "VIA",
1697 +diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
1698 +index 178b507a6fe0c..dd6797e54e8ab 100644
1699 +--- a/drivers/video/console/fbcon.c
1700 ++++ b/drivers/video/console/fbcon.c
1701 +@@ -2116,6 +2116,9 @@ static void updatescrollmode(struct display *p,
1702 + }
1703 + }
1704 +
1705 ++#define PITCH(w) (((w) + 7) >> 3)
1706 ++#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */
1707 ++
1708 + static int fbcon_resize(struct vc_data *vc, unsigned int width,
1709 + unsigned int height, unsigned int user)
1710 + {
1711 +@@ -2125,6 +2128,24 @@ static int fbcon_resize(struct vc_data *vc, unsigned int width,
1712 + struct fb_var_screeninfo var = info->var;
1713 + int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
1714 +
1715 ++ if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) {
1716 ++ int size;
1717 ++ int pitch = PITCH(vc->vc_font.width);
1718 ++
1719 ++ /*
1720 ++ * If user font, ensure that a possible change to user font
1721 ++ * height or width will not allow a font data out-of-bounds access.
1722 ++ * NOTE: must use original charcount in calculation as font
1723 ++ * charcount can change and cannot be used to determine the
1724 ++ * font data allocated size.
1725 ++ */
1726 ++ if (pitch <= 0)
1727 ++ return -EINVAL;
1728 ++ size = CALC_FONTSZ(vc->vc_font.height, pitch, FNTCHARCNT(vc->vc_font.data));
1729 ++ if (size > FNTSIZE(vc->vc_font.data))
1730 ++ return -EINVAL;
1731 ++ }
1732 ++
1733 + virt_w = FBCON_SWAP(ops->rotate, width, height);
1734 + virt_h = FBCON_SWAP(ops->rotate, height, width);
1735 + virt_fw = FBCON_SWAP(ops->rotate, vc->vc_font.width,
1736 +@@ -2586,7 +2607,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
1737 + int size;
1738 + int i, csum;
1739 + u8 *new_data, *data = font->data;
1740 +- int pitch = (font->width+7) >> 3;
1741 ++ int pitch = PITCH(font->width);
1742 +
1743 + /* Is there a reason why fbconsole couldn't handle any charcount >256?
1744 + * If not this check should be changed to charcount < 256 */
1745 +@@ -2602,7 +2623,7 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, unsigne
1746 + if (fbcon_invalid_charcount(info, charcount))
1747 + return -EINVAL;
1748 +
1749 +- size = h * pitch * charcount;
1750 ++ size = CALC_FONTSZ(h, pitch, charcount);
1751 +
1752 + new_data = kmalloc(FONT_EXTRA_WORDS * sizeof(int) + size, GFP_USER);
1753 +
1754 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
1755 +index 7a75dfda98457..00f5a54aaf9b7 100644
1756 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
1757 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dispc.c
1758 +@@ -531,8 +531,11 @@ int dispc_runtime_get(void)
1759 + DSSDBG("dispc_runtime_get\n");
1760 +
1761 + r = pm_runtime_get_sync(&dispc.pdev->dev);
1762 +- WARN_ON(r < 0);
1763 +- return r < 0 ? r : 0;
1764 ++ if (WARN_ON(r < 0)) {
1765 ++ pm_runtime_put_sync(&dispc.pdev->dev);
1766 ++ return r;
1767 ++ }
1768 ++ return 0;
1769 + }
1770 + EXPORT_SYMBOL(dispc_runtime_get);
1771 +
1772 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
1773 +index 30d49f3800b33..2bfd9063cdfc3 100644
1774 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
1775 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dsi.c
1776 +@@ -1148,8 +1148,11 @@ static int dsi_runtime_get(struct platform_device *dsidev)
1777 + DSSDBG("dsi_runtime_get\n");
1778 +
1779 + r = pm_runtime_get_sync(&dsi->pdev->dev);
1780 +- WARN_ON(r < 0);
1781 +- return r < 0 ? r : 0;
1782 ++ if (WARN_ON(r < 0)) {
1783 ++ pm_runtime_put_sync(&dsi->pdev->dev);
1784 ++ return r;
1785 ++ }
1786 ++ return 0;
1787 + }
1788 +
1789 + static void dsi_runtime_put(struct platform_device *dsidev)
1790 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/dss.c b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
1791 +index 4429ad37b64cd..acecee5b1c102 100644
1792 +--- a/drivers/video/fbdev/omap2/omapfb/dss/dss.c
1793 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/dss.c
1794 +@@ -778,8 +778,11 @@ int dss_runtime_get(void)
1795 + DSSDBG("dss_runtime_get\n");
1796 +
1797 + r = pm_runtime_get_sync(&dss.pdev->dev);
1798 +- WARN_ON(r < 0);
1799 +- return r < 0 ? r : 0;
1800 ++ if (WARN_ON(r < 0)) {
1801 ++ pm_runtime_put_sync(&dss.pdev->dev);
1802 ++ return r;
1803 ++ }
1804 ++ return 0;
1805 + }
1806 +
1807 + void dss_runtime_put(void)
1808 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
1809 +index 156a254705ea5..ab64bf0215e82 100644
1810 +--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
1811 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
1812 +@@ -50,9 +50,10 @@ static int hdmi_runtime_get(void)
1813 + DSSDBG("hdmi_runtime_get\n");
1814 +
1815 + r = pm_runtime_get_sync(&hdmi.pdev->dev);
1816 +- WARN_ON(r < 0);
1817 +- if (r < 0)
1818 ++ if (WARN_ON(r < 0)) {
1819 ++ pm_runtime_put_sync(&hdmi.pdev->dev);
1820 + return r;
1821 ++ }
1822 +
1823 + return 0;
1824 + }
1825 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
1826 +index 4da36bcab9779..c6efaca3235a8 100644
1827 +--- a/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
1828 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
1829 +@@ -54,9 +54,10 @@ static int hdmi_runtime_get(void)
1830 + DSSDBG("hdmi_runtime_get\n");
1831 +
1832 + r = pm_runtime_get_sync(&hdmi.pdev->dev);
1833 +- WARN_ON(r < 0);
1834 +- if (r < 0)
1835 ++ if (WARN_ON(r < 0)) {
1836 ++ pm_runtime_put_sync(&hdmi.pdev->dev);
1837 + return r;
1838 ++ }
1839 +
1840 + return 0;
1841 + }
1842 +diff --git a/drivers/video/fbdev/omap2/omapfb/dss/venc.c b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
1843 +index 392464da12e41..96714b4596d2d 100644
1844 +--- a/drivers/video/fbdev/omap2/omapfb/dss/venc.c
1845 ++++ b/drivers/video/fbdev/omap2/omapfb/dss/venc.c
1846 +@@ -402,8 +402,11 @@ static int venc_runtime_get(void)
1847 + DSSDBG("venc_runtime_get\n");
1848 +
1849 + r = pm_runtime_get_sync(&venc.pdev->dev);
1850 +- WARN_ON(r < 0);
1851 +- return r < 0 ? r : 0;
1852 ++ if (WARN_ON(r < 0)) {
1853 ++ pm_runtime_put_sync(&venc.pdev->dev);
1854 ++ return r;
1855 ++ }
1856 ++ return 0;
1857 + }
1858 +
1859 + static void venc_runtime_put(void)
1860 +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
1861 +index 4b0cc9d0ca537..0dadfabcfd80b 100644
1862 +--- a/drivers/xen/events/events_base.c
1863 ++++ b/drivers/xen/events/events_base.c
1864 +@@ -155,7 +155,7 @@ int get_evtchn_to_irq(unsigned evtchn)
1865 + /* Get info for IRQ */
1866 + struct irq_info *info_for_irq(unsigned irq)
1867 + {
1868 +- return irq_get_handler_data(irq);
1869 ++ return irq_get_chip_data(irq);
1870 + }
1871 +
1872 + /* Constructors for packed IRQ information. */
1873 +@@ -384,7 +384,7 @@ static void xen_irq_init(unsigned irq)
1874 + info->type = IRQT_UNBOUND;
1875 + info->refcnt = -1;
1876 +
1877 +- irq_set_handler_data(irq, info);
1878 ++ irq_set_chip_data(irq, info);
1879 +
1880 + list_add_tail(&info->list, &xen_irq_list_head);
1881 + }
1882 +@@ -433,14 +433,14 @@ static int __must_check xen_allocate_irq_gsi(unsigned gsi)
1883 +
1884 + static void xen_free_irq(unsigned irq)
1885 + {
1886 +- struct irq_info *info = irq_get_handler_data(irq);
1887 ++ struct irq_info *info = irq_get_chip_data(irq);
1888 +
1889 + if (WARN_ON(!info))
1890 + return;
1891 +
1892 + list_del(&info->list);
1893 +
1894 +- irq_set_handler_data(irq, NULL);
1895 ++ irq_set_chip_data(irq, NULL);
1896 +
1897 + WARN_ON(info->refcnt > 0);
1898 +
1899 +@@ -610,7 +610,7 @@ EXPORT_SYMBOL_GPL(xen_irq_from_gsi);
1900 + static void __unbind_from_irq(unsigned int irq)
1901 + {
1902 + int evtchn = evtchn_from_irq(irq);
1903 +- struct irq_info *info = irq_get_handler_data(irq);
1904 ++ struct irq_info *info = irq_get_chip_data(irq);
1905 +
1906 + if (info->refcnt > 0) {
1907 + info->refcnt--;
1908 +@@ -1114,7 +1114,7 @@ int bind_ipi_to_irqhandler(enum ipi_vector ipi,
1909 +
1910 + void unbind_from_irqhandler(unsigned int irq, void *dev_id)
1911 + {
1912 +- struct irq_info *info = irq_get_handler_data(irq);
1913 ++ struct irq_info *info = irq_get_chip_data(irq);
1914 +
1915 + if (WARN_ON(!info))
1916 + return;
1917 +@@ -1148,7 +1148,7 @@ int evtchn_make_refcounted(unsigned int evtchn)
1918 + if (irq == -1)
1919 + return -ENOENT;
1920 +
1921 +- info = irq_get_handler_data(irq);
1922 ++ info = irq_get_chip_data(irq);
1923 +
1924 + if (!info)
1925 + return -ENOENT;
1926 +@@ -1176,7 +1176,7 @@ int evtchn_get(unsigned int evtchn)
1927 + if (irq == -1)
1928 + goto done;
1929 +
1930 +- info = irq_get_handler_data(irq);
1931 ++ info = irq_get_chip_data(irq);
1932 +
1933 + if (!info)
1934 + goto done;
1935 +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
1936 +index d9909e2fc4c21..b100b8dae5884 100644
1937 +--- a/fs/btrfs/disk-io.c
1938 ++++ b/fs/btrfs/disk-io.c
1939 +@@ -4432,6 +4432,7 @@ static void btrfs_cleanup_bg_io(struct btrfs_block_group_cache *cache)
1940 + cache->io_ctl.inode = NULL;
1941 + iput(inode);
1942 + }
1943 ++ ASSERT(cache->io_ctl.pages == NULL);
1944 + btrfs_put_block_group(cache);
1945 + }
1946 +
1947 +diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
1948 +index 568ff2ee015be..8e93bd391b352 100644
1949 +--- a/fs/btrfs/free-space-cache.c
1950 ++++ b/fs/btrfs/free-space-cache.c
1951 +@@ -1165,7 +1165,6 @@ int btrfs_wait_cache_io(struct btrfs_root *root,
1952 + ret = update_cache_item(trans, root, inode, path, offset,
1953 + io_ctl->entries, io_ctl->bitmaps);
1954 + out:
1955 +- io_ctl_free(io_ctl);
1956 + if (ret) {
1957 + invalidate_inode_pages2(inode->i_mapping);
1958 + BTRFS_I(inode)->generation = 0;
1959 +@@ -1314,6 +1313,7 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
1960 + * them out later
1961 + */
1962 + io_ctl_drop_pages(io_ctl);
1963 ++ io_ctl_free(io_ctl);
1964 +
1965 + unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
1966 + i_size_read(inode) - 1, &cached_state, GFP_NOFS);
1967 +diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
1968 +index c28ac9c464251..5bd1758f57b64 100644
1969 +--- a/fs/btrfs/tree-log.c
1970 ++++ b/fs/btrfs/tree-log.c
1971 +@@ -3191,11 +3191,13 @@ fail:
1972 + btrfs_free_path(path);
1973 + out_unlock:
1974 + mutex_unlock(&BTRFS_I(dir)->log_mutex);
1975 +- if (ret == -ENOSPC) {
1976 ++ if (err == -ENOSPC) {
1977 + btrfs_set_log_full_commit(root->fs_info, trans);
1978 +- ret = 0;
1979 +- } else if (ret < 0)
1980 +- btrfs_abort_transaction(trans, ret);
1981 ++ err = 0;
1982 ++ } else if (err < 0 && err != -ENOENT) {
1983 ++ /* ENOENT can be returned if the entry hasn't been fsynced yet */
1984 ++ btrfs_abort_transaction(trans, err);
1985 ++ }
1986 +
1987 + btrfs_end_log_trans(root);
1988 +
1989 +diff --git a/fs/buffer.c b/fs/buffer.c
1990 +index a89be9741d125..52f1a60417d1d 100644
1991 +--- a/fs/buffer.c
1992 ++++ b/fs/buffer.c
1993 +@@ -3203,6 +3203,15 @@ int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
1994 + WARN_ON(atomic_read(&bh->b_count) < 1);
1995 + lock_buffer(bh);
1996 + if (test_clear_buffer_dirty(bh)) {
1997 ++ /*
1998 ++ * The bh should be mapped, but it might not be if the
1999 ++ * device was hot-removed. Not much we can do but fail the I/O.
2000 ++ */
2001 ++ if (!buffer_mapped(bh)) {
2002 ++ unlock_buffer(bh);
2003 ++ return -EIO;
2004 ++ }
2005 ++
2006 + get_bh(bh);
2007 + bh->b_end_io = end_buffer_write_sync;
2008 + ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
2009 +diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
2010 +index 3139fbd4c34e3..4ec5a109df82b 100644
2011 +--- a/fs/ceph/mds_client.c
2012 ++++ b/fs/ceph/mds_client.c
2013 +@@ -3386,6 +3386,9 @@ static void delayed_work(struct work_struct *work)
2014 + dout("mdsc delayed_work\n");
2015 + ceph_check_delayed_caps(mdsc);
2016 +
2017 ++ if (mdsc->stopping)
2018 ++ return;
2019 ++
2020 + mutex_lock(&mdsc->mutex);
2021 + renew_interval = mdsc->mdsmap->m_session_timeout >> 2;
2022 + renew_caps = time_after_eq(jiffies, HZ*renew_interval +
2023 +@@ -3717,7 +3720,16 @@ void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc)
2024 + static void ceph_mdsc_stop(struct ceph_mds_client *mdsc)
2025 + {
2026 + dout("stop\n");
2027 +- cancel_delayed_work_sync(&mdsc->delayed_work); /* cancel timer */
2028 ++ /*
2029 ++ * Make sure the delayed work stopped before releasing
2030 ++ * the resources.
2031 ++ *
2032 ++ * Because the cancel_delayed_work_sync() will only
2033 ++ * guarantee that the work finishes executing. But the
2034 ++ * delayed work will re-arm itself again after that.
2035 ++ */
2036 ++ flush_delayed_work(&mdsc->delayed_work);
2037 ++
2038 + if (mdsc->mdsmap)
2039 + ceph_mdsmap_destroy(mdsc->mdsmap);
2040 + kfree(mdsc->sessions);
2041 +diff --git a/fs/ext4/super.c b/fs/ext4/super.c
2042 +index 370e4273042c5..472fa29c6f604 100644
2043 +--- a/fs/ext4/super.c
2044 ++++ b/fs/ext4/super.c
2045 +@@ -4680,13 +4680,6 @@ static int ext4_commit_super(struct super_block *sb, int sync)
2046 + if (!sbh || block_device_ejected(sb))
2047 + return error;
2048 +
2049 +- /*
2050 +- * The superblock bh should be mapped, but it might not be if the
2051 +- * device was hot-removed. Not much we can do but fail the I/O.
2052 +- */
2053 +- if (!buffer_mapped(sbh))
2054 +- return error;
2055 +-
2056 + /*
2057 + * If the file system is mounted read-only, don't update the
2058 + * superblock write time. This avoids updating the superblock
2059 +diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
2060 +index 5a1a6dbbc55fb..f978ae2bb846f 100644
2061 +--- a/fs/fs-writeback.c
2062 ++++ b/fs/fs-writeback.c
2063 +@@ -45,7 +45,6 @@ struct wb_completion {
2064 + struct wb_writeback_work {
2065 + long nr_pages;
2066 + struct super_block *sb;
2067 +- unsigned long *older_than_this;
2068 + enum writeback_sync_modes sync_mode;
2069 + unsigned int tagged_writepages:1;
2070 + unsigned int for_kupdate:1;
2071 +@@ -160,7 +159,9 @@ static void inode_io_list_del_locked(struct inode *inode,
2072 + struct bdi_writeback *wb)
2073 + {
2074 + assert_spin_locked(&wb->list_lock);
2075 ++ assert_spin_locked(&inode->i_lock);
2076 +
2077 ++ inode->i_state &= ~I_SYNC_QUEUED;
2078 + list_del_init(&inode->i_io_list);
2079 + wb_io_lists_depopulated(wb);
2080 + }
2081 +@@ -1039,7 +1040,9 @@ void inode_io_list_del(struct inode *inode)
2082 + struct bdi_writeback *wb;
2083 +
2084 + wb = inode_to_wb_and_lock_list(inode);
2085 ++ spin_lock(&inode->i_lock);
2086 + inode_io_list_del_locked(inode, wb);
2087 ++ spin_unlock(&inode->i_lock);
2088 + spin_unlock(&wb->list_lock);
2089 + }
2090 +
2091 +@@ -1088,8 +1091,10 @@ void sb_clear_inode_writeback(struct inode *inode)
2092 + * the case then the inode must have been redirtied while it was being written
2093 + * out and we don't reset its dirtied_when.
2094 + */
2095 +-static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2096 ++static void redirty_tail_locked(struct inode *inode, struct bdi_writeback *wb)
2097 + {
2098 ++ assert_spin_locked(&inode->i_lock);
2099 ++
2100 + if (!list_empty(&wb->b_dirty)) {
2101 + struct inode *tail;
2102 +
2103 +@@ -1098,6 +1103,14 @@ static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2104 + inode->dirtied_when = jiffies;
2105 + }
2106 + inode_io_list_move_locked(inode, wb, &wb->b_dirty);
2107 ++ inode->i_state &= ~I_SYNC_QUEUED;
2108 ++}
2109 ++
2110 ++static void redirty_tail(struct inode *inode, struct bdi_writeback *wb)
2111 ++{
2112 ++ spin_lock(&inode->i_lock);
2113 ++ redirty_tail_locked(inode, wb);
2114 ++ spin_unlock(&inode->i_lock);
2115 + }
2116 +
2117 + /*
2118 +@@ -1136,16 +1149,13 @@ static bool inode_dirtied_after(struct inode *inode, unsigned long t)
2119 + #define EXPIRE_DIRTY_ATIME 0x0001
2120 +
2121 + /*
2122 +- * Move expired (dirtied before work->older_than_this) dirty inodes from
2123 ++ * Move expired (dirtied before dirtied_before) dirty inodes from
2124 + * @delaying_queue to @dispatch_queue.
2125 + */
2126 + static int move_expired_inodes(struct list_head *delaying_queue,
2127 + struct list_head *dispatch_queue,
2128 +- int flags,
2129 +- struct wb_writeback_work *work)
2130 ++ int flags, unsigned long dirtied_before)
2131 + {
2132 +- unsigned long *older_than_this = NULL;
2133 +- unsigned long expire_time;
2134 + LIST_HEAD(tmp);
2135 + struct list_head *pos, *node;
2136 + struct super_block *sb = NULL;
2137 +@@ -1153,21 +1163,17 @@ static int move_expired_inodes(struct list_head *delaying_queue,
2138 + int do_sb_sort = 0;
2139 + int moved = 0;
2140 +
2141 +- if ((flags & EXPIRE_DIRTY_ATIME) == 0)
2142 +- older_than_this = work->older_than_this;
2143 +- else if (!work->for_sync) {
2144 +- expire_time = jiffies - (dirtytime_expire_interval * HZ);
2145 +- older_than_this = &expire_time;
2146 +- }
2147 + while (!list_empty(delaying_queue)) {
2148 + inode = wb_inode(delaying_queue->prev);
2149 +- if (older_than_this &&
2150 +- inode_dirtied_after(inode, *older_than_this))
2151 ++ if (inode_dirtied_after(inode, dirtied_before))
2152 + break;
2153 + list_move(&inode->i_io_list, &tmp);
2154 + moved++;
2155 ++ spin_lock(&inode->i_lock);
2156 + if (flags & EXPIRE_DIRTY_ATIME)
2157 +- set_bit(__I_DIRTY_TIME_EXPIRED, &inode->i_state);
2158 ++ inode->i_state |= I_DIRTY_TIME_EXPIRED;
2159 ++ inode->i_state |= I_SYNC_QUEUED;
2160 ++ spin_unlock(&inode->i_lock);
2161 + if (sb_is_blkdev_sb(inode->i_sb))
2162 + continue;
2163 + if (sb && sb != inode->i_sb)
2164 +@@ -1205,18 +1211,22 @@ out:
2165 + * |
2166 + * +--> dequeue for IO
2167 + */
2168 +-static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work)
2169 ++static void queue_io(struct bdi_writeback *wb, struct wb_writeback_work *work,
2170 ++ unsigned long dirtied_before)
2171 + {
2172 + int moved;
2173 ++ unsigned long time_expire_jif = dirtied_before;
2174 +
2175 + assert_spin_locked(&wb->list_lock);
2176 + list_splice_init(&wb->b_more_io, &wb->b_io);
2177 +- moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, work);
2178 ++ moved = move_expired_inodes(&wb->b_dirty, &wb->b_io, 0, dirtied_before);
2179 ++ if (!work->for_sync)
2180 ++ time_expire_jif = jiffies - dirtytime_expire_interval * HZ;
2181 + moved += move_expired_inodes(&wb->b_dirty_time, &wb->b_io,
2182 +- EXPIRE_DIRTY_ATIME, work);
2183 ++ EXPIRE_DIRTY_ATIME, time_expire_jif);
2184 + if (moved)
2185 + wb_io_lists_populated(wb);
2186 +- trace_writeback_queue_io(wb, work, moved);
2187 ++ trace_writeback_queue_io(wb, work, dirtied_before, moved);
2188 + }
2189 +
2190 + static int write_inode(struct inode *inode, struct writeback_control *wbc)
2191 +@@ -1310,7 +1320,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2192 + * writeback is not making progress due to locked
2193 + * buffers. Skip this inode for now.
2194 + */
2195 +- redirty_tail(inode, wb);
2196 ++ redirty_tail_locked(inode, wb);
2197 + return;
2198 + }
2199 +
2200 +@@ -1330,7 +1340,7 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2201 + * retrying writeback of the dirty page/inode
2202 + * that cannot be performed immediately.
2203 + */
2204 +- redirty_tail(inode, wb);
2205 ++ redirty_tail_locked(inode, wb);
2206 + }
2207 + } else if (inode->i_state & I_DIRTY) {
2208 + /*
2209 +@@ -1338,10 +1348,11 @@ static void requeue_inode(struct inode *inode, struct bdi_writeback *wb,
2210 + * such as delayed allocation during submission or metadata
2211 + * updates after data IO completion.
2212 + */
2213 +- redirty_tail(inode, wb);
2214 ++ redirty_tail_locked(inode, wb);
2215 + } else if (inode->i_state & I_DIRTY_TIME) {
2216 + inode->dirtied_when = jiffies;
2217 + inode_io_list_move_locked(inode, wb, &wb->b_dirty_time);
2218 ++ inode->i_state &= ~I_SYNC_QUEUED;
2219 + } else {
2220 + /* The inode is clean. Remove from writeback lists. */
2221 + inode_io_list_del_locked(inode, wb);
2222 +@@ -1585,8 +1596,8 @@ static long writeback_sb_inodes(struct super_block *sb,
2223 + */
2224 + spin_lock(&inode->i_lock);
2225 + if (inode->i_state & (I_NEW | I_FREEING | I_WILL_FREE)) {
2226 ++ redirty_tail_locked(inode, wb);
2227 + spin_unlock(&inode->i_lock);
2228 +- redirty_tail(inode, wb);
2229 + continue;
2230 + }
2231 + if ((inode->i_state & I_SYNC) && wbc.sync_mode != WB_SYNC_ALL) {
2232 +@@ -1727,7 +1738,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
2233 + blk_start_plug(&plug);
2234 + spin_lock(&wb->list_lock);
2235 + if (list_empty(&wb->b_io))
2236 +- queue_io(wb, &work);
2237 ++ queue_io(wb, &work, jiffies);
2238 + __writeback_inodes_wb(wb, &work);
2239 + spin_unlock(&wb->list_lock);
2240 + blk_finish_plug(&plug);
2241 +@@ -1747,7 +1758,7 @@ static long writeback_inodes_wb(struct bdi_writeback *wb, long nr_pages,
2242 + * takes longer than a dirty_writeback_interval interval, then leave a
2243 + * one-second gap.
2244 + *
2245 +- * older_than_this takes precedence over nr_to_write. So we'll only write back
2246 ++ * dirtied_before takes precedence over nr_to_write. So we'll only write back
2247 + * all dirty pages if they are all attached to "old" mappings.
2248 + */
2249 + static long wb_writeback(struct bdi_writeback *wb,
2250 +@@ -1755,14 +1766,11 @@ static long wb_writeback(struct bdi_writeback *wb,
2251 + {
2252 + unsigned long wb_start = jiffies;
2253 + long nr_pages = work->nr_pages;
2254 +- unsigned long oldest_jif;
2255 ++ unsigned long dirtied_before = jiffies;
2256 + struct inode *inode;
2257 + long progress;
2258 + struct blk_plug plug;
2259 +
2260 +- oldest_jif = jiffies;
2261 +- work->older_than_this = &oldest_jif;
2262 +-
2263 + blk_start_plug(&plug);
2264 + spin_lock(&wb->list_lock);
2265 + for (;;) {
2266 +@@ -1796,14 +1804,14 @@ static long wb_writeback(struct bdi_writeback *wb,
2267 + * safe.
2268 + */
2269 + if (work->for_kupdate) {
2270 +- oldest_jif = jiffies -
2271 ++ dirtied_before = jiffies -
2272 + msecs_to_jiffies(dirty_expire_interval * 10);
2273 + } else if (work->for_background)
2274 +- oldest_jif = jiffies;
2275 ++ dirtied_before = jiffies;
2276 +
2277 + trace_writeback_start(wb, work);
2278 + if (list_empty(&wb->b_io))
2279 +- queue_io(wb, work);
2280 ++ queue_io(wb, work, dirtied_before);
2281 + if (work->sb)
2282 + progress = writeback_sb_inodes(work->sb, wb, work);
2283 + else
2284 +@@ -2176,11 +2184,12 @@ void __mark_inode_dirty(struct inode *inode, int flags)
2285 + inode->i_state |= flags;
2286 +
2287 + /*
2288 +- * If the inode is being synced, just update its dirty state.
2289 +- * The unlocker will place the inode on the appropriate
2290 +- * superblock list, based upon its state.
2291 ++ * If the inode is queued for writeback by flush worker, just
2292 ++ * update its dirty state. Once the flush worker is done with
2293 ++ * the inode it will place it on the appropriate superblock
2294 ++ * list, based upon its state.
2295 + */
2296 +- if (inode->i_state & I_SYNC)
2297 ++ if (inode->i_state & I_SYNC_QUEUED)
2298 + goto out_unlock_inode;
2299 +
2300 + /*
2301 +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
2302 +index 8de458d64134a..cfbf5474bccab 100644
2303 +--- a/fs/jbd2/transaction.c
2304 ++++ b/fs/jbd2/transaction.c
2305 +@@ -1896,6 +1896,9 @@ static void __jbd2_journal_temp_unlink_buffer(struct journal_head *jh)
2306 + */
2307 + static void __jbd2_journal_unfile_buffer(struct journal_head *jh)
2308 + {
2309 ++ J_ASSERT_JH(jh, jh->b_transaction != NULL);
2310 ++ J_ASSERT_JH(jh, jh->b_next_transaction == NULL);
2311 ++
2312 + __jbd2_journal_temp_unlink_buffer(jh);
2313 + jh->b_transaction = NULL;
2314 + jbd2_journal_put_journal_head(jh);
2315 +@@ -1987,6 +1990,7 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
2316 + {
2317 + struct buffer_head *head;
2318 + struct buffer_head *bh;
2319 ++ bool has_write_io_error = false;
2320 + int ret = 0;
2321 +
2322 + J_ASSERT(PageLocked(page));
2323 +@@ -2011,11 +2015,26 @@ int jbd2_journal_try_to_free_buffers(journal_t *journal,
2324 + jbd_unlock_bh_state(bh);
2325 + if (buffer_jbd(bh))
2326 + goto busy;
2327 ++
2328 ++ /*
2329 ++ * If we free a metadata buffer which has been failed to
2330 ++ * write out, the jbd2 checkpoint procedure will not detect
2331 ++ * this failure and may lead to filesystem inconsistency
2332 ++ * after cleanup journal tail.
2333 ++ */
2334 ++ if (buffer_write_io_error(bh)) {
2335 ++ pr_err("JBD2: Error while async write back metadata bh %llu.",
2336 ++ (unsigned long long)bh->b_blocknr);
2337 ++ has_write_io_error = true;
2338 ++ }
2339 + } while ((bh = bh->b_this_page) != head);
2340 +
2341 + ret = try_to_free_buffers(page);
2342 +
2343 + busy:
2344 ++ if (has_write_io_error)
2345 ++ jbd2_journal_abort(journal, -EIO);
2346 ++
2347 + return ret;
2348 + }
2349 +
2350 +@@ -2443,6 +2462,13 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh)
2351 +
2352 + was_dirty = test_clear_buffer_jbddirty(bh);
2353 + __jbd2_journal_temp_unlink_buffer(jh);
2354 ++
2355 ++ /*
2356 ++ * b_transaction must be set, otherwise the new b_transaction won't
2357 ++ * be holding jh reference
2358 ++ */
2359 ++ J_ASSERT_JH(jh, jh->b_transaction != NULL);
2360 ++
2361 + /*
2362 + * We set b_transaction here because b_next_transaction will inherit
2363 + * our jh reference and thus __jbd2_journal_file_buffer() must not
2364 +diff --git a/include/linux/efi.h b/include/linux/efi.h
2365 +index 02c4f16685b69..69605956beb85 100644
2366 +--- a/include/linux/efi.h
2367 ++++ b/include/linux/efi.h
2368 +@@ -910,7 +910,11 @@ extern void *efi_get_pal_addr (void);
2369 + extern void efi_map_pal_code (void);
2370 + extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
2371 + extern void efi_gettimeofday (struct timespec64 *ts);
2372 ++#ifdef CONFIG_EFI
2373 + extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
2374 ++#else
2375 ++static inline void efi_enter_virtual_mode (void) {}
2376 ++#endif
2377 + #ifdef CONFIG_X86
2378 + extern void efi_late_init(void);
2379 + extern void efi_free_boot_services(void);
2380 +diff --git a/include/linux/fs.h b/include/linux/fs.h
2381 +index 2d569738eb320..b8d65e0ab9341 100644
2382 +--- a/include/linux/fs.h
2383 ++++ b/include/linux/fs.h
2384 +@@ -1954,6 +1954,10 @@ static inline bool HAS_UNMAPPED_ID(struct inode *inode)
2385 + * wb stat updates to grab mapping->tree_lock. See
2386 + * inode_switch_wb_work_fn() for details.
2387 + *
2388 ++ * I_SYNC_QUEUED Inode is queued in b_io or b_more_io writeback lists.
2389 ++ * Used to detect that mark_inode_dirty() should not move
2390 ++ * inode between dirty lists.
2391 ++ *
2392 + * Q: What is the difference between I_WILL_FREE and I_FREEING?
2393 + */
2394 + #define I_DIRTY_SYNC (1 << 0)
2395 +@@ -1971,9 +1975,9 @@ static inline bool HAS_UNMAPPED_ID(struct inode *inode)
2396 + #define I_DIO_WAKEUP (1 << __I_DIO_WAKEUP)
2397 + #define I_LINKABLE (1 << 10)
2398 + #define I_DIRTY_TIME (1 << 11)
2399 +-#define __I_DIRTY_TIME_EXPIRED 12
2400 +-#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED)
2401 ++#define I_DIRTY_TIME_EXPIRED (1 << 12)
2402 + #define I_WB_SWITCH (1 << 13)
2403 ++#define I_SYNC_QUEUED (1 << 17)
2404 +
2405 + #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
2406 + #define I_DIRTY_ALL (I_DIRTY | I_DIRTY_TIME)
2407 +diff --git a/include/linux/overflow.h b/include/linux/overflow.h
2408 +index d309788f4cd24..40b48e2133cb8 100644
2409 +--- a/include/linux/overflow.h
2410 ++++ b/include/linux/overflow.h
2411 +@@ -233,4 +233,77 @@
2412 + (*_d >> _to_shift) != _a); \
2413 + })
2414 +
2415 ++/**
2416 ++ * array_size() - Calculate size of 2-dimensional array.
2417 ++ *
2418 ++ * @a: dimension one
2419 ++ * @b: dimension two
2420 ++ *
2421 ++ * Calculates size of 2-dimensional array: @a * @b.
2422 ++ *
2423 ++ * Returns: number of bytes needed to represent the array or SIZE_MAX on
2424 ++ * overflow.
2425 ++ */
2426 ++static inline __must_check size_t array_size(size_t a, size_t b)
2427 ++{
2428 ++ size_t bytes;
2429 ++
2430 ++ if (check_mul_overflow(a, b, &bytes))
2431 ++ return SIZE_MAX;
2432 ++
2433 ++ return bytes;
2434 ++}
2435 ++
2436 ++/**
2437 ++ * array3_size() - Calculate size of 3-dimensional array.
2438 ++ *
2439 ++ * @a: dimension one
2440 ++ * @b: dimension two
2441 ++ * @c: dimension three
2442 ++ *
2443 ++ * Calculates size of 3-dimensional array: @a * @b * @c.
2444 ++ *
2445 ++ * Returns: number of bytes needed to represent the array or SIZE_MAX on
2446 ++ * overflow.
2447 ++ */
2448 ++static inline __must_check size_t array3_size(size_t a, size_t b, size_t c)
2449 ++{
2450 ++ size_t bytes;
2451 ++
2452 ++ if (check_mul_overflow(a, b, &bytes))
2453 ++ return SIZE_MAX;
2454 ++ if (check_mul_overflow(bytes, c, &bytes))
2455 ++ return SIZE_MAX;
2456 ++
2457 ++ return bytes;
2458 ++}
2459 ++
2460 ++static inline __must_check size_t __ab_c_size(size_t n, size_t size, size_t c)
2461 ++{
2462 ++ size_t bytes;
2463 ++
2464 ++ if (check_mul_overflow(n, size, &bytes))
2465 ++ return SIZE_MAX;
2466 ++ if (check_add_overflow(bytes, c, &bytes))
2467 ++ return SIZE_MAX;
2468 ++
2469 ++ return bytes;
2470 ++}
2471 ++
2472 ++/**
2473 ++ * struct_size() - Calculate size of structure with trailing array.
2474 ++ * @p: Pointer to the structure.
2475 ++ * @member: Name of the array member.
2476 ++ * @n: Number of elements in the array.
2477 ++ *
2478 ++ * Calculates size of memory needed for structure @p followed by an
2479 ++ * array of @n @member elements.
2480 ++ *
2481 ++ * Return: number of bytes needed or SIZE_MAX on overflow.
2482 ++ */
2483 ++#define struct_size(p, member, n) \
2484 ++ __ab_c_size(n, \
2485 ++ sizeof(*(p)->member) + __must_be_array((p)->member),\
2486 ++ sizeof(*(p)))
2487 ++
2488 + #endif /* __LINUX_OVERFLOW_H */
2489 +diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
2490 +index 2ccd9ccbf9efe..ec964a924cd2f 100644
2491 +--- a/include/trace/events/writeback.h
2492 ++++ b/include/trace/events/writeback.h
2493 +@@ -360,8 +360,9 @@ DEFINE_WBC_EVENT(wbc_writepage);
2494 + TRACE_EVENT(writeback_queue_io,
2495 + TP_PROTO(struct bdi_writeback *wb,
2496 + struct wb_writeback_work *work,
2497 ++ unsigned long dirtied_before,
2498 + int moved),
2499 +- TP_ARGS(wb, work, moved),
2500 ++ TP_ARGS(wb, work, dirtied_before, moved),
2501 + TP_STRUCT__entry(
2502 + __array(char, name, 32)
2503 + __field(unsigned long, older)
2504 +@@ -371,19 +372,17 @@ TRACE_EVENT(writeback_queue_io,
2505 + __field(unsigned int, cgroup_ino)
2506 + ),
2507 + TP_fast_assign(
2508 +- unsigned long *older_than_this = work->older_than_this;
2509 + strncpy(__entry->name, dev_name(wb->bdi->dev), 32);
2510 +- __entry->older = older_than_this ? *older_than_this : 0;
2511 +- __entry->age = older_than_this ?
2512 +- (jiffies - *older_than_this) * 1000 / HZ : -1;
2513 ++ __entry->older = dirtied_before;
2514 ++ __entry->age = (jiffies - dirtied_before) * 1000 / HZ;
2515 + __entry->moved = moved;
2516 + __entry->reason = work->reason;
2517 + __entry->cgroup_ino = __trace_wb_assign_cgroup(wb);
2518 + ),
2519 + TP_printk("bdi %s: older=%lu age=%ld enqueue=%d reason=%s cgroup_ino=%u",
2520 + __entry->name,
2521 +- __entry->older, /* older_than_this in jiffies */
2522 +- __entry->age, /* older_than_this in relative milliseconds */
2523 ++ __entry->older, /* dirtied_before in jiffies */
2524 ++ __entry->age, /* dirtied_before in relative milliseconds */
2525 + __entry->moved,
2526 + __print_symbolic(__entry->reason, WB_WORK_REASON),
2527 + __entry->cgroup_ino
2528 +diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
2529 +index 75d80809c48c9..09bad6cbb95cf 100644
2530 +--- a/kernel/locking/lockdep_proc.c
2531 ++++ b/kernel/locking/lockdep_proc.c
2532 +@@ -425,7 +425,7 @@ static void seq_lock_time(struct seq_file *m, struct lock_time *lt)
2533 + seq_time(m, lt->min);
2534 + seq_time(m, lt->max);
2535 + seq_time(m, lt->total);
2536 +- seq_time(m, lt->nr ? div_s64(lt->total, lt->nr) : 0);
2537 ++ seq_time(m, lt->nr ? div64_u64(lt->total, lt->nr) : 0);
2538 + }
2539 +
2540 + static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
2541 +diff --git a/net/core/skbuff.c b/net/core/skbuff.c
2542 +index 7164569c1ec80..e72775024c6af 100644
2543 +--- a/net/core/skbuff.c
2544 ++++ b/net/core/skbuff.c
2545 +@@ -4591,8 +4591,8 @@ struct sk_buff *skb_vlan_untag(struct sk_buff *skb)
2546 + skb = skb_share_check(skb, GFP_ATOMIC);
2547 + if (unlikely(!skb))
2548 + goto err_free;
2549 +-
2550 +- if (unlikely(!pskb_may_pull(skb, VLAN_HLEN)))
2551 ++ /* We may access the two bytes after vlan_hdr in vlan_set_encap_proto(). */
2552 ++ if (unlikely(!pskb_may_pull(skb, VLAN_HLEN + sizeof(unsigned short))))
2553 + goto err_free;
2554 +
2555 + vhdr = (struct vlan_hdr *)skb->data;
2556 +diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
2557 +index ed795d50a8d2b..d9e60aa2ea1b2 100644
2558 +--- a/net/ipv6/ip6_tunnel.c
2559 ++++ b/net/ipv6/ip6_tunnel.c
2560 +@@ -871,7 +871,15 @@ int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,
2561 + struct metadata_dst *tun_dst,
2562 + bool log_ecn_err)
2563 + {
2564 +- return __ip6_tnl_rcv(t, skb, tpi, NULL, ip6ip6_dscp_ecn_decapsulate,
2565 ++ int (*dscp_ecn_decapsulate)(const struct ip6_tnl *t,
2566 ++ const struct ipv6hdr *ipv6h,
2567 ++ struct sk_buff *skb);
2568 ++
2569 ++ dscp_ecn_decapsulate = ip6ip6_dscp_ecn_decapsulate;
2570 ++ if (tpi->proto == htons(ETH_P_IP))
2571 ++ dscp_ecn_decapsulate = ip4ip6_dscp_ecn_decapsulate;
2572 ++
2573 ++ return __ip6_tnl_rcv(t, skb, tpi, NULL, dscp_ecn_decapsulate,
2574 + log_ecn_err);
2575 + }
2576 + EXPORT_SYMBOL(ip6_tnl_rcv);
2577 +diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
2578 +index cdc49e680be4b..403be9bfd8d16 100644
2579 +--- a/net/tipc/netlink_compat.c
2580 ++++ b/net/tipc/netlink_compat.c
2581 +@@ -250,8 +250,9 @@ err_out:
2582 + static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
2583 + struct tipc_nl_compat_msg *msg)
2584 + {
2585 +- int err;
2586 ++ struct nlmsghdr *nlh;
2587 + struct sk_buff *arg;
2588 ++ int err;
2589 +
2590 + if (msg->req_type && (!msg->req_size ||
2591 + !TLV_CHECK_TYPE(msg->req, msg->req_type)))
2592 +@@ -280,6 +281,15 @@ static int tipc_nl_compat_dumpit(struct tipc_nl_compat_cmd_dump *cmd,
2593 + return -ENOMEM;
2594 + }
2595 +
2596 ++ nlh = nlmsg_put(arg, 0, 0, tipc_genl_family.id, 0, NLM_F_MULTI);
2597 ++ if (!nlh) {
2598 ++ kfree_skb(arg);
2599 ++ kfree_skb(msg->rep);
2600 ++ msg->rep = NULL;
2601 ++ return -EMSGSIZE;
2602 ++ }
2603 ++ nlmsg_end(arg, nlh);
2604 ++
2605 + err = __tipc_nl_compat_dumpit(cmd, msg, arg);
2606 + if (err) {
2607 + kfree_skb(msg->rep);
2608 +diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c
2609 +index 528102cc2d5d0..d824ff4ae3e3b 100644
2610 +--- a/sound/pci/cs46xx/cs46xx_lib.c
2611 ++++ b/sound/pci/cs46xx/cs46xx_lib.c
2612 +@@ -780,7 +780,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned
2613 + rate = 48000 / 9;
2614 +
2615 + /*
2616 +- * We can not capture at at rate greater than the Input Rate (48000).
2617 ++ * We can not capture at a rate greater than the Input Rate (48000).
2618 + * Return an error if an attempt is made to stray outside that limit.
2619 + */
2620 + if (rate > 48000)
2621 +diff --git a/sound/pci/cs46xx/dsp_spos_scb_lib.c b/sound/pci/cs46xx/dsp_spos_scb_lib.c
2622 +index 7488e1b7a7707..4e726d39b05d1 100644
2623 +--- a/sound/pci/cs46xx/dsp_spos_scb_lib.c
2624 ++++ b/sound/pci/cs46xx/dsp_spos_scb_lib.c
2625 +@@ -1742,7 +1742,7 @@ int cs46xx_iec958_pre_open (struct snd_cs46xx *chip)
2626 + struct dsp_spos_instance * ins = chip->dsp_spos_instance;
2627 +
2628 + if ( ins->spdif_status_out & DSP_SPDIF_STATUS_OUTPUT_ENABLED ) {
2629 +- /* remove AsynchFGTxSCB and and PCMSerialInput_II */
2630 ++ /* remove AsynchFGTxSCB and PCMSerialInput_II */
2631 + cs46xx_dsp_disable_spdif_out (chip);
2632 +
2633 + /* save state */
2634 +diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
2635 +index cbe0248225c1c..4e67614f15f8e 100644
2636 +--- a/sound/pci/hda/hda_codec.c
2637 ++++ b/sound/pci/hda/hda_codec.c
2638 +@@ -3496,7 +3496,7 @@ EXPORT_SYMBOL_GPL(snd_hda_set_power_save);
2639 + * @nid: NID to check / update
2640 + *
2641 + * Check whether the given NID is in the amp list. If it's in the list,
2642 +- * check the current AMP status, and update the the power-status according
2643 ++ * check the current AMP status, and update the power-status according
2644 + * to the mute status.
2645 + *
2646 + * This function is supposed to be set or called from the check_power_status
2647 +diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
2648 +index 949c90a859fab..184089c5e8cbc 100644
2649 +--- a/sound/pci/hda/hda_generic.c
2650 ++++ b/sound/pci/hda/hda_generic.c
2651 +@@ -820,7 +820,7 @@ static void activate_amp_in(struct hda_codec *codec, struct nid_path *path,
2652 + }
2653 + }
2654 +
2655 +-/* sync power of each widget in the the given path */
2656 ++/* sync power of each widget in the given path */
2657 + static hda_nid_t path_power_update(struct hda_codec *codec,
2658 + struct nid_path *path,
2659 + bool allow_powerdown)
2660 +diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
2661 +index d1a6d20ace0da..80b72d0702c5e 100644
2662 +--- a/sound/pci/hda/patch_sigmatel.c
2663 ++++ b/sound/pci/hda/patch_sigmatel.c
2664 +@@ -862,7 +862,7 @@ static int stac_auto_create_beep_ctls(struct hda_codec *codec,
2665 + static struct snd_kcontrol_new beep_vol_ctl =
2666 + HDA_CODEC_VOLUME(NULL, 0, 0, 0);
2667 +
2668 +- /* check for mute support for the the amp */
2669 ++ /* check for mute support for the amp */
2670 + if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
2671 + const struct snd_kcontrol_new *temp;
2672 + if (spec->anabeep_nid == nid)
2673 +diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
2674 +index 3919aed39ca03..5e52086d7b986 100644
2675 +--- a/sound/pci/ice1712/prodigy192.c
2676 ++++ b/sound/pci/ice1712/prodigy192.c
2677 +@@ -31,7 +31,7 @@
2678 + * Experimentally I found out that only a combination of
2679 + * OCKS0=1, OCKS1=1 (128fs, 64fs output) and ice1724 -
2680 + * VT1724_MT_I2S_MCLK_128X=0 (256fs input) yields correct
2681 +- * sampling rate. That means the the FPGA doubles the
2682 ++ * sampling rate. That means that the FPGA doubles the
2683 + * MCK01 rate.
2684 + *
2685 + * Copyright (c) 2003 Takashi Iwai <tiwai@××××.de>
2686 +diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
2687 +index 4cf3200e988b0..df44135e1b0c9 100644
2688 +--- a/sound/pci/oxygen/xonar_dg.c
2689 ++++ b/sound/pci/oxygen/xonar_dg.c
2690 +@@ -39,7 +39,7 @@
2691 + * GPIO 4 <- headphone detect
2692 + * GPIO 5 -> enable ADC analog circuit for the left channel
2693 + * GPIO 6 -> enable ADC analog circuit for the right channel
2694 +- * GPIO 7 -> switch green rear output jack between CS4245 and and the first
2695 ++ * GPIO 7 -> switch green rear output jack between CS4245 and the first
2696 + * channel of CS4361 (mechanical relay)
2697 + * GPIO 8 -> enable output to speakers
2698 + *
2699 +diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c
2700 +index fef3b9a21a667..e441e23a37e4f 100644
2701 +--- a/sound/soc/tegra/tegra30_ahub.c
2702 ++++ b/sound/soc/tegra/tegra30_ahub.c
2703 +@@ -656,8 +656,10 @@ static int tegra30_ahub_resume(struct device *dev)
2704 + int ret;
2705 +
2706 + ret = pm_runtime_get_sync(dev);
2707 +- if (ret < 0)
2708 ++ if (ret < 0) {
2709 ++ pm_runtime_put(dev);
2710 + return ret;
2711 ++ }
2712 + ret = regcache_sync(ahub->regmap_ahub);
2713 + ret |= regcache_sync(ahub->regmap_apbif);
2714 + pm_runtime_put(dev);
2715 +diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c
2716 +index 8e55583aa104e..516f37896092c 100644
2717 +--- a/sound/soc/tegra/tegra30_i2s.c
2718 ++++ b/sound/soc/tegra/tegra30_i2s.c
2719 +@@ -552,8 +552,10 @@ static int tegra30_i2s_resume(struct device *dev)
2720 + int ret;
2721 +
2722 + ret = pm_runtime_get_sync(dev);
2723 +- if (ret < 0)
2724 ++ if (ret < 0) {
2725 ++ pm_runtime_put(dev);
2726 + return ret;
2727 ++ }
2728 + ret = regcache_sync(i2s->regmap);
2729 + pm_runtime_put(dev);
2730 +
2731 +diff --git a/sound/usb/quirks-table.h b/sound/usb/quirks-table.h
2732 +index 689fd3103e5b6..a917b7e02d312 100644
2733 +--- a/sound/usb/quirks-table.h
2734 ++++ b/sound/usb/quirks-table.h
2735 +@@ -3331,8 +3331,8 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
2736 + * they pretend to be 96kHz mono as a workaround for stereo being broken
2737 + * by that...
2738 + *
2739 +- * They also have swapped L-R channels, but that's for userspace to deal
2740 +- * with.
2741 ++ * They also have an issue with initial stream alignment that causes the
2742 ++ * channels to be swapped and out of phase, which is dealt with in quirks.c.
2743 + */
2744 + {
2745 + .match_flags = USB_DEVICE_ID_MATCH_DEVICE |
2746 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
2747 +index 94110b1dcd3d8..031baa43646fb 100644
2748 +--- a/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
2749 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/back_to_back_ebbs_test.c
2750 +@@ -91,8 +91,6 @@ int back_to_back_ebbs(void)
2751 + ebb_global_disable();
2752 + ebb_freeze_pmcs();
2753 +
2754 +- count_pmc(1, sample_period);
2755 +-
2756 + dump_ebb_state();
2757 +
2758 + event_close(&event);
2759 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
2760 +index 7c57a8d79535d..361e0be9df9ae 100644
2761 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
2762 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_test.c
2763 +@@ -42,8 +42,6 @@ int cycles(void)
2764 + ebb_global_disable();
2765 + ebb_freeze_pmcs();
2766 +
2767 +- count_pmc(1, sample_period);
2768 +-
2769 + dump_ebb_state();
2770 +
2771 + event_close(&event);
2772 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
2773 +index ecf5ee3283a3e..fe7d0dc2a1a26 100644
2774 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
2775 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_freeze_test.c
2776 +@@ -99,8 +99,6 @@ int cycles_with_freeze(void)
2777 + ebb_global_disable();
2778 + ebb_freeze_pmcs();
2779 +
2780 +- count_pmc(1, sample_period);
2781 +-
2782 + dump_ebb_state();
2783 +
2784 + printf("EBBs while frozen %d\n", ebbs_while_frozen);
2785 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
2786 +index c0faba520b35c..b9b30f974b5ea 100644
2787 +--- a/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
2788 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/cycles_with_mmcr2_test.c
2789 +@@ -71,8 +71,6 @@ int cycles_with_mmcr2(void)
2790 + ebb_global_disable();
2791 + ebb_freeze_pmcs();
2792 +
2793 +- count_pmc(1, sample_period);
2794 +-
2795 + dump_ebb_state();
2796 +
2797 + event_close(&event);
2798 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
2799 +index 46681fec549b8..2694ae161a84a 100644
2800 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
2801 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb.c
2802 +@@ -396,8 +396,6 @@ int ebb_child(union pipe read_pipe, union pipe write_pipe)
2803 + ebb_global_disable();
2804 + ebb_freeze_pmcs();
2805 +
2806 +- count_pmc(1, sample_period);
2807 +-
2808 + dump_ebb_state();
2809 +
2810 + event_close(&event);
2811 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
2812 +index a991d2ea8d0a1..174e4f4dae6c0 100644
2813 +--- a/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
2814 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/ebb_on_willing_child_test.c
2815 +@@ -38,8 +38,6 @@ static int victim_child(union pipe read_pipe, union pipe write_pipe)
2816 + ebb_global_disable();
2817 + ebb_freeze_pmcs();
2818 +
2819 +- count_pmc(1, sample_period);
2820 +-
2821 + dump_ebb_state();
2822 +
2823 + FAIL_IF(ebb_state.stats.ebb_count == 0);
2824 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
2825 +index eb8acb78bc6c1..531083accfcad 100644
2826 +--- a/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
2827 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/lost_exception_test.c
2828 +@@ -75,7 +75,6 @@ static int test_body(void)
2829 + ebb_freeze_pmcs();
2830 + ebb_global_disable();
2831 +
2832 +- count_pmc(4, sample_period);
2833 + mtspr(SPRN_PMC4, 0xdead);
2834 +
2835 + dump_summary_ebb_state();
2836 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
2837 +index 6ff8c8ff27d66..035c02273cd49 100644
2838 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
2839 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_counter_test.c
2840 +@@ -70,13 +70,6 @@ int multi_counter(void)
2841 + ebb_global_disable();
2842 + ebb_freeze_pmcs();
2843 +
2844 +- count_pmc(1, sample_period);
2845 +- count_pmc(2, sample_period);
2846 +- count_pmc(3, sample_period);
2847 +- count_pmc(4, sample_period);
2848 +- count_pmc(5, sample_period);
2849 +- count_pmc(6, sample_period);
2850 +-
2851 + dump_ebb_state();
2852 +
2853 + for (i = 0; i < 6; i++)
2854 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
2855 +index 037cb6154f360..3e9d4ac965c85 100644
2856 +--- a/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
2857 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/multi_ebb_procs_test.c
2858 +@@ -61,8 +61,6 @@ static int cycles_child(void)
2859 + ebb_global_disable();
2860 + ebb_freeze_pmcs();
2861 +
2862 +- count_pmc(1, sample_period);
2863 +-
2864 + dump_summary_ebb_state();
2865 +
2866 + event_close(&event);
2867 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
2868 +index c5fa64790c22e..d90891fe96a32 100644
2869 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
2870 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmae_handling_test.c
2871 +@@ -82,8 +82,6 @@ static int test_body(void)
2872 + ebb_global_disable();
2873 + ebb_freeze_pmcs();
2874 +
2875 +- count_pmc(1, sample_period);
2876 +-
2877 + dump_ebb_state();
2878 +
2879 + if (mmcr0_mismatch)
2880 +diff --git a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
2881 +index 30e1ac62e8cb4..8ca92b9ee5b01 100644
2882 +--- a/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
2883 ++++ b/tools/testing/selftests/powerpc/pmu/ebb/pmc56_overflow_test.c
2884 +@@ -76,8 +76,6 @@ int pmc56_overflow(void)
2885 + ebb_global_disable();
2886 + ebb_freeze_pmcs();
2887 +
2888 +- count_pmc(2, sample_period);
2889 +-
2890 + dump_ebb_state();
2891 +
2892 + printf("PMC5/6 overflow %d\n", pmc56_overflowed);