mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] fs: ubootvarfs: fix double-free unlinking U-Boot variables
Date: Fri, 19 Aug 2022 12:55:21 +0200	[thread overview]
Message-ID: <20220819105521.3848169-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2022-08-19 10:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 10:55 Ahmad Fatoum [this message]
2022-08-22  8:54 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220819105521.3848169-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox