net: ethernet: ti: cpsw-phy-sel: check bus_find_device() ret value
authorGrygorii Strashko <grygorii.strashko@ti.com>
Tue, 15 May 2018 23:37:25 +0000 (18:37 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:55:21 +0000 (07:55 +0200)
commit1fa620150c9b1b09f56def71aab060718c1cad64
tree517ac8b144278482a1467a2c37fd2fec69d38b10
parent77b6f72cefc82861216cd8e85c6c86d39107da32
net: ethernet: ti: cpsw-phy-sel: check bus_find_device() ret value

[ Upstream commit c6213eb1aee308e67377fd1890d84f7284caf531 ]

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 <grygorii.strashko@ti.com>
[nsekhar@ti.com: add an error message, fix return path]
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/ti/cpsw-phy-sel.c