Commit 7a759197 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman
Browse files

USB: usblp: fix use-after-free on disconnect



A recent commit addressing a runtime PM use-count regression, introduced
a use-after-free by not making sure we held a reference to the struct
usb_interface for the lifetime of the driver data.

Fixes: 9a315358 ("USB: usblp: fix runtime PM after driver unbind")
Cc: stable <stable@vger.kernel.org>
Reported-by: default avatar <syzbot+cd24df4d075c319ebfc5@syzkaller.appspotmail.com>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191015175522.18490-1-johan@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b987b66a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -445,6 +445,7 @@ static void usblp_cleanup(struct usblp *usblp)
	kfree(usblp->readbuf);
	kfree(usblp->device_id_string);
	kfree(usblp->statusbuf);
	usb_put_intf(usblp->intf);
	kfree(usblp);
}

@@ -1113,7 +1114,7 @@ static int usblp_probe(struct usb_interface *intf,
	init_waitqueue_head(&usblp->wwait);
	init_usb_anchor(&usblp->urbs);
	usblp->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
	usblp->intf = intf;
	usblp->intf = usb_get_intf(intf);

	/* Malloc device ID string buffer to the largest expected length,
	 * since we can re-query it on an ioctl and a dynamic string
@@ -1198,6 +1199,7 @@ abort:
	kfree(usblp->readbuf);
	kfree(usblp->statusbuf);
	kfree(usblp->device_id_string);
	usb_put_intf(usblp->intf);
	kfree(usblp);
abort_ret:
	return retval;