diff mbox series

[2/2] vfio/mlx5: error pointer dereference in error handling

Message ID Y5IKia5SaiVxYmG5@kili (mailing list archive)
State New, archived
Headers show
Series [1/2] vfio/mlx5: fix error code in mlx5vf_precopy_ioctl() | expand

Commit Message

Dan Carpenter Dec. 8, 2022, 4:02 p.m. UTC
This code frees the wrong "buf" variable and results in an error pointer
dereference.

Fixes: 34e2f27143d1 ("vfio/mlx5: Introduce multiple loads")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Why did get_maintainer.pl not add Yishai to the CC list?

 drivers/vfio/pci/mlx5/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Yishai Hadas Dec. 8, 2022, 4:16 p.m. UTC | #1
On 08/12/2022 18:02, Dan Carpenter wrote:
> This code frees the wrong "buf" variable and results in an error pointer
> dereference.
>
> Fixes: 34e2f27143d1 ("vfio/mlx5: Introduce multiple loads")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> Why did get_maintainer.pl not add Yishai to the CC list?
>
>   drivers/vfio/pci/mlx5/main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
> index 83137228352e..9feb89c6d939 100644
> --- a/drivers/vfio/pci/mlx5/main.c
> +++ b/drivers/vfio/pci/mlx5/main.c
> @@ -826,7 +826,7 @@ mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev)
>   	spin_lock_init(&migf->list_lock);
>   	return migf;
>   out_buf:
> -	mlx5vf_free_data_buffer(buf);
> +	mlx5vf_free_data_buffer(migf->buf);
>   out_pd:
>   	mlx5vf_cmd_dealloc_pd(migf);
>   out_free:

Thanks Dan

Reviewed-by: Yishai Hadas <yishaih@nvidia.com>
diff mbox series

Patch

diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c
index 83137228352e..9feb89c6d939 100644
--- a/drivers/vfio/pci/mlx5/main.c
+++ b/drivers/vfio/pci/mlx5/main.c
@@ -826,7 +826,7 @@  mlx5vf_pci_resume_device_data(struct mlx5vf_pci_core_device *mvdev)
 	spin_lock_init(&migf->list_lock);
 	return migf;
 out_buf:
-	mlx5vf_free_data_buffer(buf);
+	mlx5vf_free_data_buffer(migf->buf);
 out_pd:
 	mlx5vf_cmd_dealloc_pd(migf);
 out_free: