Skip to contentSkip to conversation

HID: corsair-void: Fix various memory issues

PATCH Superseded Stuart Hayhurst 3 participants 6 messages Jan 21, 2025 – Feb 11, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover HID: corsair-void: Fix various memory issues

Fixes a use-after-free and a struct without an initialiser

Attempt 2, since apparently I messed up the command the first time

Stuart Hayhurst (2):
HID: corsair-void: Add missing delayed work cancel for headset status
HID: corsair-void: Initialise memory for psy_cfg

 drivers/hid/hid-corsair-void.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.47.1
#1 lore raw

PATCH v2 1/2 HID: corsair-void: Add missing delayed work cancel for headset status

The cancel_delayed_work_sync() call was missed, causing a use-after-free in corsair_void_remove().

Fixes 6ea2a6fd3872 ("HID: corsair-void: Add Corsair Void headset family driver")
---
 drivers/hid/hid-corsair-void.c | 1 +
 1 file changed, 1 insertion(+)
drivers/hid/hid-corsair-void.c +1 -0
index 6ece56b850fc..bd8f3d849b58 100644
@@ -726,6 +726,7 @@ static void corsair_void_remove(struct hid_device *hid_dev)
 	if (drvdata->battery)
 		power_supply_unregister(drvdata->battery);
 
+	cancel_delayed_work_sync(&drvdata->delayed_status_work);
 	cancel_delayed_work_sync(&drvdata->delayed_firmware_work);
 	sysfs_remove_group(&hid_dev->dev.kobj, &corsair_void_attr_group);
 }
Signature · 1 line
2.47.1
#2 lore raw

Re: [PATCH v2 1/2] HID: corsair-void: Add missing delayed work cancel for headset status

Quoted 8 lines · Stuart Hayhurst

The cancel_delayed_work_sync() call was missed, causing a use-after-free in corsair_void_remove().

There should be no extra \n here ^^^^.

Quoted 19 lines
Fixes 6ea2a6fd3872 ("HID: corsair-void: Add Corsair Void headset family driver")
---
  drivers/hid/hid-corsair-void.c | 1 +
  1 file changed, 1 insertion(+)
drivers/hid/hid-corsair-void.c +1 -0
index 6ece56b850fc..bd8f3d849b58 100644
@@ -726,6 +726,7 @@ static void corsair_void_remove(struct hid_device *hid_dev)
  	if (drvdata->battery)
  		power_supply_unregister(drvdata->battery);
 
+	cancel_delayed_work_sync(&drvdata->delayed_status_work);
  	cancel_delayed_work_sync(&drvdata->delayed_firmware_work);
  	sysfs_remove_group(&hid_dev->dev.kobj, &corsair_void_attr_group);
  }
Signature · 2 lines
js
suse labs
#3 lore raw

PATCH v2 2/2 HID: corsair-void: Initialise memory for psy_cfg

In reply to Stuart Hayhurst

power_supply_config psy_cfg was missing its initialiser, add it in.

Fixes 6ea2a6fd3872 ("HID: corsair-void: Add Corsair Void headset family driver")
---
 drivers/hid/hid-corsair-void.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-corsair-void.c +1 -1
index bd8f3d849b58..56e858066c3c 100644
@@ -553,7 +553,7 @@ static void corsair_void_battery_remove_work_handler(struct work_struct *work)
 static void corsair_void_battery_add_work_handler(struct work_struct *work)
 {
 	struct corsair_void_drvdata *drvdata;
-	struct power_supply_config psy_cfg;
+	struct power_supply_config psy_cfg = {};
 	struct power_supply *new_supply;
 
 	drvdata = container_of(work, struct corsair_void_drvdata,
Signature · 1 line
2.47.1
maintainer
#4 lore raw
In reply to Stuart Hayhurst
Quoted 3 lines · Stuart Hayhurst

Fixes a use-after-free and a struct without an initialiser

Attempt 2, since apparently I messed up the command the first time

Are you sure you got this time this time though? I again got only cover letter and not the actual patches :)

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs
author
#5 lore raw
Quoted 2 lines

Are you sure you got this time this time though? I again got only cover letter and not the actual patches :)

Yeah thanks I just saw I emailed it to myself instead somehow I'll have a couple tries with --dry-run otherwise I'll clutter everyone's inboxes, sorry for the extra emails

Stuart