media: airspy: fix memory leak in airspy probe
authorDongliang Mu <mudongliangabcd@gmail.com>
Thu, 11 Aug 2022 04:57:00 +0000 (06:57 +0200)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 30 Aug 2022 05:31:42 +0000 (07:31 +0200)
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>
Reviewed-by: Tommaso Merciai <tommaso.merciai@amarulasolution.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/usb/airspy/airspy.c

index b8b88244f96379d55c7379b57bdfb3e4264526f6..462eb84235063a772f4b90343dd4ba74b9ab2eb8 100644 (file)
@@ -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");