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 KH X-Patchwork-Id: 51955 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp273361wrn; Thu, 2 Feb 2023 06:33:31 -0800 (PST) X-Google-Smtp-Source: AK7set8wHgdNIVebnKtxKtGoQBytARHsHdBVVZJ0I+MubAXIOi+8XpU7TmL6DRX9xx59gY1SkSia X-Received: by 2002:a62:f80b:0:b0:592:557f:9f63 with SMTP id d11-20020a62f80b000000b00592557f9f63mr5266081pfh.11.1675348411373; Thu, 02 Feb 2023 06:33:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675348411; cv=none; d=google.com; s=arc-20160816; b=OZlQ0puMAA2UD8txlVa9b2N2ZA/v6k5zslU0ppb2gXEQHV/CzOGdOUBLR96i6i5r7y bL4YiJ8cI3A0l6M217boudXd8QUL1P28Juho0j/lKTUtFPzwnfsJ+fGkN2af8a1o9CMl HnH5DlS+SZK1LbHCHEc0VJlB9bJApyHWdkOEohzBDYoaiRpAf+MsGEESbGS6Y09JpQBJ QUvpqwHjS5tZYKazpy+uATZ26OnFwM85xGmkopPgRQ88Ct0fkOknH6tAsLLQ7oNFvRbv eT5Z/2Z26FbeV2AzsByKDg21fwVzGtXQozcBeXr03huTBO0aU3by557XozXg2+7uUuIb tv+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=hSg9kYoR1g1vjonm/5GiBWmdL+ABHyJ12lq4dKbfpQ8=; b=xQM/P7GH+e7ReGjCSIyF8yGD6c9DsCYWLNXjPF+cBbGC+g8aIar5AQ8EEQEQw4kplX nNQA7DDTeatRBEqJIjqvV6Fcn9wN5EBJbaDj0vgmatOJrQPNJc4g/UO7JHcxg6uytvGb 2LtJKhpzaP1HO577BKQ26HUqrVkX5PEeNuS7Xmv9onyrBfA3Wqoh/MNKES5MqEoDsb3Q mFfLVw22Cr8ltbNmMDUYZvvMZbp/WDRwevvIVQeGCMDySfOcZsqeQ1IoI81TzkYXLiXy uIrqZNNe+V25jhhRVSdIGOJDh6VVmyUu/kF+YTSeRqgi57l4oKxjkatI0gKCrsF/mg8+ a9rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rjM27dZL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e9-20020aa798c9000000b0058e16d0b827si22391856pfm.32.2023.02.02.06.33.17; Thu, 02 Feb 2023 06:33:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rjM27dZL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232256AbjBBOUb (ORCPT + 99 others); Thu, 2 Feb 2023 09:20:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232138AbjBBOUa (ORCPT ); Thu, 2 Feb 2023 09:20:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D73E48FB7D for ; Thu, 2 Feb 2023 06:20:28 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 7F56DB8267C for ; Thu, 2 Feb 2023 14:20:27 +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-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756730135525000223?= X-GMAIL-MSGID: =?utf-8?q?1756730135525000223?= 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)