Skip to content

Commit 67d54da

Browse files
superm1heftig
authored andcommitted
HID: amd_sfh: Check that sensors are enabled before set/get report
A crash was reported in amd-sfh related to hid core initialization before SFH initialization has run. ``` amdtp_hid_request+0x36/0x50 [amd_sfh 2e3095779aada9fdb1764f08ca578ccb14e41fe4] sensor_hub_get_feature+0xad/0x170 [hid_sensor_hub d6157999c9d260a1bfa6f27d4a0dc2c3e2c5654e] hid_sensor_parse_common_attributes+0x217/0x310 [hid_sensor_iio_common 07a7935272aa9c7a28193b574580b3e953a64ec4] hid_gyro_3d_probe+0x7f/0x2e0 [hid_sensor_gyro_3d 9f2eb51294a1f0c0315b365f335617cbaef01eab] platform_probe+0x44/0xa0 really_probe+0x19e/0x3e0 ``` Ensure that sensors have been set up before calling into amd_sfh_get_report() or amd_sfh_set_report(). Cc: [email protected] Cc: Linux regression tracking (Thorsten Leemhuis) <[email protected]> Fixes: 7bcfdab ("HID: amd_sfh: if no sensors are enabled, clean up") Reported-by: Haochen Tong <[email protected]> Link: https://lore.kernel.org/all/3250319.ancTxkQ2z5@zen/T/ Signed-off-by: Mario Limonciello <[email protected]> Cherry-picked-for: https://gitlab.archlinux.org/archlinux/packaging/packages/linux/-/issues/7
1 parent 1aaa0af commit 67d54da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ void amd_sfh_set_report(struct hid_device *hid, int report_id,
2525
struct amdtp_cl_data *cli_data = hid_data->cli_data;
2626
int i;
2727

28+
if (!cli_data->is_any_sensor_enabled)
29+
return;
30+
2831
for (i = 0; i < cli_data->num_hid_devices; i++) {
2932
if (cli_data->hid_sensor_hubs[i] == hid) {
3033
cli_data->cur_hid_dev = i;
@@ -41,6 +44,9 @@ int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type)
4144
struct request_list *req_list = &cli_data->req_list;
4245
int i;
4346

47+
if (!cli_data->is_any_sensor_enabled)
48+
return -ENODEV;
49+
4450
for (i = 0; i < cli_data->num_hid_devices; i++) {
4551
if (cli_data->hid_sensor_hubs[i] == hid) {
4652
struct request_list *new = kzalloc(sizeof(*new), GFP_KERNEL);

0 commit comments

Comments
 (0)