Return-Path: Received: from mail-pl0-f68.google.com ([209.85.160.68]:32988 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752583AbeFLEWt (ORCPT ); Tue, 12 Jun 2018 00:22:49 -0400 From: Zhouyang Jia Cc: Zhouyang Jia , Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] inotify: add error handling for kmem_cache_create Date: Tue, 12 Jun 2018 12:22:42 +0800 Message-Id: <1528777362-40212-1-git-send-email-jiazhouyang09@gmail.com> To: unlisted-recipients:; (no To-header on input) Sender: linux-fsdevel-owner@vger.kernel.org List-ID: When kmem_cache_create fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling kmem_cache_create. Signed-off-by: Zhouyang Jia --- fs/notify/inotify/inotify_user.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index ef32f36..0704bab 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -805,6 +805,8 @@ static int __init inotify_user_setup(void) BUG_ON(hweight32(ALL_INOTIFY_BITS) != 21); inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark, SLAB_PANIC); + if (!inotify_inode_mark_cachep) + return -ENOMEM; inotify_max_queued_events = 16384; init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES] = 128; -- 2.7.4