From patchwork Thu Feb 2 14:20:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 13126145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD72AC61DA4 for ; Thu, 2 Feb 2023 14:20:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E07946B0073; Thu, 2 Feb 2023 09:20:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB73E6B0075; Thu, 2 Feb 2023 09:20:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7E9D6B0078; Thu, 2 Feb 2023 09:20:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B72C16B0073 for ; Thu, 2 Feb 2023 09:20:30 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 80CB1120193 for ; Thu, 2 Feb 2023 14:20:30 +0000 (UTC) X-FDA: 80422562220.21.2437D5C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id D41D7140008 for ; Thu, 2 Feb 2023 14:20:27 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=rjM27dZL; spf=pass (imf23.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675347628; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=hSg9kYoR1g1vjonm/5GiBWmdL+ABHyJ12lq4dKbfpQ8=; b=p2ZJKqvCjHtGJYQL8VDhaeEGKrGe7zJm/JY9tIFQbrQkWmEcg7bKE6/1UkZKSbOsdw/qfl 2kzphC+LOoLi78yfV/10Lw7iH6a6L8IyAnhtPcIpOxqK/m+9bUBxtHT9miGMfos0uKm4IR t81pxfHU2dNTyY4FKAQqhPjk2ghUc0M= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b=rjM27dZL; spf=pass (imf23.hostedemail.com: domain of gregkh@linuxfoundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675347628; a=rsa-sha256; cv=none; b=siAeALf3Cbcmw4Z97cWPu31BOlERq4GlQ8w4YT+claCvrZ66+PjTtwAk4TSlM6s8t6xT+j HujwIGZaL1fgn1/VwXcURy5HIQYmP4Tlv7QPmU4DKxcneKp0gPLWhks56JS0xxfnfUEO46 dPtwo8erK6QtkVqDILic2NTHI8KNmck= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB41061B76; Thu, 2 Feb 2023 14:20:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83694C433EF; Thu, 2 Feb 2023 14:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347626; bh=rjlTumiEDosDf3VoaNyjrPYahbG/tYcj2ovz/+QCuKE=; h=From:To:Cc:Subject:Date:From; b=rjM27dZLm9HA3HJZC6HsZUCqtjXY0zcHHm3bC/m3aQeX55ynmjzNkB6H3m3MSj0Tu mjM8RM4/mSLc9uMImlmdmaFXB96F1YWHkAKNco8snQq2m6OXbqdVade/yiYh0wbwjV 2hDkVBHlm9PilA0HcUkUjM8kqdjdjYWSdEmYVrB0= From: Greg Kroah-Hartman To: linux-mm@kvack.org Cc: Greg Kroah-Hartman , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-kernel@vger.kernel.org Subject: [PATCH] mm/slub: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:20:22 +0100 Message-Id: <20230202142022.2300096-1-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1198; i=gregkh@linuxfoundation.org; h=from:subject; bh=rjlTumiEDosDf3VoaNyjrPYahbG/tYcj2ovz/+QCuKE=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3jy3bUBdiu/qlfrnlRw0ZvfUvd5dnOfaeLLxadv3wv4v8 s6MSO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAi2a0M8xOPn0qcL3P/ZPmDFIVJR3 o7d84qdGVYcLphSU2ZrRmX0+4J+9/qlGftLQtjBwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: D41D7140008 X-Stat-Signature: sjf1jm1nenzsqmsq9tbseiki8yw6yrsb X-HE-Tag: 1675347627-551965 X-HE-Meta: U2FsdGVkX18NOVn+PIQpB81qNYFuLDbc+xGa5i/Ddj+pPBxm7wtzwnhhrYGd1bf/UucHhjo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4jfe/lcii0NjEh1SpoPPrXKPlUxQ0ciTple7mzlN5unyI1gejWWEp65t+PbudA1WVHxz1/wICq6o+8/IR+4i5LeY1H7Gafe6ukNUDbTcY8ZW33Z3CcS4q/G1IEmqRY4ShUHscegaG9148R5QGNuMSLGHzSD/yetw96V6+1p8jTiAsx1gfltUBVTJyd661GsIjFWop4/8QdsRJNZKfnENfMZJoOFz7DwLFiuPYwUY3HFQwPmHpNRm4OglM5sC7ZRhPooJW+6fEOc40gC5JaMYEuv2VbLkWdY+izCX8ZdgnSBdaancG1pqPt/+A7MVaqkODcvq+zHFpEE7T/6px3GQLBGibbsjAHkvBzzy/D0YKxyuze0BwvVDGKhPUlX7qoH4QrfJmHj3L7W/rHUxMHBGku74edzk1d26ZN7Aq8VORMcPMKFBneKw78MQFLiWekE2J2J0ph8kQJxkb7WyYMALrJzIWe5RUK0knzTH10MRrasXRpL6n1ndXG4ofi3+aC+fDnbcTR7HePdc8IBFVhDY2kFV2Lrpd9tNMSAlDbANly06Eylb+DMzCwGhkXBXjtzQH2cJYxoNWSqR4GdafUCHKcBSbS7ngGeDUueMvZU1Kk/Zmdys+DR93oOQWkq8n7nqfN0y8Ypk1nLTwpRI/iWtQRI53g8SmbR1guhurMvPy/vQYXqQGyDNhrUO3Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. To make things simpler, just call debugfs_lookup_and_remove() instead which handles all of the logic at once. Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrew Morton Cc: Vlastimil Babka Cc: Roman Gushchin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> Acked-by: Roman Gushchin Acked-by: David Rientjes --- mm/slub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 13459c69095a..4880e461fcc5 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -6449,7 +6449,7 @@ static void debugfs_slab_add(struct kmem_cache *s) void debugfs_slab_release(struct kmem_cache *s) { - debugfs_remove_recursive(debugfs_lookup(s->name, slab_debugfs_root)); + debugfs_lookup_and_remove(s->name, slab_debugfs_root); } static int __init slab_debugfs_init(void)