diff mbox series

fs/namespace.c: fix missing return value check of ida_pre_get()

Message ID 20180818020300.4296-1-jasonwood2031@gmail.com (mailing list archive)
State New, archived
Headers show
Series fs/namespace.c: fix missing return value check of ida_pre_get() | expand

Commit Message

Jiecheng Wu Aug. 18, 2018, 2:03 a.m. UTC
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(-)

Comments

Matthew Wilcox Aug. 18, 2018, 2:09 a.m. UTC | #1
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.
diff mbox series

Patch

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)