Netdev List
 help / color / mirror / Atom feed
From: Wentao Liang <liangwentao@iscas.ac.cn>
To: shannon.nelson@amd.com, brett.creeley@amd.com,
	davem@davemloft.net, kuba@kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	Wentao Liang <Wentao_liang_g@163.com>,
	Wentao Liang <liangwentao@iscas.ac.cn>
Subject: [PATCH v2] drivers: net: ionic: fix a memory leak bug
Date: Wed,  6 Nov 2024 16:53:07 +0800	[thread overview]
Message-ID: <20241106085307.1783-1-liangwentao@iscas.ac.cn> (raw)

From: Wentao Liang <Wentao_liang_g@163.com>

In line 334, the ionic_setup_one() creates a debugfs entry for
ionic upon successful execution. However, the ionic_probe() does
not release the dentry before returning, resulting in a memory
leak. To fix this bug, we add the ionic_debugfs_del_dev() before
line 397 to release the resources before the function returns.

Fixes: 0de38d9f1dba ("ionic: extract common bits from ionic_probe")
Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn>
---
 drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
index b93791d6b593..f5dc876eb500 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
@@ -394,6 +394,7 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 err_out_pci:
 	ionic_dev_teardown(ionic);
 	ionic_clear_pci(ionic);
+	ionic_debugfs_del_dev(ionic);
 err_out:
 	mutex_destroy(&ionic->dev_cmd_lock);
 	ionic_devlink_free(ionic);
-- 
2.42.0.windows.2


             reply	other threads:[~2024-11-06  9:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06  8:53 Wentao Liang [this message]
2024-11-06 15:30 ` [PATCH v2] drivers: net: ionic: fix a memory leak bug Jiri Pirko
2024-11-07  0:50   ` Nelson, Shannon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241106085307.1783-1-liangwentao@iscas.ac.cn \
    --to=liangwentao@iscas.ac.cn \
    --cc=Wentao_liang_g@163.com \
    --cc=brett.creeley@amd.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=shannon.nelson@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox