Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp5119521imm; Tue, 12 Jun 2018 02:54:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLyyPWXtRrfozAji/PnbNmfoVpcq5+fqe+duawyDStc6u3nxhxKXwpzeGVDezXji4HaidOk X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr3243309plp.36.1528797241309; Tue, 12 Jun 2018 02:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528797241; cv=none; d=google.com; s=arc-20160816; b=P7ImMF274GiJglbjjlbmTR3SjJCxjJyjH0LfqP2rWrb2cODJ8FsyNFavyMRhIBrg6/ WVUN4jyNe9aUcJc32aBJK/EPwzdZhSLNlvu73CVNVsIngRtHzuHsI3gQZXl43fxY3PsW 1NEdmKY6/ErZnh/GuLlUJFBI1VIpamb6KZ7GahT2ZSEoOj0GLo78ejQBPCIipUuF98cD H2mJ2DLYIDsbdcG7byVX9kCoCHxe3mwD0HPPNbwe3kJZY1MsPO9xc52tleTVELyiScKy UzR+ZSmdtXqcbSJiqsPLG/H9GHDd1eBh0kGV5F0alfe6d6WnzQcn0xXPxBTz1XdQchbu BPxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=pa7pzSFLrUqF/vyckkBeEXxwhzU7rsV7SBQBwV99bHc=; b=HNZUhK/TFAsS0wtDgVQnso3woBdJG3H7kaJLesO/garKa1ggGC5rPPubgFMLz/RPK8 Nprqn84pF08TE/DNxkCO9uAxb0a48RWxWqt2j/Z1v9ZL5x/jLPLKWBBGuiWtlWwCjtTQ kQSmE0HzL4M1DDKtpcte2yjE+wvEtWElIVGYejAVDiWynR7RxKJ1iG9nI1HPJM+Urtaq nNiX/FDPRmYwumK0CkH5ZQ6UpSophvPFvcJx5APc+I0D1v/0PQiPWh8O336yq0L2BkRV giYE6MRx6k0CBAdp0G1un5G5+eUMnbn/uucWsFemOuUiuxPZ/MQrA2eoFJaNTvfeTF05 4tRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tyytkrFv; 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 a7-v6si419108pgv.360.2018.06.12.02.53.46; Tue, 12 Jun 2018 02:54:01 -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=tyytkrFv; 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 S1754339AbeFLJxP (ORCPT + 99 others); Tue, 12 Jun 2018 05:53:15 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:42927 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932639AbeFLJxN (ORCPT ); Tue, 12 Jun 2018 05:53:13 -0400 Received: by mail-oi0-f68.google.com with SMTP id k190-v6so20527164oib.9; Tue, 12 Jun 2018 02:53:13 -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:content-transfer-encoding; bh=pa7pzSFLrUqF/vyckkBeEXxwhzU7rsV7SBQBwV99bHc=; b=tyytkrFv6Rm5bHzh0DC56UBn7VjFkm5AnbuFA4dBa4E9kqwqB6tJEnZ08ZkhTb4ATL cGiaJDzvb1x9/fMbOn44FMp36yNP7hg0jNtepTMDViBs/7eBOs1Hl/PBIhfiHKOFX23b 6Hf9aKxGU9+GiU91frz7lGcRHTd23SPLyPktRn9er0K9X5CRJU17j40AIHC1nYFHi59c e77wVhj3SLLMUNzm7Js+ddvNjtqsCYzyxnyUenhSvNvosb/aeol3dg4saTENsrS3Ouzu VHp/m+HmQbr9lAThvTLbiydl53+0bFqXhMYKPvfT2FkkFynt9TJc4Ku36BYWR1u1H9Dv YF0Q== 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:content-transfer-encoding; bh=pa7pzSFLrUqF/vyckkBeEXxwhzU7rsV7SBQBwV99bHc=; b=UfXjsBf4YZ4pmrThEPUND/Cf5Mbeu3oGReQp39mxPHedFyiYCfERv5iXzKP8b/uuJ+ JmPWzG77SHvkJPN2hKmLv1FMDJnQY2lALAldK6JFZ1aXhqoNLdDP9Olf0OdtPb1OsyLN 33cB73Us0d3sTW3pjXmDKNQ8uGzlvI0omgsS4eezsMNKTFC3XSuWVkAO913aa2XKDw3R pHiVVF0oUlRT7LJtYPc4jeHBL/mkB47TMXHjyLeofuE+o8YFeqN/IwKS9s9wiN5dqM9l CiYNwHc4b7NShz0Oiu/rddFO2vOo8ugaE30wBNCox2S42xMYcXKMhNp8VS0PHMIJScfG kO/g== X-Gm-Message-State: APt69E3prEB+N2685+zfnKmRMHBTADyLwVVKH0vWSmhX2JzMth/9h+Dk PGNwtmJiSa73zfGndWYa+W8UEyeIp7J1p+hTs14= X-Received: by 2002:aca:4f0d:: with SMTP id d13-v6mr1448718oib.138.1528797193001; Tue, 12 Jun 2018 02:53:13 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5187:0:0:0:0:0 with HTTP; Tue, 12 Jun 2018 02:53:12 -0700 (PDT) In-Reply-To: <5381809C-13EE-42BC-883B-F8E5A90FD1C5@gmx.com> References: <1528777362-40212-1-git-send-email-jiazhouyang09@gmail.com> <5381809C-13EE-42BC-883B-F8E5A90FD1C5@gmx.com> From: Kassey Date: Tue, 12 Jun 2018 17:53:12 +0800 Message-ID: Subject: Re: [PATCH] inotify: add error handling for kmem_cache_create To: "cgxu519@gmx.com" Cc: Zhouyang Jia , Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org in __kmem_cache_create->kmem_cache_open with SLAB_PANIC, kernel will panic if it fail On Tue, Jun 12, 2018 at 3:41 PM, cgxu519@gmx.com wrote: > >> =E5=9C=A8 2018=E5=B9=B46=E6=9C=8812=E6=97=A5=EF=BC=8C=E4=B8=8B=E5=8D=881= 2:22=EF=BC=8CZhouyang Jia =E5=86=99=E9=81=93=EF= =BC=9A >> >> 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. > > I think SLAB_PANIC can handle this case. > > Thanks, > Chengguang. > >> >> 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/inotif= y_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) !=3D 21); >> >> inotify_inode_mark_cachep =3D KMEM_CACHE(inotify_inode_mark, SLAB_= PANIC); >> + if (!inotify_inode_mark_cachep) >> + return -ENOMEM; >> >> inotify_max_queued_events =3D 16384; >> init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES] =3D 128; >> -- >> 2.7.4 >> > --=20 Best regards Kassey