summaryrefslogtreecommitdiffstats
path: root/fs/ubootvarfs.c
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-08-19 12:55:21 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-08-22 10:54:38 +0200
commit7fce4ae853b090559a33ea36f8beacc7926dc2a3 (patch)
tree0eb474445bf5c41edc5338c98fa77dc3631fb508 /fs/ubootvarfs.c
parent81f0511d0fde5ac917fb322f2ad2184b3b033eec (diff)
downloadbarebox-7fce4ae853b090559a33ea36f8beacc7926dc2a3.tar.gz
barebox-7fce4ae853b090559a33ea36f8beacc7926dc2a3.tar.xz
fs: ubootvarfs: fix double-free unlinking U-Boot variables
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> Link: https://lore.barebox.org/20220819105521.3848169-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/ubootvarfs.c')
-rw-r--r--fs/ubootvarfs.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/ubootvarfs.c b/fs/ubootvarfs.c
index 475e4b7a79..147fee1ea6 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);