Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: serial: io_edgeport: fix possible sleep-in-atomic

According to drivers/usb/serial/io_edgeport.c, the driver may sleep
under a spinlock.
The function call path is:
edge_bulk_in_callback (acquire the spinlock)
process_rcvd_data
process_rcvd_status
change_port_settings
send_iosp_ext_cmd
write_cmd_usb
usb_kill_urb --> may sleep

To fix it, the redundant usb_kill_urb() is removed from the error path
after usb_submit_urb() fails.

This possible bug is found by my static analysis tool (DSAC) and checked
by my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>

authored by

Jia-Ju Bai and committed by
Johan Hovold
c7b8f778 d8a42b1f

-1
-1
drivers/usb/serial/io_edgeport.c
··· 2282 2282 /* something went wrong */ 2283 2283 dev_err(dev, "%s - usb_submit_urb(write command) failed, status = %d\n", 2284 2284 __func__, status); 2285 - usb_kill_urb(urb); 2286 2285 usb_free_urb(urb); 2287 2286 atomic_dec(&CmdUrbs); 2288 2287 return status;