public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ionic: fix memory leak in ionic_probe
@ 2024-11-05  5:34 Wentao Liang
  2024-11-05 17:56 ` Nelson, Shannon
  2024-11-05 23:44 ` Jakub Kicinski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2024-11-05  5:34 UTC (permalink / raw)
  To: shannon.nelson, brett.creeley, davem, kuba; +Cc: linux-kernel, Wentao Liang

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.

Signed-off-by: Wentao Liang <Wentao_liang_g@163.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ionic: fix memory leak in ionic_probe
  2024-11-05  5:34 [PATCH] ionic: fix memory leak in ionic_probe Wentao Liang
@ 2024-11-05 17:56 ` Nelson, Shannon
  2024-11-05 23:44 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Nelson, Shannon @ 2024-11-05 17:56 UTC (permalink / raw)
  To: Wentao Liang, brett.creeley, davem, kuba; +Cc: linux-kernel

On 11/4/2024 9:34 PM, Wentao Liang wrote:
> 

Your Subject line should include the code tree this is aimed at - in 
this case, probably "net".  And since this would be an update, you'll 
also want to include a "v2" to indicate that it is a 2nd version of the 
patch.

> 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.
> 

Please include a "Fixes" tag with a pointer to the commit that 
introduced the problem.

> Signed-off-by: Wentao Liang <Wentao_liang_g@163.com>
> ---
>   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);

This leak should get cleaned up by the ionic_debugfs_destroy() call in 
ionic_cleanup_module(), but only if someone was to rmmod the driver. 
This is a good thing to add for tidiness - thanks for catching it.

sln

>   err_out:
>          mutex_destroy(&ionic->dev_cmd_lock);
>          ionic_devlink_free(ionic);
> --
> 2.42.0.windows.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ionic: fix memory leak in ionic_probe
  2024-11-05  5:34 [PATCH] ionic: fix memory leak in ionic_probe Wentao Liang
  2024-11-05 17:56 ` Nelson, Shannon
@ 2024-11-05 23:44 ` Jakub Kicinski
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-11-05 23:44 UTC (permalink / raw)
  To: Wentao Liang; +Cc: shannon.nelson, brett.creeley, davem, linux-kernel

On Tue,  5 Nov 2024 13:34:33 +0800 Wentao Liang wrote:
> 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.

If you haven't reposed yet please make sure you CC netdev@ on v2

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-05 23:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-05  5:34 [PATCH] ionic: fix memory leak in ionic_probe Wentao Liang
2024-11-05 17:56 ` Nelson, Shannon
2024-11-05 23:44 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox