Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4867508imm; Mon, 11 Jun 2018 21:31:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqrZqG5SkpAGPoS/xkGYYhDm+n9+cnbmuob1zYQMj8EovVJJyCR3X8bcTcyDKPunuo67YW X-Received: by 2002:a65:6008:: with SMTP id m8-v6mr1812643pgu.134.1528777875633; Mon, 11 Jun 2018 21:31:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528777875; cv=none; d=google.com; s=arc-20160816; b=R78tfZYb6YywnYZ3Bv6XwaABjoIwZJw2gjQsLcGGScWyBOYACqtE09Lg1Zo1ZRgBdt hBq7CIxQnPit33qM9kzFM8yOo1dpu+U98HN/b3DGg0MAieoYxSN0Z9sUhldnaoAoJO6t YMVFmssKqMY5xmvcKHVUKC0hFyjSYK/Q4Tob7BejPP8E9aoPEJEtJLzoBmh8/aLNtNPU ZwV5t2y6anAUxfYjtxmrno4Ne263qz373xu7GnQdLGJRSMD8LTFkQArZiZNGXuws+cnY 81W8JWBTqqwq7MCCA60PZVZVjEtt1aj/trVJFxndfasOezFNBwWSEwCqCkjsUrW5XJdr XFfQ== 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=bxqWUWhCKY9Y0pIQmPe1KyEDr/D7TjfHfUiC9NAULgU=; b=u43gjfO4UQY3RvUOfJzld2wE7q/CFLhpvDdG2UaY/N88rb0tBeDRtqH2wy6lXxdCLj JaKWG8tlPLcnQTro73wYb5KExICfJsI967KCB/GVyc64qNi8Wkx0JX6DOP60ELUq0TMZ xDjtvTyDZ6vLc6FodUgTWkjQMY3ZWAuxVLKtFKNUoIvsM6iUGbzvjImAsXYya2jYpG5E RG5toTsYku5ZqmQ/aVRGyAc2KEKyI7JO+Jzsf8yj+emnB4OIcPKzdjz8cKqXUbrFUaRq Yfiu6el6khv+EVOEvaTtSDOQbWdatSaBbusV4xGnqmGpBlKmDKPFYPY+JkIH4VInC1Di YpYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=GMKC4Zlo; 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.31.01; Mon, 11 Jun 2018 21:31:15 -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=GMKC4Zlo; 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 S1753943AbeFLEaG (ORCPT + 99 others); Tue, 12 Jun 2018 00:30:06 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:42459 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752632AbeFLEaE (ORCPT ); Tue, 12 Jun 2018 00:30:04 -0400 Received: by mail-pl0-f65.google.com with SMTP id w17-v6so13609616pll.9; Mon, 11 Jun 2018 21:30:04 -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=bxqWUWhCKY9Y0pIQmPe1KyEDr/D7TjfHfUiC9NAULgU=; b=GMKC4Zlot2F4YtcjsdmYovwVAbLbn8jxljL4njSXVMZ6Iw+BZVa7asrCmzBeA8J2DR 05XM64sZKpJzATfalnyKIP6Zbd5uDETbZbCkitR5fisBI7FF4Q8TVGQrIHkQEzrzFpsy h/hO4fu5BVP8YwKYgSkrT7Gag9GARh+HobQXBZPUdMigAiADRtdcEWutYBDNbcbospWd 5kgAAWuEVqlxXq1WEMZmb/a4ZDu5fE9Athk7aQFQkrhxAz115tzO/TFWM/uMwFK86EIc 7moLhnIwNWLi2X/wt2cx9dkq6BvquplJNeHuokL3Xb6BGMdwYGAG9ZvirnOsY73lIX6K E2xQ== 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=bxqWUWhCKY9Y0pIQmPe1KyEDr/D7TjfHfUiC9NAULgU=; b=QIOj/SIE6cqXqJfxmQkSiBcJZoid61B+7Hv18oDssKPiaqrfCsLKETwNya8OWi/hIy jXe62SEHeVrKHuTE/xNpuSe+fwSaxNedmUKv3WYgc4FQye9aGfdgcB4XvxiKbsbrSfN2 KVTiHkMXS+FShNErSqeLkQ0UFsq/jgD9wq0WUlemGcG8mnIegFzZNPvTzN7tNaU7nyG/ Wc1ooIEQViQ84oKJIhXOUSEh73ipdhMNeKMFealTC/vGeTKRXoG/1IH9JwCQe+cS22v0 Nm5FoQiiSoJhydhow54BxLhRsL0XIOqp/rfmogWP2a0I9UruLVAD1zj/lVoeLRjiGmPy 3c5g== X-Gm-Message-State: APt69E2TWuAMBDRW4f9LysDjRutF37m0RbW6+e90cP7S4kHOdAaoaa7U PW7hAQVtgJqhPG/M3NJxgKU= X-Received: by 2002:a17:902:8a82:: with SMTP id p2-v6mr2298190plo.244.1528777804408; Mon, 11 Jun 2018 21:30:04 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id d72-v6sm121913628pfe.150.2018.06.11.21.30.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 21:30:03 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , "David S. Miller" , Wei Wang , Martin KaFai Lau , Kees Cook , Eric Dumazet , Florian Westphal , Joe Perches , linux-decnet-user@lists.sourceforge.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: add error handling for kmem_cache_create Date: Tue, 12 Jun 2018 12:29:56 +0800 Message-Id: <1528777798-40722-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 --- net/decnet/dn_route.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c index e747650..2b743c7 100644 --- a/net/decnet/dn_route.c +++ b/net/decnet/dn_route.c @@ -1861,6 +1861,9 @@ void __init dn_route_init(void) dn_dst_ops.kmem_cachep = kmem_cache_create("dn_dst_cache", sizeof(struct dn_route), 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); + if (!dn_dst_ops.kmem_cachep) + panic("Failed to create dn_dst_cache cache\n"); + dst_entries_init(&dn_dst_ops); timer_setup(&dn_route_timer, dn_dst_check_expire, 0); dn_route_timer.expires = jiffies + decnet_dst_gc_interval * HZ; -- 2.7.4