Message ID | 20230202141009.2290380-1-gregkh@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp261687wrn; Thu, 2 Feb 2023 06:13:55 -0800 (PST) X-Google-Smtp-Source: AK7set8s3zgv96QvSXR332GtRsvXZQKBNdblEWNwqYzZ2unCjqF0rrQhasDO+Srm4jJ7CiC12+9A X-Received: by 2002:a50:a682:0:b0:483:21d8:87af with SMTP id e2-20020a50a682000000b0048321d887afmr6572039edc.24.1675347235556; Thu, 02 Feb 2023 06:13:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675347235; cv=none; d=google.com; s=arc-20160816; b=Y9ghFyKwVCJGLCVYSqkIRsw8om+Ni6sz8AuRqHduYrUaJHdbPZpX6utlfOEY08/ug8 3KQuPweb16VXB3urrqR4nKOx3yWu9PfP51qCjtFsdaKWwPPgkHVSup8oLZnbgB8IvpxV IYCMEvdoSRSm1tyVv0u/dcZSf1B2WqvlEUf2tTjAHRp1VXLh3kWPyih9Du8BUBQA/7a/ RnZEe1/yU40zNbQJLPtEYd+0ivQEHCYZy5IierlvXj6CvJC9dD+oD+fQntYiBMHEkdob Ic4IeuiGyb9fS9qwr/HndKhoNTwl4VvtWWkEgzIzIb2axRjPhZKSnduleb0lsOaux0QN 45YQ== 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=hBmGFTVjcf4B7AXiLLFvPBWp0yuphE7Ysep6XZKXwB0=; b=s61Ice8JwJotZcibKMJEcZyJjB60/0vYRsqYTTKnphVrBb2BdpaWqu+bPoFOCSXzZX 1exKsdo8x8ScdXosQPU+Q52KVBvOTlQcTCn12832O2mMRC0A9NwR5LSNT0oIvCxnYIm1 uZDejPI4XtVoikjjo3OL45QakmcxcSX99SW3zwSCE5ErQDDv408+gd1jhIN10dDR1zjP Sx4pAcqJvDu7FAJdFlh7pdur5QSHStFTAcY4jtZdY8KYjlaJvdxJnnZHq1nDF9hPCeC1 NeCpEru0bWQGb+ftc7wAjYSeVHWDt+YvFHaMrBDBHQ6hsa5do4fAbVFGNGPqgaaFj98v lDLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xHjIi4Ol; 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 y23-20020aa7ccd7000000b004a21329bc7dsi19481650edt.421.2023.02.02.06.13.31; Thu, 02 Feb 2023 06:13:55 -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=xHjIi4Ol; 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 S232024AbjBBOKU (ORCPT <rfc822;il.mystafa@gmail.com> + 99 others); Thu, 2 Feb 2023 09:10:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbjBBOKT (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Feb 2023 09:10:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F25488F13; Thu, 2 Feb 2023 06:10:18 -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 DF4DB61B5C; Thu, 2 Feb 2023 14:10:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6339C433D2; Thu, 2 Feb 2023 14:10:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1675347017; bh=KnHBoINmS58SP6n7EMnX7mpN9fx1nvdp/zRrtfMztuw=; h=From:To:Cc:Subject:Date:From; b=xHjIi4Ol/C52BR/7Yu6IPxGVAe6Nqf26XayN1nZ1i8+MV2sM9aYILtFR4FVOzjPHl Evaope9f6rGz1FEmxodot7sM0TEik3IqaedJTUB86DAZsue1GpIcXOpRNULGLDD6aW sZFwF18YEb1QgjKutftjc8EHRN/jEM38b3XIIsx0= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-scsi@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Karan Tilak Kumar <kartilak@cisco.com>, Sesidhar Baddela <sebaddel@cisco.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: snic: fix memory leak with using debugfs_lookup() Date: Thu, 2 Feb 2023 15:10:09 +0100 Message-Id: <20230202141009.2290380-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=1236; i=gregkh@linuxfoundation.org; h=from:subject; bh=KnHBoINmS58SP6n7EMnX7mpN9fx1nvdp/zRrtfMztuw=; b=owGbwMvMwCRo6H6F97bub03G02pJDMm3jzh8SExYLL/n4FGXmIAnWo0aC7fejHjzdb5o5cq9q2NT d1yb3RHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQAT0c5gmO8Y0Sdx0+n/9e1vvkbnHS kNV5j85xPDgq5FQpFnpp7ZMi+4tt10z5LnXffm7wcA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756728902844699311?= X-GMAIL-MSGID: =?utf-8?q?1756728902844699311?= |
Series |
scsi: snic: fix memory leak with using debugfs_lookup()
|
|
Commit Message
Greg KH
Feb. 2, 2023, 2:10 p.m. UTC
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: Karan Tilak Kumar <kartilak@cisco.com>
Cc: Sesidhar Baddela <sebaddel@cisco.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/scsi/snic/snic_debugfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
Greg, > 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. Applied to 6.3/scsi-staging, thanks!
On Wed, Feb 08, 2023 at 06:50:53PM -0500, Martin K. Petersen wrote: > > Greg, > > > 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. > > Applied to 6.3/scsi-staging, thanks! Wonderful, thank you!
On Thu, 02 Feb 2023 15:10:09 +0100, Greg Kroah-Hartman wrote: > 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. > > Applied to 6.3/scsi-queue, thanks! [1/1] scsi: snic: fix memory leak with using debugfs_lookup() https://git.kernel.org/mkp/scsi/c/ad0e4e2fab92
diff --git a/drivers/scsi/snic/snic_debugfs.c b/drivers/scsi/snic/snic_debugfs.c index 57bdc3ba49d9..9dd975b36b5b 100644 --- a/drivers/scsi/snic/snic_debugfs.c +++ b/drivers/scsi/snic/snic_debugfs.c @@ -437,6 +437,6 @@ void snic_trc_debugfs_init(void) void snic_trc_debugfs_term(void) { - debugfs_remove(debugfs_lookup(TRC_FILE, snic_glob->trc_root)); - debugfs_remove(debugfs_lookup(TRC_ENABLE_FILE, snic_glob->trc_root)); + debugfs_lookup_and_remove(TRC_FILE, snic_glob->trc_root); + debugfs_lookup_and_remove(TRC_ENABLE_FILE, snic_glob->trc_root); }