diff mbox series

PNP: fix name memory leak in pnp_alloc_dev()

Message ID 20221110152658.403160-1-yangyingliang@huawei.com
State Superseded
Headers show
Series PNP: fix name memory leak in pnp_alloc_dev() | expand

Commit Message

Yang Yingliang Nov. 10, 2022, 3:26 p.m. UTC
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 <yangyingliang@huawei.com>
---
 drivers/pnp/core.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index 4df5aa6a309c..bb3976566822 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -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;
 	}