summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Villemoes <linux@rasmusvillemoes.dk>2015-11-09 13:19:10 +0100
committerDavid S. Miller <davem@davemloft.net>2015-11-09 11:31:13 -0500
commitcfb76d77c009b38e607c8a2adc8bdd57b5081768 (patch)
treefac0cdc7ed28a437668efb79caef5161ff5535d7
parent3870502a66fe26c80c034db1aa915d69850854aa (diff)
downloadop-kernel-dev-cfb76d77c009b38e607c8a2adc8bdd57b5081768.zip
op-kernel-dev-cfb76d77c009b38e607c8a2adc8bdd57b5081768.tar.gz
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>
-rw-r--r--drivers/net/caif/caif_spi.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c
index de39620..4721948 100644
--- a/drivers/net/caif/caif_spi.c
+++ b/drivers/net/caif/caif_spi.c
@@ -730,11 +730,14 @@ int cfspi_spi_probe(struct platform_device *pdev)
int res;
dev = (struct cfspi_dev *)pdev->dev.platform_data;
- ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
- NET_NAME_UNKNOWN, cfspi_setup);
if (!dev)
return -ENODEV;
+ ndev = alloc_netdev(sizeof(struct cfspi), "cfspi%d",
+ NET_NAME_UNKNOWN, cfspi_setup);
+ if (!ndev)
+ return -ENOMEM;
+
cfspi = netdev_priv(ndev);
netif_stop_queue(ndev);
cfspi->ndev = ndev;
OpenPOWER on IntegriCloud