[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221112125935.3753233-1-yangyingliang@huawei.com>
Date: Sat, 12 Nov 2022 20:59:34 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <linux-kernel@...r.kernel.org>
CC: <mporter@...nel.crashing.org>, <alex.bou9@...il.com>,
<akpm@...ux-foundation.org>
Subject: [PATCH 1/2] rapidio: rio_mport_cdev: fix possible name leak in rio_mport_add_riodev()
If rio_add_net() returns error in rio_mport_add_riodev(), the
name allocated by dev_set_name() need be freed.
As comment of device_register() says, it should use put_device()
to give up the reference in the error path. So fix this by calling
put_device(), then the name can be freed in kobject_cleanup(),
and the 'net' is freed in rio_release_net().
Fixes: e8de370188d0 ("rapidio: add mport char device driver")
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/rapidio/devices/rio_mport_cdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 2cdc054e53a5..683457d8cb65 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -1740,7 +1740,7 @@ static int rio_mport_add_riodev(struct mport_cdev_priv *priv,
err = rio_add_net(net);
if (err) {
rmcd_debug(RDEV, "failed to register net, err=%d", err);
- kfree(net);
+ put_device(&net->dev);
goto cleanup;
}
}
--
2.25.1
Powered by blists - more mailing lists