Skip to contentSkip to conversation

moxa: remove pointless check of 'tty' argument vs NULL

PATCH Superseded Jesper Juhl 3 participants 5 messages May 15, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 moxa: remove pointless check of 'tty' argument vs NULL

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

(applies on top of patch 1/3)

---

 drivers/char/mxser.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/mxser.c renamed from drivers/char/mxser.c.1 +2 -2
@@ -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)
#1 lore raw
Quoted 1 line · Jesper Juhl

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.

Quoted 2 lines
drivers/char/mxser.c renamed from drivers/char/mxser.c.1 +1 -0
+	if (!info->xmit_buf)
 		return (0);
#2 lore raw
Quoted 7 lines · Alan Cox
Quoted 1 line · Jesper Juhl

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 :

Quoted 5 lines

->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).

Signature · 3 lines
Jesper Juhl <[email protected]>
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
#3 lore raw
Quoted 4 lines · Jesper Juhl
Quoted 1 line

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

#4 lore raw
In reply to Alan Cox
Quoted 6 lines · Alan Cox
Quoted 1 line · Jesper Juhl

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)
Quoted 2 lines
Quoted 2 lines
drivers/char/mxser.c renamed from drivers/char/mxser.c.1 +1 -0
+	if (!info->xmit_buf)
 		return (0);