mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] driver: call devinfo_del() during free_device_res()
@ 2025-11-27 11:34 Sascha Hauer
  2025-11-27 11:34 ` [PATCH 2/3] driver: call free_device_res() from unregister_device() Sascha Hauer
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2025-11-27 11:34 UTC (permalink / raw)
  To: Barebox List

devinfo_del() can safely be called mutiple times. Call it from
free_device_res() so that remaining resources are freed before the
device goes out of scope.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/base/driver.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index eca23d7c30..eefed4b1a5 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -348,6 +348,7 @@ EXPORT_SYMBOL(unregister_device);
  */
 void free_device_res(struct device *dev)
 {
+	devinfo_del(dev, NULL);
 	free(dev->unique_name);
 	dev->unique_name = NULL;
 	free(dev->deferred_probe_reason);
@@ -825,10 +826,11 @@ void devinfo_del(struct device *dev, void (*info)(struct device *))
 	devinfo_init(dev);
 
 	list_for_each_entry_safe(cb, tmp, &dev->info_list, list) {
-		if (cb->info == info) {
-			list_del(&cb->list);
-			free(cb);
-		}
+		if (info && cb->info != info)
+			continue;
+
+		list_del(&cb->list);
+		free(cb);
 	}
 }
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-28  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-27 11:34 [PATCH 1/3] driver: call devinfo_del() during free_device_res() Sascha Hauer
2025-11-27 11:34 ` [PATCH 2/3] driver: call free_device_res() from unregister_device() Sascha Hauer
2025-11-27 11:34 ` [PATCH 3/3] dm: fix memory leak Sascha Hauer
2025-11-28  7:11 ` [PATCH 1/3] driver: call devinfo_del() during free_device_res() Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox