Return-Path: Received: from mail-pl0-f67.google.com ([209.85.160.67]:42552 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbeHRFJB (ORCPT ); Sat, 18 Aug 2018 01:09:01 -0400 Received: by mail-pl0-f67.google.com with SMTP id g23-v6so1506422plq.9 for ; Fri, 17 Aug 2018 19:03:11 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:1501:200:5efe:a66f:53fa]) by smtp.gmail.com with ESMTPSA id h69-v6sm5805562pfh.13.2018.08.17.19.03.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 17 Aug 2018 19:03:10 -0700 (PDT) From: Jiecheng Wu 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 Message-Id: <20180818020300.4296-1-jasonwood2031@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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