Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4862941imm; Mon, 11 Jun 2018 21:24:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqOnudeYbraanRR7F+SNgL7tLP8e3thFcLJzjvRQjov53t3wiXxbCin2F/S0hBCTfHPvkN X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr1745739pgu.266.1528777476420; Mon, 11 Jun 2018 21:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528777476; cv=none; d=google.com; s=arc-20160816; b=iwwCcbYxfeChJJtFsV9G8ientKeaXbtllDgMeSxxoi4rlVWI0ZsIKRbuYJKtlTLMc1 E7ojg0varrknfc7/uATSoN1TYr2og/6j7Bt15s39cFjRqKnhuYdzvgjNuVyeaG3uNuSw HhvfLo4d64JKHQfPDmR4jauDT8HIMvutyzD1+ws0xjJ0l6nd1BsnpDSWNxzSZBeDauUT 7cpJDF4wwz8zo3NfjF+5Qiox6DuXw3btryW5tPrCUjxrmZRTXnQgu5GZbw6SNfsJO7qW zwNfA17L4wiFo+CbrFPDnfaz51fGQNb2MPeg5AfQt+iTCs+t2Ylc1lqNH0BTf6fpbNEI FhBQ== 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=75SXqYADAVAJbgMS9+7iXQBYcJeOijQdTSqG+3LO9+Q=; b=iIOsPvfXI+Y27CYR6um2L0CdN2jHQGOSO3TDjA7bsjdXsr+IFUXVnEGR5BhO1lmmsT 2Wz52GXucdGRkhP+vUc+OaUD8vMvPXaH6F1OU6fkxpnclY5XBfni55xEKupM0JO6E0TU cED8L4FWRh0yboGgo3ciDeP8fpvjYSJp6n5UXmFkUKvq3YuuDRtAR/P6Sgv4cdteJLdt Pl3UF12ESYFC2anlGZFBbVbC9wYIUU4456NIWmfj5LF1ijPa/i2agwcYmbnSbD2i2EVA Ujb8H73cuUUtcZJFu1LI2If0d5rh85Zw632todrIn8LfFQVXvci9w0eZplvTxeKYENu9 JD8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=O/RtcTZ7; 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 d10-v6si16559465pfh.119.2018.06.11.21.24.22; Mon, 11 Jun 2018 21:24:36 -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=O/RtcTZ7; 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 S1753893AbeFLEYB (ORCPT + 99 others); Tue, 12 Jun 2018 00:24:01 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39517 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752534AbeFLEYA (ORCPT ); Tue, 12 Jun 2018 00:24:00 -0400 Received: by mail-pl0-f66.google.com with SMTP id f1-v6so13609651plt.6 for ; Mon, 11 Jun 2018 21:24:00 -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=75SXqYADAVAJbgMS9+7iXQBYcJeOijQdTSqG+3LO9+Q=; b=O/RtcTZ7Mvv8Jn+llCu4iOz/bd30wSPtectJoHJGZnrL1v7w+FJ/KEXBL8nHUWUN7q IPZlBzqVvlB3fQDfL6grmE0dPJTW6FZ+xByid0Rdci6z9iCf/UPNS/Z2alSUcRszDl2p HmwjWOBwaCYPPETrJ35l2STYndshToagVyZL+D4B81SPTteLw2CesBRn6mU2UFbLNBoS yMmFyssMZ1H8OHGP/0KVOmdMIQQ3RtMol0AyeAgVbvNa6K65+7r/+o7X0FO/Ds7KPyj6 jJ9or36n4Wml8PFvbifqgMXakIbV61emmrABj2h3/4ZAIeW3tJQdAutyHhVUgpJn7eZs IbiA== 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=75SXqYADAVAJbgMS9+7iXQBYcJeOijQdTSqG+3LO9+Q=; b=mSZ/hL/6AmZBJaKrO2qJS4ZwRR/NdwnKseXpLavfR4gMMtV/RqauztT9Q7ZBAMmEyx gdKHi/bJymjWFhOie6Q+14BFYFA3XrZ/iEujX1FmSyKx4xBJfT6lWEvl9DvBJi7WIOHA EG/4Sv/Xfo5Z8tQ2UeJQ0YxryPUt70QKB7ZzIcWUw6DOfNvMExoLN3QIBNQspS4kR//6 M+ZHjtZjl/aUG9xvkL3b9xo3Qw2tgRyb1IHshoUzq9OOA9Re7EGiFRMNW5uwmQnJBNIh 4GQ5gtmMzIoe/JlDJDlJFXLIwyamU7l8P+OHsa94Aq7t1zDDuCiJyLzEXXcxDfnYfNOs lN0g== X-Gm-Message-State: APt69E2slMoL9sZUimP9LwhMQvOZuOaxCoCaADhQcR5kVSsjD3NBOsUU CUBkuqtZZWnEBpFdboCzTuY= X-Received: by 2002:a17:902:600a:: with SMTP id r10-v6mr2267064plj.70.1528777440037; Mon, 11 Jun 2018 21:24:00 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id z26-v6sm3502945pfd.60.2018.06.11.21.23.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:23:59 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Andrew Morton , Alexey Dobriyan , Al Viro , Thomas Gleixner , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH] proc: add error handling for kmem_cache_create Date: Tue, 12 Jun 2018 12:23:52 +0800 Message-Id: <1528777434-40324-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/proc/inode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 2cf3b74..5d8b2d1 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c @@ -104,6 +104,9 @@ void __init proc_init_kmemcache(void) pde_opener_cache = kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0, SLAB_ACCOUNT|SLAB_PANIC, NULL); + if (!proc_inode_cachep || !pde_opener_cache) + return -ENOMEM; + proc_dir_entry_cache = kmem_cache_create_usercopy( "proc_dir_entry", sizeof(struct proc_dir_entry), 0, SLAB_PANIC, offsetof(struct proc_dir_entry, inline_name), -- 2.7.4