net: ieee802154: fix potential null pointer dereference
authorGustavo A. R. Silva <garsilva@embeddedor.com>
Tue, 23 May 2017 18:11:47 +0000 (13:11 -0500)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 23 May 2017 18:12:53 +0000 (20:12 +0200)
Null check at line 918: if (!spi) {, implies spi might be NULL.
Function spi_get_drvdata() dereference pointer spi.
Move pointer priv assignment after the null check.

Addresses-Coverity-ID: 1408888
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/net/ieee802154/ca8210.c

index f6df75e80a60a8dd619ab560490bec6745763a7f..7a218549c80aa0f9384d3d3b400907716c81184c 100644 (file)
@@ -912,7 +912,7 @@ static int ca8210_spi_transfer(
 )
 {
        int i, status = 0;
-       struct ca8210_priv *priv = spi_get_drvdata(spi);
+       struct ca8210_priv *priv;
        struct cas_control *cas_ctl;
 
        if (!spi) {
@@ -923,6 +923,7 @@ static int ca8210_spi_transfer(
                return -ENODEV;
        }
 
+       priv = spi_get_drvdata(spi);
        reinit_completion(&priv->spi_transfer_complete);
 
        dev_dbg(&spi->dev, "ca8210_spi_transfer called\n");