[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221022113722.3409846-1-yangyingliang@huawei.com>
Date: Sat, 22 Oct 2022 19:37:22 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <netdev@...r.kernel.org>
CC: <dougmill@...ux.ibm.com>, <davem@...emloft.net>, <kuba@...nel.org>
Subject: [PATCH net] net: ehea: fix possible memory leak in ehea_register_port()
dev_set_name() in ehea_register_port() allocates memory for name,
it need be freed when of_device_register() fails, call put_device()
to give up the reference that hold in device_initialize(), so that
it can be freed in kobject_cleanup() when the refcount hit to 0.
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/net/ethernet/ibm/ehea/ehea_main.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/ibm/ehea/ehea_main.c b/drivers/net/ethernet/ibm/ehea/ehea_main.c
index 294bdbbeacc3..b4aff59b3eb4 100644
--- a/drivers/net/ethernet/ibm/ehea/ehea_main.c
+++ b/drivers/net/ethernet/ibm/ehea/ehea_main.c
@@ -2900,6 +2900,7 @@ static struct device *ehea_register_port(struct ehea_port *port,
ret = of_device_register(&port->ofdev);
if (ret) {
pr_err("failed to register device. ret=%d\n", ret);
+ put_device(&port->ofdev.dev);
goto out;
}
--
2.25.1
Powered by blists - more mailing lists