]> www.infradead.org Git - users/hch/misc.git/commitdiff
phy: fix xa_alloc_cyclic() error handling
authorMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Wed, 12 Mar 2025 09:52:51 +0000 (10:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Mar 2025 09:57:37 +0000 (09:57 +0000)
xa_alloc_cyclic() can return 1, which isn't an error. To prevent
situation when the caller of this function will treat it as no error do
a check only for negative here.

Fixes: 384968786909 ("net: phy: Introduce ethernet link topology representation")
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_link_topology.c

index 4a5d73002a1a85644ea5c4e993fce7b465f453cf..0e9e987f37dd84eccc95ed4f74c6cb47748990ab 100644 (file)
@@ -73,7 +73,7 @@ int phy_link_topo_add_phy(struct net_device *dev,
                                      xa_limit_32b, &topo->next_phy_index,
                                      GFP_KERNEL);
 
-       if (ret)
+       if (ret < 0)
                goto err;
 
        return 0;