Skip to contentSkip to conversation

wireless: potential null deref in p54spi.c

PATCH New Dan Carpenter 2 participants 3 messages Jul 19, 2009 – Jul 22, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wireless: potential null deref in p54spi.c

We can't use dev_err() becuase "priv" is NULL.

Found by smatch (http://repo.or.cz/w/smatch.git).

regards,
dan carpenter

drivers/net/wireless/p54/p54spi.c +1 -1
@@ -635,7 +635,7 @@
 
 	hw = p54_init_common(sizeof(*priv));
 	if (!hw) {
-		dev_err(&priv->spi->dev, "could not alloc ieee80211_hw");
+		printk(KERN_ERR "could not alloc ieee80211_hw");
 		return -ENOMEM;
 	}
 
#1 lore raw

PATCH v2 1/1 p54spi: fix potential null deref in p54spi.c

From: Dan Carpenter <[email protected]>

Fix a potential NULL dereference bug during
error handling in p54spi_probe.

This bug was discovered by smatch:
(http://repo.or.cz/w/smatch.git).

---

Quoted 1 line · On Sunday 19 July 2009 13:53:57 Dan Carpenter wrote:

We can't use dev_err() becuase "priv" is NULL.

yep, but that's my fault and not Micheal's.

Quoted 3 lines

Found by smatch (http://repo.or.cz/w/smatch.git).
regards,
dan carpenter

what about this alternative?
it retains the dev_err by simply moving to the spi_device *spi which comes from spi-subsystem and is initialized?

Regards,
Chr
---

drivers/net/wireless/p54/p54spi.c +1 -1
index d5f181a..eef5329 100644
@@ -600,7 +600,7 @@ static int __devinit p54spi_probe(struct spi_device *spi)
 
 	hw = p54_init_common(sizeof(*priv));
 	if (!hw) {
-		dev_err(&priv->spi->dev, "could not alloc ieee80211_hw");
+		dev_err(&spi->dev, "could not alloc ieee80211_hw");
 		return -ENOMEM;
 	}
 
author Acked-by on v2 1/1
#2 lore raw

Re: [PATCH v2] p54spi: fix potential null deref in p54spi.c

Great.

regards,
dan carpenter

Quoted 44 lines · Christian Lamparter

From: Dan Carpenter <[email protected]>

Fix a potential NULL dereference bug during
error handling in p54spi_probe.

This bug was discovered by smatch:
(http://repo.or.cz/w/smatch.git).

---

Quoted 1 line · On Sunday 19 July 2009 13:53:57 Dan Carpenter wrote:

We can't use dev_err() becuase "priv" is NULL.

yep, but that's my fault and not Micheal's.

Quoted 3 lines

Found by smatch (http://repo.or.cz/w/smatch.git).
regards,
dan carpenter

what about this alternative?
it retains the dev_err by simply moving to the spi_device *spi which comes from spi-subsystem and is initialized?

Regards,
Chr
---

drivers/net/wireless/p54/p54spi.c +1 -1
index d5f181a..eef5329 100644
@@ -600,7 +600,7 @@ static int __devinit p54spi_probe(struct spi_device
 *spi)
 
 	hw = p54_init_common(sizeof(*priv));
 	if (!hw) {
-		dev_err(&priv->spi->dev, "could not alloc ieee80211_hw");
+		dev_err(&spi->dev, "could not alloc ieee80211_hw");
 		return -ENOMEM;
 	}