USB: serial: keyspan_pda: fix modem-status error handling
authorJohan Hovold <johan@kernel.org>
Wed, 4 Jul 2018 15:02:16 +0000 (17:02 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 20 Nov 2018 18:05:36 +0000 (18:05 +0000)
commit 01b3cdfca263a17554f7b249d20a247b2a751521 upstream.

Fix broken modem-status error handling which could lead to bits of slab
data leaking to user space.

Fixes: 3b36a8fd6777 ("usb: fix uninitialized variable warning in keyspan_pda")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/serial/keyspan_pda.c

index 6b0942428917079fe7aeb0f699dc3eb0dc36f1ce..8a4047de43dce829f34615ff06397476ab0b46ff 100644 (file)
@@ -373,8 +373,10 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial,
                             3, /* get pins */
                             USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN,
                             0, 0, data, 1, 2000);
-       if (rc >= 0)
+       if (rc == 1)
                *value = *data;
+       else if (rc >= 0)
+               rc = -EIO;
 
        kfree(data);
        return rc;