]> git.karo-electronics.de Git - linux-beck.git/commitdiff
sh_eth: exit probe with unknown register layout
authorSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Sat, 15 Mar 2014 00:11:24 +0000 (03:11 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Mar 2014 20:05:18 +0000 (16:05 -0400)
Exit the driver's probe() method when the register layout is unknown as the
driver would cause kernel oops in this case anyway.

While at it, move the corresponding error message printout and convert it from
pr_err() to dev_err().

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/sh_eth.c

index 236a4414173a7c4c3be4642990d2c3d84f9310f6..8d8315bb0ceac12359513d5225263f23b2ce76c0 100644 (file)
@@ -2703,7 +2703,6 @@ static const u16 *sh_eth_get_register_offset(int register_type)
                reg_offset = sh_eth_offset_fast_sh3_sh2;
                break;
        default:
-               pr_err("Unknown register type (%d)\n", register_type);
                break;
        }
 
@@ -2859,6 +2858,12 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
                mdp->cd = (struct sh_eth_cpu_data *)match->data;
        }
        mdp->reg_offset = sh_eth_get_register_offset(mdp->cd->register_type);
+       if (!mdp->reg_offset) {
+               dev_err(&pdev->dev, "Unknown register type (%d)\n",
+                       mdp->cd->register_type);
+               ret = -EINVAL;
+               goto out_release;
+       }
        sh_eth_set_default_cpu_data(mdp->cd);
 
        /* set function */