Colin King
2021-Apr-12 16:28 UTC
[PATCH][next] vdpa/mlx5: Fix resource leak of mgtdev due to incorrect kfree
From: Colin Ian King <colin.king at canonical.com> Static analysis is reporting a memory leak on mgtdev, it appears that the wrong object is being kfree'd. Fix this by kfree'ing mgtdev rather than mdev. Addresses-Coverity: ("Resource leak") Fixes: c8a2d4c73e70 ("vdpa/mlx5: Enable user to add/delete vdpa device") Signed-off-by: Colin Ian King <colin.king at canonical.com> --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 10c5fef3c020..25533db01f5f 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2089,7 +2089,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, return 0; reg_err: - kfree(mdev); + kfree(mgtdev); return err; } -- 2.30.2
Jason Wang
2021-Apr-13 02:50 UTC
[PATCH][next] vdpa/mlx5: Fix resource leak of mgtdev due to incorrect kfree
? 2021/4/13 ??12:28, Colin King ??:> From: Colin Ian King <colin.king at canonical.com> > > Static analysis is reporting a memory leak on mgtdev, it appears > that the wrong object is being kfree'd. Fix this by kfree'ing > mgtdev rather than mdev. > > Addresses-Coverity: ("Resource leak") > Fixes: c8a2d4c73e70 ("vdpa/mlx5: Enable user to add/delete vdpa device") > Signed-off-by: Colin Ian King <colin.king at canonical.com> > --- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > index 10c5fef3c020..25533db01f5f 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -2089,7 +2089,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, > return 0; > > reg_err: > - kfree(mdev); > + kfree(mgtdev); > return err; > } >Acked-by: Jason Wang <jasowang at redhat.com>
Stefano Garzarella
2021-Apr-13 07:29 UTC
[PATCH][next] vdpa/mlx5: Fix resource leak of mgtdev due to incorrect kfree
On Mon, Apr 12, 2021 at 05:28:04PM +0100, Colin King wrote:>From: Colin Ian King <colin.king at canonical.com> > >Static analysis is reporting a memory leak on mgtdev, it appears >that the wrong object is being kfree'd. Fix this by kfree'ing >mgtdev rather than mdev. > >Addresses-Coverity: ("Resource leak") >Fixes: c8a2d4c73e70 ("vdpa/mlx5: Enable user to add/delete vdpa device") >Signed-off-by: Colin Ian King <colin.king at canonical.com> >--- > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c >index 10c5fef3c020..25533db01f5f 100644 >--- a/drivers/vdpa/mlx5/net/mlx5_vnet.c >+++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c >@@ -2089,7 +2089,7 @@ static int mlx5v_probe(struct auxiliary_device *adev, > return 0; > > reg_err: >- kfree(mdev); >+ kfree(mgtdev); > return err; > } > >-- >2.30.2 >Reviewed-by: Stefano Garzarella <sgarzare at redhat.com>