Skip to content

Commit e842f9a

Browse files
Haoxiang Liakpm00
Haoxiang Li
authored andcommitted
rapidio: add check for rio_add_net() in rio_scan_alloc_net()
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/[email protected] Fixes: e6b585c ("rapidio: move net allocation into core code") Signed-off-by: Yang Yingliang <[email protected]> Signed-off-by: Haoxiang Li <[email protected]> Cc: Alexandre Bounine <[email protected]> Cc: Matt Porter <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent b2ef51c commit e842f9a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: drivers/rapidio/rio-scan.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,10 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,
871871
dev_set_name(&net->dev, "rnet_%d", net->id);
872872
net->dev.parent = &mport->dev;
873873
net->dev.release = rio_scan_release_dev;
874-
rio_add_net(net);
874+
if (rio_add_net(net)) {
875+
put_device(&net->dev);
876+
net = NULL;
877+
}
875878
}
876879

877880
return net;

0 commit comments

Comments
 (0)