* [PATCH][rfc] media, video, stv06xx, pb0100: Don't potentially deref NULL in pb0100_start().
@ 2011-01-13 22:05 Jesper Juhl
2011-01-14 9:40 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2011-01-13 22:05 UTC (permalink / raw)
To: linux-media
Cc: linux-kernel, Jean-Francois Moine, Mauro Carvalho Chehab,
Hans de Goede, Lee Jones
usb_altnum_to_altsetting() may return NULL. If it does we'll dereference a
NULL pointer in
drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c::pb0100_start().
As far as I can tell there's not really anything more sensible than
-ENODEV that we can return in that situation, but I'm not at all intimate
with this code so I'd like a bit of review/comments on this before it's
applied.
Anyway, here's a proposed patch.
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
stv06xx_pb0100.c | 2 ++
1 file changed, 2 insertions(+)
compile tested only.
diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
index ac47b4c..75a5b9c 100644
--- a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
+++ b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
@@ -217,6 +217,8 @@ static int pb0100_start(struct sd *sd)
intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
+ if (!alt)
+ return -ENODEV;
packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
/* If we don't have enough bandwidth use a lower framerate */
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][rfc] media, video, stv06xx, pb0100: Don't potentially deref NULL in pb0100_start().
2011-01-13 22:05 [PATCH][rfc] media, video, stv06xx, pb0100: Don't potentially deref NULL in pb0100_start() Jesper Juhl
@ 2011-01-14 9:40 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2011-01-14 9:40 UTC (permalink / raw)
To: Jesper Juhl
Cc: linux-media, linux-kernel, Jean-Francois Moine,
Mauro Carvalho Chehab, Lee Jones
Hi,
On 01/13/2011 11:05 PM, Jesper Juhl wrote:
> usb_altnum_to_altsetting() may return NULL. If it does we'll dereference a
> NULL pointer in
> drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c::pb0100_start().
> As far as I can tell there's not really anything more sensible than
> -ENODEV that we can return in that situation, but I'm not at all intimate
> with this code so I'd like a bit of review/comments on this before it's
> applied.
> Anyway, here's a proposed patch.
>
Hi,
On 01/13/2011 11:05 PM, Jesper Juhl wrote:
> usb_altnum_to_altsetting() may return NULL. If it does we'll dereference a
> NULL pointer in
> drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c::pb0100_start().
> As far as I can tell there's not really anything more sensible than
> -ENODEV that we can return in that situation, but I'm not at all intimate
> with this code so I'd like a bit of review/comments on this before it's
> applied.
> Anyway, here's a proposed patch.
>
pb0100_start gets called from stv06xx_start, which also does a
usb_altnum_to_altsetting(intf, sd->gspca_dev.alt); and does contain the
NULL check before calling pb0100_start. So I left out the check on purpose,
to keep the code compact in IMHO better readable.
Still I agree this is a bit tricky. So not NACK but not ACK either. What
do others think?
Regards,
Hans
> Signed-off-by: Jesper Juhl<jj@chaosbits.net>
> ---
> stv06xx_pb0100.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> compile tested only.
>
> diff --git a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
> index ac47b4c..75a5b9c 100644
> --- a/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
> +++ b/drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c
> @@ -217,6 +217,8 @@ static int pb0100_start(struct sd *sd)
>
> intf = usb_ifnum_to_if(sd->gspca_dev.dev, sd->gspca_dev.iface);
> alt = usb_altnum_to_altsetting(intf, sd->gspca_dev.alt);
> + if (!alt)
> + return -ENODEV;
> packet_size = le16_to_cpu(alt->endpoint[0].desc.wMaxPacketSize);
>
> /* If we don't have enough bandwidth use a lower framerate */
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-01-14 9:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-13 22:05 [PATCH][rfc] media, video, stv06xx, pb0100: Don't potentially deref NULL in pb0100_start() Jesper Juhl
2011-01-14 9:40 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox