]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
clk: Prevent memory leak on error
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Fri, 21 Nov 2025 17:34:33 +0000 (17:34 +0000)
committerTom Rini <trini@konsulko.com>
Fri, 5 Dec 2025 23:03:31 +0000 (17:03 -0600)
In clk_set_default_rates() memory is allocated to store the clock rates
that are read. Direct returns fail to free this memory leading to a
memory leak so instead use 'goto fail;' which will then perform the free
before exiting the function.

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

index a72a67d75a165c2d98bb702888e848f6b075fc7d..bf9f104193573918ad2efbce2bd2578948e44811 100644 (file)
@@ -338,7 +338,7 @@ static int clk_set_default_rates(struct udevice *dev,
                                continue;
                        }
 
-                       return ret;
+                       goto fail;
                }
 
                /* This is clk provider device trying to program itself