linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get()
@ 2018-08-18  2:03 Jiecheng Wu
  2018-08-18  2:09 ` Matthew Wilcox
  0 siblings, 1 reply; 2+ messages in thread
From: Jiecheng Wu @ 2018-08-18  2:03 UTC (permalink / raw)
  To: linux-fsdevel

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get()
  2018-08-18  2:03 [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get() Jiecheng Wu
@ 2018-08-18  2:09 ` Matthew Wilcox
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2018-08-18  2:09 UTC (permalink / raw)
  To: Jiecheng Wu; +Cc: linux-fsdevel

On Sat, Aug 18, 2018 at 10:03:00AM +0800, Jiecheng Wu wrote:
> 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.

Please ignore as I've ripped all this code out in:

http://git.infradead.org/users/willy/linux-dax.git/commitdiff/4d1a8396bab0644d4d444dd28c0d622a22f39939?hp=20015ec08dd23a69776d86258c98e9b729dede8c

which is queued for Linus this merge window.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-18  5:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18  2:03 [PATCH] fs/namespace.c: fix missing return value check of ida_pre_get() Jiecheng Wu
2018-08-18  2:09 ` Matthew Wilcox

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