]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] usbserial: Fixes use-after-free in serial_open().
authorLuiz Fernando Capitulino <lcapitulino@mandriva.com.br>
Fri, 12 May 2006 01:34:17 +0000 (22:34 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 12 May 2006 18:58:09 +0000 (11:58 -0700)
If the device is disconnected while serial_open() is executing and
either try_module_get() or the device specific open function fails, the
kref_put() call in the 'bailout_kref_put' label will free the memory
pointed out by 'port'.

The subsequent dereferences in the 'bailout_kref_put' label will be
invalid.

The fix is just to assure kref_put() is called after any 'port' usage.

Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/serial/usb-serial.c

index 071f86a59c086222ecf89c8705080b064b4d8fdc..d9dceb4f57b9ec97951b3d535b565be73702da56 100644 (file)
@@ -225,9 +225,9 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
 bailout_module_put:
        module_put(serial->type->driver.owner);
 bailout_kref_put:
-       kref_put(&serial->kref, destroy_serial);
        port->open_count = 0;
        mutex_unlock(&port->mutex);
+       kref_put(&serial->kref, destroy_serial);
        return retval;
 }