Skip to contentSkip to conversation

smsc911x: Check platformdata pointer

PATCH Applied Jan Weitzel 2 participants 2 messages Sep 10, 2012 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 smsc911x: Check platformdata pointer

If pdata is NULL smc911x_probe will crash. Checking the zero initialized priv->shift results in default configuration if pdata is not set.

---
 drivers/net/smc911x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/smc911x.c +2 -2
index bc1e001..f697608 100644
@@ -435,7 +435,7 @@ static int smc911x_probe(struct device_d *dev)
 		priv->shift = pdata->shift;
 
 	if (is_32bit) {
-		if (pdata->shift) {
+		if (priv->shift) {
 			priv->reg_read = __smc911x_reg_readl_shift;
 			priv->reg_write = __smc911x_reg_writel_shift;
 		} else {
@@ -443,7 +443,7 @@ static int smc911x_probe(struct device_d *dev)
 			priv->reg_write = __smc911x_reg_writel;
 		}
 	} else {
-		if (pdata->shift) {
+		if (priv->shift) {
 			priv->reg_read = __smc911x_reg_readw_shift;
 			priv->reg_write = __smc911x_reg_writew_shift;
 		} else {
Signature · 7 lines
1.7.0.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 4 lines · Jan Weitzel

If pdata is NULL smc911x_probe will crash. Checking the zero initialized priv->shift results in default configuration if pdata is not set.

Applied, thanks

Sascha

Quoted 35 lines
---
 drivers/net/smc911x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/smc911x.c +2 -2
index bc1e001..f697608 100644
@@ -435,7 +435,7 @@ static int smc911x_probe(struct device_d *dev)
 		priv->shift = pdata->shift;
 
 	if (is_32bit) {
-		if (pdata->shift) {
+		if (priv->shift) {
 			priv->reg_read = __smc911x_reg_readl_shift;
 			priv->reg_write = __smc911x_reg_writel_shift;
 		} else {
@@ -443,7 +443,7 @@ static int smc911x_probe(struct device_d *dev)
 			priv->reg_write = __smc911x_reg_writel;
 		}
 	} else {
-		if (pdata->shift) {
+		if (priv->shift) {
 			priv->reg_read = __smc911x_reg_readw_shift;
 			priv->reg_write = __smc911x_reg_writew_shift;
 		} else {
Signature · 7 lines
1.7.0.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox