• Jia-Ju Bai's avatar
    tty/isicom: Fix a possible sleep-in-atomic bug in WaitTillCardIsFree · fe8e7ace
    Jia-Ju Bai authored
    The driver may sleep under a spinlock.
    The function call paths are:
    isicom_activate (acquire the spinlock)
      isicom_setup_board
        drop_dtr_rts
          WaitTillCardIsFree
            msleep --> may sleep
    
    isicom_set_termios
      isicom_config_port
        drop_dtr
          WaitTillCardIsFree
            msleep --> may sleep
    
    isicom_tiocmset
      drop_dtr
        WaitTillCardIsFree
          msleep --> may sleep
    
    Though "in_atomic" is used to check atomic context,
    but it is not recommended to use in driver code (see include/linux/preempt.h).
    
    To fix it, only using mdelay instead.
    
    This bug is found by my static analysis tool(DSAC) and checked by my code review.
    Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    fe8e7ace
isicom.c 41 KB