mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-04-24 10:49:54 +02:00
rapidio: add check for rio_add_net() in rio_scan_alloc_net()
commite842f9a1edupstream. The return value of rio_add_net() should be checked. If it fails, put_device() should be called to free the memory and give up the reference initialized in rio_add_net(). Link: https://lkml.kernel.org/r/20250227041131.3680761-1-haoxiang_li2024@163.com Fixes:e6b585ca6e("rapidio: move net allocation into core code") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com> Cc: Alexandre Bounine <alex.bou9@gmail.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Dan Carpenter <dan.carpenter@linaro.org> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
848526581f
commit
c332f3e2df
@@ -871,7 +871,10 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,
|
||||
dev_set_name(&net->dev, "rnet_%d", net->id);
|
||||
net->dev.parent = &mport->dev;
|
||||
net->dev.release = rio_scan_release_dev;
|
||||
rio_add_net(net);
|
||||
if (rio_add_net(net)) {
|
||||
put_device(&net->dev);
|
||||
net = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return net;
|
||||
|
||||
Reference in New Issue
Block a user