]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: fm: NULL check dev before dereference
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Mon, 4 Aug 2025 16:03:58 +0000 (17:03 +0100)
committerPeng Fan <peng.fan@nxp.com>
Wed, 27 Aug 2025 07:39:57 +0000 (15:39 +0800)
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 <andrew.goodbody@linaro.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/net/fm/eth.c

index c83b789693ad6bdfa376991911d8f645c69baf8e..f0e7c0eca42d150f03f65b6f41e48c96ad701794 100644 (file)
@@ -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;
        }