* [PATCH 1/1] NET: irda, fix potential null dereference
@ 2010-01-10 9:11 Jiri Slaby
2010-01-10 11:17 ` [PATCH 1/1] NET: irda, remove unnecessary checks Jiri Slaby
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2010-01-10 9:11 UTC (permalink / raw)
To: samuel
Cc: linux-kernel, jirislaby, David S. Miller, Alan Cox,
Greg Kroah-Hartman, netdev
Stanse found a potential null dereference in ircomm_tty_close
and ircomm_tty_hangup. There is a check for tty being NULL,
but it is dereferenced earlier. Move the dereference after
the check.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: netdev@vger.kernel.org
---
net/irda/ircomm/ircomm_tty.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 811984d..42a7d75 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -491,7 +491,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
*/
static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
{
- struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
+ struct ircomm_tty_cb *self;
unsigned long flags;
IRDA_DEBUG(0, "%s()\n", __func__ );
@@ -499,6 +499,8 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
if (!tty)
return;
+ self = tty->driver_data;
+
IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -999,17 +1001,19 @@ static void ircomm_tty_shutdown(struct ircomm_tty_cb *self)
*/
static void ircomm_tty_hangup(struct tty_struct *tty)
{
- struct ircomm_tty_cb *self = (struct ircomm_tty_cb *) tty->driver_data;
+ struct ircomm_tty_cb *self;
unsigned long flags;
IRDA_DEBUG(0, "%s()\n", __func__ );
- IRDA_ASSERT(self != NULL, return;);
- IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
-
if (!tty)
return;
+ self = tty->driver_data;
+
+ IRDA_ASSERT(self != NULL, return;);
+ IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
+
/* ircomm_tty_flush_buffer(tty); */
ircomm_tty_shutdown(self);
--
1.6.5.7
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 1/1] NET: irda, remove unnecessary checks
2010-01-10 9:11 [PATCH 1/1] NET: irda, fix potential null dereference Jiri Slaby
@ 2010-01-10 11:17 ` Jiri Slaby
2010-01-10 21:28 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Jiri Slaby @ 2010-01-10 11:17 UTC (permalink / raw)
To: samuel
Cc: linux-kernel, jirislaby, David S. Miller, Alan Cox,
Greg Kroah-Hartman, netdev
Stanse found a potential null dereference in ircomm_tty_close
and ircomm_tty_hangup. There is a check for tty being NULL,
but it is dereferenced earlier. But it is bogus, the tty cannot
be NULL, so remove the !tty checks.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
Cc: netdev@vger.kernel.org
---
net/irda/ircomm/ircomm_tty.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 811984d..8b85d77 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -496,9 +496,6 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
IRDA_DEBUG(0, "%s()\n", __func__ );
- if (!tty)
- return;
-
IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
@@ -1007,9 +1004,6 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
IRDA_ASSERT(self != NULL, return;);
IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
- if (!tty)
- return;
-
/* ircomm_tty_flush_buffer(tty); */
ircomm_tty_shutdown(self);
--
1.6.5.7
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] NET: irda, remove unnecessary checks
2010-01-10 11:17 ` [PATCH 1/1] NET: irda, remove unnecessary checks Jiri Slaby
@ 2010-01-10 21:28 ` David Miller
0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2010-01-10 21:28 UTC (permalink / raw)
To: jslaby; +Cc: samuel, linux-kernel, jirislaby, alan, gregkh, netdev
From: Jiri Slaby <jslaby@suse.cz>
Date: Sun, 10 Jan 2010 12:17:34 +0100
> Stanse found a potential null dereference in ircomm_tty_close
> and ircomm_tty_hangup. There is a check for tty being NULL,
> but it is dereferenced earlier. But it is bogus, the tty cannot
> be NULL, so remove the !tty checks.
>
> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-01-10 21:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-10 9:11 [PATCH 1/1] NET: irda, fix potential null dereference Jiri Slaby
2010-01-10 11:17 ` [PATCH 1/1] NET: irda, remove unnecessary checks Jiri Slaby
2010-01-10 21:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).