net: caif: check return value of alloc_netdev
I don't know if dev can actually be NULL here, but the test should be above alloc_netdev(), to avoid leaking the struct net_device in case dev is actually NULL. And of course the return value from alloc_netdev should be tested. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3870502a66
commit
cfb76d77c0
|
@ -730,11 +730,14 @@ int cfspi_spi_probe(struct platform_device *pdev)
|
||||||
int res;
|
int res;
|
||||||
dev = (struct cfspi_dev *)pdev->dev.platform_data;
|
dev = (struct cfspi_dev *)pdev->dev.platform_data;
|
||||||
|
|
||||||
ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
|
|
||||||
NET_NAME_UNKNOWN, cfspi_setup);
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
|
||||||
|
NET_NAME_UNKNOWN, cfspi_setup);
|
||||||
|
if (!ndev)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
cfspi = netdev_priv(ndev);
|
cfspi = netdev_priv(ndev);
|
||||||
netif_stop_queue(ndev);
|
netif_stop_queue(ndev);
|
||||||
cfspi->ndev = ndev;
|
cfspi->ndev = ndev;
|
||||||
|
|
Loading…
Reference in New Issue