net: mvpp2: Use field just assigned in error test
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Tue, 5 Aug 2025 14:18:19 +0000 (15:18 +0100)
committerJerome Forissier <jerome.forissier@linaro.org>
Mon, 18 Aug 2025 13:47:57 +0000 (15:47 +0200)
In mvpp2_probe the code attempts to get a value for "gop-port-id" and
assigns it to port->gop_id but it then tests port->id for being equal to
-1. That is an impossible test as port->id is a field of type u8 so
cannot be negative. Change the test to port->gop_id.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
drivers/net/mvpp2.c

index 3a3510f..f9e979c 100644 (file)
@@ -5353,7 +5353,7 @@ static int mvpp2_probe(struct udevice *dev)
        } else {
                port->gop_id = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
                                              "gop-port-id", -1);
-               if (port->id == -1) {
+               if (port->gop_id == -1) {
                        dev_err(dev, "missing gop-port-id value\n");
                        return -EINVAL;
                }