• Ryan S. Arnold's avatar
    [PATCH] hvc_console fix to protect hvc_write against ldisc write after hvc_close · 9642f757
    Ryan S. Arnold authored
    Due to the tty ldisc code not stopping write operations against a driver
    even after a tty has been closed I added a mechanism to hvc_console in my
    previous patch to prevent this by nulling out the tty->driver_data in
    hvc_close() but I forgot to check tty->driver_data in hvc_write().  Anton
    Blanchard got several oops'es from hvc_write() accessing NULL as if it were
    a pointer to an hvc_struct usually stored in tty->driver_data.
    
    So this patch checks tty->driver_data in hvc_write() before it is used. 
    Hopefully once Alan Cox's patch is checked in ldisc writes won't continue
    to happen after tty closes.
    
    Anton Blanchard has tested this patch and is unable to reproduce the oops
    with it applied.
    
    Changelog:
    
    drivers/char/hvc_console.c
    
    - Added comment to hvc_close() to explain the reason for NULLing
      tty->driver_data.
    
    - Added check to hvc_write() to verify that tty->driver_data is valid
      (NOT NULL) which would be the case if the write operation was invoked
      after a tty close was initiated on the tty.
    Signed-off-by: default avatarRyan S. Arnold <rsa@us.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    9642f757
hvc_console.c 20.9 KB