Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4857962imm; Mon, 11 Jun 2018 21:17:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfQDkVRqHgbmpOr1qbmQdo/r+5yYGrQTKcfzvPNFwPk5p7w6OZ20cXovW7ADNZn6LBwFFT X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr1719394pge.67.1528777041507; Mon, 11 Jun 2018 21:17:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528777041; cv=none; d=google.com; s=arc-20160816; b=GdfGqhlP96RG0Pian/vUhnbxfVQHERLgX/G2Lpml/5yqzuMDt9ol3/DK0Kkqe1HiVh 6kh1M8x4pPRI8LuNWenz2P2gzqCKHcuS6XSH4IQJmCygdlF0Tu6lJIy7/3JBC9KStzhr 0Z/IPTAM11p6r0B+WAYFKWwfUe1N4BpioAvlVmUBcXdmapla6sFn9AZ/idDToI+jnIYy 6v/+75vRvdkCx2a1wDkrcpwP7NBIHfhsMGNXBqYtLkURbwydJ7/KEKhh3m7z2XMpPBbG gpR6KFPAECpJf1ffw5aXpqcl7x3P02utZjLZHXxfq/J0dnWlJetH/xdlAlos63VaD515 gQ9g== 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=2e58dYCyHjCrRMzvDJHZ4B3vN5K2NBtjTra2hTQl9ng=; b=PJj/NiSTRW2BuYnbFk0idBxhJYqy+E3KFjXAXHyT9PRhzheKpU72pRJFQuWmecQz0i 1upgtn+8DWvUSApjJdHDNahWwXXKdb/PHN8P+5Q49Ky4JBkRj7JTO2jxbs9Ypa/3vkLZ SvUB5r4wYQdghrQfj2+Nxr5PLBjNSoMfhdIfhghNC2NpWweXw84/fYx0K8bXhp5zmdVm GvO2YOjEXn9i207WHpEDn/ecictLR2Vtw7UZAOZOGBensJT0xSFUFBBd8T/ivCq7TIYv BGnvQvnTXHOjIRqtcB+XK0s6bhaQDuESYhc0T54jW5bopYcwlOAwkGL26nBeDa2IhT0T AiOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=p0NXaujO; 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 e12-v6si7083160pgn.171.2018.06.11.21.17.06; Mon, 11 Jun 2018 21:17:21 -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=p0NXaujO; 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 S1753380AbeFLEQM (ORCPT + 99 others); Tue, 12 Jun 2018 00:16:12 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33643 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750811AbeFLEQK (ORCPT ); Tue, 12 Jun 2018 00:16:10 -0400 Received: by mail-pf0-f193.google.com with SMTP id b17-v6so11392953pfi.0; Mon, 11 Jun 2018 21:16:10 -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=2e58dYCyHjCrRMzvDJHZ4B3vN5K2NBtjTra2hTQl9ng=; b=p0NXaujO2gFA7R17e3n4gMS9ahNGRQy4ijuKc8o2+xegxT11KFX3m/Rv4CboJfE0QB p1WSsJo33JB4aAKxCY5lb9Uh5qNBw3Wy2mAX85452Yk164l/Anmp2YIjO8D7QwLJMk4c uUqO295UNoAVxMRdPf4MECuFIr5MiW5CkxPDIo9+YnAnzr5i0YPUKXj3k8voAGI9Ndr0 IvZ7b8hlWzCI4lp+pqrCRB9T0rP7noaUu5DpikAJMgJHGRCBVj6ZeFwwqihh0CEYj+UE CgG35ZNej49VhqMnRuNedfYgPv5fjygZWWJ0jY2Dq5nYl4d9Vo8vqtcXeYWoOprFZbfv VoKw== 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=2e58dYCyHjCrRMzvDJHZ4B3vN5K2NBtjTra2hTQl9ng=; b=FWx6+4T2ewYjn3VXPkSf6DHiTCVEXO6riUZlT6E+4iuxZC2JoHi/uHXfj8bo6huw2D 0ib/kiWVbW9FW0UalAZcJhVcRRqga+0XoZRKfQQ3KCuwnDFeO8V1bQTQTEXvbVLX+Fb/ grnZT37yanBfzQnlyNVL/zN2+UtriPaoyObzO8fr2bi/gk3WkOHBVZj8iaXj2epK3H+k OGp2rXFkcIHpn04vZfnUv+XhUrjtQPVVQcXgh/3+7viwgKXOFtOOuvNDIVc3UFbhkYBF wcgL17RJoDHNKNqdI5lCvtnbZtAFJqBZApcNNonw3wR4ZtSQbfBJTT/DU8qa7P7BrEWa IuzQ== X-Gm-Message-State: APt69E0wEcIYp9uM8hl82CqMj7C+UPepZv+S9hS2FIfkcXjLmvS91cTM mChcJqcWcIIsrQ0MfMJ25M2DMtEXyiA= X-Received: by 2002:a62:e401:: with SMTP id r1-v6mr2092542pfh.172.1528776970506; Mon, 11 Jun 2018 21:16:10 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id a11-v6sm103315474pgn.64.2018.06.11.21.16.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:16:09 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fsnotify: add error handling for kmem_cache_create Date: Tue, 12 Jun 2018 12:16:04 +0800 Message-Id: <1528776964-39826-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/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; + 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