Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4862001imm; Mon, 11 Jun 2018 21:23:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYADuSbJQMY8ML/VHjSLX2J4ckDxfwTT88X3dMbHHHaVfiW2T3yZsn+xzPsMNqR/HGk1ZW X-Received: by 2002:a17:902:9883:: with SMTP id s3-v6mr2209257plp.194.1528777405787; Mon, 11 Jun 2018 21:23:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528777405; cv=none; d=google.com; s=arc-20160816; b=lw2l7z1XBdXmbJfg+G8l5vHkShb11vdrngikHS7KAjJbXz+Sk0TJTmopLRj5pqZXoF se6n0+VUW5tkXyoujuQXT1a2BeEUwuJqb6vQIkZ7UVLiRQFkHW9oJRLQjYK38ODtKJO9 3tFmM2xppO3iK0NmYEPo3UZMe9uDcsJZdJtEon+YAzV4v5iKZt+iXe2bbAq988fRsMD8 oTxpTVMoEH+T90qNK+aLGKXw2aMjkTtxr+ps6F8BY8sLOVpKqfeARMiMoGioHhy9hIcX UWihwo1x9lUvsVA4k1ncRUa980WBQN0ZxlK6sVBziwBT1K2eDOeAcnWwCFazHyiiZX8W MVww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=uHfPz/0FW3DSovSQYFdQIsmxMGKsKBoCByGmkyBWYKA=; b=iWnx2vw1wcWOGbO813a+1E3jmXL/Go3H7gxQrMcDKK1vATPvNAIbFaOE5bGq7yqfEu 8/PXfPTJk4Owblgw8Dfz5G7oQru2Oe/NKz7WSFnuXkZFO4vqRE6heAgxnkxEdYGHf6RP R9fKtqvDMRcAlmkKMkiYyTSi0TeGiFBEUr6/bFq3lCCx/PrLMSOkGaNJZKUeg4AkNbvu dPNQoCesGQuipDQWojDkWClMmHT2aAEMSE/J87wnI9PZyaXIKXOcyR7D3Xj1meKXO8KF /j6d7CL9TL+FNzvYdBw0P6Ae0UXLZEO4Cd0BVAuzovc5IwdwzuhMbXUBnkBbsdSaJjhA FMkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VL4+v27h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12-v6si27045942plk.48.2018.06.11.21.23.10; Mon, 11 Jun 2018 21:23:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=VL4+v27h; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753202AbeFLEWu (ORCPT + 99 others); Tue, 12 Jun 2018 00:22:50 -0400 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 Received: by mail-pl0-f68.google.com with SMTP id n10-v6so13593055plp.0; Mon, 11 Jun 2018 21:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=uHfPz/0FW3DSovSQYFdQIsmxMGKsKBoCByGmkyBWYKA=; b=VL4+v27h66QkObEfYs32z1TljQLoSd4MfG1ZFZ6DaYH7IqimT+ha0FgVkJPCFeZfkw XT2t9apL+bAoeP2x6ra2N7ra7MRB297I/61bWvFIwBFYfZHOoUUob/DHLuBD0mu1Pcnd gQBuuoRdH7ACzW9R9ke/zn0t6okMUKWphEQfHv2D1H++P3gsZbJG52J57D1DkOrnDnOP IVDXcPpMYIJ6eBDIf2fB7BxxZ1J2Ky161736Fbw0Zy7HGCFriQDR/wowyqz5uDwaLpQV iPzSX61r36LRGduqj0uPKnP3wDmBvcIrnvrpYpq1lmed7P3bhuN9ALtAnOAzaLbzRjEg UUCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=uHfPz/0FW3DSovSQYFdQIsmxMGKsKBoCByGmkyBWYKA=; b=Jd8Qs6WYFnQSGX37Z+tE/DDwvxJmChBvHTN6Yykwsbgu8pYf42jD3Q+XAsjpFMoO+a Vu/MPu6vKCxC4ihRkq+I9ovNou78gabkCgE+TY0CzTtMR14FataeUQiPahnRBoZS3/2B 3MoHuJdD0FV4Mp5J35Y0nk0UXqHwDXd5Vj4XX9Wjey4NZiBdAyvZRWqprNMRpPUC5my0 xFLTQElqNi3k+s8Wh+IWSylFub5nFqGVbv24spMH31wFJ81J+1S+xITgXv+tniE8gpie CTCQosIm0m7Csw2F2vtqaqfBDItImGTqmT5KYt60+3EN6LF0gu2xlNGlA2gJnEPQzjba EYjQ== X-Gm-Message-State: APt69E1kz68oaguEAeP+ysnFYlUGC8bE4KfbcarpXHQKcr5YqD03+Nn0 NVdg4SgU+MrO8rd84x0y1YeHmp8naR0= X-Received: by 2002:a17:902:206:: with SMTP id 6-v6mr2205808plc.294.1528777368784; Mon, 11 Jun 2018 21:22:48 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id u84-v6sm78869678pfg.156.2018.06.11.21.22.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:22:48 -0700 (PDT) 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> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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