Skip to contentSkip to conversation

sh_eth: check TSU registers ioremap() error

PATCH In review Sergei Shtylyov 3 participants 6 messages Mar 19, 2013 – Mar 20, 2013

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

PATCH 2/2 sh_eth: check TSU registers ioremap() error

One must check the result of ioremap() -- in this case it prevents potential kernel oops when initializing TSU registers further on...

---
 drivers/net/ethernet/renesas/sh_eth.c |    5 +++++
 1 file changed, 5 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +5 -0
Index: renesas/drivers/net/ethernet/renesas/sh_eth.c
===================================================================
@@ -2446,6 +2446,11 @@ static int sh_eth_drv_probe(struct platf
 		}
 		mdp->tsu_addr = ioremap(rtsu->start,
 					resource_size(rtsu));
+		if (mdp->tsu_addr == NULL) {
+			ret = -ENOMEM;
+			dev_err(&pdev->dev, "TSU ioremap failed.\n");
+			goto out_release;
+		}
 		mdp->port = devno % 2;
 		ndev->features = NETIF_F_HW_VLAN_FILTER;
 	}
#2 lore raw

Hello.

Quoted 8 lines · David Miller

From: Sergei Shtylyov <[email protected]>
Date: Wed, 20 Mar 2013 02:41:32 +0300

Quoted 4 lines

One must check the result of ioremap() -- in this case it prevents potential kernel oops when initializing TSU registers further on...

Applied and queued up for -stable.

Thanks. However, do you really think it's needed in stable? It's
only error path, after all...

WBR, Sergei

#3 lore raw
Quoted 10 lines · Sergei Shtylyov
Quoted 7 lines
Quoted 6 lines

One must check the result of ioremap() -- in this case it prevents potential kernel oops when initializing TSU registers further on...

Applied and queued up for -stable.

Thanks. However, do you really think it's needed in stable? It's
only error path, after all...

I forgot to add "unlikely" to the "error path". I usually don't mark
such patches for stable, when I'm not in a hurry. :-)

WBR, Sergei

#4 lore raw

It doesn't make sense to worry about branch misprediction during probe() :)

Quoted 24 lines · Sergei Shtylyov
Quoted 11 lines · Sergei Shtylyov
Quoted 8 lines
Quoted 7 lines

One must check the result of ioremap() -- in this case it prevents potential
kernel oops when initializing TSU registers further on...

Applied and queued up for -stable.

Thanks. However, do you really think it's needed in stable? It's
only error path, after all...

I forgot to add "unlikely" to the "error path". I usually don't mark
such patches for stable, when I'm not in a hurry. :-)

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hello.

Quoted 1 line · Denis Kirjanov

It doesn't make sense to worry about branch misprediction during probe() :)

You misunderstood. I didn't mean using unlikely() at all, just that
the ioremap() failure is unlikely.

PS: Please, don't top post.

Quoted 7 lines · Sergei Shtylyov
Quoted 6 lines · Sergei Shtylyov
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

One must check the result of ioremap() -- in this case it prevents potential
kernel oops when initializing TSU registers further on...

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Applied and queued up for -stable.

Thanks. However, do you really think it's needed in stable? It's
only error path, after all...

I forgot to add "unlikely" to the "error path". I usually don't mark
such patches for stable, when I'm not in a hurry. :-)

WBR, Sergei