diff mbox series

[net] net: libwx: fix memory leak on msix entry

Message ID 20231128095928.1083292-1-jiawenwu@trustnetic.com (mailing list archive)
State Accepted
Commit 91fdb30ddfdb651509914d3ed0a0302712540fed
Delegated to: Netdev Maintainers
Headers show
Series [net] net: libwx: fix memory leak on msix entry | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
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: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
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

Commit Message

Jiawen Wu Nov. 28, 2023, 9:59 a.m. UTC
Since pci_free_irq_vectors() set pdev->msix_enabled as 0 in the
calling of pci_msix_shutdown(), wx->msix_entries is never freed.
Reordering the lines to fix the memory leak.

Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
---
 drivers/net/ethernet/wangxun/libwx/wx_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jiawen Wu Nov. 29, 2023, 3:20 a.m. UTC | #1
Cc: stable@vger.kernel.org

> -----Original Message-----
> From: Jiawen Wu <jiawenwu@trustnetic.com>
> Sent: Tuesday, November 28, 2023 5:59 PM
> To: netdev@vger.kernel.org; edumazet@google.com; davem@davemloft.net; kuba@kernel.org; pabeni@redhat.com
> Cc: mengyuanlou@net-swift.com; Jiawen Wu <jiawenwu@trustnetic.com>
> Subject: [PATCH net] net: libwx: fix memory leak on msix entry
> 
> Since pci_free_irq_vectors() set pdev->msix_enabled as 0 in the
> calling of pci_msix_shutdown(), wx->msix_entries is never freed.
> Reordering the lines to fix the memory leak.
> 
> Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 2823861e5a92..a5a50b5a8816 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -1972,11 +1972,11 @@ void wx_reset_interrupt_capability(struct wx *wx)
>  	if (!pdev->msi_enabled && !pdev->msix_enabled)
>  		return;
> 
> -	pci_free_irq_vectors(wx->pdev);
>  	if (pdev->msix_enabled) {
>  		kfree(wx->msix_entries);
>  		wx->msix_entries = NULL;
>  	}
> +	pci_free_irq_vectors(wx->pdev);
>  }
>  EXPORT_SYMBOL(wx_reset_interrupt_capability);
> 
> --
> 2.27.0
>
Kalesh Anakkur Purayil Nov. 29, 2023, 3:51 a.m. UTC | #2
On Tue, Nov 28, 2023 at 3:35 PM Jiawen Wu <jiawenwu@trustnetic.com> wrote:

> Since pci_free_irq_vectors() set pdev->msix_enabled as 0 in the
> calling of pci_msix_shutdown(), wx->msix_entries is never freed.
> Reordering the lines to fix the memory leak.
>
> Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> ---
>  drivers/net/ethernet/wangxun/libwx/wx_lib.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>

Looks good to me.

Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

>
> diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> index 2823861e5a92..a5a50b5a8816 100644
> --- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> +++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
> @@ -1972,11 +1972,11 @@ void wx_reset_interrupt_capability(struct wx *wx)
>         if (!pdev->msi_enabled && !pdev->msix_enabled)
>                 return;
>
> -       pci_free_irq_vectors(wx->pdev);
>         if (pdev->msix_enabled) {
>                 kfree(wx->msix_entries);
>                 wx->msix_entries = NULL;
>         }
> +       pci_free_irq_vectors(wx->pdev);
>  }
>  EXPORT_SYMBOL(wx_reset_interrupt_capability);
>
> --
> 2.27.0
>
>
>
patchwork-bot+netdevbpf@kernel.org Nov. 30, 2023, 4:20 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 28 Nov 2023 17:59:28 +0800 you wrote:
> Since pci_free_irq_vectors() set pdev->msix_enabled as 0 in the
> calling of pci_msix_shutdown(), wx->msix_entries is never freed.
> Reordering the lines to fix the memory leak.
> 
> Fixes: 3f703186113f ("net: libwx: Add irq flow functions")
> Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
> 
> [...]

Here is the summary with links:
  - [net] net: libwx: fix memory leak on msix entry
    https://git.kernel.org/netdev/net/c/91fdb30ddfdb

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/wangxun/libwx/wx_lib.c b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
index 2823861e5a92..a5a50b5a8816 100644
--- a/drivers/net/ethernet/wangxun/libwx/wx_lib.c
+++ b/drivers/net/ethernet/wangxun/libwx/wx_lib.c
@@ -1972,11 +1972,11 @@  void wx_reset_interrupt_capability(struct wx *wx)
 	if (!pdev->msi_enabled && !pdev->msix_enabled)
 		return;
 
-	pci_free_irq_vectors(wx->pdev);
 	if (pdev->msix_enabled) {
 		kfree(wx->msix_entries);
 		wx->msix_entries = NULL;
 	}
+	pci_free_irq_vectors(wx->pdev);
 }
 EXPORT_SYMBOL(wx_reset_interrupt_capability);