mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master] fs: ubootvarfs: fix double-free unlinking U-Boot variables
@ 2022-08-19 10:55 Ahmad Fatoum
  2022-08-22  8:54 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-08-19 10:55 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We free the struct ubootvarfs_inode::var as part of destroy_inode. In
case we have unlinked the U-Boot variable beforehand, we will end up
double-freeing. Set the member to NULL, so it's skipped in
destory_inode. We keep the free in destroy_inode, because that's still
needed for all the other inodes that aren't unlinked.

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

diff --git a/fs/ubootvarfs.c b/fs/ubootvarfs.c
index 475e4b7a79c4..147fee1ea631 100644
--- a/fs/ubootvarfs.c
+++ b/fs/ubootvarfs.c
@@ -259,6 +259,7 @@ static int ubootvarfs_unlink(struct inode *dir, struct dentry *dentry)
 
 		list_del(&var->list);
 		free(var);
+		node->var = NULL;
 	}
 
 	return simple_unlink(dir, dentry);
-- 
2.30.2




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

end of thread, other threads:[~2022-08-22  9:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19 10:55 [PATCH master] fs: ubootvarfs: fix double-free unlinking U-Boot variables Ahmad Fatoum
2022-08-22  8:54 ` Sascha Hauer

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