diff mbox

net, TTY: initialize tty->driver_data before usage

Message ID 1349395281-12495-1-git-send-email-sasha.levin@oracle.com
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Sasha Levin Oct. 5, 2012, 12:01 a.m. UTC
Commit 9c650ffc ("TTY: ircomm_tty, add tty install") split _open() to
_install() and _open(). It also moved the initialization of driver_data
out of open(), but never added it to install() - causing a NULL ptr
deref whenever the driver was used.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/irda/ircomm/ircomm_tty.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Jiri Slaby Oct. 5, 2012, 8:09 a.m. UTC | #1
On 10/05/2012 02:01 AM, Sasha Levin wrote:
> Commit 9c650ffc ("TTY: ircomm_tty, add tty install") split _open() to
> _install() and _open(). It also moved the initialization of driver_data
> out of open(), but never added it to install() - causing a NULL ptr
> deref whenever the driver was used.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> ---
>  net/irda/ircomm/ircomm_tty.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
> index 95a3a7a..496ce2c 100644
> --- a/net/irda/ircomm/ircomm_tty.c
> +++ b/net/irda/ircomm/ircomm_tty.c
> @@ -421,6 +421,8 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
>  		hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
>  	}
>  
> +	tty->driver_data = self;
> +
>  	return tty_port_install(&self->port, driver, tty);

Yes, a good catch.

Acked-by: Jiri Slaby <jslaby@suse.cz>

thanks,
Greg Kroah-Hartman Oct. 5, 2012, 4:25 p.m. UTC | #2
On Thu, Oct 04, 2012 at 08:01:21PM -0400, Sasha Levin wrote:
> Commit 9c650ffc ("TTY: ircomm_tty, add tty install") split _open() to
> _install() and _open(). It also moved the initialization of driver_data
> out of open(), but never added it to install() - causing a NULL ptr
> deref whenever the driver was used.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
> Acked-by: Jiri Slaby <jslaby@suse.cz>
> ---
>  net/irda/ircomm/ircomm_tty.c | 2 ++
>  1 file changed, 2 insertions(+)

Nice catch, now applied.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 95a3a7a..496ce2c 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -421,6 +421,8 @@  static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
 		hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
 	}
 
+	tty->driver_data = self;
+
 	return tty_port_install(&self->port, driver, tty);
 }