Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2174633yba; Sat, 27 Apr 2019 16:43:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKc44FlIotoUGbDpwEvFJ+rdWdu/+z8yDgFwKd3U50kmIIcvvvPOWOJOep9+Piok0nnyG/ X-Received: by 2002:a17:902:9686:: with SMTP id n6mr55174463plp.282.1556408607561; Sat, 27 Apr 2019 16:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556408607; cv=none; d=google.com; s=arc-20160816; b=ShxaV3iw5yHVKTQThwX8W1GUy2bf7sYScRPXZxdwHe8HH1vjml8WMtsNv2Em71g5Th gs2j3gLptGOjCRcWXmqRXeSrmv7veJKEAlf+SltYM6uGcBLq5sVah3ERv0x8VWUtKOAu NH+Xu79C941HgnvWFge7oYkzAloOdXp6loqP+yg+D6DnlWlHEsw2bdnvUnqhL4mPxze1 jb/oCmfqmC18OkFuWMRgThKGAMJSRRaKUo2LMzYKyFpCLeX5w40fe4JNxE2b4h1gM+pb iT0dOLL9PcAXIYCwQGmJDvGDktormHwszA8O0QjrP0cN4sAy3ojSmTmvbSt+7+8+DKDt B+Fw== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=jmuzgn2qTwOZmaWMMrvylpYaoQfaw7rrRV6d+SYFgtc=; b=awEaekyGRRjKpzOy6vhBuHAslCLBuSFiLI6umtCgeJ8OnKXQYdTKFqI2VxRYphvjsH /Io01vtbhNAejB8XyCpqtvsjg8H6hAyVmxx+p4s78igdFYNCFqDl5CLCKnPsTMW5v9J6 BxYLC/NJivttUtkdt+78UrMkSy+9M21kyjEGduzoSpOwYRvMA0EWtljg4FcLzyXoUF4h CUerhjdCVBnE5hhPIeLh++GrVIBohhAPTTNByVDA3amyfglxtoEuQVrg8QvPrmXmzy6h S7pokrCyqNkz1baMKUN1BH4o6pEXnwnoM+tQk/bWPiLLleVsJlK3roLOr3KUSedSQ2S8 34kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=gAwdxj7a; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w7si27381922pgs.230.2019.04.27.16.43.11; Sat, 27 Apr 2019 16:43:27 -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=@messagingengine.com header.s=fm2 header.b=gAwdxj7a; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726181AbfD0XlC (ORCPT + 99 others); Sat, 27 Apr 2019 19:41:02 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:51337 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbfD0XlC (ORCPT ); Sat, 27 Apr 2019 19:41:02 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 6B94E21448; Sat, 27 Apr 2019 19:41:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 27 Apr 2019 19:41:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=jmuzgn2qTwOZmaWMM rvylpYaoQfaw7rrRV6d+SYFgtc=; b=gAwdxj7a4OFG119tyqRF80dXmpgeZjX/X D+xqe9Iptje2ETPSOVUowRM4r2BvmHZcZMx0sFENa2FdCDc3d1TUxdpzlGbk88U+ Ys1wwttMZFyPMJuCF/7ZB+pdpNEnSr3q70vOJFVOiDlgfgB3V6rMzM2NCKNjkGE7 0GfSJEel3NlT1/YWfmv3fawsSvxXxJUj83hFsXWVTVunK3sK7RgQrzxJVyqiFK+e pyU9oXdfRj9ChbyADD2HDCmfPutFKud4aaEHX5/TsZ9vp45DkBKZ0L1c0JYYy4vR 2NsbiyVZZkhOHtW3kP8kPYX+KN4vWdSs65t0ue0U9K/e6fch0ZPVA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrheelgddviecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhnucev rdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkphepud dukedrvdduuddrvddttddrudeileenucfrrghrrghmpehmrghilhhfrhhomhepthhosghi nheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from eros.localdomain (ppp118-211-200-169.bras1.syd2.internode.on.net [118.211.200.169]) by mail.messagingengine.com (Postfix) with ESMTPA id AE348E4176; Sat, 27 Apr 2019 19:40:56 -0400 (EDT) From: "Tobin C. Harding" To: Andrew Morton Cc: "Tobin C. Harding" , Greg Kroah-Hartman , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: Fix kobject memleak in SLUB Date: Sun, 28 Apr 2019 09:40:00 +1000 Message-Id: <20190427234000.32749-1-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently error return from kobject_init_and_add() is not followed by a call to kobject_put(). This means there is a memory leak. Add call to kobject_put() in error path of kobject_init_and_add(). Signed-off-by: Tobin C. Harding --- mm/slub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index d30ede89f4a6..84a9d6c06c27 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5756,8 +5756,10 @@ static int sysfs_slab_add(struct kmem_cache *s) s->kobj.kset = kset; err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name); - if (err) + if (err) { + kobject_put(&s->kobj); goto out; + } err = sysfs_create_group(&s->kobj, &slab_attr_group); if (err) -- 2.21.0