From: Nickolai Zeldovich <nickolai@csail.mit.edu>
To: Anton Altaparmakov <anton@tuxera.com>
Cc: Nickolai Zeldovich <nickolai@csail.mit.edu>,
linux-ntfs-dev@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: [PATCH] ntfs: do not dereference a null ctx on error
Date: Wed, 16 Jan 2013 21:28:29 -0500 [thread overview]
Message-ID: <1358389709-20561-1-git-send-email-nickolai@csail.mit.edu> (raw)
In ntfs_mft_data_extend_allocation_nolock(), if an error condition occurs
prior to 'ctx' being set to a non-NULL value, avoid dereferencing the NULL
'ctx' pointer by jumping to later cleanup code.
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
---
fs/ntfs/mft.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 3014a36..e6ea11c 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -1822,13 +1822,13 @@ static int ntfs_mft_data_extend_allocation_nolock(ntfs_volume *vol)
if (IS_ERR(mrec)) {
ntfs_error(vol->sb, "Failed to map mft record.");
ret = PTR_ERR(mrec);
- goto undo_alloc;
+ goto undo_alloc_noctx;
}
ctx = ntfs_attr_get_search_ctx(mft_ni, mrec);
if (unlikely(!ctx)) {
ntfs_error(vol->sb, "Failed to get search context.");
ret = -ENOMEM;
- goto undo_alloc;
+ goto undo_alloc_noctx;
}
ret = ntfs_attr_lookup(mft_ni->type, mft_ni->name, mft_ni->name_len,
CASE_SENSITIVE, rl[1].vcn, NULL, 0, ctx);
@@ -1988,8 +1988,8 @@ undo_alloc:
"context.%s", es);
NVolSetErrors(vol);
}
- if (ctx)
- ntfs_attr_put_search_ctx(ctx);
+ ntfs_attr_put_search_ctx(ctx);
+undo_alloc_noctx:
if (!IS_ERR(mrec))
unmap_mft_record(mft_ni);
up_write(&mft_ni->runlist.lock);
--
1.7.10.4
next reply other threads:[~2013-01-17 2:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-17 2:28 Nickolai Zeldovich [this message]
2023-04-07 19:44 Danila Chernetsov
2023-05-05 6:20 ` Namjae Jeon
2023-05-06 0:52 ` Namjae Jeon
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=1358389709-20561-1-git-send-email-nickolai@csail.mit.edu \
--to=nickolai@csail.mit.edu \
--cc=anton@tuxera.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-ntfs-dev@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®