The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL
@ 2006-05-15 21:57 Jesper Juhl
  2006-05-15 21:59 ` Alan Cox
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2006-05-15 21:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: Moxa Technologies, Alan Cox, Martin Mares, Alexey Dobriyan,
	Jesper Juhl


Remove pointless check of 'tty' argument vs NULL from moxa driver.

(applies on top of patch 1/3)


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 drivers/char/mxser.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

--- linux-2.6.17-rc4-mm1/drivers/char/mxser.c.1	2006-05-15 22:33:49.000000000 +0200
+++ linux-2.6.17-rc4-mm1/drivers/char/mxser.c	2006-05-15 22:34:38.000000000 +0200
@@ -1081,7 +1081,7 @@ static int mxser_write(struct tty_struct
 	struct mxser_struct *info = tty->driver_data;
 	unsigned long flags;
 
-	if (!tty || !info->xmit_buf)
+	if (!info->xmit_buf)
 		return (0);
 
 	while (1) {
@@ -1117,7 +1117,7 @@ static void mxser_put_char(struct tty_st
 	struct mxser_struct *info = tty->driver_data;
 	unsigned long flags;
 
-	if (!tty || !info->xmit_buf)
+	if (!info->xmit_buf)
 		return;
 
 	if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1)




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL
  2006-05-15 21:57 [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL Jesper Juhl
@ 2006-05-15 21:59 ` Alan Cox
  2006-05-15 22:08   ` Jesper Juhl
  2006-05-15 22:09   ` Alexey Dobriyan
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Cox @ 2006-05-15 21:59 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, Moxa Technologies, Alan Cox, Martin Mares,
	Alexey Dobriyan

On Mon, May 15, 2006 at 11:57:35PM +0200, Jesper Juhl wrote:
> Remove pointless check of 'tty' argument vs NULL from moxa driver.

Can you leave those in for the moment but change them to BUG_ON() because
I've seen the pop up once or twice. They may be fixed but Im not 100% sure
yet.

> +	if (!info->xmit_buf)
>  		return (0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL
  2006-05-15 21:59 ` Alan Cox
@ 2006-05-15 22:08   ` Jesper Juhl
  2006-05-15 22:49     ` Alan Cox
  2006-05-15 22:09   ` Alexey Dobriyan
  1 sibling, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2006-05-15 22:08 UTC (permalink / raw)
  To: Alan Cox
  Cc: linux-kernel, Moxa Technologies, Martin Mares, Alexey Dobriyan,
	Jesper Juhl

On 15/05/06, Alan Cox <alan@redhat.com> wrote:
> On Mon, May 15, 2006 at 11:57:35PM +0200, Jesper Juhl wrote:
> > Remove pointless check of 'tty' argument vs NULL from moxa driver.
>
> Can you leave those in for the moment but change them to BUG_ON() because
> I've seen the pop up once or twice. They may be fixed but Im not 100% sure
> yet.
>

I could, but would that really make sense?

As Alexey pointed out in the previous thread :

  >  ->write() is called via
  >
  >         tty->driver->write(tty, ...);
  >
  >  See? tty was already dereferenced.

And besides, we wouldn't ever get to the BUG_ON() because even if the
function did manage to get called it would then explode in the
  struct mxser_struct *info = tty->driver_data;
assignment, before it ever got to the BUG_ON() (that assignment could
ofcourse be moved as I did in my original patch, but that still leaves
Alexeys point in place).

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL
  2006-05-15 21:59 ` Alan Cox
  2006-05-15 22:08   ` Jesper Juhl
@ 2006-05-15 22:09   ` Alexey Dobriyan
  1 sibling, 0 replies; 5+ messages in thread
From: Alexey Dobriyan @ 2006-05-15 22:09 UTC (permalink / raw)
  To: Alan Cox; +Cc: Jesper Juhl, linux-kernel, Moxa Technologies, Martin Mares

On Mon, May 15, 2006 at 05:59:01PM -0400, Alan Cox wrote:
> On Mon, May 15, 2006 at 11:57:35PM +0200, Jesper Juhl wrote:
> > Remove pointless check of 'tty' argument vs NULL from moxa driver.
> 
> Can you leave those in for the moment but change them to BUG_ON() because
> I've seen the pop up once or twice. They may be fixed but Im not 100% sure
> yet.

Dereference to get ->driver_data will show the very same backtrace?

	struct mxser_struct *info = (struct mxser_struct *) tty->driver_data;

    -	if (!tty || !info->xmit_buf)
> > +	if (!info->xmit_buf)
> >  		return (0);


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL
  2006-05-15 22:08   ` Jesper Juhl
@ 2006-05-15 22:49     ` Alan Cox
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Cox @ 2006-05-15 22:49 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Alan Cox, linux-kernel, Moxa Technologies, Martin Mares,
	Alexey Dobriyan

On Tue, May 16, 2006 at 12:08:41AM +0200, Jesper Juhl wrote:
>  >  See? tty was already dereferenced.
> 
> And besides, we wouldn't ever get to the BUG_ON() because even if the
> function did manage to get called it would then explode in the

Agreed - your analysis is right

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-15 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-15 21:57 [PATCH 2/3] moxa: remove pointless check of 'tty' argument vs NULL Jesper Juhl
2006-05-15 21:59 ` Alan Cox
2006-05-15 22:08   ` Jesper Juhl
2006-05-15 22:49     ` Alan Cox
2006-05-15 22:09   ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox