[PATCH master 6/7] fs: don't free device in remove callback

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 14 06:05:52 EDT 2020


The probe doesn't allocate the device, so remove shouldn't free it
either. This fixes a use-after-free on barebox shutdown:
Iterating over the list of devices requires that remove callbacks
don't remove the devices. This happened to work so far, because
apparently not much new allocations are going on during barebox
shutdown, but let's do it right.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 fs/fs.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index 17f4aee80fd4..303b62ae1718 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -710,7 +710,6 @@ static void fs_remove(struct device_d *dev)
 	mntput(fsdev->vfsmount.parent);
 
 	free(fsdev->backingstore);
-	free(fsdev);
 }
 
 struct bus_type fs_bus = {
-- 
2.28.0




More information about the barebox mailing list