archive mirror
 help / color / mirror / Atom feed
From: Jiecheng Wu <>
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: <> (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;
-	ida_pre_get(&mnt_id_ida, GFP_KERNEL);
+	if (!ida_pre_get(&mnt_id_ida, GFP_KERNEL))
+		return -ENOMEM;
 	res = ida_get_new_above(&mnt_id_ida, mnt_id_start, &mnt->mnt_id);
 	if (!res)

             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:

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

  git send-email \ \ \ \

* 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).