Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4910563imm; Mon, 11 Jun 2018 22:32:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJirNnxBpuCnQEthY8wASvUE2Pk6es4xsluQ664jqFANBq4ZOUHccKzvOta81E+KtHN+rlK X-Received: by 2002:a17:902:6b8b:: with SMTP id p11-v6mr2434615plk.212.1528781570550; Mon, 11 Jun 2018 22:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528781570; cv=none; d=google.com; s=arc-20160816; b=Ju62bNfgNs4r65cSnCghjTWoLkE8jHzMnnVBYRjl5gXxG06nFyScNb8xmP1Yqcv6FG Ipqv7MzCb+RMObCwNVPVgpu/iDgBe4/BeFLDxy3AXz5OswHl5oQN+dgUPmT67/XUO0Nt TMmc/WxcQMWCKhNroJajtRht797Y7F4yrYyMxe2jhPbe83UAzRFAOUa4rkcOUThmqIJ2 zxAwVdRg2sHDnAV6ojA/+FKj30d8kEA9B5U8eMHvP7voS+rWGEd61NSe2piQwPTiRRvT W4pHZfpNPOuvPYi00xyn141YWJxaAJAPjjAL9f/RY2ZZ+UVUOdp/m2ZbtN9LuU60F86G ED3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=5SP2n5WBdA+IozLYtV2m690qBT9t4zUE1sxh2Fu2vQQ=; b=exVVREK0fXCENPofGb2rX4Tte3NyG31EEGrLyd1vHaKCPygw0H9gXHanPEUVEUHWSr UrZwckTORCQH6xWxOp0EVgHYq1Nx5w+dzUwGrNcQVvNaFWaURKzeGW00pibLIVk1Z/7z P1pAJsq0YM6fZ2niyNGURu1dcnGiLNvvSo/gLagv6vqHaI/va9MM5Nr1p+YAosVL7eDb Er2xy67uCsLLoiwvz5ijJAKKjZC99en4d5UQTg+1qKn5RaqAdfnSjNFPhAZzH7lIqME3 dmviIgNEDKAvbOKdIv3bVjMQjjcN9QQBX9NUjXH6G7yn9OX7CG1UDyqvebsMZeWEHLL+ LPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=baJZAMMB; 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=pass (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 n3-v6si48010pld.116.2018.06.11.22.32.35; Mon, 11 Jun 2018 22:32:50 -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=pass header.i=@gmail.com header.s=20161025 header.b=baJZAMMB; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932630AbeFLFcL (ORCPT + 99 others); Tue, 12 Jun 2018 01:32:11 -0400 Received: from mail-yw0-f193.google.com ([209.85.161.193]:39884 "EHLO mail-yw0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753584AbeFLFcK (ORCPT ); Tue, 12 Jun 2018 01:32:10 -0400 Received: by mail-yw0-f193.google.com with SMTP id 81-v6so7105709ywb.6; Mon, 11 Jun 2018 22:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=5SP2n5WBdA+IozLYtV2m690qBT9t4zUE1sxh2Fu2vQQ=; b=baJZAMMBentMrgyOIG8410RtMDLvsOFVhFlrlB5v7qFf3+0rPZR6044zVmJjTjDjiZ INSTujkr0OYMduff3BmFNMdozRkyfH9r8kQKzaK/nd0ZMSq61pGn0irK9qeex5q/iOP7 qj9vMK543TbfaDJ9dasf/9X4qWEpUilcw3F96LsmIv7dQ6z56wPMyvpZYPjTE/6Te0Y3 Z0wpnDy5vel/0L4F5un1NZDWxLcRx3DQGTCQxzKa0zo6zelpUinOfWIMgxgQxuOYIZhy zSPiaxHFcMss03pfOVt8nh1QNPkSLOQNjuBWO5V2QS9R+i1mU5rke0D7Bd7rb9oCPY88 dMPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=5SP2n5WBdA+IozLYtV2m690qBT9t4zUE1sxh2Fu2vQQ=; b=hBntX7kckQVB6EFrFSazwsrUIa05lAXKtU9v7M21nOY60yG5V2EzKTroXuZ4R4Mhmq nd5gUYNS4qphTj3APfnF1UzEjiEPV4C5BRySROGGlrvW1q+PYJ5drn7eULPEQ7E+UXNu gpK0sN68k1sD5bu3ggIHJnizubCQ1P5LOmfYIFR/Fnttu+dbwAiiM+ozB0bYRKH3QwKW ETffr8r5ViZkb7TlWBgyQNSiTMZJyYhlXknc5c4cFnTtL/yWHElU2q4m4CKe2H8fOojX G4LZmBjI2ufDrOJgzKjhteC7RyNd1HQ0BzsfVSvRlEXdndYeOOSwpFxOAdnxQhDtD3rM YN4w== X-Gm-Message-State: APt69E1Hm2+syvcBOZjDPn3Bn4InX/5cs1vPAcIPdxo1mL3enbaCbROe 12Y0CZXc2rV+bdDEF3sF2eXSpjYSQ4kjdeBwrCA= X-Received: by 2002:a81:168a:: with SMTP id 132-v6mr828013yww.183.1528781529894; Mon, 11 Jun 2018 22:32:09 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a81:79cf:0:0:0:0:0 with HTTP; Mon, 11 Jun 2018 22:32:09 -0700 (PDT) In-Reply-To: <1528776964-39826-1-git-send-email-jiazhouyang09@gmail.com> References: <1528776964-39826-1-git-send-email-jiazhouyang09@gmail.com> From: Amir Goldstein Date: Tue, 12 Jun 2018 08:32:09 +0300 Message-ID: Subject: Re: [PATCH] fsnotify: add error handling for kmem_cache_create To: Zhouyang Jia Cc: Jan Kara , linux-fsdevel , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 12, 2018 at 7:16 AM, Zhouyang Jia wrote: > 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/dnotify/dnotify.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/notify/dnotify/dnotify.c b/fs/notify/dnotify/dnotify.c > index 63a1ca4..216b411 100644 > --- a/fs/notify/dnotify/dnotify.c > +++ b/fs/notify/dnotify/dnotify.c > @@ -387,6 +387,9 @@ static int __init dnotify_init(void) > dnotify_struct_cache = KMEM_CACHE(dnotify_struct, SLAB_PANIC); > dnotify_mark_cache = KMEM_CACHE(dnotify_mark, SLAB_PANIC); > > + if (!dnotify_struct_cache || !dnotify_mark_cache) > + return -ENOMEM; > + If only one failed need to free the other. > dnotify_group = fsnotify_alloc_group(&dnotify_fsnotify_ops); > if (IS_ERR(dnotify_group)) > panic("unable to allocate fsnotify group for dnotify\n"); > -- > 2.7.4 >