From: Jiecheng Wu <jasonwood2031@gmail.com>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get()
Date: Sat, 18 Aug 2018 10:03:00 +0800 [thread overview]
Message-ID: <20180818020300.4296-1-jasonwood2031@gmail.com> (raw)
Function mnt_alloc_id() defined in fs/namespace.c calls ida_pre_get() to allocate memory. It may return 0 on failure. The return code should be checked against 0.
---
fs/namespace.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/namespace.c b/fs/namespace.c
index bd2f4c6..ae89b69 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -104,7 +104,8 @@ static int mnt_alloc_id(struct mount *mnt)
int res;
retry:
- ida_pre_get(&mnt_id_ida, GFP_KERNEL);
+ if (!ida_pre_get(&mnt_id_ida, GFP_KERNEL))
+ return -ENOMEM;
spin_lock(&mnt_id_lock);
res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id);
if (!res)
--
2.6.4
next reply other threads:[~2018-08-18 5:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-18 2:03 Jiecheng Wu [this message]
2018-08-18 2:09 ` [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get() Matthew Wilcox
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=20180818020300.4296-1-jasonwood2031@gmail.com \
--to=jasonwood2031@gmail.com \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).