Commit d9ad7ef1979d65a4200847ec91be5b9ad961eba8

Authored by TINNES Julien RD-MAPS-ISS
Committed by Linus Torvalds
1 parent 17abee3d50

[PATCH] Potential null pointer dereference in amiga serial driver

A pointer is dereferenced before it is null-checked.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff

drivers/char/amiserial.c
... ... @@ -861,13 +861,18 @@
861 861  
862 862 static void rs_put_char(struct tty_struct *tty, unsigned char ch)
863 863 {
864   - struct async_struct *info = (struct async_struct *)tty->driver_data;
  864 + struct async_struct *info;
865 865 unsigned long flags;
866 866  
  867 + if (!tty)
  868 + return;
  869 +
  870 + info = tty->driver_data;
  871 +
867 872 if (serial_paranoia_check(info, tty->name, "rs_put_char"))
868 873 return;
869 874  
870   - if (!tty || !info->xmit.buf)
  875 + if (!info->xmit.buf)
871 876 return;
872 877  
873 878 local_irq_save(flags);
874 879  
875 880  
... ... @@ -910,13 +915,18 @@
910 915 static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count)
911 916 {
912 917 int c, ret = 0;
913   - struct async_struct *info = (struct async_struct *)tty->driver_data;
  918 + struct async_struct *info;
914 919 unsigned long flags;
915 920  
  921 + if (!tty)
  922 + return 0;
  923 +
  924 + info = tty->driver_data;
  925 +
916 926 if (serial_paranoia_check(info, tty->name, "rs_write"))
917 927 return 0;
918 928  
919   - if (!tty || !info->xmit.buf || !tmp_buf)
  929 + if (!info->xmit.buf || !tmp_buf)
920 930 return 0;
921 931  
922 932 local_save_flags(flags);