diff mbox series

[v2] drivers: net: ionic: fix a memory leak bug

Message ID 20241106085307.1783-1-liangwentao@iscas.ac.cn (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v2] drivers: net: ionic: fix a memory leak bug | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: andrew+netdev@lunn.ch pabeni@redhat.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Wentao Liang <Wentao_liang_g@163.com>' != 'Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn>'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-06--12-00 (tests: 782)

Commit Message

Wentao Liang Nov. 6, 2024, 8:53 a.m. UTC
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(+)

Comments

Jiri Pirko Nov. 6, 2024, 3:30 p.m. UTC | #1
Regarding subject. "fix a memory leak bug" sounds just too vague. Try to
be more specific. "add missed debugfs cleanup to ionic_probe() error path"
perhaps? IDK.


Wed, Nov 06, 2024 at 09:53:07AM CET, liangwentao@iscas.ac.cn wrote:
>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.

Please don't use line numbers in patch description.


>
>Fixes: 0de38d9f1dba ("ionic: extract common bits from ionic_probe")
>Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn>



Code looks okay.


>---
> 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
>
>
Nelson, Shannon Nov. 7, 2024, 12:50 a.m. UTC | #2
On 11/6/2024 7:30 AM, Jiri Pirko wrote:
> 
> Regarding subject. "fix a memory leak bug" sounds just too vague. Try to
> be more specific. "add missed debugfs cleanup to ionic_probe() error path"
> perhaps? IDK.

Also still needs the "net" tag in the [PATCH ...]" part.
sln


> 
> 
> Wed, Nov 06, 2024 at 09:53:07AM CET, liangwentao@iscas.ac.cn wrote:
>> 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.
> 
> Please don't use line numbers in patch description.
> 
> 
>>
>> Fixes: 0de38d9f1dba ("ionic: extract common bits from ionic_probe")
>> Signed-off-by: Wentao Liang <liangwentao@iscas.ac.cn>
> 
> 
> 
> Code looks okay.
> 
> 
>> ---
>> 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
>>
>>
diff mbox series

Patch

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);