Skip to content

Commit

Permalink
net: ethernet: ti: cpsw-phy-sel: check bus_find_device() ret value
Browse files Browse the repository at this point in the history
This fixes klockworks warnings: Pointer 'dev' returned from call to
function 'bus_find_device' at line 179 may be NULL and will be dereferenced
at line 181.

    cpsw-phy-sel.c:179: 'dev' is assigned the return value from function 'bus_find_device'.
    bus.c:342: 'bus_find_device' explicitly returns a NULL value.
    cpsw-phy-sel.c:181: 'dev' is dereferenced by passing argument 1 to function 'dev_get_drvdata'.
    device.h:1024: 'dev' is passed to function 'dev_get_drvdata'.
    device.h:1026: 'dev' is explicitly dereferenced.

Signed-off-by: Grygorii Strashko <[email protected]>
[[email protected]: add an error message, fix return path]
Signed-off-by: Sekhar Nori <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
grygoriyS authored and davem330 committed May 16, 2018
1 parent b3c898e commit c6213eb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/net/ethernet/ti/cpsw-phy-sel.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,18 @@ void cpsw_phy_sel(struct device *dev, phy_interface_t phy_mode, int slave)
}

dev = bus_find_device(&platform_bus_type, NULL, node, match);
of_node_put(node);
if (!dev) {
dev_err(dev, "unable to find platform device for %pOF\n", node);
goto out;
}

priv = dev_get_drvdata(dev);

priv->cpsw_phy_sel(priv, phy_mode, slave);

put_device(dev);
out:
of_node_put(node);
}
EXPORT_SYMBOL_GPL(cpsw_phy_sel);

Expand Down

0 comments on commit c6213eb

Please sign in to comment.