Skip to contentSkip to conversation

devcoredump: fix double free on device registration failure

PATCH Applied Johan Hovold 2 participants 2 messages Nov 2 – Nov 9

Subsystems (3)
lore
Share & tools
lore

Johan Hovold

author maintainer
#0 lore raw

PATCH 1/1 devcoredump: fix double free on device registration failure

The device coredump class release function devcd_dev_release() puts the module reference and frees the data so just return after dropping the device reference on registration failures to avoid a module reference imbalance and double free.

This issue was flagged by an LLM.

Fixes 833c95456a70 ("device coredump: add new device coredump class")
Cc Johannes Berg <[email protected]>
---
 drivers/base/devcoredump.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/base/devcoredump.c +2 -0
index 8bb1763083dd..16e99ac926a7 100644
@@ -433,10 +433,12 @@ void dev_coredumpm_timeout(struct device *dev, struct module *owner,
 	devcd->init_completed = true;
 	mutex_unlock(&devcd->mutex);
 	return;
+
  put_device:
 	mutex_unlock(&devcd->mutex);
 	cancel_delayed_work_sync(&devcd->del_wk);
 	put_device(&devcd->devcd_dev);
+	return;
 
  put_module:
 	module_put(owner);
Signature · 1 line
2.55.0
maintainer Applied
#1 lore raw
Quoted 1 line · Johan Hovold

[PATCH] devcoredump: fix double free on device registration failure

Applied, thanks!

Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git

[1/1] devcoredump: fix double free on device registration failure

      commit: de7625abe4e9

The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).

The patch is in the driver-core-testing branch and will be promoted to driver-core-next after validation.