Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: wacom - don't use on-stack memory for report buffers

Tested-by: Martin Capitanio <martin@capitanio.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+29 -14
+29 -14
drivers/input/tablet/wacom_sys.c
··· 388 388 return result; 389 389 } 390 390 391 + static int wacom_query_tablet_data(struct usb_interface *intf) 392 + { 393 + unsigned char *rep_data; 394 + int limit = 0; 395 + int error; 396 + 397 + rep_data = kmalloc(2, GFP_KERNEL); 398 + if (!rep_data) 399 + return -ENOMEM; 400 + 401 + do { 402 + rep_data[0] = 2; 403 + rep_data[1] = 2; 404 + error = usb_set_report(intf, WAC_HID_FEATURE_REPORT, 405 + 2, rep_data, 2); 406 + if (error >= 0) 407 + error = usb_get_report(intf, 408 + WAC_HID_FEATURE_REPORT, 2, 409 + rep_data, 2); 410 + } while ((error < 0 || rep_data[1] != 2) && limit++ < 5); 411 + 412 + kfree(rep_data); 413 + 414 + return error < 0 ? error : 0; 415 + } 416 + 391 417 static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 392 418 { 393 419 struct usb_device *dev = interface_to_usbdev(intf); ··· 424 398 struct wacom_features *features; 425 399 struct input_dev *input_dev; 426 400 int error = -ENOMEM; 427 - char rep_data[2], limit = 0; 428 401 struct hid_descriptor *hid_desc; 429 402 430 403 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); ··· 514 489 515 490 /* 516 491 * Ask the tablet to report tablet data if it is not a Tablet PC. 517 - * Repeat until it succeeds 492 + * Note that if query fails it is not a hard failure. 518 493 */ 519 - if (wacom_wac->features->type != TABLETPC) { 520 - do { 521 - rep_data[0] = 2; 522 - rep_data[1] = 2; 523 - error = usb_set_report(intf, WAC_HID_FEATURE_REPORT, 524 - 2, rep_data, 2); 525 - if (error >= 0) 526 - error = usb_get_report(intf, 527 - WAC_HID_FEATURE_REPORT, 2, 528 - rep_data, 2); 529 - } while ((error < 0 || rep_data[1] != 2) && limit++ < 5); 530 - } 494 + if (wacom_wac->features->type != TABLETPC) 495 + wacom_query_tablet_data(intf); 531 496 532 497 usb_set_intfdata(intf, wacom); 533 498 return 0;