提交 9ae2b3bc 编写于 作者: O Oliver Neukum 提交者: Yang Yingliang

appledisplay: fix error handling in the scheduled work

commit 91feb01596e5efc0cc922cc73f5583114dccf4d2 upstream.

The work item can operate on

1. stale memory left over from the last transfer
the actual length of the data transfered needs to be checked
2. memory already freed
the error handling in appledisplay_probe() needs
to cancel the work in that case

Reported-and-tested-by: syzbot+495dab1f175edc9c2f13@syzkaller.appspotmail.com
Signed-off-by: NOliver Neukum <oneukum@suse.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20191106124902.7765-1-oneukum@suse.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 24a65739
...@@ -170,7 +170,12 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd) ...@@ -170,7 +170,12 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd)
0, 0,
pdata->msgdata, 2, pdata->msgdata, 2,
ACD_USB_TIMEOUT); ACD_USB_TIMEOUT);
if (retval < 2) {
if (retval >= 0)
retval = -EMSGSIZE;
} else {
brightness = pdata->msgdata[1]; brightness = pdata->msgdata[1];
}
mutex_unlock(&pdata->sysfslock); mutex_unlock(&pdata->sysfslock);
if (retval < 0) if (retval < 0)
...@@ -305,6 +310,7 @@ static int appledisplay_probe(struct usb_interface *iface, ...@@ -305,6 +310,7 @@ static int appledisplay_probe(struct usb_interface *iface,
if (pdata) { if (pdata) {
if (pdata->urb) { if (pdata->urb) {
usb_kill_urb(pdata->urb); usb_kill_urb(pdata->urb);
cancel_delayed_work_sync(&pdata->work);
if (pdata->urbdata) if (pdata->urbdata)
usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN, usb_free_coherent(pdata->udev, ACD_URB_BUFFER_LEN,
pdata->urbdata, pdata->urb->transfer_dma); pdata->urbdata, pdata->urb->transfer_dma);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册