* [PATCH] media: usb: fix memory leak in af9005_identify_state
@ 2019-09-13 23:55 Navid Emamdoost
2019-10-09 12:42 ` Hans Verkuil
0 siblings, 1 reply; 4+ messages in thread
From: Navid Emamdoost @ 2019-09-13 23:55 UTC (permalink / raw)
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Thomas Gleixner, Richard Fontana,
Kate Stewart, linux-media, linux-kernel
In af9005_identify_state when returning -EIO the allocated buffer should
be released.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/media/usb/dvb-usb/af9005.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index 02697d86e8c1..aee500beaab6 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -975,8 +975,10 @@ static int af9005_identify_state(struct usb_device *udev,
*cold = 1;
else if (reply == 0x02)
*cold = 0;
- else
+ else {
+ kfree(buf);
return -EIO;
+ }
deb_info("Identify state cold = %d\n", *cold);
err:
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: usb: fix memory leak in af9005_identify_state
2019-09-13 23:55 [PATCH] media: usb: fix memory leak in af9005_identify_state Navid Emamdoost
@ 2019-10-09 12:42 ` Hans Verkuil
2019-10-09 15:00 ` Navid Emamdoost
2019-10-09 15:01 ` [PATCH v2] " Navid Emamdoost
0 siblings, 2 replies; 4+ messages in thread
From: Hans Verkuil @ 2019-10-09 12:42 UTC (permalink / raw)
To: Navid Emamdoost
Cc: emamd001, smccaman, kjlu, Mauro Carvalho Chehab,
Greg Kroah-Hartman, Thomas Gleixner, Richard Fontana,
Kate Stewart, linux-media, linux-kernel
On 9/14/19 1:55 AM, Navid Emamdoost wrote:
> In af9005_identify_state when returning -EIO the allocated buffer should
> be released.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/media/usb/dvb-usb/af9005.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
> index 02697d86e8c1..aee500beaab6 100644
> --- a/drivers/media/usb/dvb-usb/af9005.c
> +++ b/drivers/media/usb/dvb-usb/af9005.c
> @@ -975,8 +975,10 @@ static int af9005_identify_state(struct usb_device *udev,
> *cold = 1;
> else if (reply == 0x02)
> *cold = 0;
> - else
> + else {
> + kfree(buf);
> return -EIO;
> + }
Why not just set ret = -EIO; here?
You only need to add a
if (!ret)
> deb_info("Identify state cold = %d\n", *cold);
before this line.
So this becomes:
else
ret = -EIO;
if (!ret)
deb_info("Identify state cold = %d\n", *cold);
Regards,
Hans
>
> err:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: usb: fix memory leak in af9005_identify_state
2019-10-09 12:42 ` Hans Verkuil
@ 2019-10-09 15:00 ` Navid Emamdoost
2019-10-09 15:01 ` [PATCH v2] " Navid Emamdoost
1 sibling, 0 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-10-09 15:00 UTC (permalink / raw)
To: Hans Verkuil
Cc: Navid Emamdoost, Stephen McCamant, Kangjie Lu,
Mauro Carvalho Chehab, Greg Kroah-Hartman, Thomas Gleixner,
Richard Fontana, Kate Stewart, linux-media, LKML
Hi Hans,
On Wed, Oct 9, 2019 at 7:42 AM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
> On 9/14/19 1:55 AM, Navid Emamdoost wrote:
> > In af9005_identify_state when returning -EIO the allocated buffer should
> > be released.
> >
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> > ---
> > drivers/media/usb/dvb-usb/af9005.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
> > index 02697d86e8c1..aee500beaab6 100644
> > --- a/drivers/media/usb/dvb-usb/af9005.c
> > +++ b/drivers/media/usb/dvb-usb/af9005.c
> > @@ -975,8 +975,10 @@ static int af9005_identify_state(struct usb_device *udev,
> > *cold = 1;
> > else if (reply == 0x02)
> > *cold = 0;
> > - else
> > + else {
> > + kfree(buf);
> > return -EIO;
> > + }
>
> Why not just set ret = -EIO; here?
>
This makes sense. I will send a v2.
> You only need to add a
>
> if (!ret)
> > deb_info("Identify state cold = %d\n", *cold);
>
> before this line.
>
> So this becomes:
>
> else
> ret = -EIO;
> if (!ret)
> deb_info("Identify state cold = %d\n", *cold);
>
> Regards,
>
> Hans
>
> >
> > err:
> >
>
--
Navid.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] media: usb: fix memory leak in af9005_identify_state
2019-10-09 12:42 ` Hans Verkuil
2019-10-09 15:00 ` Navid Emamdoost
@ 2019-10-09 15:01 ` Navid Emamdoost
1 sibling, 0 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-10-09 15:01 UTC (permalink / raw)
To: hverkuil
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Mauro Carvalho Chehab,
Richard Fontana, Thomas Gleixner, Greg Kroah-Hartman,
Allison Randal, linux-media, linux-kernel
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>
---
Changes in v2:
-- Reused the error handling to release buf
-- Added Fixes tag
---
drivers/media/usb/dvb-usb/af9005.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/media/usb/dvb-usb/af9005.c b/drivers/media/usb/dvb-usb/af9005.c
index 02697d86e8c1..bc6e7659c37b 100644
--- a/drivers/media/usb/dvb-usb/af9005.c
+++ b/drivers/media/usb/dvb-usb/af9005.c
@@ -975,9 +975,10 @@ static int af9005_identify_state(struct usb_device *udev,
*cold = 1;
else if (reply == 0x02)
*cold = 0;
- else
- return -EIO;
- deb_info("Identify state cold = %d\n", *cold);
+ else
+ ret = -EIO;
+ if (!ret)
+ deb_info("Identify state cold = %d\n", *cold);
err:
kfree(buf);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-10-09 15:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-13 23:55 [PATCH] media: usb: fix memory leak in af9005_identify_state Navid Emamdoost
2019-10-09 12:42 ` Hans Verkuil
2019-10-09 15:00 ` Navid Emamdoost
2019-10-09 15:01 ` [PATCH v2] " Navid Emamdoost
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).