Skip to contentSkip to conversation

net: ieee802154: fix potential null pointer dereference

PATCH In review Gustavo A. R. Silva 2 participants 3 messages May 23, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ieee802154: fix potential null pointer dereference

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

---
 drivers/net/ieee802154/ca8210.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +2 -1
index 25fd3b0..ccaf20d 100644
@@ -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");
Signature · 1 line
2.5.0
#1 lore raw

Hi Gustavo,

Quoted 9 lines

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

---
drivers/net/ieee802154/ca8210.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#2 lore raw

Hi Marcel,

Quoting Marcel Holtmann <[email protected]>:

Quoted 6 lines

Hi Gustavo,

Quoted 4 lines

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.

Quoted 8 lines
Quoted 5 lines

Addresses-Coverity-ID: 1408888

---
drivers/net/ieee802154/ca8210.c | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Awesome :)

Thanks
--
Gustavo A. R. Silva