From: TINNES Julien RD-MAPS-ISS A pointer is dereferenced before it is null-checked. Signed-off-by: Andrew Morton --- drivers/char/amiserial.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff -puN drivers/char/amiserial.c~potential-null-pointer-dereference-in-amiga-serial-driver drivers/char/amiserial.c --- 25/drivers/char/amiserial.c~potential-null-pointer-dereference-in-amiga-serial-driver 2005-05-31 02:08:02.000000000 -0700 +++ 25-akpm/drivers/char/amiserial.c 2005-05-31 02:08:02.000000000 -0700 @@ -861,13 +861,18 @@ static void change_speed(struct async_st static void rs_put_char(struct tty_struct *tty, unsigned char ch) { - struct async_struct *info = (struct async_struct *)tty->driver_data; + struct async_struct *info; unsigned long flags; + if (!tty) + return; + + info = tty->driver_data; + if (serial_paranoia_check(info, tty->name, "rs_put_char")) return; - if (!tty || !info->xmit.buf) + if (!info->xmit.buf) return; local_irq_save(flags); @@ -910,13 +915,18 @@ static void rs_flush_chars(struct tty_st static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) { int c, ret = 0; - struct async_struct *info = (struct async_struct *)tty->driver_data; + struct async_struct *info; unsigned long flags; + if (!tty) + return 0; + + info = tty->driver_data; + if (serial_paranoia_check(info, tty->name, "rs_write")) return 0; - if (!tty || !info->xmit.buf || !tmp_buf) + if (!info->xmit.buf || !tmp_buf) return 0; local_save_flags(flags); _