Skip to content

Commit 8c2dd54

Browse files
khoroshilovdavem330
authored andcommitted
ieee802154: fix error handling in ieee802154fake_probe()
In case of any failure ieee802154fake_probe() just calls unregister_netdev(). But it does not look safe to unregister netdevice before it was registered. The patch implements straightforward resource deallocation in case of failure in ieee802154fake_probe(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f1227c5 commit 8c2dd54

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

drivers/net/ieee802154/fakehard.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,20 @@ static int ieee802154fake_probe(struct platform_device *pdev)
377377

378378
err = wpan_phy_register(phy);
379379
if (err)
380-
goto out;
380+
goto err_phy_reg;
381381

382382
err = register_netdev(dev);
383-
if (err < 0)
384-
goto out;
383+
if (err)
384+
goto err_netdev_reg;
385385

386386
dev_info(&pdev->dev, "Added ieee802154 HardMAC hardware\n");
387387
return 0;
388388

389-
out:
390-
unregister_netdev(dev);
389+
err_netdev_reg:
390+
wpan_phy_unregister(phy);
391+
err_phy_reg:
392+
free_netdev(dev);
393+
wpan_phy_free(phy);
391394
return err;
392395
}
393396

0 commit comments

Comments
 (0)