driver core: fix memory leak in physical location error path
Subsystems (2)
Johan Hovold
maintainerPATCH 1/1 driver core: fix memory leak in physical location error path
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")
Cc [email protected] # 5.19
Cc Won Chung <[email protected]>
Signed-off-by Johan Hovold <[email protected]>
--- drivers/base/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/base/core.c +3 -2
@@ -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);
Signature · 1 line
2.55.0
Quoted 1 line · Johan Hovold
[PATCH] driver core: fix memory leak in physical location error path
Applied, thanks!
Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] driver core: fix memory leak in physical location error path
commit: c890943b295b
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.