media: usb: fix memory leak in af9005_identify_state

This change “media: usb: fix memory leak in af9005_identify_state” (commit 2289adb) in Linux kernel is authored by Navid Emamdoost <navid.emamdoost [at] gmail.com> on Wed Oct 9 12:01:47 2019 -0300.

Description of "media: usb: fix memory leak in af9005_identify_state"

The change “media: usb: fix memory leak in af9005_identify_state” introduces changes as follows.

media: usb: fix memory leak in af9005_identify_state

In af9005_identify_state when returning -EIO the allocated buffer should
be released. Replace the "return -EIO" with assignment into ret and move
deb_info() under a check.

Fixes: af4e067e1dcf ("V4L/DVB (5625): Add support for the AF9005 demodulator from Afatech")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

Linux kernel releases containing commit 2289adb

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "media: usb: fix memory leak in af9005_identify_state"

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/media/usb/dvb-usb/af9005.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
 
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index 02697d86e8c1..ac93e88d7038 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -976,8 +976,9 @@ static int af9005_identify_state(struct usb_device *udev,
 	else if (reply == 0x02)
 		*cold = 0;
 	else
-		return -EIO;
-	deb_info("Identify state cold = %d\n", *cold);
+		ret = -EIO;
+	if (!ret)
+		deb_info("Identify state cold = %d\n", *cold);
 
 err:
 	kfree(buf);

The commit for this change in Linux stable tree is 2289adb (patch).

Last modified: 2020/02/08