[PATCH 1/8] regmap-mmio: don't call kfree on non kmalloc allocated buffers

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jul 16 04:58:27 PDT 2024


If we don't use kmalloc() or friends, we shouldn't use kfree() to free
the buffer either.

Currently, kfree and free are identical, but they are defined in
different headers.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 drivers/base/regmap/regmap-mmio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 01b0a9963110..9d2ab9cb8dc7 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -7,6 +7,7 @@
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <io.h>
+#include <malloc.h>
 #include <linux/regmap.h>
 
 #include "internal.h"
@@ -272,7 +273,7 @@ static struct regmap_mmio_context *regmap_mmio_gen_context(struct device *dev,
 	return ctx;
 
 err_free:
-	kfree(ctx);
+	free(ctx);
 
 	return ERR_PTR(ret);
 }
@@ -293,7 +294,7 @@ struct regmap *regmap_init_mmio_clk(struct device *dev,
 
 		clk = clk_get(dev, clk_id);
 		if (IS_ERR(clk)) {
-			kfree(ctx);
+			free(ctx);
 			return ERR_CAST(clk);
 		}
 
-- 
2.39.2




More information about the barebox mailing list