* [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
@ 2018-03-11 22:45 ` Christophe JAILLET
0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2018-03-11 22:45 UTC (permalink / raw)
To: tariqt
Cc: netdev, linux-rdma, linux-kernel, kernel-janitors, Christophe JAILLET
If 'kzalloc' fails, we must free some memory before returning.
Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 8fc51bc29003..f9db018e858f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
if (!priv->tx_cq[t]) {
kfree(priv->tx_ring[t]);
err = -ENOMEM;
- goto out;
+ goto err_free_tx;
}
}
priv->rx_ring_num = prof->rx_ring_num;
--
2.14.1
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
@ 2018-03-11 22:45 ` Christophe JAILLET
0 siblings, 0 replies; 6+ messages in thread
From: Christophe JAILLET @ 2018-03-11 22:45 UTC (permalink / raw)
To: tariqt
Cc: netdev, linux-rdma, linux-kernel, kernel-janitors, Christophe JAILLET
If 'kzalloc' fails, we must free some memory before returning.
Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 8fc51bc29003..f9db018e858f 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
if (!priv->tx_cq[t]) {
kfree(priv->tx_ring[t]);
err = -ENOMEM;
- goto out;
+ goto err_free_tx;
}
}
priv->rx_ring_num = prof->rx_ring_num;
--
2.14.1
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
2018-03-11 22:45 ` Christophe JAILLET
@ 2018-03-12 8:42 ` Tariq Toukan
-1 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2018-03-12 8:42 UTC (permalink / raw)
To: Christophe JAILLET, tariqt
Cc: netdev, linux-rdma, linux-kernel, kernel-janitors
On 12/03/2018 12:45 AM, Christophe JAILLET wrote:
> If 'kzalloc' fails, we must free some memory before returning.
>
> Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index 8fc51bc29003..f9db018e858f 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
> if (!priv->tx_cq[t]) {
> kfree(priv->tx_ring[t]);
> err = -ENOMEM;
> - goto out;
> + goto err_free_tx;
> }
> }
> priv->rx_ring_num = prof->rx_ring_num;
>
Hi Christophe, thanks for spotting this.
However, I think these err_free_tx label and loop are redundant.
Both tx_ring/tx_cq flows should just goto out, as resources are freed
later in mlx4_en_destroy_netdev() -> mlx4_en_free_resources().
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
@ 2018-03-12 8:42 ` Tariq Toukan
0 siblings, 0 replies; 6+ messages in thread
From: Tariq Toukan @ 2018-03-12 8:42 UTC (permalink / raw)
To: Christophe JAILLET, tariqt
Cc: netdev, linux-rdma, linux-kernel, kernel-janitors
On 12/03/2018 12:45 AM, Christophe JAILLET wrote:
> If 'kzalloc' fails, we must free some memory before returning.
>
> Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> index 8fc51bc29003..f9db018e858f 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
> @@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
> if (!priv->tx_cq[t]) {
> kfree(priv->tx_ring[t]);
> err = -ENOMEM;
> - goto out;
> + goto err_free_tx;
> }
> }
> priv->rx_ring_num = prof->rx_ring_num;
>
Hi Christophe, thanks for spotting this.
However, I think these err_free_tx label and loop are redundant.
Both tx_ring/tx_cq flows should just goto out, as resources are freed
later in mlx4_en_destroy_netdev() -> mlx4_en_free_resources().
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
2018-03-12 8:42 ` Tariq Toukan
@ 2018-03-12 19:32 ` Christophe Jaillet
-1 siblings, 0 replies; 6+ messages in thread
From: Christophe Jaillet @ 2018-03-12 19:32 UTC (permalink / raw)
To: Tariq Toukan; +Cc: netdev, linux-rdma, linux-kernel, kernel-janitors
Le 12/03/2018 à 09:42, Tariq Toukan a écrit :
>
>
> On 12/03/2018 12:45 AM, Christophe JAILLET wrote:
>> If 'kzalloc' fails, we must free some memory before returning.
>>
>> Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings
>> scheme")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> index 8fc51bc29003..f9db018e858f 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> @@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev
>> *mdev, int port,
>> if (!priv->tx_cq[t]) {
>> kfree(priv->tx_ring[t]);
>> err = -ENOMEM;
>> - goto out;
>> + goto err_free_tx;
>> }
>> }
>> priv->rx_ring_num = prof->rx_ring_num;
>>
>
> Hi Christophe, thanks for spotting this.
>
> However, I think these err_free_tx label and loop are redundant.
> Both tx_ring/tx_cq flows should just goto out, as resources are freed
> later in mlx4_en_destroy_netdev() -> mlx4_en_free_resources().
>
Hi,
I do not agree with you and I think that the patch is relevant.
If 'mlx4_en_init_netdev' fails, the only caller, 'mlx4_en_activate()',
will set:
mdev->pndev[i] = NULL
(see
https://elixir.bootlin.com/linux/v4.16-rc5/source/drivers/net/ethernet/mellanox/mlx4/en_main.c#L254)
and 'mlx4_en_destroy_netdev()' is not called in this case.
(see
https://elixir.bootlin.com/linux/v4.16-rc5/source/drivers/net/ethernet/mellanox/mlx4/en_main.c#L232)
My understanding is that 'mlx4_en_destroy_netdev()' will free resources
in the normal case but that resources should be freed at allocation time
if it does not fully succeed.
Best regards,
CJ
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()'
@ 2018-03-12 19:32 ` Christophe Jaillet
0 siblings, 0 replies; 6+ messages in thread
From: Christophe Jaillet @ 2018-03-12 19:32 UTC (permalink / raw)
To: Tariq Toukan; +Cc: netdev, linux-rdma, linux-kernel, kernel-janitors
Le 12/03/2018 à 09:42, Tariq Toukan a écrit :
>
>
> On 12/03/2018 12:45 AM, Christophe JAILLET wrote:
>> If 'kzalloc' fails, we must free some memory before returning.
>>
>> Fixes: 67f8b1dcb9ee ("net/mlx4_en: Refactor the XDP forwarding rings
>> scheme")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> index 8fc51bc29003..f9db018e858f 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
>> @@ -3327,7 +3327,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev
>> *mdev, int port,
>> if (!priv->tx_cq[t]) {
>> kfree(priv->tx_ring[t]);
>> err = -ENOMEM;
>> - goto out;
>> + goto err_free_tx;
>> }
>> }
>> priv->rx_ring_num = prof->rx_ring_num;
>>
>
> Hi Christophe, thanks for spotting this.
>
> However, I think these err_free_tx label and loop are redundant.
> Both tx_ring/tx_cq flows should just goto out, as resources are freed
> later in mlx4_en_destroy_netdev() -> mlx4_en_free_resources().
>
Hi,
I do not agree with you and I think that the patch is relevant.
If 'mlx4_en_init_netdev' fails, the only caller, 'mlx4_en_activate()',
will set:
mdev->pndev[i] = NULL
(see
https://elixir.bootlin.com/linux/v4.16-rc5/source/drivers/net/ethernet/mellanox/mlx4/en_main.c#L254)
and 'mlx4_en_destroy_netdev()' is not called in this case.
(see
https://elixir.bootlin.com/linux/v4.16-rc5/source/drivers/net/ethernet/mellanox/mlx4/en_main.c#L232)
My understanding is that 'mlx4_en_destroy_netdev()' will free resources
in the normal case but that resources should be freed at allocation time
if it does not fully succeed.
Best regards,
CJ
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-12 19:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-11 22:45 [PATCH] net/mlx4_en: Fix a memory leak in case of error in 'mlx4_en_init_netdev()' Christophe JAILLET
2018-03-11 22:45 ` Christophe JAILLET
2018-03-12 8:42 ` Tariq Toukan
2018-03-12 8:42 ` Tariq Toukan
2018-03-12 19:32 ` Christophe Jaillet
2018-03-12 19:32 ` Christophe Jaillet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.