[media] gspca/stv06xx_pb0100: Don't potentially deref NULL in pb0100_start()
authorJesper Juhl <jj@chaosbits.net>
Thu, 13 Jan 2011 22:05:47 +0000 (19:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Fri, 20 May 2011 12:29:56 +0000 (09:29 -0300)
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>
Cc: Jean-Francois Moine <moinejf@free.fr>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Erik Andren <erik.andren@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/gspca/stv06xx/stv06xx_pb0100.c

index ac47b4c9438874af6c7038d0d8516f17347b1b58..75a5b9c2f15ff35810637c4f4b04ff6398eda736 100644 (file)
@@ -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 */