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

mfd: rtsx_usb: Avoid setting ucr->current_sg.status

Member "status" of struct usb_sg_request is managed by usb core. A
spin lock is used to serialize the change of it. The driver could
check the value of req->status, but should avoid changing it without
the hold of the spinlock. Otherwise, it could cause race or error
in usb core.

This patch could be backported to stable kernels with version later
than v3.14.

Cc: stable@vger.kernel.org # 3.14+
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Roger Tseng <rogerable@realtek.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Lu Baolu and committed by
Lee Jones
8dcc5ff8 09185a59

+5 -5
+5 -5
drivers/mfd/rtsx_usb.c
··· 46 46 47 47 dev_dbg(&ucr->pusb_intf->dev, "%s: sg transfer timed out", __func__); 48 48 usb_sg_cancel(&ucr->current_sg); 49 - 50 - /* we know the cancellation is caused by time-out */ 51 - ucr->current_sg.status = -ETIMEDOUT; 52 49 } 53 50 54 51 static int rtsx_usb_bulk_transfer_sglist(struct rtsx_ucr *ucr, ··· 64 67 ucr->sg_timer.expires = jiffies + msecs_to_jiffies(timeout); 65 68 add_timer(&ucr->sg_timer); 66 69 usb_sg_wait(&ucr->current_sg); 67 - del_timer_sync(&ucr->sg_timer); 70 + if (!del_timer_sync(&ucr->sg_timer)) 71 + ret = -ETIMEDOUT; 72 + else 73 + ret = ucr->current_sg.status; 68 74 69 75 if (act_len) 70 76 *act_len = ucr->current_sg.bytes; 71 77 72 - return ucr->current_sg.status; 78 + return ret; 73 79 } 74 80 75 81 int rtsx_usb_transfer_data(struct rtsx_ucr *ucr, unsigned int pipe,