Commit 37bb5628 authored by Dan Carpenter's avatar Dan Carpenter Committed by Johan Hovold
Browse files

USB: serial: io_edgeport: fix use after free in debug printk



The "dev_dbg(&urb->dev->dev, ..." which happens after usb_free_urb(urb)
is a use after free of the "urb" pointer.  Store the "dev" pointer at the
start of the function to avoid this issue.

Fixes: 984f6868 ("USB: serial: io_edgeport.c: remove dbg() usage")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 3b05949b
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -770,11 +770,12 @@ static void edge_bulk_out_data_callback(struct urb *urb)
static void edge_bulk_out_cmd_callback(struct urb *urb)
{
	struct edgeport_port *edge_port = urb->context;
	struct device *dev = &urb->dev->dev;
	int status = urb->status;

	atomic_dec(&CmdUrbs);
	dev_dbg(&urb->dev->dev, "%s - FREE URB %p (outstanding %d)\n",
		__func__, urb, atomic_read(&CmdUrbs));
	dev_dbg(dev, "%s - FREE URB %p (outstanding %d)\n", __func__, urb,
		atomic_read(&CmdUrbs));


	/* clean up the transfer buffer */
@@ -784,8 +785,7 @@ static void edge_bulk_out_cmd_callback(struct urb *urb)
	usb_free_urb(urb);

	if (status) {
		dev_dbg(&urb->dev->dev,
			"%s - nonzero write bulk status received: %d\n",
		dev_dbg(dev, "%s - nonzero write bulk status received: %d\n",
			__func__, status);
		return;
	}