USB: sisusbvga: fix oops in error path of sisusb_probe
authorOliver Neukum <oneukum@suse.com>
Thu, 9 May 2019 12:41:50 +0000 (14:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 9 Jun 2019 07:18:14 +0000 (09:18 +0200)
commit 9a5729f68d3a82786aea110b1bfe610be318f80a upstream.

The pointer used to log a failure of usb_register_dev() must
be set before the error is logged.

v2: fix that minor is not available before registration

Signed-off-by: oliver Neukum <oneukum@suse.com>
Reported-by: syzbot+a0cbdbd6d169020c8959@syzkaller.appspotmail.com
Fixes: 7b5cd5fefbe02 ("USB: SisUSB2VGA: Convert printk to dev_* macros")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/sisusbvga/sisusb.c

index 30774e0aeadde4b88903ef688881ced60108ea03..3121fa31aabf93a64448d1852466e717e54e7f9e 100644 (file)
@@ -3028,6 +3028,13 @@ static int sisusb_probe(struct usb_interface *intf,
 
        mutex_init(&(sisusb->lock));
 
+       sisusb->sisusb_dev = dev;
+       sisusb->vrambase   = SISUSB_PCI_MEMBASE;
+       sisusb->mmiobase   = SISUSB_PCI_MMIOBASE;
+       sisusb->mmiosize   = SISUSB_PCI_MMIOSIZE;
+       sisusb->ioportbase = SISUSB_PCI_IOPORTBASE;
+       /* Everything else is zero */
+
        /* Register device */
        retval = usb_register_dev(intf, &usb_sisusb_class);
        if (retval) {
@@ -3038,13 +3045,7 @@ static int sisusb_probe(struct usb_interface *intf,
                goto error_1;
        }
 
-       sisusb->sisusb_dev = dev;
-       sisusb->minor      = intf->minor;
-       sisusb->vrambase   = SISUSB_PCI_MEMBASE;
-       sisusb->mmiobase   = SISUSB_PCI_MMIOBASE;
-       sisusb->mmiosize   = SISUSB_PCI_MMIOSIZE;
-       sisusb->ioportbase = SISUSB_PCI_IOPORTBASE;
-       /* Everything else is zero */
+       sisusb->minor = intf->minor;
 
        /* Allocate buffers */
        sisusb->ibufsize = SISUSB_IBUF_SIZE;