]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: fm: Correct test for timeout
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Mon, 4 Aug 2025 16:03:57 +0000 (17:03 +0100)
committerPeng Fan <peng.fan@nxp.com>
Wed, 27 Aug 2025 07:39:57 +0000 (15:39 +0800)
In bmi_rx_port_disable and bmi_tx_port_disable the use of post-decrement
on the test in the while loop for a timeout means that timeout will be
equal to -1 on exit in that case. Adjust the test for this expected
value.

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 63fe4b2d33c46020c3aa34b0ac0bd79d0629e783..c83b789693ad6bdfa376991911d8f645c69baf8e 100644 (file)
@@ -169,7 +169,7 @@ static void bmi_rx_port_disable(struct fm_bmi_rx_port *rx_port)
        /* wait until the rx port is not busy */
        while ((in_be32(&rx_port->fmbm_rst) & FMBM_RST_BSY) && timeout--)
                ;
-       if (!timeout)
+       if (timeout == -1)
                printf("%s - timeout\n", __func__);
 }
 
@@ -199,7 +199,7 @@ static void bmi_tx_port_disable(struct fm_bmi_tx_port *tx_port)
        /* wait until the tx port is not busy */
        while ((in_be32(&tx_port->fmbm_tst) & FMBM_TST_BSY) && timeout--)
                ;
-       if (!timeout)
+       if (timeout == -1)
                printf("%s - timeout\n", __func__);
 }