From patchwork Fri Mar 10 13:38:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 67447 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp945667wrd; Fri, 10 Mar 2023 07:47:47 -0800 (PST) X-Google-Smtp-Source: AK7set8ZLSumZ+8MUzm4P8OkX0QLBPs0nxYn6WF0IluDWyXfYKXZLF0mUQOIBPhQ0ukLlSA7et59 X-Received: by 2002:a05:6a20:1607:b0:cd:ed5c:4cd with SMTP id l7-20020a056a20160700b000cded5c04cdmr31269336pzj.6.1678463266940; Fri, 10 Mar 2023 07:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678463266; cv=none; d=google.com; s=arc-20160816; b=kObrHD1U1K0qlj0VgujgGPaUkVOetOrw5OIBBn7RnupvwwllOAlrV/BOAJVc0xtnKB AUXJb0xe0Jxa2JG8sy1SB3RPUFEMfGDqA3XQ/SIXoxmcYeAKibJqb31DPvyKytmRG7Kv uGEZBO4esY384yk75ZGrjich5rNcMu/9hDD9/lW3gFFHnneslehhk+Yj8ePOY4MojZ3g MqO3orlmKNd672xN5JmeH5BXcIrajb+sRh1e53zeEpOtPl/uOldFADxv9o0x0HjiZ/wz JEJ15vPmsd1AH5yNGumcxLFAEzSGgPL7k5ogycrvfcX31KkaW1R1iuQtkGEH4ApVP4m/ CW0Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7s8Cc3RX37KS2AKj+zxcVkp6+TBcRELmUMvK0H7fqP0=; b=XzR9SXOGnZW0DDFmsSLTfJZLgXd1wxzfDDFpWA/DcGd66pqWM8EreGp2pEBCOTfWGQ cbTG8pSntaxiURovcv6B/DnDkUagJiW1Ux4CjriqfTX2hu2NHPI3fbvnquitT4OeCsBd I0LClQb91oaDbi4IWJtDQ+WVR39OvjYFjNBxOTdIBbrnwPqVFWJ6Za+Vh/i4gqUIfc/S SDHMkvGoZ3LXYim6r9xKWLPH0O2pWXqMB1K/Mi41KlbiUBaNqnF9MunIV8GQPJ9TwU26 +LC2KsOwuBKa9eYvt5aAOZymFPbUBfhYOs+WCXafxYcMU1EsJg+GIximrBvOwr+LjjAm dczQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EiATd6AA; 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 124-20020a620682000000b005a8ec643a4bsi6024pfg.131.2023.03.10.07.47.34; Fri, 10 Mar 2023 07:47:46 -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=EiATd6AA; 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 S231465AbjCJN75 (ORCPT + 99 others); Fri, 10 Mar 2023 08:59:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231492AbjCJN7z (ORCPT ); Fri, 10 Mar 2023 08:59:55 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A251115DF1; Fri, 10 Mar 2023 05:59:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1431D61552; Fri, 10 Mar 2023 13:59:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26464C433EF; Fri, 10 Mar 2023 13:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678456792; bh=QUVyWcpNPiRRb0YcbMLuwPP4ifg6zlz8Ly/SlacKjmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EiATd6AAeocnQCAiRswg+oMqifYdZGhRuFyA5BD6PcQURRZhQ/Cls1T9HZJ2pzJS/ VB2w1DKzi4r31pZMp+divYSdikLbZ2a/lZC0OCnDZkgBa2v2bTLpUIVf9Ad0UUAQY2 gWEBuQ9mXnXiWOa1jByN4rSuHxgwlgZm0TYs2ryQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Down , Petr Mladek , Sergey Senozhatsky , Steven Rostedt , John Ogness , linux-kernel@vger.kernel.org, Sasha Levin Subject: [PATCH 6.2 126/211] kernel/printk/index.c: fix memory leak with using debugfs_lookup() Date: Fri, 10 Mar 2023 14:38:26 +0100 Message-Id: <20230310133722.564658451@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133718.689332661@linuxfoundation.org> References: <20230310133718.689332661@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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,URIBL_BLOCKED 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?1759996298681030717?= X-GMAIL-MSGID: =?utf-8?q?1759996298681030717?= From: Greg Kroah-Hartman [ Upstream commit 55bf243c514553e907efcf2bda92ba090eca8c64 ] 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: Chris Down Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: John Ogness Cc: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Reviewed-by: Sergey Senozhatsky Reviewed-by: John Ogness Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20230202151411.2308576-1-gregkh@linuxfoundation.org Signed-off-by: Sasha Levin --- kernel/printk/index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printk/index.c b/kernel/printk/index.c index c85be186a7832..a6b27526baaf6 100644 --- a/kernel/printk/index.c +++ b/kernel/printk/index.c @@ -145,7 +145,7 @@ static void pi_create_file(struct module *mod) #ifdef CONFIG_MODULES static void pi_remove_file(struct module *mod) { - debugfs_remove(debugfs_lookup(pi_get_module_name(mod), dfs_index)); + debugfs_lookup_and_remove(pi_get_module_name(mod), dfs_index); } static int pi_module_notify(struct notifier_block *nb, unsigned long op,