drivers/net/ethernet/ti: Move call to PTR_ERR after reassignment
authorJulia Lawall <Julia.Lawall@lip6.fr>
Thu, 2 Feb 2012 04:53:01 +0000 (04:53 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 2 Feb 2012 19:35:12 +0000 (14:35 -0500)
PTR_ERR should be called before its argument is cleared.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression e,e1;
constant c;
@@

*e = c
... when != e = e1
    when != &e
    when != true IS_ERR(e)
*PTR_ERR(e)
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/davinci_emac.c
drivers/net/ethernet/ti/davinci_mdio.c

index 794ac30a577b61b1baaf8a1499c1e0f9ee41bcaf..4fa0bcb25dfc0d5dadeb175a4c36ada14c0f680d 100644 (file)
@@ -1600,8 +1600,9 @@ static int emac_dev_open(struct net_device *ndev)
                if (IS_ERR(priv->phydev)) {
                        dev_err(emac_dev, "could not connect to phy %s\n",
                                priv->phy_id);
+                       ret = PTR_ERR(priv->phydev);
                        priv->phydev = NULL;
-                       return PTR_ERR(priv->phydev);
+                       return ret;
                }
 
                priv->link = 0;
index ef7c9c17bfffccbebd94ba0530fc1643e947812e..af8b8fc39eb2c0d7702e760820759a1f6bac103c 100644 (file)
@@ -318,9 +318,9 @@ static int __devinit davinci_mdio_probe(struct platform_device *pdev)
 
        data->clk = clk_get(dev, NULL);
        if (IS_ERR(data->clk)) {
-               data->clk = NULL;
                dev_err(dev, "failed to get device clock\n");
                ret = PTR_ERR(data->clk);
+               data->clk = NULL;
                goto bail_out;
        }