PNP: fix name memory leak in pnp_alloc_dev()
Subsystems (2)
PATCH 1/1 PNP: fix name memory leak in pnp_alloc_dev()
Afer commit 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array"), the name of device is allocated dynamically, it need be freed in the error path.
Fixes 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
Signed-off-by Yang Yingliang <[email protected]>
--- drivers/pnp/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/pnp/core.c +1 -0
@@ -152,6 +152,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, dev_id =pnp_add_id (dev, pnpid);if (!dev_id) { +kfree_const (dev->dev.kobj.name);kfree (dev);return NULL ; }
Signature · 1 line
2.25.1
Rafael J. Wysocki
maintainerQuoted 2 lines · Yang Yingliang
Afer commit
1fa5ae857bb1("driver core: get rid of struct device's
After
Quoted 14 lines
bus_idstring array"), the name of device is allocated dynamically, it need be freed in the error path.Fixes 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")Signed-off-by Yang Yingliang <[email protected]>--- drivers/pnp/core.c | 1 + 1 file changed, 1 insertion(+)drivers/pnp/core.c +0
-0
drivers/pnp/core.c struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, · line 155
Quoted 4 lines
drivers/pnp/core.c +1
-0@@ -152,6 +152,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, dev_id =pnp_add_id (dev, pnpid);if (!dev_id) { +kfree_const (dev->dev.kobj.name);
Would be better to move the dev_set_name() invocation after this if () unstead.
Quoted 4 lines
drivers/pnp/core.c +0
-1kfree (dev);return NULL ; } --