mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
rapidio: fix an API misues when rio_add_net() fails
rio_add_net() calls device_register() and fails when device_register()
fails. Thus, put_device() should be used rather than kfree(). Add
"mport->net = NULL;" to avoid a use after free issue.
Link: https://lkml.kernel.org/r/20250227073409.3696854-1-haoxiang_li2024@163.com
Fixes: e8de370188 ("rapidio: add mport char device driver")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Alexandre Bounine <alex.bou9@gmail.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Yang Yingliang <yangyingliang@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
88f5a9a945
commit
b2ef51c74b
@@ -1742,7 +1742,8 @@ 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);
|
||||
mport->net = NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user