[PATCH] coverity: tty_ldisc_ref return null check

We add a check of the return value of tty_ldisc_ref(), which
is checked 7 out of 8 times, e.g.:

149 ld = tty_ldisc_ref(tty);
150 if (ld != NULL) {
151 if (ld->set_termios)
152 (ld->set_termios)(tty, &old_termios);
153 tty_ldisc_deref(ld);
154 }

This defect was found automatically by Coverity Prevent, a static analysis
tool.

(akpm: presumably `ld' is never NULL. Oh well)

Signed-off-by: Zaur Kambarov <zkambarov@coverity.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by KAMBAROV, ZAUR and committed by Linus Torvalds 69f63c5c c7f1721e

+2 -2
+2 -2
drivers/char/tty_ioctl.c
··· 476 476 ld = tty_ldisc_ref(tty); 477 477 switch (arg) { 478 478 case TCIFLUSH: 479 - if (ld->flush_buffer) 479 + if (ld && ld->flush_buffer) 480 480 ld->flush_buffer(tty); 481 481 break; 482 482 case TCIOFLUSH: 483 - if (ld->flush_buffer) 483 + if (ld && ld->flush_buffer) 484 484 ld->flush_buffer(tty); 485 485 /* fall through */ 486 486 case TCOFLUSH: