In fm_eth_bind there is a dereference of dev before it is NULL checked.
Add a NULL check before the first dereference and remove a later NULL
check that is now redundant.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <[email protected]>
---
 drivers/net/fm/eth.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fm/eth.c b/drivers/net/fm/eth.c
index c83b789693a..f0e7c0eca42 100644
--- a/drivers/net/fm/eth.c
+++ b/drivers/net/fm/eth.c
@@ -727,12 +727,15 @@ static int fm_eth_bind(struct udevice *dev)
        char mac_name[11];
        u32 fm, num;
 
+       if (!dev)
+               return -EINVAL;
+
        if (ofnode_read_u32(ofnode_get_parent(dev_ofnode(dev)), "cell-index", 
&fm)) {
                printf("FMan node property cell-index missing\n");
                return -EINVAL;
        }
 
-       if (dev && dev_read_u32(dev, "cell-index", &num)) {
+       if (dev_read_u32(dev, "cell-index", &num)) {
                printf("FMan MAC node property cell-index missing\n");
                return -EINVAL;
        }

-- 
2.39.5

Reply via email to