From patchwork Wed Feb 8 12:57:58 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: 1739451 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=3XLs5zj/; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=rIlTvocD; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PBg6g27fjz23j0 for ; Wed, 8 Feb 2023 23:58:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=4XqWPbCiu2gYvC0ZTrj4o8llITSul2GnUugRoyxIhc8=; b=3XLs5zj/OkG5p6 WXl63TYHlOsFF+9eRGzStwWU4w3UyH88gR0GxsnwXzFTLXbl77T166NS7Zdh206cPvR9Zve19d2fy AeW7sIKX1FThSAz2d8ZcpNYD4HXFHvzRwXyKgQJYjvgT5CDyIeL4ItiQJo7mFPq16IuOYsU+WgRtJ EJr5E448PEPaZzfzKX2GGBl3g/86LNEZ/AAGrp6S3a306235JrWNq+c4KyKuYWNzi4oHA1v2FIE24 /gHwCmauqhgjrCZhpAfniMQ9pN0enblYSywW+F+0/aT/2ITg6TAMq0u/KMPnvSfexo5K+W+CAI+vY 6Qq3NaZxAzz3bwmg4QvQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPk1c-00FfhV-Sr; Wed, 08 Feb 2023 12:58:12 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pPk1Z-00Fff8-M5 for linux-mtd@lists.infradead.org; Wed, 08 Feb 2023 12:58:11 +0000 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 sin.source.kernel.org (Postfix) with ESMTPS id 5852ECE217F; Wed, 8 Feb 2023 12:58:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4FCACC4339B; Wed, 8 Feb 2023 12:58:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675861083; bh=VrbCzxOmy3ybuwWlA7ZbkY+1uA2a/fPo2GEiHFqaUl0=; h=From:To:Cc:Subject:Date:From; b=rIlTvocDgkpF8y33io5K1nKHrLhuLFhEc02ASgrKCdZaxXRVEKswfLAiqe/ugm03u 895TSS/cqANm0zLs0qn/ySYsi6wiWqwHRhTEYr/ibwFTwrfMOPJHZdbOFSy6gy29la 8GQgrLZaBruG/XIR7MltHmqrBUos2sb54QbBoDWY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Tudor Ambarus , Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, stable Subject: [PATCH v2] mtd: spi-nor: fix memory leak when using debugfs_lookup() Date: Wed, 8 Feb 2023 13:57:58 +0100 Message-Id: <20230208125758.1515806-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=1182; i=gregkh@linuxfoundation.org; h=from:subject; bh=VrbCzxOmy3ybuwWlA7ZbkY+1uA2a/fPo2GEiHFqaUl0=; b=owGbwMvMwCRo6H6F97bub03G02pJDMmP54Ryek+ZorD9hV7p6l9CjqdzVNf0XSpOMHpxnaF/7ZOJ zNxzOmJZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiq3czzNNu1r/I6+bHMdeX6U9VjZ IO22RTdYYFl/3mfCr3X3LS9eLdeym7n8tLr/x3CgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230208_045810_723440_C1783758 X-CRM114-Status: GOOD ( 11.07 ) X-Spam-Score: -2.7 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Cc: Tudor Ambarus Cc: Pratyush Yadav Cc: Michael Walle Cc: Miquel Raynal Cc: Richard Weinberger List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org When calling debugfs_lookup() the result must have dput() called on it, otherwise the memory will leak over time. Cc: Tudor Ambarus Cc: Pratyush Yadav Cc: Michael Walle Cc: Miquel Raynal Cc: Richard Weinberger Cc: Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org Cc: stable Signed-off-by: Greg Kroah-Hartman --- v2: fix up to work when module is removed and added, making the fix much simpler. drivers/mtd/spi-nor/debugfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/mtd/spi-nor/debugfs.c b/drivers/mtd/spi-nor/debugfs.c index ff895f6758ea..af41fbc09a97 100644 --- a/drivers/mtd/spi-nor/debugfs.c +++ b/drivers/mtd/spi-nor/debugfs.c @@ -242,6 +242,7 @@ void spi_nor_debugfs_register(struct spi_nor *nor) d = debugfs_create_dir(dev_name(nor->dev), rootdir); nor->debugfs_root = d; + dput(rootdir); debugfs_create_file("params", 0444, d, nor, &spi_nor_params_fops); debugfs_create_file("capabilities", 0444, d, nor,