[net] be2net: Fix memory leak in be_cmd_get_profile_config()

Message ID 20180905123746.7399-1-poros@redhat.com
State Accepted
Delegated to: David Miller
Headers show
Series
  • [net] be2net: Fix memory leak in be_cmd_get_profile_config()
Related show

Commit Message

Petr Oros Sept. 5, 2018, 12:37 p.m.
DMA allocated memory is lost in be_cmd_get_profile_config() when we
call it with non-NULL port_res parameter.

Signed-off-by: Petr Oros <poros@redhat.com>
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ivan Vecera Sept. 5, 2018, 12:45 p.m. | #1
On 5.9.2018 14:37, Petr Oros wrote:
> DMA allocated memory is lost in be_cmd_get_profile_config() when we
> call it with non-NULL port_res parameter.
> 
> Signed-off-by: Petr Oros <poros@redhat.com>
> ---
>  drivers/net/ethernet/emulex/benet/be_cmds.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
> index ff92ab1daeb8..1e9d882c04ef 100644
> --- a/drivers/net/ethernet/emulex/benet/be_cmds.c
> +++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
> @@ -4500,7 +4500,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
>  				port_res->max_vfs += le16_to_cpu(pcie->num_vfs);
>  			}
>  		}
> -		return status;
> +		goto err;
>  	}
>  
>  	pcie = be_get_pcie_desc(resp->func_param, desc_count,
> 

Good catch, Petr.

Reviewed-by: Ivan Vecera <ivecera@redhat.com>
David Miller Sept. 5, 2018, 3:08 p.m. | #2
From: Petr Oros <poros@redhat.com>
Date: Wed,  5 Sep 2018 14:37:45 +0200

> DMA allocated memory is lost in be_cmd_get_profile_config() when we
> call it with non-NULL port_res parameter.
> 
> Signed-off-by: Petr Oros <poros@redhat.com>

Applied, thank you.

Patch

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index ff92ab1daeb8..1e9d882c04ef 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4500,7 +4500,7 @@  int be_cmd_get_profile_config(struct be_adapter *adapter,
 				port_res->max_vfs += le16_to_cpu(pcie->num_vfs);
 			}
 		}
-		return status;
+		goto err;
 	}
 
 	pcie = be_get_pcie_desc(resp->func_param, desc_count,