diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-08-19 12:55:21 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-22 10:54:38 +0200 |
commit | 7fce4ae853b090559a33ea36f8beacc7926dc2a3 (patch) | |
tree | 0eb474445bf5c41edc5338c98fa77dc3631fb508 /fs/ubootvarfs.c | |
parent | 81f0511d0fde5ac917fb322f2ad2184b3b033eec (diff) | |
download | barebox-7fce4ae853b090559a33ea36f8beacc7926dc2a3.tar.gz |
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.c | 1 |
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); |