diff mbox

[media] cx231xx-cards: fix NULL-deref on missing association descriptor

Message ID 20170921084018.30510-1-johan@kernel.org (mailing list archive)
State New, archived
Headers show

Commit Message

Johan Hovold Sept. 21, 2017, 8:40 a.m. UTC
Make sure to check that we actually have an Interface Association
Descriptor before dereferencing it during probe to avoid dereferencing a
NULL-pointer.

Fixes: e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver")
Cc: stable <stable@vger.kernel.org>     # 2.6.30
Cc: Sri Deevi <Srinivasa.Deevi@conexant.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrey Konovalov Sept. 21, 2017, 2 p.m. UTC | #1
On Thu, Sep 21, 2017 at 10:40 AM, Johan Hovold <johan@kernel.org> wrote:
> Make sure to check that we actually have an Interface Association
> Descriptor before dereferencing it during probe to avoid dereferencing a
> NULL-pointer.
>
> Fixes: e0d3bafd0258 ("V4L/DVB (10954): Add cx231xx USB driver")
> Cc: stable <stable@vger.kernel.org>     # 2.6.30
> Cc: Sri Deevi <Srinivasa.Deevi@conexant.com>
> Reported-by: Andrey Konovalov <andreyknvl@google.com>
> Signed-off-by: Johan Hovold <johan@kernel.org>

Tested-by: Andrey Konovalov <andreyknvl@google.com>

Thanks!

> ---
>  drivers/media/usb/cx231xx/cx231xx-cards.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
> index e0daa9b6c2a0..9b742d569fb5 100644
> --- a/drivers/media/usb/cx231xx/cx231xx-cards.c
> +++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
> @@ -1684,7 +1684,7 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
>         nr = dev->devno;
>
>         assoc_desc = udev->actconfig->intf_assoc[0];
> -       if (assoc_desc->bFirstInterface != ifnum) {
> +       if (!assoc_desc || assoc_desc->bFirstInterface != ifnum) {
>                 dev_err(d, "Not found matching IAD interface\n");
>                 retval = -ENODEV;
>                 goto err_if;
> --
> 2.14.1
>
diff mbox

Patch

diff --git a/drivers/media/usb/cx231xx/cx231xx-cards.c b/drivers/media/usb/cx231xx/cx231xx-cards.c
index e0daa9b6c2a0..9b742d569fb5 100644
--- a/drivers/media/usb/cx231xx/cx231xx-cards.c
+++ b/drivers/media/usb/cx231xx/cx231xx-cards.c
@@ -1684,7 +1684,7 @@  static int cx231xx_usb_probe(struct usb_interface *interface,
 	nr = dev->devno;
 
 	assoc_desc = udev->actconfig->intf_assoc[0];
-	if (assoc_desc->bFirstInterface != ifnum) {
+	if (!assoc_desc || assoc_desc->bFirstInterface != ifnum) {
 		dev_err(d, "Not found matching IAD interface\n");
 		retval = -ENODEV;
 		goto err_if;