2
0

084-0002-usb-core-usbport-Use-proper-LED-API-to-fix-potential.patch 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From 89778ba335e302a450932ce5b703c1ee6216e949 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Tue, 6 Dec 2016 00:39:33 +0100
  4. Subject: [PATCH] usb: core: usbport: Use proper LED API to fix potential crash
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Calling brightness_set manually isn't safe as some LED drivers don't
  9. implement this callback. The best idea is to just use a proper helper
  10. which will fallback to the brightness_set_blocking callback if needed.
  11. This fixes:
  12. [ 1461.761528] Unable to handle kernel NULL pointer dereference at virtual address 00000000
  13. (...)
  14. [ 1462.117049] Backtrace:
  15. [ 1462.119521] [<bf228164>] (usbport_trig_port_store [ledtrig_usbport]) from [<c023f758>] (dev_attr_store+0x20/0x2c)
  16. [ 1462.129826] r7:dcabc7c0 r6:dee0ff80 r5:00000002 r4:bf228164
  17. [ 1462.135511] [<c023f738>] (dev_attr_store) from [<c0169310>] (sysfs_kf_write+0x48/0x4c)
  18. [ 1462.143459] r5:00000002 r4:c023f738
  19. [ 1462.147049] [<c01692c8>] (sysfs_kf_write) from [<c0168ab8>] (kernfs_fop_write+0xf8/0x1f8)
  20. [ 1462.155258] r5:00000002 r4:df4a1000
  21. [ 1462.158850] [<c01689c0>] (kernfs_fop_write) from [<c0100c78>] (__vfs_write+0x34/0x120)
  22. [ 1462.166800] r10:00000000 r9:dee0e000 r8:c000fc24 r7:00000002 r6:dee0ff80 r5:c01689c0
  23. [ 1462.174660] r4:df727a80
  24. [ 1462.177204] [<c0100c44>] (__vfs_write) from [<c0101ae4>] (vfs_write+0xac/0x170)
  25. [ 1462.184543] r9:dee0e000 r8:c000fc24 r7:dee0ff80 r6:b6f092d0 r5:df727a80 r4:00000002
  26. [ 1462.192319] [<c0101a38>] (vfs_write) from [<c01028dc>] (SyS_write+0x4c/0xa8)
  27. [ 1462.199396] r9:dee0e000 r8:c000fc24 r7:00000002 r6:b6f092d0 r5:df727a80 r4:df727a80
  28. [ 1462.207174] [<c0102890>] (SyS_write) from [<c000fa60>] (ret_fast_syscall+0x0/0x3c)
  29. [ 1462.214774] r7:00000004 r6:ffffffff r5:00000000 r4:00000000
  30. [ 1462.220456] Code: bad PC value
  31. [ 1462.223560] ---[ end trace 676638a3a12c7a56 ]---
  32. Reported-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
  33. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  34. Fixes: 0f247626cbb ("usb: core: Introduce a USB port LED trigger")
  35. Cc: stable@vger.kernel.org # 4.9+
  36. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  37. ---
  38. drivers/usb/core/ledtrig-usbport.c | 7 +++----
  39. 1 file changed, 3 insertions(+), 4 deletions(-)
  40. --- a/drivers/usb/core/ledtrig-usbport.c
  41. +++ b/drivers/usb/core/ledtrig-usbport.c
  42. @@ -74,8 +74,7 @@ static void usbport_trig_update_count(st
  43. usbport_data->count = 0;
  44. usb_for_each_dev(usbport_data, usbport_trig_usb_dev_check);
  45. - led_cdev->brightness_set(led_cdev,
  46. - usbport_data->count ? LED_FULL : LED_OFF);
  47. + led_set_brightness(led_cdev, usbport_data->count ? LED_FULL : LED_OFF);
  48. }
  49. /***************************************
  50. @@ -228,12 +227,12 @@ static int usbport_trig_notify(struct no
  51. case USB_DEVICE_ADD:
  52. usbport_trig_add_usb_dev_ports(usb_dev, usbport_data);
  53. if (observed && usbport_data->count++ == 0)
  54. - led_cdev->brightness_set(led_cdev, LED_FULL);
  55. + led_set_brightness(led_cdev, LED_FULL);
  56. return NOTIFY_OK;
  57. case USB_DEVICE_REMOVE:
  58. usbport_trig_remove_usb_dev_ports(usbport_data, usb_dev);
  59. if (observed && --usbport_data->count == 0)
  60. - led_cdev->brightness_set(led_cdev, LED_OFF);
  61. + led_set_brightness(led_cdev, LED_OFF);
  62. return NOTIFY_OK;
  63. }