Magellan Linux

Contents of /trunk/kernel-alx-legacy/patches-4.9/0392-4.9.293-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3694 - (show annotations) (download)
Mon Oct 24 14:08:08 2022 UTC (18 months, 1 week ago) by niro
File size: 49247 byte(s)
-linux-4.9.293
1 diff --git a/Makefile b/Makefile
2 index 6e941bc98dbd3..a07a010095bc9 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,6 +1,6 @@
6 VERSION = 4
7 PATCHLEVEL = 9
8 -SUBLEVEL = 292
9 +SUBLEVEL = 293
10 EXTRAVERSION =
11 NAME = Roaring Lionus
12
13 diff --git a/block/ioprio.c b/block/ioprio.c
14 index 01b8116298a13..284bdfa3aacfc 100644
15 --- a/block/ioprio.c
16 +++ b/block/ioprio.c
17 @@ -202,6 +202,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
18 pgrp = task_pgrp(current);
19 else
20 pgrp = find_vpid(who);
21 + read_lock(&tasklist_lock);
22 do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
23 tmpio = get_task_ioprio(p);
24 if (tmpio < 0)
25 @@ -211,6 +212,8 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
26 else
27 ret = ioprio_best(ret, tmpio);
28 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
29 + read_unlock(&tasklist_lock);
30 +
31 break;
32 case IOPRIO_WHO_USER:
33 uid = make_kuid(current_user_ns(), who);
34 diff --git a/drivers/android/binder.c b/drivers/android/binder.c
35 index bf047f16fce9e..31a204ebfa6c5 100644
36 --- a/drivers/android/binder.c
37 +++ b/drivers/android/binder.c
38 @@ -2641,21 +2641,18 @@ static int binder_free_thread(struct binder_proc *proc,
39 }
40
41 /*
42 - * If this thread used poll, make sure we remove the waitqueue
43 - * from any epoll data structures holding it with POLLFREE.
44 - * waitqueue_active() is safe to use here because we're holding
45 - * the global lock.
46 + * If this thread used poll, make sure we remove the waitqueue from any
47 + * poll data structures holding it.
48 */
49 - if ((thread->looper & BINDER_LOOPER_STATE_POLL) &&
50 - waitqueue_active(&thread->wait)) {
51 - wake_up_poll(&thread->wait, POLLHUP | POLLFREE);
52 - }
53 + if (thread->looper & BINDER_LOOPER_STATE_POLL)
54 + wake_up_pollfree(&thread->wait);
55
56 /*
57 - * This is needed to avoid races between wake_up_poll() above and
58 - * and ep_remove_waitqueue() called for other reasons (eg the epoll file
59 - * descriptor being closed); ep_remove_waitqueue() holds an RCU read
60 - * lock, so we can be sure it's done after calling synchronize_rcu().
61 + * This is needed to avoid races between wake_up_pollfree() above and
62 + * someone else removing the last entry from the queue for other reasons
63 + * (e.g. ep_remove_wait_queue() being called due to an epoll file
64 + * descriptor being closed). Such other users hold an RCU read lock, so
65 + * we can be sure they're done after we call synchronize_rcu().
66 */
67 if (thread->looper & BINDER_LOOPER_STATE_POLL)
68 synchronize_rcu();
69 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
70 index d3804b215ffa6..a92cbe1aa72a2 100644
71 --- a/drivers/ata/libata-core.c
72 +++ b/drivers/ata/libata-core.c
73 @@ -4332,6 +4332,8 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
74 { "VRFDFC22048UCHC-TE*", NULL, ATA_HORKAGE_NODMA },
75 /* Odd clown on sil3726/4726 PMPs */
76 { "Config Disk", NULL, ATA_HORKAGE_DISABLE },
77 + /* Similar story with ASMedia 1092 */
78 + { "ASMT109x- Config", NULL, ATA_HORKAGE_DISABLE },
79
80 /* Weird ATAPI devices */
81 { "TORiSAN DVD-ROM DRD-N216", NULL, ATA_HORKAGE_MAX_SEC_128 },
82 diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
83 index 8eed456a67bed..2d2422705ccf7 100644
84 --- a/drivers/hid/Kconfig
85 +++ b/drivers/hid/Kconfig
86 @@ -176,14 +176,14 @@ config HID_CHERRY
87
88 config HID_CHICONY
89 tristate "Chicony devices"
90 - depends on HID
91 + depends on USB_HID
92 default !EXPERT
93 ---help---
94 Support for Chicony Tactical pad and special keys on Chicony keyboards.
95
96 config HID_CORSAIR
97 tristate "Corsair devices"
98 - depends on HID && USB && LEDS_CLASS
99 + depends on USB_HID && LEDS_CLASS
100 ---help---
101 Support for Corsair devices that are not fully compliant with the
102 HID standard.
103 @@ -194,7 +194,7 @@ config HID_CORSAIR
104
105 config HID_PRODIKEYS
106 tristate "Prodikeys PC-MIDI Keyboard support"
107 - depends on HID && SND
108 + depends on USB_HID && SND
109 select SND_RAWMIDI
110 ---help---
111 Support for Prodikeys PC-MIDI Keyboard device support.
112 @@ -421,7 +421,7 @@ config HID_LENOVO
113
114 config HID_LOGITECH
115 tristate "Logitech devices"
116 - depends on HID
117 + depends on USB_HID
118 default !EXPERT
119 ---help---
120 Support for Logitech devices that are not fully compliant with HID standard.
121 @@ -730,7 +730,7 @@ config HID_SAITEK
122
123 config HID_SAMSUNG
124 tristate "Samsung InfraRed remote control or keyboards"
125 - depends on HID
126 + depends on USB_HID
127 ---help---
128 Support for Samsung InfraRed remote control or keyboards.
129
130 diff --git a/drivers/hid/hid-chicony.c b/drivers/hid/hid-chicony.c
131 index f04ed9aabc3f9..f11948ddf642e 100644
132 --- a/drivers/hid/hid-chicony.c
133 +++ b/drivers/hid/hid-chicony.c
134 @@ -61,8 +61,12 @@ static int ch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
135 static __u8 *ch_switch12_report_fixup(struct hid_device *hdev, __u8 *rdesc,
136 unsigned int *rsize)
137 {
138 - struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
139 -
140 + struct usb_interface *intf;
141 +
142 + if (!hid_is_usb(hdev))
143 + return rdesc;
144 +
145 + intf = to_usb_interface(hdev->dev.parent);
146 if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
147 /* Change usage maximum and logical maximum from 0x7fff to
148 * 0x2fff, so they don't exceed HID_MAX_USAGES */
149 diff --git a/drivers/hid/hid-corsair.c b/drivers/hid/hid-corsair.c
150 index 9ba5d98a11804..d8cf08b6b31c6 100644
151 --- a/drivers/hid/hid-corsair.c
152 +++ b/drivers/hid/hid-corsair.c
153 @@ -553,7 +553,12 @@ static int corsair_probe(struct hid_device *dev, const struct hid_device_id *id)
154 int ret;
155 unsigned long quirks = id->driver_data;
156 struct corsair_drvdata *drvdata;
157 - struct usb_interface *usbif = to_usb_interface(dev->dev.parent);
158 + struct usb_interface *usbif;
159 +
160 + if (!hid_is_usb(dev))
161 + return -EINVAL;
162 +
163 + usbif = to_usb_interface(dev->dev.parent);
164
165 drvdata = devm_kzalloc(&dev->dev, sizeof(struct corsair_drvdata),
166 GFP_KERNEL);
167 diff --git a/drivers/hid/hid-elo.c b/drivers/hid/hid-elo.c
168 index 5eea6fe0d7bd8..c3ecac13e6203 100644
169 --- a/drivers/hid/hid-elo.c
170 +++ b/drivers/hid/hid-elo.c
171 @@ -230,6 +230,9 @@ static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
172 struct elo_priv *priv;
173 int ret;
174
175 + if (!hid_is_usb(hdev))
176 + return -EINVAL;
177 +
178 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
179 if (!priv)
180 return -ENOMEM;
181 diff --git a/drivers/hid/hid-holtek-kbd.c b/drivers/hid/hid-holtek-kbd.c
182 index ab9da597106fa..2f8eb66397444 100644
183 --- a/drivers/hid/hid-holtek-kbd.c
184 +++ b/drivers/hid/hid-holtek-kbd.c
185 @@ -143,12 +143,17 @@ static int holtek_kbd_input_event(struct input_dev *dev, unsigned int type,
186 static int holtek_kbd_probe(struct hid_device *hdev,
187 const struct hid_device_id *id)
188 {
189 - struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
190 - int ret = hid_parse(hdev);
191 + struct usb_interface *intf;
192 + int ret;
193 +
194 + if (!hid_is_usb(hdev))
195 + return -EINVAL;
196
197 + ret = hid_parse(hdev);
198 if (!ret)
199 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
200
201 + intf = to_usb_interface(hdev->dev.parent);
202 if (!ret && intf->cur_altsetting->desc.bInterfaceNumber == 1) {
203 struct hid_input *hidinput;
204 list_for_each_entry(hidinput, &hdev->inputs, list) {
205 diff --git a/drivers/hid/hid-holtek-mouse.c b/drivers/hid/hid-holtek-mouse.c
206 index 78b3a0c767751..27c08ddab0e1a 100644
207 --- a/drivers/hid/hid-holtek-mouse.c
208 +++ b/drivers/hid/hid-holtek-mouse.c
209 @@ -65,6 +65,14 @@ static __u8 *holtek_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
210 return rdesc;
211 }
212
213 +static int holtek_mouse_probe(struct hid_device *hdev,
214 + const struct hid_device_id *id)
215 +{
216 + if (!hid_is_usb(hdev))
217 + return -EINVAL;
218 + return 0;
219 +}
220 +
221 static const struct hid_device_id holtek_mouse_devices[] = {
222 { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT,
223 USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A067) },
224 @@ -86,6 +94,7 @@ static struct hid_driver holtek_mouse_driver = {
225 .name = "holtek_mouse",
226 .id_table = holtek_mouse_devices,
227 .report_fixup = holtek_mouse_report_fixup,
228 + .probe = holtek_mouse_probe,
229 };
230
231 module_hid_driver(holtek_mouse_driver);
232 diff --git a/drivers/hid/hid-lg.c b/drivers/hid/hid-lg.c
233 index 7e55d3f755dd5..f8d1d481c8384 100644
234 --- a/drivers/hid/hid-lg.c
235 +++ b/drivers/hid/hid-lg.c
236 @@ -714,12 +714,18 @@ static int lg_raw_event(struct hid_device *hdev, struct hid_report *report,
237
238 static int lg_probe(struct hid_device *hdev, const struct hid_device_id *id)
239 {
240 - struct usb_interface *iface = to_usb_interface(hdev->dev.parent);
241 - __u8 iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
242 + struct usb_interface *iface;
243 + __u8 iface_num;
244 unsigned int connect_mask = HID_CONNECT_DEFAULT;
245 struct lg_drv_data *drv_data;
246 int ret;
247
248 + if (!hid_is_usb(hdev))
249 + return -EINVAL;
250 +
251 + iface = to_usb_interface(hdev->dev.parent);
252 + iface_num = iface->cur_altsetting->desc.bInterfaceNumber;
253 +
254 /* G29 only work with the 1st interface */
255 if ((hdev->product == USB_DEVICE_ID_LOGITECH_G29_WHEEL) &&
256 (iface_num != 0)) {
257 diff --git a/drivers/hid/hid-prodikeys.c b/drivers/hid/hid-prodikeys.c
258 index 762f33817dd0d..7c3e42efbc567 100644
259 --- a/drivers/hid/hid-prodikeys.c
260 +++ b/drivers/hid/hid-prodikeys.c
261 @@ -803,12 +803,18 @@ static int pk_raw_event(struct hid_device *hdev, struct hid_report *report,
262 static int pk_probe(struct hid_device *hdev, const struct hid_device_id *id)
263 {
264 int ret;
265 - struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
266 - unsigned short ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
267 + struct usb_interface *intf;
268 + unsigned short ifnum;
269 unsigned long quirks = id->driver_data;
270 struct pk_device *pk;
271 struct pcmidi_snd *pm = NULL;
272
273 + if (!hid_is_usb(hdev))
274 + return -EINVAL;
275 +
276 + intf = to_usb_interface(hdev->dev.parent);
277 + ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
278 +
279 pk = kzalloc(sizeof(*pk), GFP_KERNEL);
280 if (pk == NULL) {
281 hid_err(hdev, "can't alloc descriptor\n");
282 diff --git a/drivers/hid/hid-roccat-arvo.c b/drivers/hid/hid-roccat-arvo.c
283 index 329c5d1270f94..fb545a11214f0 100644
284 --- a/drivers/hid/hid-roccat-arvo.c
285 +++ b/drivers/hid/hid-roccat-arvo.c
286 @@ -347,6 +347,9 @@ static int arvo_probe(struct hid_device *hdev,
287 {
288 int retval;
289
290 + if (!hid_is_usb(hdev))
291 + return -EINVAL;
292 +
293 retval = hid_parse(hdev);
294 if (retval) {
295 hid_err(hdev, "parse failed\n");
296 diff --git a/drivers/hid/hid-roccat-isku.c b/drivers/hid/hid-roccat-isku.c
297 index 02db537f8f3ea..c07a7ea8a6873 100644
298 --- a/drivers/hid/hid-roccat-isku.c
299 +++ b/drivers/hid/hid-roccat-isku.c
300 @@ -327,6 +327,9 @@ static int isku_probe(struct hid_device *hdev,
301 {
302 int retval;
303
304 + if (!hid_is_usb(hdev))
305 + return -EINVAL;
306 +
307 retval = hid_parse(hdev);
308 if (retval) {
309 hid_err(hdev, "parse failed\n");
310 diff --git a/drivers/hid/hid-roccat-kone.c b/drivers/hid/hid-roccat-kone.c
311 index 9be8c31f613fd..ef978586ff2f5 100644
312 --- a/drivers/hid/hid-roccat-kone.c
313 +++ b/drivers/hid/hid-roccat-kone.c
314 @@ -752,6 +752,9 @@ static int kone_probe(struct hid_device *hdev, const struct hid_device_id *id)
315 {
316 int retval;
317
318 + if (!hid_is_usb(hdev))
319 + return -EINVAL;
320 +
321 retval = hid_parse(hdev);
322 if (retval) {
323 hid_err(hdev, "parse failed\n");
324 diff --git a/drivers/hid/hid-roccat-koneplus.c b/drivers/hid/hid-roccat-koneplus.c
325 index 09e8fc72aa1d4..b63de4c5b5dd3 100644
326 --- a/drivers/hid/hid-roccat-koneplus.c
327 +++ b/drivers/hid/hid-roccat-koneplus.c
328 @@ -434,6 +434,9 @@ static int koneplus_probe(struct hid_device *hdev,
329 {
330 int retval;
331
332 + if (!hid_is_usb(hdev))
333 + return -EINVAL;
334 +
335 retval = hid_parse(hdev);
336 if (retval) {
337 hid_err(hdev, "parse failed\n");
338 diff --git a/drivers/hid/hid-roccat-konepure.c b/drivers/hid/hid-roccat-konepure.c
339 index 07de2f9014c67..ef9508822e5f0 100644
340 --- a/drivers/hid/hid-roccat-konepure.c
341 +++ b/drivers/hid/hid-roccat-konepure.c
342 @@ -136,6 +136,9 @@ static int konepure_probe(struct hid_device *hdev,
343 {
344 int retval;
345
346 + if (!hid_is_usb(hdev))
347 + return -EINVAL;
348 +
349 retval = hid_parse(hdev);
350 if (retval) {
351 hid_err(hdev, "parse failed\n");
352 diff --git a/drivers/hid/hid-roccat-kovaplus.c b/drivers/hid/hid-roccat-kovaplus.c
353 index 317c9c2c0a7ce..6256c211398a1 100644
354 --- a/drivers/hid/hid-roccat-kovaplus.c
355 +++ b/drivers/hid/hid-roccat-kovaplus.c
356 @@ -504,6 +504,9 @@ static int kovaplus_probe(struct hid_device *hdev,
357 {
358 int retval;
359
360 + if (!hid_is_usb(hdev))
361 + return -EINVAL;
362 +
363 retval = hid_parse(hdev);
364 if (retval) {
365 hid_err(hdev, "parse failed\n");
366 diff --git a/drivers/hid/hid-roccat-lua.c b/drivers/hid/hid-roccat-lua.c
367 index ac1a7313e2596..13ae2a7d176d3 100644
368 --- a/drivers/hid/hid-roccat-lua.c
369 +++ b/drivers/hid/hid-roccat-lua.c
370 @@ -163,6 +163,9 @@ static int lua_probe(struct hid_device *hdev,
371 {
372 int retval;
373
374 + if (!hid_is_usb(hdev))
375 + return -EINVAL;
376 +
377 retval = hid_parse(hdev);
378 if (retval) {
379 hid_err(hdev, "parse failed\n");
380 diff --git a/drivers/hid/hid-roccat-pyra.c b/drivers/hid/hid-roccat-pyra.c
381 index b30aa7b82bf87..027aa9d0ec1f2 100644
382 --- a/drivers/hid/hid-roccat-pyra.c
383 +++ b/drivers/hid/hid-roccat-pyra.c
384 @@ -452,6 +452,9 @@ static int pyra_probe(struct hid_device *hdev, const struct hid_device_id *id)
385 {
386 int retval;
387
388 + if (!hid_is_usb(hdev))
389 + return -EINVAL;
390 +
391 retval = hid_parse(hdev);
392 if (retval) {
393 hid_err(hdev, "parse failed\n");
394 diff --git a/drivers/hid/hid-roccat-ryos.c b/drivers/hid/hid-roccat-ryos.c
395 index 47cc8f30ff6d4..fda4a396a12e8 100644
396 --- a/drivers/hid/hid-roccat-ryos.c
397 +++ b/drivers/hid/hid-roccat-ryos.c
398 @@ -144,6 +144,9 @@ static int ryos_probe(struct hid_device *hdev,
399 {
400 int retval;
401
402 + if (!hid_is_usb(hdev))
403 + return -EINVAL;
404 +
405 retval = hid_parse(hdev);
406 if (retval) {
407 hid_err(hdev, "parse failed\n");
408 diff --git a/drivers/hid/hid-roccat-savu.c b/drivers/hid/hid-roccat-savu.c
409 index 6dbf6e04dce75..0230fb54f08a5 100644
410 --- a/drivers/hid/hid-roccat-savu.c
411 +++ b/drivers/hid/hid-roccat-savu.c
412 @@ -116,6 +116,9 @@ static int savu_probe(struct hid_device *hdev,
413 {
414 int retval;
415
416 + if (!hid_is_usb(hdev))
417 + return -EINVAL;
418 +
419 retval = hid_parse(hdev);
420 if (retval) {
421 hid_err(hdev, "parse failed\n");
422 diff --git a/drivers/hid/hid-samsung.c b/drivers/hid/hid-samsung.c
423 index 7cbb067d4a9e3..89bb2260367f3 100644
424 --- a/drivers/hid/hid-samsung.c
425 +++ b/drivers/hid/hid-samsung.c
426 @@ -157,6 +157,9 @@ static int samsung_probe(struct hid_device *hdev,
427 int ret;
428 unsigned int cmask = HID_CONNECT_DEFAULT;
429
430 + if (!hid_is_usb(hdev))
431 + return -EINVAL;
432 +
433 ret = hid_parse(hdev);
434 if (ret) {
435 hid_err(hdev, "parse failed\n");
436 diff --git a/drivers/hid/hid-uclogic.c b/drivers/hid/hid-uclogic.c
437 index 1509d7287ff3e..b3f2e40b1c5bd 100644
438 --- a/drivers/hid/hid-uclogic.c
439 +++ b/drivers/hid/hid-uclogic.c
440 @@ -791,6 +791,9 @@ static int uclogic_tablet_enable(struct hid_device *hdev)
441 __u8 *p;
442 s32 v;
443
444 + if (!hid_is_usb(hdev))
445 + return -EINVAL;
446 +
447 /*
448 * Read string descriptor containing tablet parameters. The specific
449 * string descriptor and data were discovered by sniffing the Windows
450 diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
451 index 800c477dd0761..518ccf15188ef 100644
452 --- a/drivers/hid/i2c-hid/i2c-hid-core.c
453 +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
454 @@ -875,7 +875,7 @@ static int i2c_hid_power(struct hid_device *hid, int lvl)
455 return 0;
456 }
457
458 -static struct hid_ll_driver i2c_hid_ll_driver = {
459 +struct hid_ll_driver i2c_hid_ll_driver = {
460 .parse = i2c_hid_parse,
461 .start = i2c_hid_start,
462 .stop = i2c_hid_stop,
463 @@ -885,6 +885,7 @@ static struct hid_ll_driver i2c_hid_ll_driver = {
464 .output_report = i2c_hid_output_report,
465 .raw_request = i2c_hid_raw_request,
466 };
467 +EXPORT_SYMBOL_GPL(i2c_hid_ll_driver);
468
469 static int i2c_hid_init_irq(struct i2c_client *client)
470 {
471 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
472 index 731a7b3e01870..e60e41e775020 100644
473 --- a/drivers/hid/uhid.c
474 +++ b/drivers/hid/uhid.c
475 @@ -372,7 +372,7 @@ static int uhid_hid_output_report(struct hid_device *hid, __u8 *buf,
476 return uhid_hid_output_raw(hid, buf, count, HID_OUTPUT_REPORT);
477 }
478
479 -static struct hid_ll_driver uhid_hid_driver = {
480 +struct hid_ll_driver uhid_hid_driver = {
481 .start = uhid_hid_start,
482 .stop = uhid_hid_stop,
483 .open = uhid_hid_open,
484 @@ -381,6 +381,7 @@ static struct hid_ll_driver uhid_hid_driver = {
485 .raw_request = uhid_hid_raw_request,
486 .output_report = uhid_hid_output_report,
487 };
488 +EXPORT_SYMBOL_GPL(uhid_hid_driver);
489
490 #ifdef CONFIG_COMPAT
491
492 diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
493 index 368f849decd1f..cb57ccff31c20 100644
494 --- a/drivers/hid/usbhid/hid-core.c
495 +++ b/drivers/hid/usbhid/hid-core.c
496 @@ -1272,7 +1272,7 @@ static int usbhid_idle(struct hid_device *hid, int report, int idle,
497 return hid_set_idle(dev, ifnum, report, idle);
498 }
499
500 -static struct hid_ll_driver usb_hid_driver = {
501 +struct hid_ll_driver usb_hid_driver = {
502 .parse = usbhid_parse,
503 .start = usbhid_start,
504 .stop = usbhid_stop,
505 @@ -1285,6 +1285,7 @@ static struct hid_ll_driver usb_hid_driver = {
506 .output_report = usbhid_output_report,
507 .idle = usbhid_idle,
508 };
509 +EXPORT_SYMBOL_GPL(usb_hid_driver);
510
511 static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *id)
512 {
513 diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
514 index e8b90b534f08e..b74fcda49a223 100644
515 --- a/drivers/hid/wacom_sys.c
516 +++ b/drivers/hid/wacom_sys.c
517 @@ -506,7 +506,7 @@ static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
518 * Skip the query for this type and modify defaults based on
519 * interface number.
520 */
521 - if (features->type == WIRELESS) {
522 + if (features->type == WIRELESS && intf) {
523 if (intf->cur_altsetting->desc.bInterfaceNumber == 0)
524 features->device_type = WACOM_DEVICETYPE_WL_MONITOR;
525 else
526 @@ -2115,6 +2115,9 @@ static void wacom_wireless_work(struct work_struct *work)
527
528 wacom_destroy_battery(wacom);
529
530 + if (!usbdev)
531 + return;
532 +
533 /* Stylus interface */
534 hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
535 wacom1 = hid_get_drvdata(hdev1);
536 @@ -2354,8 +2357,6 @@ static void wacom_remote_work(struct work_struct *work)
537 static int wacom_probe(struct hid_device *hdev,
538 const struct hid_device_id *id)
539 {
540 - struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
541 - struct usb_device *dev = interface_to_usbdev(intf);
542 struct wacom *wacom;
543 struct wacom_wac *wacom_wac;
544 struct wacom_features *features;
545 @@ -2388,8 +2389,14 @@ static int wacom_probe(struct hid_device *hdev,
546 wacom_wac->hid_data.inputmode = -1;
547 wacom_wac->mode_report = -1;
548
549 - wacom->usbdev = dev;
550 - wacom->intf = intf;
551 + if (hid_is_usb(hdev)) {
552 + struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
553 + struct usb_device *dev = interface_to_usbdev(intf);
554 +
555 + wacom->usbdev = dev;
556 + wacom->intf = intf;
557 + }
558 +
559 mutex_init(&wacom->lock);
560 INIT_WORK(&wacom->wireless_work, wacom_wireless_work);
561 INIT_WORK(&wacom->battery_work, wacom_battery_work);
562 diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
563 index 626a605a0c0e6..799457aa36020 100644
564 --- a/drivers/iio/accel/kxcjk-1013.c
565 +++ b/drivers/iio/accel/kxcjk-1013.c
566 @@ -1290,8 +1290,7 @@ static int kxcjk1013_probe(struct i2c_client *client,
567 return 0;
568
569 err_buffer_cleanup:
570 - if (data->dready_trig)
571 - iio_triggered_buffer_cleanup(indio_dev);
572 + iio_triggered_buffer_cleanup(indio_dev);
573 err_trigger_unregister:
574 if (data->dready_trig)
575 iio_trigger_unregister(data->dready_trig);
576 @@ -1314,8 +1313,8 @@ static int kxcjk1013_remove(struct i2c_client *client)
577 pm_runtime_set_suspended(&client->dev);
578 pm_runtime_put_noidle(&client->dev);
579
580 + iio_triggered_buffer_cleanup(indio_dev);
581 if (data->dready_trig) {
582 - iio_triggered_buffer_cleanup(indio_dev);
583 iio_trigger_unregister(data->dready_trig);
584 iio_trigger_unregister(data->motion_trig);
585 }
586 diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
587 index 1bda730a71c0b..c3ac798083f4f 100644
588 --- a/drivers/iio/accel/kxsd9.c
589 +++ b/drivers/iio/accel/kxsd9.c
590 @@ -227,14 +227,14 @@ static irqreturn_t kxsd9_trigger_handler(int irq, void *p)
591 hw_values.chan,
592 sizeof(hw_values.chan));
593 if (ret) {
594 - dev_err(st->dev,
595 - "error reading data\n");
596 - return ret;
597 + dev_err(st->dev, "error reading data: %d\n", ret);
598 + goto out;
599 }
600
601 iio_push_to_buffers_with_timestamp(indio_dev,
602 &hw_values,
603 iio_get_time_ns(indio_dev));
604 +out:
605 iio_trigger_notify_done(indio_dev->trig);
606
607 return IRQ_HANDLED;
608 diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
609 index 90d4179e8c3de..0346c37b1e285 100644
610 --- a/drivers/iio/accel/mma8452.c
611 +++ b/drivers/iio/accel/mma8452.c
612 @@ -1389,7 +1389,7 @@ static int mma8452_trigger_setup(struct iio_dev *indio_dev)
613 if (ret)
614 return ret;
615
616 - indio_dev->trig = trig;
617 + indio_dev->trig = iio_trigger_get(trig);
618
619 return 0;
620 }
621 diff --git a/drivers/iio/gyro/itg3200_buffer.c b/drivers/iio/gyro/itg3200_buffer.c
622 index e04483254b283..7157b1a731a60 100644
623 --- a/drivers/iio/gyro/itg3200_buffer.c
624 +++ b/drivers/iio/gyro/itg3200_buffer.c
625 @@ -64,9 +64,9 @@ static irqreturn_t itg3200_trigger_handler(int irq, void *p)
626
627 iio_push_to_buffers_with_timestamp(indio_dev, &scan, pf->timestamp);
628
629 +error_ret:
630 iio_trigger_notify_done(indio_dev->trig);
631
632 -error_ret:
633 return IRQ_HANDLED;
634 }
635
636 diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
637 index 414fe857fa9d7..5e3cbb694a753 100644
638 --- a/drivers/iio/light/ltr501.c
639 +++ b/drivers/iio/light/ltr501.c
640 @@ -1248,7 +1248,7 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
641 ret = regmap_bulk_read(data->regmap, LTR501_ALS_DATA1,
642 (u8 *)als_buf, sizeof(als_buf));
643 if (ret < 0)
644 - return ret;
645 + goto done;
646 if (test_bit(0, indio_dev->active_scan_mask))
647 scan.channels[j++] = le16_to_cpu(als_buf[1]);
648 if (test_bit(1, indio_dev->active_scan_mask))
649 diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
650 index 45cf8b0a43637..ed9cf1ffec7bc 100644
651 --- a/drivers/iio/light/stk3310.c
652 +++ b/drivers/iio/light/stk3310.c
653 @@ -546,9 +546,8 @@ static irqreturn_t stk3310_irq_event_handler(int irq, void *private)
654 mutex_lock(&data->lock);
655 ret = regmap_field_read(data->reg_flag_nf, &dir);
656 if (ret < 0) {
657 - dev_err(&data->client->dev, "register read failed\n");
658 - mutex_unlock(&data->lock);
659 - return ret;
660 + dev_err(&data->client->dev, "register read failed: %d\n", ret);
661 + goto out;
662 }
663 event = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1,
664 IIO_EV_TYPE_THRESH,
665 @@ -560,6 +559,7 @@ static irqreturn_t stk3310_irq_event_handler(int irq, void *private)
666 ret = regmap_field_write(data->reg_flag_psint, 0);
667 if (ret < 0)
668 dev_err(&data->client->dev, "failed to reset interrupts\n");
669 +out:
670 mutex_unlock(&data->lock);
671
672 return IRQ_HANDLED;
673 diff --git a/drivers/infiniband/hw/hfi1/init.c b/drivers/infiniband/hw/hfi1/init.c
674 index 9dc8cf096e2ea..93ace2609bdd1 100644
675 --- a/drivers/infiniband/hw/hfi1/init.c
676 +++ b/drivers/infiniband/hw/hfi1/init.c
677 @@ -955,7 +955,7 @@ void hfi1_free_ctxtdata(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd)
678 kfree(rcd->egrbufs.rcvtids);
679
680 for (e = 0; e < rcd->egrbufs.alloced; e++) {
681 - if (rcd->egrbufs.buffers[e].dma)
682 + if (rcd->egrbufs.buffers[e].addr)
683 dma_free_coherent(&dd->pcidev->dev,
684 rcd->egrbufs.buffers[e].len,
685 rcd->egrbufs.buffers[e].addr,
686 diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
687 index 8bcee65a0b8c9..ace01a626b098 100644
688 --- a/drivers/irqchip/irq-armada-370-xp.c
689 +++ b/drivers/irqchip/irq-armada-370-xp.c
690 @@ -153,16 +153,12 @@ static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
691 int hwirq, i;
692
693 mutex_lock(&msi_used_lock);
694 + hwirq = bitmap_find_free_region(msi_used, PCI_MSI_DOORBELL_NR,
695 + order_base_2(nr_irqs));
696 + mutex_unlock(&msi_used_lock);
697
698 - hwirq = bitmap_find_next_zero_area(msi_used, PCI_MSI_DOORBELL_NR,
699 - 0, nr_irqs, 0);
700 - if (hwirq >= PCI_MSI_DOORBELL_NR) {
701 - mutex_unlock(&msi_used_lock);
702 + if (hwirq < 0)
703 return -ENOSPC;
704 - }
705 -
706 - bitmap_set(msi_used, hwirq, nr_irqs);
707 - mutex_unlock(&msi_used_lock);
708
709 for (i = 0; i < nr_irqs; i++) {
710 irq_domain_set_info(domain, virq + i, hwirq + i,
711 @@ -171,7 +167,7 @@ static int armada_370_xp_msi_alloc(struct irq_domain *domain, unsigned int virq,
712 NULL, NULL);
713 }
714
715 - return hwirq;
716 + return 0;
717 }
718
719 static void armada_370_xp_msi_free(struct irq_domain *domain,
720 @@ -180,7 +176,7 @@ static void armada_370_xp_msi_free(struct irq_domain *domain,
721 struct irq_data *d = irq_domain_get_irq_data(domain, virq);
722
723 mutex_lock(&msi_used_lock);
724 - bitmap_clear(msi_used, d->hwirq, nr_irqs);
725 + bitmap_release_region(msi_used, d->hwirq, order_base_2(nr_irqs));
726 mutex_unlock(&msi_used_lock);
727 }
728
729 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c
730 index d1efbb8dadc53..a964e381cbb81 100644
731 --- a/drivers/irqchip/irq-gic-v3-its.c
732 +++ b/drivers/irqchip/irq-gic-v3-its.c
733 @@ -369,7 +369,7 @@ static struct its_collection *its_build_invall_cmd(struct its_cmd_block *cmd,
734
735 its_fixup_cmd(cmd);
736
737 - return NULL;
738 + return desc->its_invall_cmd.col;
739 }
740
741 static u64 its_cmd_ptr_to_offset(struct its_node *its,
742 diff --git a/drivers/irqchip/irq-nvic.c b/drivers/irqchip/irq-nvic.c
743 index b1777104fd9fe..9694529b709de 100644
744 --- a/drivers/irqchip/irq-nvic.c
745 +++ b/drivers/irqchip/irq-nvic.c
746 @@ -29,7 +29,7 @@
747
748 #define NVIC_ISER 0x000
749 #define NVIC_ICER 0x080
750 -#define NVIC_IPR 0x300
751 +#define NVIC_IPR 0x400
752
753 #define NVIC_MAX_BANKS 16
754 /*
755 diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
756 index c1317889d3d8d..ced11ea892698 100644
757 --- a/drivers/net/can/pch_can.c
758 +++ b/drivers/net/can/pch_can.c
759 @@ -703,11 +703,11 @@ static int pch_can_rx_normal(struct net_device *ndev, u32 obj_num, int quota)
760 cf->data[i + 1] = data_reg >> 8;
761 }
762
763 - netif_receive_skb(skb);
764 rcv_pkts++;
765 stats->rx_packets++;
766 quota--;
767 stats->rx_bytes += cf->can_dlc;
768 + netif_receive_skb(skb);
769
770 pch_fifo_thresh(priv, obj_num);
771 obj_num++;
772 diff --git a/drivers/net/can/sja1000/ems_pcmcia.c b/drivers/net/can/sja1000/ems_pcmcia.c
773 index 381de998d2f16..fef5c59c0f4ca 100644
774 --- a/drivers/net/can/sja1000/ems_pcmcia.c
775 +++ b/drivers/net/can/sja1000/ems_pcmcia.c
776 @@ -243,7 +243,12 @@ static int ems_pcmcia_add_card(struct pcmcia_device *pdev, unsigned long base)
777 free_sja1000dev(dev);
778 }
779
780 - err = request_irq(dev->irq, &ems_pcmcia_interrupt, IRQF_SHARED,
781 + if (!card->channels) {
782 + err = -ENODEV;
783 + goto failure_cleanup;
784 + }
785 +
786 + err = request_irq(pdev->irq, &ems_pcmcia_interrupt, IRQF_SHARED,
787 DRV_NAME, card);
788 if (!err)
789 return 0;
790 diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
791 index e306342506f1f..e02b99f77b1ca 100644
792 --- a/drivers/net/ethernet/altera/altera_tse_main.c
793 +++ b/drivers/net/ethernet/altera/altera_tse_main.c
794 @@ -1361,16 +1361,19 @@ static int altera_tse_probe(struct platform_device *pdev)
795 priv->rxdescmem_busaddr = dma_res->start;
796
797 } else {
798 + ret = -ENODEV;
799 goto err_free_netdev;
800 }
801
802 - if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask)))
803 + if (!dma_set_mask(priv->device, DMA_BIT_MASK(priv->dmaops->dmamask))) {
804 dma_set_coherent_mask(priv->device,
805 DMA_BIT_MASK(priv->dmaops->dmamask));
806 - else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32)))
807 + } else if (!dma_set_mask(priv->device, DMA_BIT_MASK(32))) {
808 dma_set_coherent_mask(priv->device, DMA_BIT_MASK(32));
809 - else
810 + } else {
811 + ret = -EIO;
812 goto err_free_netdev;
813 + }
814
815 /* MAC address space */
816 ret = request_and_map(pdev, "control_port", &control_port,
817 diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
818 index 5ea740b4cf14c..b4e23ab108527 100644
819 --- a/drivers/net/ethernet/freescale/fec.h
820 +++ b/drivers/net/ethernet/freescale/fec.h
821 @@ -371,6 +371,9 @@ struct bufdesc_ex {
822 #define FEC_ENET_WAKEUP ((uint)0x00020000) /* Wakeup request */
823 #define FEC_ENET_TXF (FEC_ENET_TXF_0 | FEC_ENET_TXF_1 | FEC_ENET_TXF_2)
824 #define FEC_ENET_RXF (FEC_ENET_RXF_0 | FEC_ENET_RXF_1 | FEC_ENET_RXF_2)
825 +#define FEC_ENET_RXF_GET(X) (((X) == 0) ? FEC_ENET_RXF_0 : \
826 + (((X) == 1) ? FEC_ENET_RXF_1 : \
827 + FEC_ENET_RXF_2))
828 #define FEC_ENET_TS_AVAIL ((uint)0x00010000)
829 #define FEC_ENET_TS_TIMER ((uint)0x00008000)
830
831 diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
832 index 5fc40f025d214..c06ac5f66a17c 100644
833 --- a/drivers/net/ethernet/freescale/fec_main.c
834 +++ b/drivers/net/ethernet/freescale/fec_main.c
835 @@ -1380,7 +1380,7 @@ fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id)
836 break;
837 pkt_received++;
838
839 - writel(FEC_ENET_RXF, fep->hwp + FEC_IEVENT);
840 + writel(FEC_ENET_RXF_GET(queue_id), fep->hwp + FEC_IEVENT);
841
842 /* Check for errors. */
843 status ^= BD_ENET_RX_LAST;
844 diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
845 index cb9d43c871c4c..147effc16316f 100644
846 --- a/drivers/net/ethernet/qlogic/qla3xxx.c
847 +++ b/drivers/net/ethernet/qlogic/qla3xxx.c
848 @@ -3491,20 +3491,19 @@ static int ql_adapter_up(struct ql3_adapter *qdev)
849
850 spin_lock_irqsave(&qdev->hw_lock, hw_flags);
851
852 - err = ql_wait_for_drvr_lock(qdev);
853 - if (err) {
854 - err = ql_adapter_initialize(qdev);
855 - if (err) {
856 - netdev_err(ndev, "Unable to initialize adapter\n");
857 - goto err_init;
858 - }
859 - netdev_err(ndev, "Releasing driver lock\n");
860 - ql_sem_unlock(qdev, QL_DRVR_SEM_MASK);
861 - } else {
862 + if (!ql_wait_for_drvr_lock(qdev)) {
863 netdev_err(ndev, "Could not acquire driver lock\n");
864 + err = -ENODEV;
865 goto err_lock;
866 }
867
868 + err = ql_adapter_initialize(qdev);
869 + if (err) {
870 + netdev_err(ndev, "Unable to initialize adapter\n");
871 + goto err_init;
872 + }
873 + ql_sem_unlock(qdev, QL_DRVR_SEM_MASK);
874 +
875 spin_unlock_irqrestore(&qdev->hw_lock, hw_flags);
876
877 set_bit(QL_ADAPTER_UP, &qdev->flags);
878 diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
879 index 5a5db2f09f788..8ed525a063cfb 100644
880 --- a/drivers/net/usb/cdc_ncm.c
881 +++ b/drivers/net/usb/cdc_ncm.c
882 @@ -175,6 +175,8 @@ static u32 cdc_ncm_check_tx_max(struct usbnet *dev, u32 new_tx)
883 /* clamp new_tx to sane values */
884 min = ctx->max_datagram_size + ctx->max_ndp_size + sizeof(struct usb_cdc_ncm_nth16);
885 max = min_t(u32, CDC_NCM_NTB_MAX_SIZE_TX, le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
886 + if (max == 0)
887 + max = CDC_NCM_NTB_MAX_SIZE_TX; /* dwNtbOutMaxSize not set */
888
889 /* some devices set dwNtbOutMaxSize too low for the above default */
890 min = min(min, max);
891 diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
892 index 34081f03b1f56..fc55f7e31c4b2 100644
893 --- a/drivers/usb/core/config.c
894 +++ b/drivers/usb/core/config.c
895 @@ -404,7 +404,7 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
896 * the USB-2 spec requires such endpoints to have wMaxPacketSize = 0
897 * (see the end of section 5.6.3), so don't warn about them.
898 */
899 - maxp = usb_endpoint_maxp(&endpoint->desc);
900 + maxp = le16_to_cpu(endpoint->desc.wMaxPacketSize);
901 if (maxp == 0 && !(usb_endpoint_xfer_isoc(d) && asnum == 0)) {
902 dev_warn(ddev, "config %d interface %d altsetting %d endpoint 0x%X has invalid wMaxPacketSize 0\n",
903 cfgno, inum, asnum, d->bEndpointAddress);
904 @@ -420,9 +420,9 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno,
905 maxpacket_maxes = full_speed_maxpacket_maxes;
906 break;
907 case USB_SPEED_HIGH:
908 - /* Bits 12..11 are allowed only for HS periodic endpoints */
909 + /* Multiple-transactions bits are allowed only for HS periodic endpoints */
910 if (usb_endpoint_xfer_int(d) || usb_endpoint_xfer_isoc(d)) {
911 - i = maxp & (BIT(12) | BIT(11));
912 + i = maxp & USB_EP_MAXP_MULT_MASK;
913 maxp &= ~i;
914 }
915 /* fallthrough */
916 diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
917 index 438efa36552c8..3d14a316830a6 100644
918 --- a/drivers/usb/gadget/composite.c
919 +++ b/drivers/usb/gadget/composite.c
920 @@ -1631,6 +1631,18 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
921 struct usb_function *f = NULL;
922 u8 endp;
923
924 + if (w_length > USB_COMP_EP0_BUFSIZ) {
925 + if (ctrl->bRequestType == USB_DIR_OUT) {
926 + goto done;
927 + } else {
928 + /* Cast away the const, we are going to overwrite on purpose. */
929 + __le16 *temp = (__le16 *)&ctrl->wLength;
930 +
931 + *temp = cpu_to_le16(USB_COMP_EP0_BUFSIZ);
932 + w_length = USB_COMP_EP0_BUFSIZ;
933 + }
934 + }
935 +
936 /* partial re-init of the response message; the function or the
937 * gadget might need to intercept e.g. a control-OUT completion
938 * when we delegate to it.
939 @@ -2171,7 +2183,7 @@ int composite_dev_prepare(struct usb_composite_driver *composite,
940 if (!cdev->req)
941 return -ENOMEM;
942
943 - cdev->req->buf = kmalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
944 + cdev->req->buf = kzalloc(USB_COMP_EP0_BUFSIZ, GFP_KERNEL);
945 if (!cdev->req->buf)
946 goto fail;
947
948 diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
949 index 99ca3dabc4f34..f1c5a22704b28 100644
950 --- a/drivers/usb/gadget/legacy/dbgp.c
951 +++ b/drivers/usb/gadget/legacy/dbgp.c
952 @@ -136,7 +136,7 @@ static int dbgp_enable_ep_req(struct usb_ep *ep)
953 goto fail_1;
954 }
955
956 - req->buf = kmalloc(DBGP_REQ_LEN, GFP_KERNEL);
957 + req->buf = kzalloc(DBGP_REQ_LEN, GFP_KERNEL);
958 if (!req->buf) {
959 err = -ENOMEM;
960 stp = 2;
961 @@ -344,6 +344,19 @@ static int dbgp_setup(struct usb_gadget *gadget,
962 void *data = NULL;
963 u16 len = 0;
964
965 + if (length > DBGP_REQ_LEN) {
966 + if (ctrl->bRequestType == USB_DIR_OUT) {
967 + return err;
968 + } else {
969 + /* Cast away the const, we are going to overwrite on purpose. */
970 + __le16 *temp = (__le16 *)&ctrl->wLength;
971 +
972 + *temp = cpu_to_le16(DBGP_REQ_LEN);
973 + length = DBGP_REQ_LEN;
974 + }
975 + }
976 +
977 +
978 if (request == USB_REQ_GET_DESCRIPTOR) {
979 switch (value>>8) {
980 case USB_DT_DEVICE:
981 diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
982 index de0f3c2c9f6f3..d39bd1a1ab8fc 100644
983 --- a/drivers/usb/gadget/legacy/inode.c
984 +++ b/drivers/usb/gadget/legacy/inode.c
985 @@ -113,6 +113,8 @@ enum ep0_state {
986 /* enough for the whole queue: most events invalidate others */
987 #define N_EVENT 5
988
989 +#define RBUF_SIZE 256
990 +
991 struct dev_data {
992 spinlock_t lock;
993 atomic_t count;
994 @@ -147,7 +149,7 @@ struct dev_data {
995 struct dentry *dentry;
996
997 /* except this scratch i/o buffer for ep0 */
998 - u8 rbuf [256];
999 + u8 rbuf[RBUF_SIZE];
1000 };
1001
1002 static inline void get_dev (struct dev_data *data)
1003 @@ -1336,6 +1338,18 @@ gadgetfs_setup (struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
1004 u16 w_value = le16_to_cpu(ctrl->wValue);
1005 u16 w_length = le16_to_cpu(ctrl->wLength);
1006
1007 + if (w_length > RBUF_SIZE) {
1008 + if (ctrl->bRequestType == USB_DIR_OUT) {
1009 + return value;
1010 + } else {
1011 + /* Cast away the const, we are going to overwrite on purpose. */
1012 + __le16 *temp = (__le16 *)&ctrl->wLength;
1013 +
1014 + *temp = cpu_to_le16(RBUF_SIZE);
1015 + w_length = RBUF_SIZE;
1016 + }
1017 + }
1018 +
1019 spin_lock (&dev->lock);
1020 dev->setup_abort = 0;
1021 if (dev->state == STATE_DEV_UNCONNECTED) {
1022 diff --git a/fs/signalfd.c b/fs/signalfd.c
1023 index 270221fcef42c..9c5fa0ab5e0fe 100644
1024 --- a/fs/signalfd.c
1025 +++ b/fs/signalfd.c
1026 @@ -34,17 +34,7 @@
1027
1028 void signalfd_cleanup(struct sighand_struct *sighand)
1029 {
1030 - wait_queue_head_t *wqh = &sighand->signalfd_wqh;
1031 - /*
1032 - * The lockless check can race with remove_wait_queue() in progress,
1033 - * but in this case its caller should run under rcu_read_lock() and
1034 - * sighand_cachep is SLAB_DESTROY_BY_RCU, we can safely return.
1035 - */
1036 - if (likely(!waitqueue_active(wqh)))
1037 - return;
1038 -
1039 - /* wait_queue_t->func(POLLFREE) should do remove_wait_queue() */
1040 - wake_up_poll(wqh, POLLHUP | POLLFREE);
1041 + wake_up_pollfree(&sighand->signalfd_wqh);
1042 }
1043
1044 struct signalfd_ctx {
1045 diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
1046 index 985cccfcedad9..e00594ad99724 100644
1047 --- a/fs/tracefs/inode.c
1048 +++ b/fs/tracefs/inode.c
1049 @@ -162,6 +162,77 @@ struct tracefs_fs_info {
1050 struct tracefs_mount_opts mount_opts;
1051 };
1052
1053 +static void change_gid(struct dentry *dentry, kgid_t gid)
1054 +{
1055 + if (!dentry->d_inode)
1056 + return;
1057 + dentry->d_inode->i_gid = gid;
1058 +}
1059 +
1060 +/*
1061 + * Taken from d_walk, but without he need for handling renames.
1062 + * Nothing can be renamed while walking the list, as tracefs
1063 + * does not support renames. This is only called when mounting
1064 + * or remounting the file system, to set all the files to
1065 + * the given gid.
1066 + */
1067 +static void set_gid(struct dentry *parent, kgid_t gid)
1068 +{
1069 + struct dentry *this_parent;
1070 + struct list_head *next;
1071 +
1072 + this_parent = parent;
1073 + spin_lock(&this_parent->d_lock);
1074 +
1075 + change_gid(this_parent, gid);
1076 +repeat:
1077 + next = this_parent->d_subdirs.next;
1078 +resume:
1079 + while (next != &this_parent->d_subdirs) {
1080 + struct list_head *tmp = next;
1081 + struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
1082 + next = tmp->next;
1083 +
1084 + spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
1085 +
1086 + change_gid(dentry, gid);
1087 +
1088 + if (!list_empty(&dentry->d_subdirs)) {
1089 + spin_unlock(&this_parent->d_lock);
1090 + spin_release(&dentry->d_lock.dep_map, 1, _RET_IP_);
1091 + this_parent = dentry;
1092 + spin_acquire(&this_parent->d_lock.dep_map, 0, 1, _RET_IP_);
1093 + goto repeat;
1094 + }
1095 + spin_unlock(&dentry->d_lock);
1096 + }
1097 + /*
1098 + * All done at this level ... ascend and resume the search.
1099 + */
1100 + rcu_read_lock();
1101 +ascend:
1102 + if (this_parent != parent) {
1103 + struct dentry *child = this_parent;
1104 + this_parent = child->d_parent;
1105 +
1106 + spin_unlock(&child->d_lock);
1107 + spin_lock(&this_parent->d_lock);
1108 +
1109 + /* go into the first sibling still alive */
1110 + do {
1111 + next = child->d_child.next;
1112 + if (next == &this_parent->d_subdirs)
1113 + goto ascend;
1114 + child = list_entry(next, struct dentry, d_child);
1115 + } while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED));
1116 + rcu_read_unlock();
1117 + goto resume;
1118 + }
1119 + rcu_read_unlock();
1120 + spin_unlock(&this_parent->d_lock);
1121 + return;
1122 +}
1123 +
1124 static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
1125 {
1126 substring_t args[MAX_OPT_ARGS];
1127 @@ -194,6 +265,7 @@ static int tracefs_parse_options(char *data, struct tracefs_mount_opts *opts)
1128 if (!gid_valid(gid))
1129 return -EINVAL;
1130 opts->gid = gid;
1131 + set_gid(tracefs_mount->mnt_root, gid);
1132 break;
1133 case Opt_mode:
1134 if (match_octal(&args[0], &option))
1135 @@ -411,6 +483,8 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode,
1136 inode->i_mode = mode;
1137 inode->i_fop = fops ? fops : &tracefs_file_operations;
1138 inode->i_private = data;
1139 + inode->i_uid = d_inode(dentry->d_parent)->i_uid;
1140 + inode->i_gid = d_inode(dentry->d_parent)->i_gid;
1141 d_instantiate(dentry, inode);
1142 fsnotify_create(dentry->d_parent->d_inode, dentry);
1143 return end_creating(dentry);
1144 @@ -433,6 +507,8 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent,
1145 inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP;
1146 inode->i_op = ops;
1147 inode->i_fop = &simple_dir_operations;
1148 + inode->i_uid = d_inode(dentry->d_parent)->i_uid;
1149 + inode->i_gid = d_inode(dentry->d_parent)->i_gid;
1150
1151 /* directory inodes start off with i_nlink == 2 (for "." entry) */
1152 inc_nlink(inode);
1153 diff --git a/include/linux/hid.h b/include/linux/hid.h
1154 index 2ed6850356ead..a07fa623fd0c2 100644
1155 --- a/include/linux/hid.h
1156 +++ b/include/linux/hid.h
1157 @@ -762,6 +762,22 @@ struct hid_ll_driver {
1158 int (*idle)(struct hid_device *hdev, int report, int idle, int reqtype);
1159 };
1160
1161 +extern struct hid_ll_driver i2c_hid_ll_driver;
1162 +extern struct hid_ll_driver hidp_hid_driver;
1163 +extern struct hid_ll_driver uhid_hid_driver;
1164 +extern struct hid_ll_driver usb_hid_driver;
1165 +
1166 +static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
1167 + struct hid_ll_driver *driver)
1168 +{
1169 + return hdev->ll_driver == driver;
1170 +}
1171 +
1172 +static inline bool hid_is_usb(struct hid_device *hdev)
1173 +{
1174 + return hid_is_using_ll_driver(hdev, &usb_hid_driver);
1175 +}
1176 +
1177 #define PM_HINT_FULLON 1<<5
1178 #define PM_HINT_NORMAL 1<<1
1179
1180 diff --git a/include/linux/wait.h b/include/linux/wait.h
1181 index 2408e8d5c05cc..e022ee95bd45c 100644
1182 --- a/include/linux/wait.h
1183 +++ b/include/linux/wait.h
1184 @@ -202,6 +202,7 @@ void __wake_up_locked_key(wait_queue_head_t *q, unsigned int mode, void *key);
1185 void __wake_up_sync_key(wait_queue_head_t *q, unsigned int mode, int nr, void *key);
1186 void __wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr);
1187 void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr);
1188 +void __wake_up_pollfree(wait_queue_head_t *wq_head);
1189 void __wake_up_bit(wait_queue_head_t *, void *, int);
1190 int __wait_on_bit(wait_queue_head_t *, struct wait_bit_queue *, wait_bit_action_f *, unsigned);
1191 int __wait_on_bit_lock(wait_queue_head_t *, struct wait_bit_queue *, wait_bit_action_f *, unsigned);
1192 @@ -236,6 +237,31 @@ wait_queue_head_t *bit_waitqueue(void *, int);
1193 #define wake_up_interruptible_sync_poll(x, m) \
1194 __wake_up_sync_key((x), TASK_INTERRUPTIBLE, 1, (void *) (m))
1195
1196 +/**
1197 + * wake_up_pollfree - signal that a polled waitqueue is going away
1198 + * @wq_head: the wait queue head
1199 + *
1200 + * In the very rare cases where a ->poll() implementation uses a waitqueue whose
1201 + * lifetime is tied to a task rather than to the 'struct file' being polled,
1202 + * this function must be called before the waitqueue is freed so that
1203 + * non-blocking polls (e.g. epoll) are notified that the queue is going away.
1204 + *
1205 + * The caller must also RCU-delay the freeing of the wait_queue_head, e.g. via
1206 + * an explicit synchronize_rcu() or call_rcu(), or via SLAB_DESTROY_BY_RCU.
1207 + */
1208 +static inline void wake_up_pollfree(wait_queue_head_t *wq_head)
1209 +{
1210 + /*
1211 + * For performance reasons, we don't always take the queue lock here.
1212 + * Therefore, we might race with someone removing the last entry from
1213 + * the queue, and proceed while they still hold the queue lock.
1214 + * However, rcu_read_lock() is required to be held in such cases, so we
1215 + * can safely proceed with an RCU-delayed free.
1216 + */
1217 + if (waitqueue_active(wq_head))
1218 + __wake_up_pollfree(wq_head);
1219 +}
1220 +
1221 #define ___wait_cond_timeout(condition) \
1222 ({ \
1223 bool __cond = (condition); \
1224 diff --git a/kernel/sched/wait.c b/kernel/sched/wait.c
1225 index 9453efe9b25a6..133afaf05c3f4 100644
1226 --- a/kernel/sched/wait.c
1227 +++ b/kernel/sched/wait.c
1228 @@ -10,6 +10,7 @@
1229 #include <linux/wait.h>
1230 #include <linux/hash.h>
1231 #include <linux/kthread.h>
1232 +#include <linux/poll.h>
1233
1234 void __init_waitqueue_head(wait_queue_head_t *q, const char *name, struct lock_class_key *key)
1235 {
1236 @@ -156,6 +157,13 @@ void __wake_up_sync(wait_queue_head_t *q, unsigned int mode, int nr_exclusive)
1237 }
1238 EXPORT_SYMBOL_GPL(__wake_up_sync); /* For internal use only */
1239
1240 +void __wake_up_pollfree(wait_queue_head_t *wq_head)
1241 +{
1242 + __wake_up(wq_head, TASK_NORMAL, 0, (void *)(POLLHUP | POLLFREE));
1243 + /* POLLFREE must have cleared the queue. */
1244 + WARN_ON_ONCE(waitqueue_active(wq_head));
1245 +}
1246 +
1247 /*
1248 * Note: we use "set_current_state()" _after_ the wait-queue add,
1249 * because we need a memory barrier there on SMP, so that any
1250 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
1251 index aad61d0175a1c..09f123b3e7eb6 100644
1252 --- a/mm/backing-dev.c
1253 +++ b/mm/backing-dev.c
1254 @@ -865,6 +865,13 @@ void bdi_unregister(struct backing_dev_info *bdi)
1255 wb_shutdown(&bdi->wb);
1256 cgwb_bdi_destroy(bdi);
1257
1258 + /*
1259 + * If this BDI's min ratio has been set, use bdi_set_min_ratio() to
1260 + * update the global bdi_min_ratio.
1261 + */
1262 + if (bdi->min_ratio)
1263 + bdi_set_min_ratio(bdi, 0);
1264 +
1265 if (bdi->dev) {
1266 bdi_debug_unregister(bdi);
1267 device_unregister(bdi->dev);
1268 diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
1269 index 9ec37c6c8c4aa..00f25e54119cf 100644
1270 --- a/net/bluetooth/hidp/core.c
1271 +++ b/net/bluetooth/hidp/core.c
1272 @@ -734,7 +734,7 @@ static void hidp_stop(struct hid_device *hid)
1273 hid->claimed = 0;
1274 }
1275
1276 -static struct hid_ll_driver hidp_hid_driver = {
1277 +struct hid_ll_driver hidp_hid_driver = {
1278 .parse = hidp_parse,
1279 .start = hidp_start,
1280 .stop = hidp_stop,
1281 @@ -743,6 +743,7 @@ static struct hid_ll_driver hidp_hid_driver = {
1282 .raw_request = hidp_raw_request,
1283 .output_report = hidp_output_report,
1284 };
1285 +EXPORT_SYMBOL_GPL(hidp_hid_driver);
1286
1287 /* This function sets up the hid device. It does not add it
1288 to the HID system. That is done in hidp_add_connection(). */
1289 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
1290 index 2aa5c231560d2..19e6049058d18 100644
1291 --- a/net/core/neighbour.c
1292 +++ b/net/core/neighbour.c
1293 @@ -597,7 +597,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
1294
1295 ASSERT_RTNL();
1296
1297 - n = kmalloc(sizeof(*n) + key_len, GFP_KERNEL);
1298 + n = kzalloc(sizeof(*n) + key_len, GFP_KERNEL);
1299 if (!n)
1300 goto out;
1301
1302 diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
1303 index f326a6ea35fc7..27ad73861a33f 100644
1304 --- a/net/nfc/netlink.c
1305 +++ b/net/nfc/netlink.c
1306 @@ -1403,8 +1403,10 @@ static int nfc_genl_dump_ses_done(struct netlink_callback *cb)
1307 {
1308 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
1309
1310 - nfc_device_iter_exit(iter);
1311 - kfree(iter);
1312 + if (iter) {
1313 + nfc_device_iter_exit(iter);
1314 + kfree(iter);
1315 + }
1316
1317 return 0;
1318 }
1319 diff --git a/sound/core/control_compat.c b/sound/core/control_compat.c
1320 index 84ee29c3b1a0b..be5ca6f58e55a 100644
1321 --- a/sound/core/control_compat.c
1322 +++ b/sound/core/control_compat.c
1323 @@ -281,6 +281,7 @@ static int copy_ctl_value_to_user(void __user *userdata,
1324 struct snd_ctl_elem_value *data,
1325 int type, int count)
1326 {
1327 + struct snd_ctl_elem_value32 __user *data32 = userdata;
1328 int i, size;
1329
1330 if (type == SNDRV_CTL_ELEM_TYPE_BOOLEAN ||
1331 @@ -297,6 +298,8 @@ static int copy_ctl_value_to_user(void __user *userdata,
1332 if (copy_to_user(valuep, data->value.bytes.data, size))
1333 return -EFAULT;
1334 }
1335 + if (copy_to_user(&data32->id, &data->id, sizeof(data32->id)))
1336 + return -EFAULT;
1337 return 0;
1338 }
1339
1340 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
1341 index c2fb5198d5d56..0ce3f42721c4d 100644
1342 --- a/sound/core/oss/pcm_oss.c
1343 +++ b/sound/core/oss/pcm_oss.c
1344 @@ -173,7 +173,7 @@ snd_pcm_hw_param_value_min(const struct snd_pcm_hw_params *params,
1345 *
1346 * Return the maximum value for field PAR.
1347 */
1348 -static unsigned int
1349 +static int
1350 snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params,
1351 snd_pcm_hw_param_t var, int *dir)
1352 {
1353 @@ -708,18 +708,24 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
1354 struct snd_pcm_hw_params *oss_params,
1355 struct snd_pcm_hw_params *slave_params)
1356 {
1357 - size_t s;
1358 - size_t oss_buffer_size, oss_period_size, oss_periods;
1359 - size_t min_period_size, max_period_size;
1360 + ssize_t s;
1361 + ssize_t oss_buffer_size;
1362 + ssize_t oss_period_size, oss_periods;
1363 + ssize_t min_period_size, max_period_size;
1364 struct snd_pcm_runtime *runtime = substream->runtime;
1365 size_t oss_frame_size;
1366
1367 oss_frame_size = snd_pcm_format_physical_width(params_format(oss_params)) *
1368 params_channels(oss_params) / 8;
1369
1370 + oss_buffer_size = snd_pcm_hw_param_value_max(slave_params,
1371 + SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
1372 + NULL);
1373 + if (oss_buffer_size <= 0)
1374 + return -EINVAL;
1375 oss_buffer_size = snd_pcm_plug_client_size(substream,
1376 - snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, NULL)) * oss_frame_size;
1377 - if (!oss_buffer_size)
1378 + oss_buffer_size * oss_frame_size);
1379 + if (oss_buffer_size <= 0)
1380 return -EINVAL;
1381 oss_buffer_size = rounddown_pow_of_two(oss_buffer_size);
1382 if (atomic_read(&substream->mmap_count)) {
1383 @@ -756,7 +762,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
1384
1385 min_period_size = snd_pcm_plug_client_size(substream,
1386 snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
1387 - if (min_period_size) {
1388 + if (min_period_size > 0) {
1389 min_period_size *= oss_frame_size;
1390 min_period_size = roundup_pow_of_two(min_period_size);
1391 if (oss_period_size < min_period_size)
1392 @@ -765,7 +771,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
1393
1394 max_period_size = snd_pcm_plug_client_size(substream,
1395 snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
1396 - if (max_period_size) {
1397 + if (max_period_size > 0) {
1398 max_period_size *= oss_frame_size;
1399 max_period_size = rounddown_pow_of_two(max_period_size);
1400 if (oss_period_size > max_period_size)
1401 @@ -778,7 +784,7 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
1402 oss_periods = substream->oss.setup.periods;
1403
1404 s = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL);
1405 - if (runtime->oss.maxfrags && s > runtime->oss.maxfrags)
1406 + if (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags)
1407 s = runtime->oss.maxfrags;
1408 if (oss_periods > s)
1409 oss_periods = s;
1410 @@ -904,8 +910,15 @@ static int snd_pcm_oss_change_params_locked(struct snd_pcm_substream *substream)
1411 err = -EINVAL;
1412 goto failure;
1413 }
1414 - choose_rate(substream, sparams, runtime->oss.rate);
1415 - snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_CHANNELS, runtime->oss.channels, NULL);
1416 +
1417 + err = choose_rate(substream, sparams, runtime->oss.rate);
1418 + if (err < 0)
1419 + goto failure;
1420 + err = snd_pcm_hw_param_near(substream, sparams,
1421 + SNDRV_PCM_HW_PARAM_CHANNELS,
1422 + runtime->oss.channels, NULL);
1423 + if (err < 0)
1424 + goto failure;
1425
1426 format = snd_pcm_oss_format_from(runtime->oss.format);
1427
1428 @@ -2013,7 +2026,7 @@ static int snd_pcm_oss_set_fragment1(struct snd_pcm_substream *substream, unsign
1429 if (runtime->oss.subdivision || runtime->oss.fragshift)
1430 return -EINVAL;
1431 fragshift = val & 0xffff;
1432 - if (fragshift >= 31)
1433 + if (fragshift >= 25) /* should be large enough */
1434 return -EINVAL;
1435 runtime->oss.fragshift = fragshift;
1436 runtime->oss.maxfrags = (val >> 16) & 0xffff;