public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: sunliming@linux.dev
To: miklos@szeredi.hu, amir73il@gmail.com
Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	sunliming <sunliming@kylinos.cn>
Subject: [PATCH] ovl: Fix possible NULL pointer dereference in ovl_destroy_inode
Date: Tue, 21 Apr 2026 17:23:49 +0800	[thread overview]
Message-ID: <20260421092349.148002-1-sunliming@linux.dev> (raw)

From: sunliming <sunliming@kylinos.cn>

In the ovl_destroy_inode function, a variable reference oi->lowerdata_redirect
that might be NULL is directly freed. Add a non-null check, and only free
the space when it is not NULL.

Signed-off-by: sunliming <sunliming@kylinos.cn>
---
 fs/overlayfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c
index 60f0b7ceef0a..4b8b5fd4ab59 100644
--- a/fs/overlayfs/super.c
+++ b/fs/overlayfs/super.c
@@ -218,7 +218,7 @@ static void ovl_destroy_inode(struct inode *inode)
 	ovl_stack_put(ovl_lowerstack(oi->oe), ovl_numlower(oi->oe));
 	if (S_ISDIR(inode->i_mode))
 		ovl_dir_cache_free(inode);
-	else
+	else if (oi->lowerdata_redirect)
 		kfree(oi->lowerdata_redirect);
 }
 
-- 
2.25.1


             reply	other threads:[~2026-04-21  9:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  9:23 sunliming [this message]
2026-04-21  9:45 ` [PATCH] ovl: Fix possible NULL pointer dereference in ovl_destroy_inode Amir Goldstein
2026-04-21 11:37   ` sunliming

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=20260421092349.148002-1-sunliming@linux.dev \
    --to=sunliming@linux.dev \
    --cc=amir73il@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=sunliming@kylinos.cn \
    /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