Commit 7e4d5c13d8048ed37f94dbcdf54228b404a775c7

Authored by Shawn Bohrer
Committed by Greg Kroah-Hartman
1 parent c0e6e7c1b2

staging: line6: Convert simple_strtoul to strict_strtoul in pod.c

Signed-off-by: Shawn Bohrer <shawn.bohrer@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 47 additions and 9 deletions Side-by-side Diff

drivers/staging/line6/pod.c
... ... @@ -422,13 +422,21 @@
422 422 /*
423 423 Resolve value to memory location.
424 424 */
425   -static void pod_resolve(const char *buf, short block0, short block1, unsigned char *location)
  425 +static int pod_resolve(const char *buf, short block0, short block1, unsigned char *location)
426 426 {
427   - int value = simple_strtoul(buf, NULL, 10);
428   - short block = (value < 0x40) ? block0 : block1;
  427 + unsigned long value;
  428 + short block;
  429 + int ret;
  430 +
  431 + ret = strict_strtoul(buf, 10, &value);
  432 + if (ret)
  433 + return ret;
  434 +
  435 + block = (value < 0x40) ? block0 : block1;
429 436 value &= 0x3f;
430 437 location[0] = block >> 7;
431 438 location[1] = value | (block & 0x7f);
  439 + return 0;
432 440 }
433 441  
434 442 /*
435 443  
436 444  
... ... @@ -438,14 +446,20 @@
438 446 {
439 447 struct usb_interface *interface = to_usb_interface(dev);
440 448 struct usb_line6_pod *pod = usb_get_intfdata(interface);
441   -
  449 + int ret;
442 450 int size = 3 + sizeof(pod->prog_data_buf);
443 451 char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_STORE, size);
  452 +
444 453 if (!sysex)
445 454 return 0;
446 455  
447 456 sysex[SYSEX_DATA_OFS] = 5; /* see pod_dump() */
448   - pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
  457 + ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS + 1);
  458 + if (ret) {
  459 + kfree(sysex);
  460 + return ret;
  461 + }
  462 +
449 463 memcpy(sysex + SYSEX_DATA_OFS + 3, &pod->prog_data_buf, sizeof(pod->prog_data_buf));
450 464  
451 465 line6_send_sysex_message(&pod->line6, sysex, size);
452 466  
... ... @@ -461,13 +475,18 @@
461 475 {
462 476 struct usb_interface *interface = to_usb_interface(dev);
463 477 struct usb_line6_pod *pod = usb_get_intfdata(interface);
  478 + int ret;
464 479 int size = 4;
465 480 char *sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_DUMPMEM, size);
466 481  
467 482 if (!sysex)
468 483 return 0;
469 484  
470   - pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS);
  485 + ret = pod_resolve(buf, block0, block1, sysex + SYSEX_DATA_OFS);
  486 + if (ret) {
  487 + kfree(sysex);
  488 + return ret;
  489 + }
471 490 sysex[SYSEX_DATA_OFS + 2] = 0;
472 491 sysex[SYSEX_DATA_OFS + 3] = 0;
473 492 line6_dump_started(&pod->dumpreq, POD_DUMP_MEMORY);
... ... @@ -526,7 +545,13 @@
526 545 {
527 546 struct usb_interface *interface = to_usb_interface(dev);
528 547 struct usb_line6_pod *pod = usb_get_intfdata(interface);
529   - int value = simple_strtoul(buf, NULL, 10);
  548 + unsigned long value;
  549 + int ret;
  550 +
  551 + ret = strict_strtoul(buf, 10, &value);
  552 + if (ret)
  553 + return ret;
  554 +
530 555 pod_send_channel(pod, value);
531 556 return count;
532 557 }
... ... @@ -645,6 +670,8 @@
645 670 char *sysex;
646 671 static const int size = 5;
647 672 unsigned short value;
  673 + unsigned long result;
  674 + int ret;
648 675  
649 676 if (((pod->prog_data.control[POD_tuner] & 0x40) == 0) && tuner)
650 677 return -EINVAL;
... ... @@ -653,7 +680,12 @@
653 680 sysex = pod_alloc_sysex_buffer(pod, POD_SYSEX_SYSTEM, size);
654 681 if (!sysex)
655 682 return 0;
656   - value = simple_strtoul(buf, NULL, 10) & mask;
  683 +
  684 + ret = strict_strtoul(buf, 10, &result);
  685 + if (ret)
  686 + return ret;
  687 +
  688 + value = result & mask;
657 689 sysex[SYSEX_DATA_OFS] = code;
658 690 sysex[SYSEX_DATA_OFS + 1] = (value >> 12) & 0x0f;
659 691 sysex[SYSEX_DATA_OFS + 2] = (value >> 8) & 0x0f;
... ... @@ -812,7 +844,13 @@
812 844 {
813 845 struct usb_interface *interface = to_usb_interface(dev);
814 846 struct usb_line6_pod *pod = usb_get_intfdata(interface);
815   - int value = simple_strtoul(buf, NULL, 10);
  847 + unsigned long value;
  848 + int ret;
  849 +
  850 + ret = strict_strtoul(buf, 10, &value);
  851 + if (ret)
  852 + return ret;
  853 +
816 854 pod->midi_postprocess = value ? 1 : 0;
817 855 return count;
818 856 }