]> Pileus Git - ~andy/linux/commitdiff
Staging: ipack/devices/ipoctal: fix dereference NULL pointer
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Fri, 13 Jul 2012 11:33:13 +0000 (13:33 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Jul 2012 02:11:37 +0000 (19:11 -0700)
After opening and closing the file /dev/ipoctal.X.Y.Z for the second time, it
gives a kernel oops due to a dereference of a NULL pointer.

The problem was that tty->driver_data was not properly initialized when
accessing the file for the second time.

Reported-by: Alberto Garcia Gonzalez <agarcia@igalia.com>
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ipack/devices/ipoctal.c

index a5af423a4e7c7bdde83a4e6f7ddba2c1c099d911..a1aae40ce68de643fbce818012c4f3a177492b94 100644 (file)
@@ -114,8 +114,6 @@ static int ipoctal_port_activate(struct tty_port *port, struct tty_struct *tty)
 
        ipoctal_write_io_reg(ipoctal, &ipoctal->chan_regs[channel].u.w.cr,
                             CR_ENABLE_RX);
-       tty->driver_data = ipoctal;
-
        return 0;
 }
 
@@ -136,6 +134,8 @@ static int ipoctal_open(struct tty_struct *tty, struct file *file)
        if (atomic_read(&ipoctal->open[channel]))
                return -EBUSY;
 
+       tty->driver_data = ipoctal;
+
        res = tty_port_open(&ipoctal->tty_port[channel], tty, file);
        if (res)
                return res;