Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0346-4.9.247-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3648 - (show annotations) (download)
Mon Oct 24 14:07:28 2022 UTC (18 months, 3 weeks ago) by niro
File size: 56626 byte(s)
-linux-4.9.247
1 diff --git a/Makefile b/Makefile
2 index b9e2a97da5da7..82f71f9460cb6 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 246
9 +SUBLEVEL = 247
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
14 index 199f434f99a49..60e92da7bf37b 100644
15 --- a/arch/arm64/include/asm/pgtable.h
16 +++ b/arch/arm64/include/asm/pgtable.h
17 @@ -85,8 +85,6 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
18 #define pte_valid(pte) (!!(pte_val(pte) & PTE_VALID))
19 #define pte_valid_not_user(pte) \
20 ((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
21 -#define pte_valid_young(pte) \
22 - ((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
23 #define pte_valid_user(pte) \
24 ((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
25
26 @@ -94,9 +92,12 @@ extern unsigned long empty_zero_page[PAGE_SIZE / sizeof(unsigned long)];
27 * Could the pte be present in the TLB? We must check mm_tlb_flush_pending
28 * so that we don't erroneously return false for pages that have been
29 * remapped as PROT_NONE but are yet to be flushed from the TLB.
30 + * Note that we can't make any assumptions based on the state of the access
31 + * flag, since ptep_clear_flush_young() elides a DSB when invalidating the
32 + * TLB.
33 */
34 #define pte_accessible(mm, pte) \
35 - (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte))
36 + (mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid(pte))
37
38 /*
39 * p??_access_permitted() is true for valid user mappings (subject to the
40 diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c
41 index 72d09340c24d2..88ba013d08d49 100644
42 --- a/arch/x86/events/intel/cstate.c
43 +++ b/arch/x86/events/intel/cstate.c
44 @@ -98,14 +98,14 @@
45 MODULE_LICENSE("GPL");
46
47 #define DEFINE_CSTATE_FORMAT_ATTR(_var, _name, _format) \
48 -static ssize_t __cstate_##_var##_show(struct kobject *kobj, \
49 - struct kobj_attribute *attr, \
50 +static ssize_t __cstate_##_var##_show(struct device *dev, \
51 + struct device_attribute *attr, \
52 char *page) \
53 { \
54 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
55 return sprintf(page, _format "\n"); \
56 } \
57 -static struct kobj_attribute format_attr_##_var = \
58 +static struct device_attribute format_attr_##_var = \
59 __ATTR(_name, 0444, __cstate_##_var##_show, NULL)
60
61 static ssize_t cstate_get_attr_cpumask(struct device *dev,
62 diff --git a/arch/x86/events/intel/rapl.c b/arch/x86/events/intel/rapl.c
63 index 4c1b7ea185415..38dae3d1391b5 100644
64 --- a/arch/x86/events/intel/rapl.c
65 +++ b/arch/x86/events/intel/rapl.c
66 @@ -115,18 +115,6 @@ static const char *const rapl_domain_names[NR_RAPL_DOMAINS] __initconst = {
67 * any other bit is reserved
68 */
69 #define RAPL_EVENT_MASK 0xFFULL
70 -
71 -#define DEFINE_RAPL_FORMAT_ATTR(_var, _name, _format) \
72 -static ssize_t __rapl_##_var##_show(struct kobject *kobj, \
73 - struct kobj_attribute *attr, \
74 - char *page) \
75 -{ \
76 - BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
77 - return sprintf(page, _format "\n"); \
78 -} \
79 -static struct kobj_attribute format_attr_##_var = \
80 - __ATTR(_name, 0444, __rapl_##_var##_show, NULL)
81 -
82 #define RAPL_CNTR_WIDTH 32
83
84 #define RAPL_EVENT_ATTR_STR(_name, v, str) \
85 @@ -548,7 +536,7 @@ static struct attribute_group rapl_pmu_events_group = {
86 .attrs = NULL, /* patched at runtime */
87 };
88
89 -DEFINE_RAPL_FORMAT_ATTR(event, event, "config:0-7");
90 +PMU_FORMAT_ATTR(event, "config:0-7");
91 static struct attribute *rapl_formats_attr[] = {
92 &format_attr_event.attr,
93 NULL,
94 diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c
95 index 4f365267b12fe..9f572bf6c6216 100644
96 --- a/arch/x86/events/intel/uncore.c
97 +++ b/arch/x86/events/intel/uncore.c
98 @@ -90,8 +90,8 @@ end:
99 return map;
100 }
101
102 -ssize_t uncore_event_show(struct kobject *kobj,
103 - struct kobj_attribute *attr, char *buf)
104 +ssize_t uncore_event_show(struct device *dev,
105 + struct device_attribute *attr, char *buf)
106 {
107 struct uncore_event_desc *event =
108 container_of(attr, struct uncore_event_desc, attr);
109 diff --git a/arch/x86/events/intel/uncore.h b/arch/x86/events/intel/uncore.h
110 index ad986c1e29bcc..f699783114ee3 100644
111 --- a/arch/x86/events/intel/uncore.h
112 +++ b/arch/x86/events/intel/uncore.h
113 @@ -124,7 +124,7 @@ struct intel_uncore_box {
114 #define UNCORE_BOX_FLAG_CTL_OFFS8 1 /* event config registers are 8-byte apart */
115
116 struct uncore_event_desc {
117 - struct kobj_attribute attr;
118 + struct device_attribute attr;
119 const char *config;
120 };
121
122 @@ -136,8 +136,8 @@ struct pci2phy_map {
123
124 struct pci2phy_map *__find_pci2phy_map(int segment);
125
126 -ssize_t uncore_event_show(struct kobject *kobj,
127 - struct kobj_attribute *attr, char *buf);
128 +ssize_t uncore_event_show(struct device *dev,
129 + struct device_attribute *attr, char *buf);
130
131 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
132 { \
133 @@ -146,14 +146,14 @@ ssize_t uncore_event_show(struct kobject *kobj,
134 }
135
136 #define DEFINE_UNCORE_FORMAT_ATTR(_var, _name, _format) \
137 -static ssize_t __uncore_##_var##_show(struct kobject *kobj, \
138 - struct kobj_attribute *attr, \
139 +static ssize_t __uncore_##_var##_show(struct device *dev, \
140 + struct device_attribute *attr, \
141 char *page) \
142 { \
143 BUILD_BUG_ON(sizeof(_format) >= PAGE_SIZE); \
144 return sprintf(page, _format "\n"); \
145 } \
146 -static struct kobj_attribute format_attr_##_var = \
147 +static struct device_attribute format_attr_##_var = \
148 __ATTR(_name, 0444, __uncore_##_var##_show, NULL)
149
150 static inline unsigned uncore_pci_box_ctl(struct intel_uncore_box *box)
151 diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
152 index f8a7aba4b0959..a884bb7e7b01d 100644
153 --- a/arch/x86/kernel/cpu/bugs.c
154 +++ b/arch/x86/kernel/cpu/bugs.c
155 @@ -732,11 +732,13 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)
156 if (boot_cpu_has(X86_FEATURE_IBPB)) {
157 setup_force_cpu_cap(X86_FEATURE_USE_IBPB);
158
159 + spectre_v2_user_ibpb = mode;
160 switch (cmd) {
161 case SPECTRE_V2_USER_CMD_FORCE:
162 case SPECTRE_V2_USER_CMD_PRCTL_IBPB:
163 case SPECTRE_V2_USER_CMD_SECCOMP_IBPB:
164 static_branch_enable(&switch_mm_always_ibpb);
165 + spectre_v2_user_ibpb = SPECTRE_V2_USER_STRICT;
166 break;
167 case SPECTRE_V2_USER_CMD_PRCTL:
168 case SPECTRE_V2_USER_CMD_AUTO:
169 @@ -750,8 +752,6 @@ spectre_v2_user_select_mitigation(enum spectre_v2_mitigation_cmd v2_cmd)
170 pr_info("mitigation: Enabling %s Indirect Branch Prediction Barrier\n",
171 static_key_enabled(&switch_mm_always_ibpb) ?
172 "always-on" : "conditional");
173 -
174 - spectre_v2_user_ibpb = mode;
175 }
176
177 /*
178 diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
179 index 8d2c6f071dccf..44bf8a22c97b8 100644
180 --- a/arch/x86/xen/spinlock.c
181 +++ b/arch/x86/xen/spinlock.c
182 @@ -98,10 +98,20 @@ void xen_init_lock_cpu(int cpu)
183
184 void xen_uninit_lock_cpu(int cpu)
185 {
186 + int irq;
187 +
188 if (!xen_pvspin)
189 return;
190
191 - unbind_from_irqhandler(per_cpu(lock_kicker_irq, cpu), NULL);
192 + /*
193 + * When booting the kernel with 'mitigations=auto,nosmt', the secondary
194 + * CPUs are not activated, and lock_kicker_irq is not initialized.
195 + */
196 + irq = per_cpu(lock_kicker_irq, cpu);
197 + if (irq == -1)
198 + return;
199 +
200 + unbind_from_irqhandler(irq, NULL);
201 per_cpu(lock_kicker_irq, cpu) = -1;
202 kfree(per_cpu(irq_name, cpu));
203 per_cpu(irq_name, cpu) = NULL;
204 diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
205 index 16c08846ea0e1..f5a9bb1231882 100644
206 --- a/drivers/dma/pl330.c
207 +++ b/drivers/dma/pl330.c
208 @@ -2682,7 +2682,7 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
209 * If burst size is smaller than bus width then make sure we only
210 * transfer one at a time to avoid a burst stradling an MFIFO entry.
211 */
212 - if (desc->rqcfg.brst_size * 8 < pl330->pcfg.data_bus_width)
213 + if (burst * 8 < pl330->pcfg.data_bus_width)
214 desc->rqcfg.brst_len = 1;
215
216 desc->bytes_requested = len;
217 diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
218 index cd271f7826051..ef99ef0bb1ca2 100644
219 --- a/drivers/dma/xilinx/xilinx_dma.c
220 +++ b/drivers/dma/xilinx/xilinx_dma.c
221 @@ -420,8 +420,8 @@ struct xilinx_dma_device {
222 #define to_dma_tx_descriptor(tx) \
223 container_of(tx, struct xilinx_dma_tx_descriptor, async_tx)
224 #define xilinx_dma_poll_timeout(chan, reg, val, cond, delay_us, timeout_us) \
225 - readl_poll_timeout(chan->xdev->regs + chan->ctrl_offset + reg, val, \
226 - cond, delay_us, timeout_us)
227 + readl_poll_timeout_atomic(chan->xdev->regs + chan->ctrl_offset + reg, \
228 + val, cond, delay_us, timeout_us)
229
230 /* IO accessors */
231 static inline u32 dma_read(struct xilinx_dma_chan *chan, u32 reg)
232 diff --git a/drivers/hid/hid-cypress.c b/drivers/hid/hid-cypress.c
233 index 1689568b597d4..12c5d7c96527a 100644
234 --- a/drivers/hid/hid-cypress.c
235 +++ b/drivers/hid/hid-cypress.c
236 @@ -26,19 +26,17 @@
237 #define CP_2WHEEL_MOUSE_HACK 0x02
238 #define CP_2WHEEL_MOUSE_HACK_ON 0x04
239
240 +#define VA_INVAL_LOGICAL_BOUNDARY 0x08
241 +
242 /*
243 * Some USB barcode readers from cypress have usage min and usage max in
244 * the wrong order
245 */
246 -static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
247 +static __u8 *cp_rdesc_fixup(struct hid_device *hdev, __u8 *rdesc,
248 unsigned int *rsize)
249 {
250 - unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
251 unsigned int i;
252
253 - if (!(quirks & CP_RDESC_SWAPPED_MIN_MAX))
254 - return rdesc;
255 -
256 if (*rsize < 4)
257 return rdesc;
258
259 @@ -51,6 +49,40 @@ static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
260 return rdesc;
261 }
262
263 +static __u8 *va_logical_boundary_fixup(struct hid_device *hdev, __u8 *rdesc,
264 + unsigned int *rsize)
265 +{
266 + /*
267 + * Varmilo VA104M (with VID Cypress and device ID 07B1) incorrectly
268 + * reports Logical Minimum of its Consumer Control device as 572
269 + * (0x02 0x3c). Fix this by setting its Logical Minimum to zero.
270 + */
271 + if (*rsize == 25 &&
272 + rdesc[0] == 0x05 && rdesc[1] == 0x0c &&
273 + rdesc[2] == 0x09 && rdesc[3] == 0x01 &&
274 + rdesc[6] == 0x19 && rdesc[7] == 0x00 &&
275 + rdesc[11] == 0x16 && rdesc[12] == 0x3c && rdesc[13] == 0x02) {
276 + hid_info(hdev,
277 + "fixing up varmilo VA104M consumer control report descriptor\n");
278 + rdesc[12] = 0x00;
279 + rdesc[13] = 0x00;
280 + }
281 + return rdesc;
282 +}
283 +
284 +static __u8 *cp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
285 + unsigned int *rsize)
286 +{
287 + unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
288 +
289 + if (quirks & CP_RDESC_SWAPPED_MIN_MAX)
290 + rdesc = cp_rdesc_fixup(hdev, rdesc, rsize);
291 + if (quirks & VA_INVAL_LOGICAL_BOUNDARY)
292 + rdesc = va_logical_boundary_fixup(hdev, rdesc, rsize);
293 +
294 + return rdesc;
295 +}
296 +
297 static int cp_input_mapped(struct hid_device *hdev, struct hid_input *hi,
298 struct hid_field *field, struct hid_usage *usage,
299 unsigned long **bit, int *max)
300 @@ -131,6 +163,8 @@ static const struct hid_device_id cp_devices[] = {
301 .driver_data = CP_RDESC_SWAPPED_MIN_MAX },
302 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE),
303 .driver_data = CP_2WHEEL_MOUSE_HACK },
304 + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_VARMILO_VA104M_07B1),
305 + .driver_data = VA_INVAL_LOGICAL_BOUNDARY },
306 { }
307 };
308 MODULE_DEVICE_TABLE(hid, cp_devices);
309 diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
310 index 4630b58634d87..c4a53fc648e95 100644
311 --- a/drivers/hid/hid-ids.h
312 +++ b/drivers/hid/hid-ids.h
313 @@ -307,6 +307,8 @@
314 #define USB_DEVICE_ID_CYPRESS_BARCODE_4 0xed81
315 #define USB_DEVICE_ID_CYPRESS_TRUETOUCH 0xc001
316
317 +#define USB_DEVICE_ID_CYPRESS_VARMILO_VA104M_07B1 0X07b1
318 +
319 #define USB_VENDOR_ID_DATA_MODUL 0x7374
320 #define USB_VENDOR_ID_DATA_MODUL_EASYMAXTOUCH 0x1201
321
322 diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
323 index 4ef73374a8f98..7001f07ca3996 100644
324 --- a/drivers/hid/hid-sensor-hub.c
325 +++ b/drivers/hid/hid-sensor-hub.c
326 @@ -489,7 +489,8 @@ static int sensor_hub_raw_event(struct hid_device *hdev,
327 return 1;
328
329 ptr = raw_data;
330 - ptr++; /* Skip report id */
331 + if (report->id)
332 + ptr++; /* Skip report id */
333
334 spin_lock_irqsave(&pdata->lock, flags);
335
336 diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
337 index a6531ffe29a6f..a5694dec3f2ee 100644
338 --- a/drivers/infiniband/hw/mthca/mthca_cq.c
339 +++ b/drivers/infiniband/hw/mthca/mthca_cq.c
340 @@ -808,8 +808,10 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
341 }
342
343 mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
344 - if (IS_ERR(mailbox))
345 + if (IS_ERR(mailbox)) {
346 + err = PTR_ERR(mailbox);
347 goto err_out_arm;
348 + }
349
350 cq_context = mailbox->buf;
351
352 @@ -851,9 +853,9 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
353 }
354
355 spin_lock_irq(&dev->cq_table.lock);
356 - if (mthca_array_set(&dev->cq_table.cq,
357 - cq->cqn & (dev->limits.num_cqs - 1),
358 - cq)) {
359 + err = mthca_array_set(&dev->cq_table.cq,
360 + cq->cqn & (dev->limits.num_cqs - 1), cq);
361 + if (err) {
362 spin_unlock_irq(&dev->cq_table.lock);
363 goto err_out_free_mr;
364 }
365 diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
366 index c84c685056b99..6b648339733fa 100644
367 --- a/drivers/input/serio/i8042.c
368 +++ b/drivers/input/serio/i8042.c
369 @@ -125,6 +125,7 @@ module_param_named(unmask_kbd_data, i8042_unmask_kbd_data, bool, 0600);
370 MODULE_PARM_DESC(unmask_kbd_data, "Unconditional enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-condition: i8042.debug=1 enabled]");
371 #endif
372
373 +static bool i8042_present;
374 static bool i8042_bypass_aux_irq_test;
375 static char i8042_kbd_firmware_id[128];
376 static char i8042_aux_firmware_id[128];
377 @@ -343,6 +344,9 @@ int i8042_command(unsigned char *param, int command)
378 unsigned long flags;
379 int retval;
380
381 + if (!i8042_present)
382 + return -1;
383 +
384 spin_lock_irqsave(&i8042_lock, flags);
385 retval = __i8042_command(param, command);
386 spin_unlock_irqrestore(&i8042_lock, flags);
387 @@ -1597,12 +1601,15 @@ static int __init i8042_init(void)
388
389 err = i8042_platform_init();
390 if (err)
391 - return err;
392 + return (err == -ENODEV) ? 0 : err;
393
394 err = i8042_controller_check();
395 if (err)
396 goto err_platform_exit;
397
398 + /* Set this before creating the dev to allow i8042_command to work right away */
399 + i8042_present = true;
400 +
401 pdev = platform_create_bundle(&i8042_driver, i8042_probe, NULL, 0, NULL, 0);
402 if (IS_ERR(pdev)) {
403 err = PTR_ERR(pdev);
404 @@ -1621,6 +1628,9 @@ static int __init i8042_init(void)
405
406 static void __exit i8042_exit(void)
407 {
408 + if (!i8042_present)
409 + return;
410 +
411 platform_device_unregister(i8042_platform_device);
412 platform_driver_unregister(&i8042_driver);
413 i8042_platform_exit();
414 diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
415 index a65203e6ea5f4..d21c68882e867 100644
416 --- a/drivers/net/can/usb/gs_usb.c
417 +++ b/drivers/net/can/usb/gs_usb.c
418 @@ -71,21 +71,27 @@ enum gs_can_identify_mode {
419 };
420
421 /* data types passed between host and device */
422 +
423 +/* The firmware on the original USB2CAN by Geschwister Schneider
424 + * Technologie Entwicklungs- und Vertriebs UG exchanges all data
425 + * between the host and the device in host byte order. This is done
426 + * with the struct gs_host_config::byte_order member, which is sent
427 + * first to indicate the desired byte order.
428 + *
429 + * The widely used open source firmware candleLight doesn't support
430 + * this feature and exchanges the data in little endian byte order.
431 + */
432 struct gs_host_config {
433 - u32 byte_order;
434 + __le32 byte_order;
435 } __packed;
436 -/* All data exchanged between host and device is exchanged in host byte order,
437 - * thanks to the struct gs_host_config byte_order member, which is sent first
438 - * to indicate the desired byte order.
439 - */
440
441 struct gs_device_config {
442 u8 reserved1;
443 u8 reserved2;
444 u8 reserved3;
445 u8 icount;
446 - u32 sw_version;
447 - u32 hw_version;
448 + __le32 sw_version;
449 + __le32 hw_version;
450 } __packed;
451
452 #define GS_CAN_MODE_NORMAL 0
453 @@ -95,26 +101,26 @@ struct gs_device_config {
454 #define GS_CAN_MODE_ONE_SHOT BIT(3)
455
456 struct gs_device_mode {
457 - u32 mode;
458 - u32 flags;
459 + __le32 mode;
460 + __le32 flags;
461 } __packed;
462
463 struct gs_device_state {
464 - u32 state;
465 - u32 rxerr;
466 - u32 txerr;
467 + __le32 state;
468 + __le32 rxerr;
469 + __le32 txerr;
470 } __packed;
471
472 struct gs_device_bittiming {
473 - u32 prop_seg;
474 - u32 phase_seg1;
475 - u32 phase_seg2;
476 - u32 sjw;
477 - u32 brp;
478 + __le32 prop_seg;
479 + __le32 phase_seg1;
480 + __le32 phase_seg2;
481 + __le32 sjw;
482 + __le32 brp;
483 } __packed;
484
485 struct gs_identify_mode {
486 - u32 mode;
487 + __le32 mode;
488 } __packed;
489
490 #define GS_CAN_FEATURE_LISTEN_ONLY BIT(0)
491 @@ -125,23 +131,23 @@ struct gs_identify_mode {
492 #define GS_CAN_FEATURE_IDENTIFY BIT(5)
493
494 struct gs_device_bt_const {
495 - u32 feature;
496 - u32 fclk_can;
497 - u32 tseg1_min;
498 - u32 tseg1_max;
499 - u32 tseg2_min;
500 - u32 tseg2_max;
501 - u32 sjw_max;
502 - u32 brp_min;
503 - u32 brp_max;
504 - u32 brp_inc;
505 + __le32 feature;
506 + __le32 fclk_can;
507 + __le32 tseg1_min;
508 + __le32 tseg1_max;
509 + __le32 tseg2_min;
510 + __le32 tseg2_max;
511 + __le32 sjw_max;
512 + __le32 brp_min;
513 + __le32 brp_max;
514 + __le32 brp_inc;
515 } __packed;
516
517 #define GS_CAN_FLAG_OVERFLOW 1
518
519 struct gs_host_frame {
520 u32 echo_id;
521 - u32 can_id;
522 + __le32 can_id;
523
524 u8 can_dlc;
525 u8 channel;
526 @@ -337,13 +343,13 @@ static void gs_usb_receive_bulk_callback(struct urb *urb)
527 if (!skb)
528 return;
529
530 - cf->can_id = hf->can_id;
531 + cf->can_id = le32_to_cpu(hf->can_id);
532
533 cf->can_dlc = get_can_dlc(hf->can_dlc);
534 memcpy(cf->data, hf->data, 8);
535
536 /* ERROR frames tell us information about the controller */
537 - if (hf->can_id & CAN_ERR_FLAG)
538 + if (le32_to_cpu(hf->can_id) & CAN_ERR_FLAG)
539 gs_update_state(dev, cf);
540
541 netdev->stats.rx_packets++;
542 @@ -426,11 +432,11 @@ static int gs_usb_set_bittiming(struct net_device *netdev)
543 if (!dbt)
544 return -ENOMEM;
545
546 - dbt->prop_seg = bt->prop_seg;
547 - dbt->phase_seg1 = bt->phase_seg1;
548 - dbt->phase_seg2 = bt->phase_seg2;
549 - dbt->sjw = bt->sjw;
550 - dbt->brp = bt->brp;
551 + dbt->prop_seg = cpu_to_le32(bt->prop_seg);
552 + dbt->phase_seg1 = cpu_to_le32(bt->phase_seg1);
553 + dbt->phase_seg2 = cpu_to_le32(bt->phase_seg2);
554 + dbt->sjw = cpu_to_le32(bt->sjw);
555 + dbt->brp = cpu_to_le32(bt->brp);
556
557 /* request bit timings */
558 rc = usb_control_msg(interface_to_usbdev(intf),
559 @@ -511,7 +517,7 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
560
561 cf = (struct can_frame *)skb->data;
562
563 - hf->can_id = cf->can_id;
564 + hf->can_id = cpu_to_le32(cf->can_id);
565 hf->can_dlc = cf->can_dlc;
566 memcpy(hf->data, cf->data, cf->can_dlc);
567
568 @@ -582,6 +588,7 @@ static int gs_can_open(struct net_device *netdev)
569 int rc, i;
570 struct gs_device_mode *dm;
571 u32 ctrlmode;
572 + u32 flags = 0;
573
574 rc = open_candev(netdev);
575 if (rc)
576 @@ -649,24 +656,24 @@ static int gs_can_open(struct net_device *netdev)
577
578 /* flags */
579 ctrlmode = dev->can.ctrlmode;
580 - dm->flags = 0;
581
582 if (ctrlmode & CAN_CTRLMODE_LOOPBACK)
583 - dm->flags |= GS_CAN_MODE_LOOP_BACK;
584 + flags |= GS_CAN_MODE_LOOP_BACK;
585 else if (ctrlmode & CAN_CTRLMODE_LISTENONLY)
586 - dm->flags |= GS_CAN_MODE_LISTEN_ONLY;
587 + flags |= GS_CAN_MODE_LISTEN_ONLY;
588
589 /* Controller is not allowed to retry TX
590 * this mode is unavailable on atmels uc3c hardware
591 */
592 if (ctrlmode & CAN_CTRLMODE_ONE_SHOT)
593 - dm->flags |= GS_CAN_MODE_ONE_SHOT;
594 + flags |= GS_CAN_MODE_ONE_SHOT;
595
596 if (ctrlmode & CAN_CTRLMODE_3_SAMPLES)
597 - dm->flags |= GS_CAN_MODE_TRIPLE_SAMPLE;
598 + flags |= GS_CAN_MODE_TRIPLE_SAMPLE;
599
600 /* finally start device */
601 - dm->mode = GS_CAN_MODE_START;
602 + dm->mode = cpu_to_le32(GS_CAN_MODE_START);
603 + dm->flags = cpu_to_le32(flags);
604 rc = usb_control_msg(interface_to_usbdev(dev->iface),
605 usb_sndctrlpipe(interface_to_usbdev(dev->iface), 0),
606 GS_USB_BREQ_MODE,
607 @@ -746,9 +753,9 @@ static int gs_usb_set_identify(struct net_device *netdev, bool do_identify)
608 return -ENOMEM;
609
610 if (do_identify)
611 - imode->mode = GS_CAN_IDENTIFY_ON;
612 + imode->mode = cpu_to_le32(GS_CAN_IDENTIFY_ON);
613 else
614 - imode->mode = GS_CAN_IDENTIFY_OFF;
615 + imode->mode = cpu_to_le32(GS_CAN_IDENTIFY_OFF);
616
617 rc = usb_control_msg(interface_to_usbdev(dev->iface),
618 usb_sndctrlpipe(interface_to_usbdev(dev->iface),
619 @@ -799,6 +806,7 @@ static struct gs_can *gs_make_candev(unsigned int channel,
620 struct net_device *netdev;
621 int rc;
622 struct gs_device_bt_const *bt_const;
623 + u32 feature;
624
625 bt_const = kmalloc(sizeof(*bt_const), GFP_KERNEL);
626 if (!bt_const)
627 @@ -839,14 +847,14 @@ static struct gs_can *gs_make_candev(unsigned int channel,
628
629 /* dev settup */
630 strcpy(dev->bt_const.name, "gs_usb");
631 - dev->bt_const.tseg1_min = bt_const->tseg1_min;
632 - dev->bt_const.tseg1_max = bt_const->tseg1_max;
633 - dev->bt_const.tseg2_min = bt_const->tseg2_min;
634 - dev->bt_const.tseg2_max = bt_const->tseg2_max;
635 - dev->bt_const.sjw_max = bt_const->sjw_max;
636 - dev->bt_const.brp_min = bt_const->brp_min;
637 - dev->bt_const.brp_max = bt_const->brp_max;
638 - dev->bt_const.brp_inc = bt_const->brp_inc;
639 + dev->bt_const.tseg1_min = le32_to_cpu(bt_const->tseg1_min);
640 + dev->bt_const.tseg1_max = le32_to_cpu(bt_const->tseg1_max);
641 + dev->bt_const.tseg2_min = le32_to_cpu(bt_const->tseg2_min);
642 + dev->bt_const.tseg2_max = le32_to_cpu(bt_const->tseg2_max);
643 + dev->bt_const.sjw_max = le32_to_cpu(bt_const->sjw_max);
644 + dev->bt_const.brp_min = le32_to_cpu(bt_const->brp_min);
645 + dev->bt_const.brp_max = le32_to_cpu(bt_const->brp_max);
646 + dev->bt_const.brp_inc = le32_to_cpu(bt_const->brp_inc);
647
648 dev->udev = interface_to_usbdev(intf);
649 dev->iface = intf;
650 @@ -863,28 +871,29 @@ static struct gs_can *gs_make_candev(unsigned int channel,
651
652 /* can settup */
653 dev->can.state = CAN_STATE_STOPPED;
654 - dev->can.clock.freq = bt_const->fclk_can;
655 + dev->can.clock.freq = le32_to_cpu(bt_const->fclk_can);
656 dev->can.bittiming_const = &dev->bt_const;
657 dev->can.do_set_bittiming = gs_usb_set_bittiming;
658
659 dev->can.ctrlmode_supported = 0;
660
661 - if (bt_const->feature & GS_CAN_FEATURE_LISTEN_ONLY)
662 + feature = le32_to_cpu(bt_const->feature);
663 + if (feature & GS_CAN_FEATURE_LISTEN_ONLY)
664 dev->can.ctrlmode_supported |= CAN_CTRLMODE_LISTENONLY;
665
666 - if (bt_const->feature & GS_CAN_FEATURE_LOOP_BACK)
667 + if (feature & GS_CAN_FEATURE_LOOP_BACK)
668 dev->can.ctrlmode_supported |= CAN_CTRLMODE_LOOPBACK;
669
670 - if (bt_const->feature & GS_CAN_FEATURE_TRIPLE_SAMPLE)
671 + if (feature & GS_CAN_FEATURE_TRIPLE_SAMPLE)
672 dev->can.ctrlmode_supported |= CAN_CTRLMODE_3_SAMPLES;
673
674 - if (bt_const->feature & GS_CAN_FEATURE_ONE_SHOT)
675 + if (feature & GS_CAN_FEATURE_ONE_SHOT)
676 dev->can.ctrlmode_supported |= CAN_CTRLMODE_ONE_SHOT;
677
678 SET_NETDEV_DEV(netdev, &intf->dev);
679
680 - if (dconf->sw_version > 1)
681 - if (bt_const->feature & GS_CAN_FEATURE_IDENTIFY)
682 + if (le32_to_cpu(dconf->sw_version) > 1)
683 + if (feature & GS_CAN_FEATURE_IDENTIFY)
684 netdev->ethtool_ops = &gs_usb_ethtool_ops;
685
686 kfree(bt_const);
687 @@ -919,7 +928,7 @@ static int gs_usb_probe(struct usb_interface *intf,
688 if (!hconf)
689 return -ENOMEM;
690
691 - hconf->byte_order = 0x0000beef;
692 + hconf->byte_order = cpu_to_le32(0x0000beef);
693
694 /* send host config */
695 rc = usb_control_msg(interface_to_usbdev(intf),
696 diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
697 index da21886609e30..de3d6f8b54316 100644
698 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
699 +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
700 @@ -2345,16 +2345,9 @@ static int ena_device_init(struct ena_com_dev *ena_dev, struct pci_dev *pdev,
701 goto err_mmio_read_less;
702 }
703
704 - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(dma_width));
705 + rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(dma_width));
706 if (rc) {
707 - dev_err(dev, "pci_set_dma_mask failed 0x%x\n", rc);
708 - goto err_mmio_read_less;
709 - }
710 -
711 - rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(dma_width));
712 - if (rc) {
713 - dev_err(dev, "err_pci_set_consistent_dma_mask failed 0x%x\n",
714 - rc);
715 + dev_err(dev, "dma_set_mask_and_coherent failed %d\n", rc);
716 goto err_mmio_read_less;
717 }
718
719 @@ -2894,6 +2887,12 @@ static int ena_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
720 return rc;
721 }
722
723 + rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(ENA_MAX_PHYS_ADDR_SIZE_BITS));
724 + if (rc) {
725 + dev_err(&pdev->dev, "dma_set_mask_and_coherent failed %d\n", rc);
726 + goto err_disable_device;
727 + }
728 +
729 pci_set_master(pdev);
730
731 ena_dev = vzalloc(sizeof(*ena_dev));
732 diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
733 index dc34cfa2a58fc..f9610f860e6d1 100644
734 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
735 +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
736 @@ -6319,7 +6319,8 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
737 if (dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)) != 0 &&
738 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)) != 0) {
739 dev_err(&pdev->dev, "System does not support DMA, aborting\n");
740 - goto init_err_disable;
741 + rc = -EIO;
742 + goto init_err_release;
743 }
744
745 pci_set_master(pdev);
746 diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
747 index d25b76440c114..88c837504c7d6 100644
748 --- a/drivers/net/ethernet/ibm/ibmvnic.c
749 +++ b/drivers/net/ethernet/ibm/ibmvnic.c
750 @@ -3525,6 +3525,9 @@ static int ibmvnic_reset_crq(struct ibmvnic_adapter *adapter)
751 } while (rc == H_BUSY || H_IS_LONG_BUSY(rc));
752
753 /* Clean out the queue */
754 + if (!crq->msgs)
755 + return -EINVAL;
756 +
757 memset(crq->msgs, 0, PAGE_SIZE);
758 crq->cur = 0;
759
760 diff --git a/drivers/nfc/s3fwrn5/i2c.c b/drivers/nfc/s3fwrn5/i2c.c
761 index 3ed0adf6479b0..5b0c065bd279f 100644
762 --- a/drivers/nfc/s3fwrn5/i2c.c
763 +++ b/drivers/nfc/s3fwrn5/i2c.c
764 @@ -37,8 +37,8 @@ struct s3fwrn5_i2c_phy {
765 struct i2c_client *i2c_dev;
766 struct nci_dev *ndev;
767
768 - unsigned int gpio_en;
769 - unsigned int gpio_fw_wake;
770 + int gpio_en;
771 + int gpio_fw_wake;
772
773 struct mutex mutex;
774
775 diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
776 index c288e5a525754..32001787cff3f 100644
777 --- a/drivers/pci/bus.c
778 +++ b/drivers/pci/bus.c
779 @@ -324,12 +324,8 @@ void pci_bus_add_device(struct pci_dev *dev)
780
781 dev->match_driver = true;
782 retval = device_attach(&dev->dev);
783 - if (retval < 0 && retval != -EPROBE_DEFER) {
784 + if (retval < 0 && retval != -EPROBE_DEFER)
785 dev_warn(&dev->dev, "device attach failed (%d)\n", retval);
786 - pci_proc_detach_device(dev);
787 - pci_remove_sysfs_dev_files(dev);
788 - return;
789 - }
790
791 dev->is_added = 1;
792 }
793 diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c
794 index bd0e659002161..0156134dd022d 100644
795 --- a/drivers/phy/tegra/xusb.c
796 +++ b/drivers/phy/tegra/xusb.c
797 @@ -916,6 +916,7 @@ remove_pads:
798 reset:
799 reset_control_assert(padctl->rst);
800 remove:
801 + platform_set_drvdata(pdev, NULL);
802 soc->ops->remove(padctl);
803 return err;
804 }
805 diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
806 index 79a2289370729..f25278bb3e1a8 100644
807 --- a/drivers/platform/x86/toshiba_acpi.c
808 +++ b/drivers/platform/x86/toshiba_acpi.c
809 @@ -1497,7 +1497,7 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
810 struct toshiba_acpi_dev *dev = PDE_DATA(file_inode(file));
811 char *buffer;
812 char *cmd;
813 - int lcd_out, crt_out, tv_out;
814 + int lcd_out = -1, crt_out = -1, tv_out = -1;
815 int remain = count;
816 int value;
817 int ret;
818 @@ -1534,7 +1534,6 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
819
820 kfree(cmd);
821
822 - lcd_out = crt_out = tv_out = -1;
823 ret = get_video_status(dev, &video_out);
824 if (!ret) {
825 unsigned int new_video_out = video_out;
826 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
827 index 0a0dd0aac047c..23323add5b0b1 100644
828 --- a/drivers/regulator/core.c
829 +++ b/drivers/regulator/core.c
830 @@ -1550,6 +1550,15 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
831 }
832 }
833
834 + if (r == rdev) {
835 + dev_err(dev, "Supply for %s (%s) resolved to itself\n",
836 + rdev->desc->name, rdev->supply_name);
837 + if (!have_full_constraints())
838 + return -EINVAL;
839 + r = dummy_regulator_rdev;
840 + get_device(&r->dev);
841 + }
842 +
843 /* Recursively resolve the supply of the supply */
844 ret = regulator_resolve_supply(r);
845 if (ret < 0) {
846 diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
847 index c4336b01db23c..a84b473d4a08b 100644
848 --- a/drivers/scsi/libiscsi.c
849 +++ b/drivers/scsi/libiscsi.c
850 @@ -570,8 +570,8 @@ static void iscsi_complete_task(struct iscsi_task *task, int state)
851 if (conn->task == task)
852 conn->task = NULL;
853
854 - if (conn->ping_task == task)
855 - conn->ping_task = NULL;
856 + if (READ_ONCE(conn->ping_task) == task)
857 + WRITE_ONCE(conn->ping_task, NULL);
858
859 /* release get from queueing */
860 __iscsi_put_task(task);
861 @@ -780,6 +780,9 @@ __iscsi_conn_send_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
862 task->conn->session->age);
863 }
864
865 + if (unlikely(READ_ONCE(conn->ping_task) == INVALID_SCSI_TASK))
866 + WRITE_ONCE(conn->ping_task, task);
867 +
868 if (!ihost->workq) {
869 if (iscsi_prep_mgmt_task(conn, task))
870 goto free_task;
871 @@ -987,8 +990,11 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
872 struct iscsi_nopout hdr;
873 struct iscsi_task *task;
874
875 - if (!rhdr && conn->ping_task)
876 - return -EINVAL;
877 + if (!rhdr) {
878 + if (READ_ONCE(conn->ping_task))
879 + return -EINVAL;
880 + WRITE_ONCE(conn->ping_task, INVALID_SCSI_TASK);
881 + }
882
883 memset(&hdr, 0, sizeof(struct iscsi_nopout));
884 hdr.opcode = ISCSI_OP_NOOP_OUT | ISCSI_OP_IMMEDIATE;
885 @@ -1003,11 +1009,12 @@ static int iscsi_send_nopout(struct iscsi_conn *conn, struct iscsi_nopin *rhdr)
886
887 task = __iscsi_conn_send_pdu(conn, (struct iscsi_hdr *)&hdr, NULL, 0);
888 if (!task) {
889 + if (!rhdr)
890 + WRITE_ONCE(conn->ping_task, NULL);
891 iscsi_conn_printk(KERN_ERR, conn, "Could not send nopout\n");
892 return -EIO;
893 } else if (!rhdr) {
894 /* only track our nops */
895 - conn->ping_task = task;
896 conn->last_ping = jiffies;
897 }
898
899 @@ -1020,7 +1027,7 @@ static int iscsi_nop_out_rsp(struct iscsi_task *task,
900 struct iscsi_conn *conn = task->conn;
901 int rc = 0;
902
903 - if (conn->ping_task != task) {
904 + if (READ_ONCE(conn->ping_task) != task) {
905 /*
906 * If this is not in response to one of our
907 * nops then it must be from userspace.
908 @@ -1960,7 +1967,7 @@ static void iscsi_start_tx(struct iscsi_conn *conn)
909 */
910 static int iscsi_has_ping_timed_out(struct iscsi_conn *conn)
911 {
912 - if (conn->ping_task &&
913 + if (READ_ONCE(conn->ping_task) &&
914 time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) +
915 (conn->ping_timeout * HZ), jiffies))
916 return 1;
917 @@ -2095,7 +2102,7 @@ static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc)
918 * Checking the transport already or nop from a cmd timeout still
919 * running
920 */
921 - if (conn->ping_task) {
922 + if (READ_ONCE(conn->ping_task)) {
923 task->have_checked_conn = true;
924 rc = BLK_EH_RESET_TIMER;
925 goto done;
926 diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
927 index ad5f2e2b4cbaf..ad80e4223c2d3 100644
928 --- a/drivers/scsi/ufs/ufshcd.c
929 +++ b/drivers/scsi/ufs/ufshcd.c
930 @@ -6521,11 +6521,7 @@ int ufshcd_shutdown(struct ufs_hba *hba)
931 if (ufshcd_is_ufs_dev_poweroff(hba) && ufshcd_is_link_off(hba))
932 goto out;
933
934 - if (pm_runtime_suspended(hba->dev)) {
935 - ret = ufshcd_runtime_resume(hba);
936 - if (ret)
937 - goto out;
938 - }
939 + pm_runtime_get_sync(hba->dev);
940
941 ret = ufshcd_suspend(hba, UFS_SHUTDOWN_PM);
942 out:
943 diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
944 index 7c0f4b96816a8..eba21f06a9b95 100644
945 --- a/drivers/target/iscsi/iscsi_target.c
946 +++ b/drivers/target/iscsi/iscsi_target.c
947 @@ -493,8 +493,7 @@ void iscsit_aborted_task(struct iscsi_conn *conn, struct iscsi_cmd *cmd)
948 bool scsi_cmd = (cmd->iscsi_opcode == ISCSI_OP_SCSI_CMD);
949
950 spin_lock_bh(&conn->cmd_lock);
951 - if (!list_empty(&cmd->i_conn_node) &&
952 - !(cmd->se_cmd.transport_state & CMD_T_FABRIC_STOP))
953 + if (!list_empty(&cmd->i_conn_node))
954 list_del_init(&cmd->i_conn_node);
955 spin_unlock_bh(&conn->cmd_lock);
956
957 @@ -4093,12 +4092,22 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)
958 spin_lock_bh(&conn->cmd_lock);
959 list_splice_init(&conn->conn_cmd_list, &tmp_list);
960
961 - list_for_each_entry(cmd, &tmp_list, i_conn_node) {
962 + list_for_each_entry_safe(cmd, cmd_tmp, &tmp_list, i_conn_node) {
963 struct se_cmd *se_cmd = &cmd->se_cmd;
964
965 if (se_cmd->se_tfo != NULL) {
966 spin_lock_irq(&se_cmd->t_state_lock);
967 - se_cmd->transport_state |= CMD_T_FABRIC_STOP;
968 + if (se_cmd->transport_state & CMD_T_ABORTED) {
969 + /*
970 + * LIO's abort path owns the cleanup for this,
971 + * so put it back on the list and let
972 + * aborted_task handle it.
973 + */
974 + list_move_tail(&cmd->i_conn_node,
975 + &conn->conn_cmd_list);
976 + } else {
977 + se_cmd->transport_state |= CMD_T_FABRIC_STOP;
978 + }
979 spin_unlock_irq(&se_cmd->t_state_lock);
980 }
981 }
982 diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
983 index edf66b2f916b8..34081f03b1f56 100644
984 --- a/drivers/usb/core/config.c
985 +++ b/drivers/usb/core/config.c
986 @@ -251,6 +251,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
987 struct usb_host_interface *ifp, int num_ep,
988 unsigned char *buffer, int size)
989 {
990 + struct usb_device *udev = to_usb_device(ddev);
991 unsigned char *buffer0 = buffer;
992 struct usb_endpoint_descriptor *d;
993 struct usb_host_endpoint *endpoint;
994 @@ -292,6 +293,16 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
995 goto skip_to_next_endpoint_or_interface_descriptor;
996 }
997
998 + /* Ignore blacklisted endpoints */
999 + if (udev->quirks & USB_QUIRK_ENDPOINT_BLACKLIST) {
1000 + if (usb_endpoint_is_blacklisted(udev, ifp, d)) {
1001 + dev_warn(ddev, "config %d interface %d altsetting %d has a blacklisted endpoint with address 0x%X, skipping\n",
1002 + cfgno, inum, asnum,
1003 + d->bEndpointAddress);
1004 + goto skip_to_next_endpoint_or_interface_descriptor;
1005 + }
1006 + }
1007 +
1008 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
1009 ++ifp->desc.bNumEndpoints;
1010
1011 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
1012 index 059e71d71b666..781db58004f7f 100644
1013 --- a/drivers/usb/core/devio.c
1014 +++ b/drivers/usb/core/devio.c
1015 @@ -477,11 +477,11 @@ static void snoop_urb(struct usb_device *udev,
1016
1017 if (userurb) { /* Async */
1018 if (when == SUBMIT)
1019 - dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
1020 + dev_info(&udev->dev, "userurb %px, ep%d %s-%s, "
1021 "length %u\n",
1022 userurb, ep, t, d, length);
1023 else
1024 - dev_info(&udev->dev, "userurb %pK, ep%d %s-%s, "
1025 + dev_info(&udev->dev, "userurb %px, ep%d %s-%s, "
1026 "actual_length %u status %d\n",
1027 userurb, ep, t, d, length,
1028 timeout_or_status);
1029 @@ -1945,7 +1945,7 @@ static int proc_reapurb(struct usb_dev_state *ps, void __user *arg)
1030 if (as) {
1031 int retval;
1032
1033 - snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1034 + snoop(&ps->dev->dev, "reap %px\n", as->userurb);
1035 retval = processcompl(as, (void __user * __user *)arg);
1036 free_async(as);
1037 return retval;
1038 @@ -1962,7 +1962,7 @@ static int proc_reapurbnonblock(struct usb_dev_state *ps, void __user *arg)
1039
1040 as = async_getcompleted(ps);
1041 if (as) {
1042 - snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1043 + snoop(&ps->dev->dev, "reap %px\n", as->userurb);
1044 retval = processcompl(as, (void __user * __user *)arg);
1045 free_async(as);
1046 } else {
1047 @@ -2094,7 +2094,7 @@ static int proc_reapurb_compat(struct usb_dev_state *ps, void __user *arg)
1048 if (as) {
1049 int retval;
1050
1051 - snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1052 + snoop(&ps->dev->dev, "reap %px\n", as->userurb);
1053 retval = processcompl_compat(as, (void __user * __user *)arg);
1054 free_async(as);
1055 return retval;
1056 @@ -2111,7 +2111,7 @@ static int proc_reapurbnonblock_compat(struct usb_dev_state *ps, void __user *ar
1057
1058 as = async_getcompleted(ps);
1059 if (as) {
1060 - snoop(&ps->dev->dev, "reap %pK\n", as->userurb);
1061 + snoop(&ps->dev->dev, "reap %px\n", as->userurb);
1062 retval = processcompl_compat(as, (void __user * __user *)arg);
1063 free_async(as);
1064 } else {
1065 @@ -2540,7 +2540,7 @@ static long usbdev_do_ioctl(struct file *file, unsigned int cmd,
1066 #endif
1067
1068 case USBDEVFS_DISCARDURB:
1069 - snoop(&dev->dev, "%s: DISCARDURB %pK\n", __func__, p);
1070 + snoop(&dev->dev, "%s: DISCARDURB %px\n", __func__, p);
1071 ret = proc_unlinkurb(ps, p);
1072 break;
1073
1074 diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
1075 index ca74b67c4450d..34d8cece6dd3b 100644
1076 --- a/drivers/usb/core/quirks.c
1077 +++ b/drivers/usb/core/quirks.c
1078 @@ -195,6 +195,10 @@ static const struct usb_device_id usb_quirk_list[] = {
1079 /* Guillemot Webcam Hercules Dualpix Exchange*/
1080 { USB_DEVICE(0x06f8, 0x3005), .driver_info = USB_QUIRK_RESET_RESUME },
1081
1082 + /* Guillemot Hercules DJ Console audio card (BZ 208357) */
1083 + { USB_DEVICE(0x06f8, 0xb000), .driver_info =
1084 + USB_QUIRK_ENDPOINT_BLACKLIST },
1085 +
1086 /* Midiman M-Audio Keystation 88es */
1087 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
1088
1089 @@ -344,6 +348,40 @@ static const struct usb_device_id usb_amd_resume_quirk_list[] = {
1090 { } /* terminating entry must be last */
1091 };
1092
1093 +/*
1094 + * Entries for blacklisted endpoints that should be ignored when parsing
1095 + * configuration descriptors.
1096 + *
1097 + * Matched for devices with USB_QUIRK_ENDPOINT_BLACKLIST.
1098 + */
1099 +static const struct usb_device_id usb_endpoint_blacklist[] = {
1100 + { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x01 },
1101 + { USB_DEVICE_INTERFACE_NUMBER(0x06f8, 0xb000, 5), .driver_info = 0x81 },
1102 + { }
1103 +};
1104 +
1105 +bool usb_endpoint_is_blacklisted(struct usb_device *udev,
1106 + struct usb_host_interface *intf,
1107 + struct usb_endpoint_descriptor *epd)
1108 +{
1109 + const struct usb_device_id *id;
1110 + unsigned int address;
1111 +
1112 + for (id = usb_endpoint_blacklist; id->match_flags; ++id) {
1113 + if (!usb_match_device(udev, id))
1114 + continue;
1115 +
1116 + if (!usb_match_one_id_intf(udev, intf, id))
1117 + continue;
1118 +
1119 + address = id->driver_info;
1120 + if (address == epd->bEndpointAddress)
1121 + return true;
1122 + }
1123 +
1124 + return false;
1125 +}
1126 +
1127 static bool usb_match_any_interface(struct usb_device *udev,
1128 const struct usb_device_id *id)
1129 {
1130 diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
1131 index 6b2f115442838..462a00c749b87 100644
1132 --- a/drivers/usb/core/usb.h
1133 +++ b/drivers/usb/core/usb.h
1134 @@ -31,6 +31,9 @@ extern void usb_deauthorize_interface(struct usb_interface *);
1135 extern void usb_authorize_interface(struct usb_interface *);
1136 extern void usb_detect_quirks(struct usb_device *udev);
1137 extern void usb_detect_interface_quirks(struct usb_device *udev);
1138 +extern bool usb_endpoint_is_blacklisted(struct usb_device *udev,
1139 + struct usb_host_interface *intf,
1140 + struct usb_endpoint_descriptor *epd);
1141 extern int usb_remove_device(struct usb_device *udev);
1142
1143 extern int usb_get_device_descriptor(struct usb_device *dev,
1144 diff --git a/drivers/usb/gadget/function/f_midi.c b/drivers/usb/gadget/function/f_midi.c
1145 index 70ac1963b5987..cab5fbd5b9557 100644
1146 --- a/drivers/usb/gadget/function/f_midi.c
1147 +++ b/drivers/usb/gadget/function/f_midi.c
1148 @@ -1256,7 +1256,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
1149 midi->id = kstrdup(opts->id, GFP_KERNEL);
1150 if (opts->id && !midi->id) {
1151 status = -ENOMEM;
1152 - goto setup_fail;
1153 + goto midi_free;
1154 }
1155 midi->in_ports = opts->in_ports;
1156 midi->out_ports = opts->out_ports;
1157 @@ -1267,7 +1267,7 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
1158
1159 status = kfifo_alloc(&midi->in_req_fifo, midi->qlen, GFP_KERNEL);
1160 if (status)
1161 - goto setup_fail;
1162 + goto midi_free;
1163
1164 spin_lock_init(&midi->transmit_lock);
1165
1166 @@ -1283,9 +1283,13 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
1167
1168 return &midi->func;
1169
1170 +midi_free:
1171 + if (midi)
1172 + kfree(midi->id);
1173 + kfree(midi);
1174 setup_fail:
1175 mutex_unlock(&opts->lock);
1176 - kfree(midi);
1177 +
1178 return ERR_PTR(status);
1179 }
1180
1181 diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
1182 index cb02e9ecd8e7d..de0f3c2c9f6f3 100644
1183 --- a/drivers/usb/gadget/legacy/inode.c
1184 +++ b/drivers/usb/gadget/legacy/inode.c
1185 @@ -2045,6 +2045,9 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
1186 return 0;
1187
1188 Enomem:
1189 + kfree(CHIP);
1190 + CHIP = NULL;
1191 +
1192 return -ENOMEM;
1193 }
1194
1195 diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c
1196 index 2fd49b2358f8b..f3938c5278832 100644
1197 --- a/drivers/video/fbdev/hyperv_fb.c
1198 +++ b/drivers/video/fbdev/hyperv_fb.c
1199 @@ -712,7 +712,12 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info)
1200 goto err1;
1201 }
1202
1203 - fb_virt = ioremap(par->mem->start, screen_fb_size);
1204 + /*
1205 + * Map the VRAM cacheable for performance. This is also required for
1206 + * VM Connect to display properly for ARM64 Linux VM, as the host also
1207 + * maps the VRAM cacheable.
1208 + */
1209 + fb_virt = ioremap_cache(par->mem->start, screen_fb_size);
1210 if (!fb_virt)
1211 goto err2;
1212
1213 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
1214 index dfc0b3adf57af..6f8f37e37abb2 100644
1215 --- a/fs/btrfs/inode.c
1216 +++ b/fs/btrfs/inode.c
1217 @@ -5440,11 +5440,13 @@ no_delete:
1218 }
1219
1220 /*
1221 - * this returns the key found in the dir entry in the location pointer.
1222 + * Return the key found in the dir entry in the location pointer, fill @type
1223 + * with BTRFS_FT_*, and return 0.
1224 + *
1225 * If no dir entries were found, location->objectid is 0.
1226 */
1227 static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
1228 - struct btrfs_key *location)
1229 + struct btrfs_key *location, u8 *type)
1230 {
1231 const char *name = dentry->d_name.name;
1232 int namelen = dentry->d_name.len;
1233 @@ -5466,6 +5468,8 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
1234 goto out_err;
1235
1236 btrfs_dir_item_key_to_cpu(path->nodes[0], di, location);
1237 + if (!ret)
1238 + *type = btrfs_dir_type(path->nodes[0], di);
1239 out:
1240 btrfs_free_path(path);
1241 return ret;
1242 @@ -5755,19 +5759,25 @@ static struct inode *new_simple_dir(struct super_block *s,
1243 return inode;
1244 }
1245
1246 +static inline u8 btrfs_inode_type(struct inode *inode)
1247 +{
1248 + return btrfs_type_by_mode[(inode->i_mode & S_IFMT) >> S_SHIFT];
1249 +}
1250 +
1251 struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
1252 {
1253 struct inode *inode;
1254 struct btrfs_root *root = BTRFS_I(dir)->root;
1255 struct btrfs_root *sub_root = root;
1256 struct btrfs_key location;
1257 + u8 di_type = 0;
1258 int index;
1259 int ret = 0;
1260
1261 if (dentry->d_name.len > BTRFS_NAME_LEN)
1262 return ERR_PTR(-ENAMETOOLONG);
1263
1264 - ret = btrfs_inode_by_name(dir, dentry, &location);
1265 + ret = btrfs_inode_by_name(dir, dentry, &location, &di_type);
1266 if (ret < 0)
1267 return ERR_PTR(ret);
1268
1269 @@ -5776,6 +5786,18 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
1270
1271 if (location.type == BTRFS_INODE_ITEM_KEY) {
1272 inode = btrfs_iget(dir->i_sb, &location, root, NULL);
1273 + if (IS_ERR(inode))
1274 + return inode;
1275 +
1276 + /* Do extra check against inode mode with di_type */
1277 + if (btrfs_inode_type(inode) != di_type) {
1278 + btrfs_crit(root->fs_info,
1279 +"inode mode mismatch with dir: inode mode=0%o btrfs type=%u dir type=%u",
1280 + inode->i_mode, btrfs_inode_type(inode),
1281 + di_type);
1282 + iput(inode);
1283 + return ERR_PTR(-EUCLEAN);
1284 + }
1285 return inode;
1286 }
1287
1288 @@ -6391,11 +6413,6 @@ fail:
1289 return ERR_PTR(ret);
1290 }
1291
1292 -static inline u8 btrfs_inode_type(struct inode *inode)
1293 -{
1294 - return btrfs_type_by_mode[(inode->i_mode & S_IFMT) >> S_SHIFT];
1295 -}
1296 -
1297 /*
1298 * utility function to add 'inode' into 'parent_inode' with
1299 * a give name and a given sequence number.
1300 @@ -6981,6 +6998,14 @@ again:
1301 extent_start = found_key.offset;
1302 if (found_type == BTRFS_FILE_EXTENT_REG ||
1303 found_type == BTRFS_FILE_EXTENT_PREALLOC) {
1304 + /* Only regular file could have regular/prealloc extent */
1305 + if (!S_ISREG(inode->i_mode)) {
1306 + ret = -EUCLEAN;
1307 + btrfs_crit(root->fs_info,
1308 + "regular/prealloc extent found for non-regular inode %llu",
1309 + btrfs_ino(inode));
1310 + goto out;
1311 + }
1312 extent_end = extent_start +
1313 btrfs_file_extent_num_bytes(leaf, item);
1314 } else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
1315 diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
1316 index 0355e6d9e21cb..154008e245a2f 100644
1317 --- a/fs/btrfs/qgroup.c
1318 +++ b/fs/btrfs/qgroup.c
1319 @@ -461,13 +461,13 @@ next2:
1320 break;
1321 }
1322 out:
1323 + btrfs_free_path(path);
1324 fs_info->qgroup_flags |= flags;
1325 if (!(fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_ON))
1326 clear_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags);
1327 else if (fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN &&
1328 ret >= 0)
1329 ret = qgroup_rescan_init(fs_info, rescan_progress, 0);
1330 - btrfs_free_path(path);
1331
1332 if (ret < 0) {
1333 ulist_free(fs_info->qgroup_ulist);
1334 diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
1335 index 0bf46808ce8f2..ee89de7f4d61b 100644
1336 --- a/fs/btrfs/tests/inode-tests.c
1337 +++ b/fs/btrfs/tests/inode-tests.c
1338 @@ -245,6 +245,7 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
1339 return ret;
1340 }
1341
1342 + inode->i_mode = S_IFREG;
1343 BTRFS_I(inode)->location.type = BTRFS_INODE_ITEM_KEY;
1344 BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID;
1345 BTRFS_I(inode)->location.offset = 0;
1346 diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
1347 index c31b02692f706..7391634520ab2 100644
1348 --- a/fs/btrfs/volumes.c
1349 +++ b/fs/btrfs/volumes.c
1350 @@ -6414,6 +6414,13 @@ static int btrfs_check_chunk_valid(struct btrfs_root *root,
1351 return -EIO;
1352 }
1353
1354 + if (!is_power_of_2(type & BTRFS_BLOCK_GROUP_PROFILE_MASK) &&
1355 + (type & BTRFS_BLOCK_GROUP_PROFILE_MASK) != 0) {
1356 + btrfs_err(root->fs_info,
1357 + "invalid chunk profile flag: 0x%llx, expect 0 or 1 bit set",
1358 + type & BTRFS_BLOCK_GROUP_PROFILE_MASK);
1359 + return -EUCLEAN;
1360 + }
1361 if ((type & BTRFS_BLOCK_GROUP_TYPE_MASK) == 0) {
1362 btrfs_err(root->fs_info, "missing chunk type flag: 0x%llx", type);
1363 return -EIO;
1364 diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
1365 index 71fccccf317e8..5decb3e06563f 100644
1366 --- a/fs/efivarfs/inode.c
1367 +++ b/fs/efivarfs/inode.c
1368 @@ -10,6 +10,7 @@
1369 #include <linux/efi.h>
1370 #include <linux/fs.h>
1371 #include <linux/ctype.h>
1372 +#include <linux/kmemleak.h>
1373 #include <linux/slab.h>
1374 #include <linux/uuid.h>
1375
1376 @@ -104,6 +105,7 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
1377 var->var.VariableName[i] = '\0';
1378
1379 inode->i_private = var;
1380 + kmemleak_ignore(var);
1381
1382 err = efivar_entry_add(var, &efivarfs_list);
1383 if (err)
1384 diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
1385 index bbf056191aaa4..b1e6acec53041 100644
1386 --- a/fs/efivarfs/super.c
1387 +++ b/fs/efivarfs/super.c
1388 @@ -23,7 +23,6 @@ LIST_HEAD(efivarfs_list);
1389 static void efivarfs_evict_inode(struct inode *inode)
1390 {
1391 clear_inode(inode);
1392 - kfree(inode->i_private);
1393 }
1394
1395 static const struct super_operations efivarfs_ops = {
1396 diff --git a/fs/proc/self.c b/fs/proc/self.c
1397 index c8bbc1c84a39a..f6e2e3fb8a226 100644
1398 --- a/fs/proc/self.c
1399 +++ b/fs/proc/self.c
1400 @@ -26,6 +26,13 @@ static const char *proc_self_get_link(struct dentry *dentry,
1401 pid_t tgid = task_tgid_nr_ns(current, ns);
1402 char *name;
1403
1404 + /*
1405 + * Not currently supported. Once we can inherit all of struct pid,
1406 + * we can allow this.
1407 + */
1408 + if (current->flags & PF_KTHREAD)
1409 + return ERR_PTR(-EOPNOTSUPP);
1410 +
1411 if (!tgid)
1412 return ERR_PTR(-ENOENT);
1413 /* 11 for max length of signed int in decimal + NULL term */
1414 diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
1415 index ea4f81c2a6d5e..602dff213bae1 100644
1416 --- a/include/linux/usb/quirks.h
1417 +++ b/include/linux/usb/quirks.h
1418 @@ -59,4 +59,7 @@
1419 /* Device needs a pause after every control message. */
1420 #define USB_QUIRK_DELAY_CTRL_MSG BIT(13)
1421
1422 +/* device has blacklisted endpoints */
1423 +#define USB_QUIRK_ENDPOINT_BLACKLIST BIT(15)
1424 +
1425 #endif /* __LINUX_USB_QUIRKS_H */
1426 diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
1427 index c7b1dc713cdd7..9c7f4aad6db66 100644
1428 --- a/include/scsi/libiscsi.h
1429 +++ b/include/scsi/libiscsi.h
1430 @@ -144,6 +144,9 @@ struct iscsi_task {
1431 void *dd_data; /* driver/transport data */
1432 };
1433
1434 +/* invalid scsi_task pointer */
1435 +#define INVALID_SCSI_TASK (struct iscsi_task *)-1l
1436 +
1437 static inline int iscsi_task_has_unsol_data(struct iscsi_task *task)
1438 {
1439 return task->unsol_r2t.data_length > task->unsol_r2t.sent;
1440 diff --git a/mm/huge_memory.c b/mm/huge_memory.c
1441 index cf4c0a61b3708..0385c57a2b7af 100644
1442 --- a/mm/huge_memory.c
1443 +++ b/mm/huge_memory.c
1444 @@ -661,7 +661,6 @@ int do_huge_pmd_anonymous_page(struct fault_env *fe)
1445 transparent_hugepage_use_zero_page()) {
1446 pgtable_t pgtable;
1447 struct page *zero_page;
1448 - bool set;
1449 int ret;
1450 pgtable = pte_alloc_one(vma->vm_mm, haddr);
1451 if (unlikely(!pgtable))
1452 @@ -674,22 +673,21 @@ int do_huge_pmd_anonymous_page(struct fault_env *fe)
1453 }
1454 fe->ptl = pmd_lock(vma->vm_mm, fe->pmd);
1455 ret = 0;
1456 - set = false;
1457 if (pmd_none(*fe->pmd)) {
1458 if (userfaultfd_missing(vma)) {
1459 spin_unlock(fe->ptl);
1460 + pte_free(vma->vm_mm, pgtable);
1461 ret = handle_userfault(fe, VM_UFFD_MISSING);
1462 VM_BUG_ON(ret & VM_FAULT_FALLBACK);
1463 } else {
1464 set_huge_zero_page(pgtable, vma->vm_mm, vma,
1465 haddr, fe->pmd, zero_page);
1466 spin_unlock(fe->ptl);
1467 - set = true;
1468 }
1469 - } else
1470 + } else {
1471 spin_unlock(fe->ptl);
1472 - if (!set)
1473 pte_free(vma->vm_mm, pgtable);
1474 + }
1475 return ret;
1476 }
1477 gfp = alloc_hugepage_direct_gfpmask(vma);
1478 diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c
1479 index 56dc532f7a2c2..b422a8b34b9f5 100644
1480 --- a/net/batman-adv/log.c
1481 +++ b/net/batman-adv/log.c
1482 @@ -196,6 +196,7 @@ static const struct file_operations batadv_log_fops = {
1483 .read = batadv_log_read,
1484 .poll = batadv_log_poll,
1485 .llseek = no_llseek,
1486 + .owner = THIS_MODULE,
1487 };
1488
1489 int batadv_debug_log_setup(struct batadv_priv *bat_priv)
1490 diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
1491 index 4f8dd558af48f..ba0c3a381933e 100644
1492 --- a/sound/pci/hda/patch_hdmi.c
1493 +++ b/sound/pci/hda/patch_hdmi.c
1494 @@ -307,13 +307,13 @@ static int hdmi_eld_ctl_info(struct snd_kcontrol *kcontrol,
1495 if (!per_pin) {
1496 /* no pin is bound to the pcm */
1497 uinfo->count = 0;
1498 - mutex_unlock(&spec->pcm_lock);
1499 - return 0;
1500 + goto unlock;
1501 }
1502 eld = &per_pin->sink_eld;
1503 uinfo->count = eld->eld_valid ? eld->eld_size : 0;
1504 - mutex_unlock(&spec->pcm_lock);
1505
1506 + unlock:
1507 + mutex_unlock(&spec->pcm_lock);
1508 return 0;
1509 }
1510
1511 @@ -325,6 +325,7 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
1512 struct hdmi_spec_per_pin *per_pin;
1513 struct hdmi_eld *eld;
1514 int pcm_idx;
1515 + int err = 0;
1516
1517 pcm_idx = kcontrol->private_value;
1518 mutex_lock(&spec->pcm_lock);
1519 @@ -333,16 +334,15 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
1520 /* no pin is bound to the pcm */
1521 memset(ucontrol->value.bytes.data, 0,
1522 ARRAY_SIZE(ucontrol->value.bytes.data));
1523 - mutex_unlock(&spec->pcm_lock);
1524 - return 0;
1525 + goto unlock;
1526 }
1527 - eld = &per_pin->sink_eld;
1528
1529 + eld = &per_pin->sink_eld;
1530 if (eld->eld_size > ARRAY_SIZE(ucontrol->value.bytes.data) ||
1531 eld->eld_size > ELD_MAX_SIZE) {
1532 - mutex_unlock(&spec->pcm_lock);
1533 snd_BUG();
1534 - return -EINVAL;
1535 + err = -EINVAL;
1536 + goto unlock;
1537 }
1538
1539 memset(ucontrol->value.bytes.data, 0,
1540 @@ -350,9 +350,10 @@ static int hdmi_eld_ctl_get(struct snd_kcontrol *kcontrol,
1541 if (eld->eld_valid)
1542 memcpy(ucontrol->value.bytes.data, eld->eld_buffer,
1543 eld->eld_size);
1544 - mutex_unlock(&spec->pcm_lock);
1545
1546 - return 0;
1547 + unlock:
1548 + mutex_unlock(&spec->pcm_lock);
1549 + return err;
1550 }
1551
1552 static struct snd_kcontrol_new eld_bytes_ctl = {
1553 @@ -1114,8 +1115,8 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1554 pin_idx = hinfo_to_pin_index(codec, hinfo);
1555 if (!spec->dyn_pcm_assign) {
1556 if (snd_BUG_ON(pin_idx < 0)) {
1557 - mutex_unlock(&spec->pcm_lock);
1558 - return -EINVAL;
1559 + err = -EINVAL;
1560 + goto unlock;
1561 }
1562 } else {
1563 /* no pin is assigned to the PCM
1564 @@ -1123,16 +1124,13 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1565 */
1566 if (pin_idx < 0) {
1567 err = hdmi_pcm_open_no_pin(hinfo, codec, substream);
1568 - mutex_unlock(&spec->pcm_lock);
1569 - return err;
1570 + goto unlock;
1571 }
1572 }
1573
1574 err = hdmi_choose_cvt(codec, pin_idx, &cvt_idx);
1575 - if (err < 0) {
1576 - mutex_unlock(&spec->pcm_lock);
1577 - return err;
1578 - }
1579 + if (err < 0)
1580 + goto unlock;
1581
1582 per_cvt = get_cvt(spec, cvt_idx);
1583 /* Claim converter */
1584 @@ -1168,12 +1166,11 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1585 per_cvt->assigned = 0;
1586 hinfo->nid = 0;
1587 snd_hda_spdif_ctls_unassign(codec, pcm_idx);
1588 - mutex_unlock(&spec->pcm_lock);
1589 - return -ENODEV;
1590 + err = -ENODEV;
1591 + goto unlock;
1592 }
1593 }
1594
1595 - mutex_unlock(&spec->pcm_lock);
1596 /* Store the updated parameters */
1597 runtime->hw.channels_min = hinfo->channels_min;
1598 runtime->hw.channels_max = hinfo->channels_max;
1599 @@ -1182,7 +1179,9 @@ static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
1600
1601 snd_pcm_hw_constraint_step(substream->runtime, 0,
1602 SNDRV_PCM_HW_PARAM_CHANNELS, 2);
1603 - return 0;
1604 + unlock:
1605 + mutex_unlock(&spec->pcm_lock);
1606 + return err;
1607 }
1608
1609 /*
1610 @@ -1726,7 +1725,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1611 struct snd_pcm_runtime *runtime = substream->runtime;
1612 bool non_pcm;
1613 int pinctl;
1614 - int err;
1615 + int err = 0;
1616
1617 mutex_lock(&spec->pcm_lock);
1618 pin_idx = hinfo_to_pin_index(codec, hinfo);
1619 @@ -1738,13 +1737,12 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1620 pin_cvt_fixup(codec, NULL, cvt_nid);
1621 snd_hda_codec_setup_stream(codec, cvt_nid,
1622 stream_tag, 0, format);
1623 - mutex_unlock(&spec->pcm_lock);
1624 - return 0;
1625 + goto unlock;
1626 }
1627
1628 if (snd_BUG_ON(pin_idx < 0)) {
1629 - mutex_unlock(&spec->pcm_lock);
1630 - return -EINVAL;
1631 + err = -EINVAL;
1632 + goto unlock;
1633 }
1634 per_pin = get_pin(spec, pin_idx);
1635 pin_nid = per_pin->pin_nid;
1636 @@ -1781,6 +1779,7 @@ static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
1637
1638 err = spec->ops.setup_stream(codec, cvt_nid, pin_nid,
1639 stream_tag, format);
1640 + unlock:
1641 mutex_unlock(&spec->pcm_lock);
1642 return err;
1643 }
1644 @@ -1802,32 +1801,34 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
1645 struct hdmi_spec_per_cvt *per_cvt;
1646 struct hdmi_spec_per_pin *per_pin;
1647 int pinctl;
1648 + int err = 0;
1649
1650 + mutex_lock(&spec->pcm_lock);
1651 if (hinfo->nid) {
1652 pcm_idx = hinfo_to_pcm_index(codec, hinfo);
1653 - if (snd_BUG_ON(pcm_idx < 0))
1654 - return -EINVAL;
1655 + if (snd_BUG_ON(pcm_idx < 0)) {
1656 + err = -EINVAL;
1657 + goto unlock;
1658 + }
1659 cvt_idx = cvt_nid_to_cvt_index(codec, hinfo->nid);
1660 - if (snd_BUG_ON(cvt_idx < 0))
1661 - return -EINVAL;
1662 + if (snd_BUG_ON(cvt_idx < 0)) {
1663 + err = -EINVAL;
1664 + goto unlock;
1665 + }
1666 per_cvt = get_cvt(spec, cvt_idx);
1667 -
1668 snd_BUG_ON(!per_cvt->assigned);
1669 per_cvt->assigned = 0;
1670 hinfo->nid = 0;
1671
1672 - mutex_lock(&spec->pcm_lock);
1673 snd_hda_spdif_ctls_unassign(codec, pcm_idx);
1674 clear_bit(pcm_idx, &spec->pcm_in_use);
1675 pin_idx = hinfo_to_pin_index(codec, hinfo);
1676 - if (spec->dyn_pcm_assign && pin_idx < 0) {
1677 - mutex_unlock(&spec->pcm_lock);
1678 - return 0;
1679 - }
1680 + if (spec->dyn_pcm_assign && pin_idx < 0)
1681 + goto unlock;
1682
1683 if (snd_BUG_ON(pin_idx < 0)) {
1684 - mutex_unlock(&spec->pcm_lock);
1685 - return -EINVAL;
1686 + err = -EINVAL;
1687 + goto unlock;
1688 }
1689 per_pin = get_pin(spec, pin_idx);
1690
1691 @@ -1846,10 +1847,12 @@ static int hdmi_pcm_close(struct hda_pcm_stream *hinfo,
1692 per_pin->setup = false;
1693 per_pin->channels = 0;
1694 mutex_unlock(&per_pin->lock);
1695 - mutex_unlock(&spec->pcm_lock);
1696 }
1697
1698 - return 0;
1699 +unlock:
1700 + mutex_unlock(&spec->pcm_lock);
1701 +
1702 + return err;
1703 }
1704
1705 static const struct hda_pcm_ops generic_ops = {
1706 diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
1707 index fb4e1d2839c5f..cbbacc3467494 100644
1708 --- a/tools/perf/util/dwarf-aux.c
1709 +++ b/tools/perf/util/dwarf-aux.c
1710 @@ -329,6 +329,7 @@ bool die_is_func_def(Dwarf_Die *dw_die)
1711 int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
1712 {
1713 Dwarf_Addr base, end;
1714 + Dwarf_Attribute attr;
1715
1716 if (!addr)
1717 return -EINVAL;
1718 @@ -336,6 +337,13 @@ int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr)
1719 if (dwarf_entrypc(dw_die, addr) == 0)
1720 return 0;
1721
1722 + /*
1723 + * Since the dwarf_ranges() will return 0 if there is no
1724 + * DW_AT_ranges attribute, we should check it first.
1725 + */
1726 + if (!dwarf_attr(dw_die, DW_AT_ranges, &attr))
1727 + return -ENOENT;
1728 +
1729 return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0;
1730 }
1731
1732 diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
1733 index 2d5744d986f0b..659c41004322d 100644
1734 --- a/tools/perf/util/event.c
1735 +++ b/tools/perf/util/event.c
1736 @@ -682,11 +682,13 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
1737 int err;
1738 union perf_event *event;
1739
1740 - if (symbol_conf.kptr_restrict)
1741 - return -1;
1742 if (map == NULL)
1743 return -1;
1744
1745 + kmap = map__kmap(map);
1746 + if (!kmap->ref_reloc_sym)
1747 + return -1;
1748 +
1749 /*
1750 * We should get this from /sys/kernel/sections/.text, but till that is
1751 * available use this, and after it is use this as a fallback for older
1752 @@ -710,7 +712,6 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool,
1753 event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL;
1754 }
1755
1756 - kmap = map__kmap(map);
1757 size = snprintf(event->mmap.filename, sizeof(event->mmap.filename),
1758 "%s%s", mmap_name, kmap->ref_reloc_sym->name) + 1;
1759 size = PERF_ALIGN(size, sizeof(u64));