1 From foo@baz Sat Jul 28 10:25:26 CEST 2018
2 From: Grygorii Strashko <grygorii.strashko@ti.com>
3 Date: Tue, 15 May 2018 18:37:25 -0500
4 Subject: net: ethernet: ti: cpsw-phy-sel: check bus_find_device() ret value
6 From: Grygorii Strashko <grygorii.strashko@ti.com>
8 [ Upstream commit c6213eb1aee308e67377fd1890d84f7284caf531 ]
10 This fixes klockworks warnings: Pointer 'dev' returned from call to
11 function 'bus_find_device' at line 179 may be NULL and will be dereferenced
14 cpsw-phy-sel.c:179: 'dev' is assigned the return value from function 'bus_find_device'.
15 bus.c:342: 'bus_find_device' explicitly returns a NULL value.
16 cpsw-phy-sel.c:181: 'dev' is dereferenced by passing argument 1 to function 'dev_get_drvdata'.
17 device.h:1024: 'dev' is passed to function 'dev_get_drvdata'.
18 device.h:1026: 'dev' is explicitly dereferenced.
20 Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
21 [nsekhar@ti.com: add an error message, fix return path]
22 Signed-off-by: Sekhar Nori <nsekhar@ti.com>
23 Signed-off-by: David S. Miller <davem@davemloft.net>
24 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27 drivers/net/ethernet/ti/cpsw-phy-sel.c | 8 +++++++-
28 1 file changed, 7 insertions(+), 1 deletion(-)
30 --- a/drivers/net/ethernet/ti/cpsw-phy-sel.c
31 +++ b/drivers/net/ethernet/ti/cpsw-phy-sel.c
32 @@ -177,12 +177,18 @@ void cpsw_phy_sel(struct device *dev, ph
35 dev = bus_find_device(&platform_bus_type, NULL, node, match);
38 + dev_err(dev, "unable to find platform device for %pOF\n", node);
42 priv = dev_get_drvdata(dev);
44 priv->cpsw_phy_sel(priv, phy_mode, slave);
50 EXPORT_SYMBOL_GPL(cpsw_phy_sel);