0003-HID-amd_sfh-Check-that-sensors-are-enabled-before-se.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 32e4bc1b86e21f941767b2faf48446145ca30d44 Mon Sep 17 00:00:00 2001
  2. From: Mario Limonciello <mario.limonciello@amd.com>
  3. Date: Tue, 20 Jun 2023 15:01:17 -0500
  4. Subject: [PATCH 3/5] HID: amd_sfh: Check that sensors are enabled before
  5. set/get report
  6. A crash was reported in amd-sfh related to hid core initialization
  7. before SFH initialization has run.
  8. ```
  9. amdtp_hid_request+0x36/0x50 [amd_sfh
  10. 2e3095779aada9fdb1764f08ca578ccb14e41fe4]
  11. sensor_hub_get_feature+0xad/0x170 [hid_sensor_hub
  12. d6157999c9d260a1bfa6f27d4a0dc2c3e2c5654e]
  13. hid_sensor_parse_common_attributes+0x217/0x310 [hid_sensor_iio_common
  14. 07a7935272aa9c7a28193b574580b3e953a64ec4]
  15. hid_gyro_3d_probe+0x7f/0x2e0 [hid_sensor_gyro_3d
  16. 9f2eb51294a1f0c0315b365f335617cbaef01eab]
  17. platform_probe+0x44/0xa0
  18. really_probe+0x19e/0x3e0
  19. ```
  20. Ensure that sensors have been set up before calling into
  21. amd_sfh_get_report() or amd_sfh_set_report().
  22. Cc: stable@vger.kernel.org
  23. Cc: Linux regression tracking (Thorsten Leemhuis) <regressions@leemhuis.info>
  24. Fixes: 7bcfdab3f0c6 ("HID: amd_sfh: if no sensors are enabled, clean up")
  25. Reported-by: Haochen Tong <linux@hexchain.org>
  26. Link: https://lore.kernel.org/all/3250319.ancTxkQ2z5@zen/T/
  27. Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
  28. Cherry-picked-for: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/7
  29. ---
  30. drivers/hid/amd-sfh-hid/amd_sfh_client.c | 6 ++++++
  31. 1 file changed, 6 insertions(+)
  32. diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
  33. index bdb578e0899f..0f1d6778051f 100644
  34. --- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
  35. +++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
  36. @@ -25,6 +25,9 @@ void amd_sfh_set_report(struct hid_device *hid, int report_id,
  37. struct amdtp_cl_data *cli_data = hid_data->cli_data;
  38. int i;
  39. + if (!cli_data->is_any_sensor_enabled)
  40. + return;
  41. +
  42. for (i = 0; i < cli_data->num_hid_devices; i++) {
  43. if (cli_data->hid_sensor_hubs[i] == hid) {
  44. cli_data->cur_hid_dev = i;
  45. @@ -41,6 +44,9 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type)
  46. struct request_list *req_list = &cli_data->req_list;
  47. int i;
  48. + if (!cli_data->is_any_sensor_enabled)
  49. + return -ENODEV;
  50. +
  51. for (i = 0; i < cli_data->num_hid_devices; i++) {
  52. if (cli_data->hid_sensor_hubs[i] == hid) {
  53. struct request_list *new = kzalloc(sizeof(*new), GFP_KERNEL);
  54. --
  55. 2.43.0