Skip to contentSkip to conversation

gianfar: Fix potential oops during OF address translation

PATCH In review Anton Vorontsov 2 participants 2 messages Apr 23, 2010

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

PATCH 2/2 gianfar: Fix potential oops during OF address translation

gianfar driver may pass NULL pointer to the of_translate_address(), which may lead to a kernel oops. Fix this by using of_iomap(), which is also much simpler and shorter.

---
 drivers/net/gianfar.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
drivers/net/gianfar.c +1 -5
index 080d1ce..df49af3 100644
@@ -549,12 +549,8 @@ static int gfar_parse_group(struct device_node *np,
 		struct gfar_private *priv, const char *model)
 {
 	u32 *queue_mask;
-	u64 addr, size;
-
-	addr = of_translate_address(np,
-			of_get_address(np, 0, &size, NULL));
-	priv->gfargrp[priv->num_grps].regs = ioremap(addr, size);
 
+	priv->gfargrp[priv->num_grps].regs = of_iomap(np, 0);
 	if (!priv->gfargrp[priv->num_grps].regs)
 		return -ENOMEM;
 
Signature · 1 line
1.7.0.5
maintainer
#1 lore raw

From: Anton Vorontsov <[email protected]>
Date: Fri, 23 Apr 2010 21:12:44 +0400

Quoted 5 lines

gianfar driver may pass NULL pointer to the of_translate_address(), which may lead to a kernel oops. Fix this by using of_iomap(), which is also much simpler and shorter.

Also applied to net-2.6, thanks.