media: usb: fix memory leak in af9005_identify_state
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 9 Oct 2019 15:01:47 +0000 (12:01 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 24 Oct 2019 21:31:51 +0000 (18:31 -0300)
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>
drivers/media/usb/dvb-usb/af9005.c

index 02697d86e8c10da9ef8da5ee9af40aaa7fa4c8b9..ac93e88d70382a11f03410f4242df6a016ecac18 100644 (file)
@@ -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);