Re: [PATCH] usb: serial: visor: fix crash on detecting device without write_urbs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.

On 01/11/2016 09:09 PM, Vladis Dronov wrote:

The visor driver crashes in clie_5_attach() when a specially crafted USB
device without bulk-out endpoint is detected. This fix adds a check that
the device has proper configuration expected by the driver. Also error
message output is added to the one of the error paths.

Reported-by: Ralf Spenneberg <ralf@xxxxxxxxxxxxxx>
Signed-off-by: Vladis Dronov <vdronov@xxxxxxxxxx>
---
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1296466

  drivers/usb/serial/visor.c | 14 ++++++++++++--
  1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index 60afb39..9913039 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
[...]
@@ -607,7 +611,13 @@ static int clie_5_attach(struct usb_serial *serial)

  	pipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);
  	for (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)
-		port->write_urbs[j]->pipe = pipe;
+		if (port->write_urbs[j])
+			port->write_urbs[j]->pipe = pipe;
+		else {
+			dev_err(dev, "%s: Write URB %d for port 0 was not allocated\n",
+			    __func__, j);
+			return -1;
+		}

The kernel coding style dictates that all *if* branches should have {} if at least one branch has them.

[...]

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux