All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: airspy: fix memory leak in airspy probe
@ 2022-08-11  4:57 Dongliang Mu
  2022-08-11 13:42 ` Tommaso Merciai
  0 siblings, 1 reply; 2+ messages in thread
From: Dongliang Mu @ 2022-08-11  4:57 UTC (permalink / raw)
  To: Antti Palosaari, Mauro Carvalho Chehab, Hans Verkuil, Oliver Neukum
  Cc: Dongliang Mu, syzbot+bb25f85e5aa482864dc0, linux-media, linux-kernel

From: Dongliang Mu <mudongliangabcd@gmail.com>

The commit ca9dc8d06ab6 ("media: airspy: respect the DMA coherency
 rules") moves variable buf from stack to heap, however, it only frees
buf in the error handling code, missing deallocation in the success
path.

Fix this by freeing buf in the success path since this variable does not
have any references in other code.

Fixes: ca9dc8d06ab6 ("media: airspy: respect the DMA coherency rules")
Reported-by: syzbot+bb25f85e5aa482864dc0@syzkaller.appspotmail.com
Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
---
 drivers/media/usb/airspy/airspy.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 240a7cc56777..7b1c40132555 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -1070,6 +1070,10 @@ static int airspy_probe(struct usb_interface *intf,
 				ret);
 		goto err_free_controls;
 	}
+
+	/* Free buf if success*/
+	kfree(buf);
+
 	dev_info(s->dev, "Registered as %s\n",
 			video_device_node_name(&s->vdev));
 	dev_notice(s->dev, "SDR API is still slightly experimental and functionality changes may follow\n");
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: airspy: fix memory leak in airspy probe
  2022-08-11  4:57 [PATCH] media: airspy: fix memory leak in airspy probe Dongliang Mu
@ 2022-08-11 13:42 ` Tommaso Merciai
  0 siblings, 0 replies; 2+ messages in thread
From: Tommaso Merciai @ 2022-08-11 13:42 UTC (permalink / raw)
  To: Dongliang Mu
  Cc: Antti Palosaari, Mauro Carvalho Chehab, Hans Verkuil,
	Oliver Neukum, Dongliang Mu, syzbot+bb25f85e5aa482864dc0,
	linux-media, linux-kernel

Hi Dongliang,

On Thu, Aug 11, 2022 at 12:57:00PM +0800, Dongliang Mu wrote:
> From: Dongliang Mu <mudongliangabcd@gmail.com>
> 
> The commit ca9dc8d06ab6 ("media: airspy: respect the DMA coherency
>  rules") moves variable buf from stack to heap, however, it only frees
> buf in the error handling code, missing deallocation in the success
> path.
> 
> Fix this by freeing buf in the success path since this variable does not
> have any references in other code.
> 
> Fixes: ca9dc8d06ab6 ("media: airspy: respect the DMA coherency rules")
> Reported-by: syzbot+bb25f85e5aa482864dc0@syzkaller.appspotmail.com
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
>  drivers/media/usb/airspy/airspy.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
> index 240a7cc56777..7b1c40132555 100644
> --- a/drivers/media/usb/airspy/airspy.c
> +++ b/drivers/media/usb/airspy/airspy.c
> @@ -1070,6 +1070,10 @@ static int airspy_probe(struct usb_interface *intf,
>  				ret);
>  		goto err_free_controls;
>  	}
> +
> +	/* Free buf if success*/
> +	kfree(buf);
> +

buf var is only used to print the fw version during the probe.
I think you are right we need to free this.

Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolution.com>

>  	dev_info(s->dev, "Registered as %s\n",
>  			video_device_node_name(&s->vdev));
>  	dev_notice(s->dev, "SDR API is still slightly experimental and functionality changes may follow\n");
> -- 
> 2.35.1
> 

Regards,
Tommaso

-- 
Tommaso Merciai
Embedded Linux Engineer
tommaso.merciai@amarulasolutions.com
__________________________________

Amarula Solutions SRL
Via Le Canevare 30, 31100 Treviso, Veneto, IT
T. +39 042 243 5310
info@amarulasolutions.com
www.amarulasolutions.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-11 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-11  4:57 [PATCH] media: airspy: fix memory leak in airspy probe Dongliang Mu
2022-08-11 13:42 ` Tommaso Merciai

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.