]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
USB: serial: ir-usb: add missing endpoint sanity check
authorJohan Hovold <johan@kernel.org>
Wed, 22 Jan 2020 10:15:26 +0000 (11:15 +0100)
committerPaolo Pisati <paolo.pisati@canonical.com>
Tue, 4 Feb 2020 09:18:13 +0000 (09:18 +0000)
BugLink: https://bugs.launchpad.net/bugs/1861784
commit 2988a8ae7476fe9535ab620320790d1714bdad1d upstream.

Add missing endpoint sanity check to avoid dereferencing a NULL-pointer
on open() in case a device lacks a bulk-out endpoint.

Note that prior to commit f4a4cbb2047e ("USB: ir-usb: reimplement using
generic framework") the oops would instead happen on open() if the
device lacked a bulk-in endpoint and on write() if it lacked a bulk-out
endpoint.

Fixes: f4a4cbb2047e ("USB: ir-usb: reimplement using generic framework")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/usb/serial/ir-usb.c

index 302eb9530859fc5de214d26bfe1f4f735c87768f..c3b06fc5a7f055b712283e3a0eb87b72023865d6 100644 (file)
@@ -195,6 +195,9 @@ static int ir_startup(struct usb_serial *serial)
        struct usb_irda_cs_descriptor *irda_desc;
        int rates;
 
+       if (serial->num_bulk_in < 1 || serial->num_bulk_out < 1)
+               return -ENODEV;
+
        irda_desc = irda_usb_find_class_desc(serial, 0);
        if (!irda_desc) {
                dev_err(&serial->dev->dev,