NTFS3 file system kernel mode driver
 help / color / mirror / Atom feed
From: Su Hui <suhui@nfschina.com>
To: almaz.alexandrovich@paragon-software.com
Cc: Su Hui <suhui@nfschina.com>,
	ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] fs/ntfs3: Avoid possible NULL dereference
Date: Mon, 25 Sep 2023 12:48:06 +0800	[thread overview]
Message-ID: <20230925044807.92037-1-suhui@nfschina.com> (raw)

smatch error:
fs/ntfs3/attrib.c:1826 attr_allocate_frame() error:
we previously assumed 'attr_b' could be null (see line 1739)

Return error code directly if 'attr_b' is NULL.

Signed-off-by: Su Hui <suhui@nfschina.com>
---
 fs/ntfs3/attrib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index a9d82bbb4729..ebc934ac5cf5 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1737,8 +1737,7 @@ int attr_allocate_frame(struct ntfs_inode *ni, CLST frame, size_t compr_size,
 			attr_b = ni_find_attr(ni, NULL, &le_b, ATTR_DATA, NULL,
 					      0, NULL, &mi_b);
 			if (!attr_b) {
-				err = -ENOENT;
-				goto out;
+				return -ENOENT;
 			}
 
 			attr = attr_b;
-- 
2.30.2


             reply	other threads:[~2023-09-25  4:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25  4:48 Su Hui [this message]
2023-09-25  4:48 ` [PATCH 2/2] fs/ntfs3: Avoid possible memory leak Su Hui

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=20230925044807.92037-1-suhui@nfschina.com \
    --to=suhui@nfschina.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).