* [PATCH] driver core: fix memory leak in physical location error path
@ 2026-11-02 8:30 Johan Hovold
0 siblings, 0 replies; only message in thread
From: Johan Hovold @ 2026-11-02 8:30 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
Johan Hovold
Cc: driver-core, linux-kernel, stable, Won Chung
Make sure to free the physical location memory also in the unlikely
event that creating its sysfs attributes fails during probe.
Fixes: 6423d2951087 ("driver core: Add sysfs support for physical location of a device")
Closes: https://sashiko.dev/#/bug/linux-b178c32c-f23b-48fd-9463-70f321f2d91e
Cc: stable@vger.kernel.org # 5.19
Cc: Won Chung <wonchung@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/base/core.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index cbe05197d4a0..bf97b06337a1 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -3011,12 +3011,13 @@ static int device_add_attrs(struct device *dev)
error = device_add_group(dev,
&dev_attr_physical_location_group);
if (error)
- goto err_remove_dev_removable;
+ goto err_free_physical_location;
}
return 0;
- err_remove_dev_removable:
+ err_free_physical_location:
+ kfree(dev->physical_location);
device_remove_file(dev, &dev_attr_removable);
err_remove_dev_waiting_for_supplier:
device_remove_file(dev, &dev_attr_waiting_for_supplier);
--
2.55.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-02 8:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-02 8:30 [PATCH] driver core: fix memory leak in physical location error path Johan Hovold
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.