Skip to contentSkip to conversation

usb: misc: cypress_cy7c63: check result of IO

PATCH New Oliver Neukum 1 participant 1 message Jul 10 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: misc: cypress_cy7c63: check result of IO

If the device returns a bogus short read, treat it as EIO. Actually check for IO errors.

---
 drivers/usb/misc/cypress_cy7c63.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/usb/misc/cypress_cy7c63.c +6 -2
index 4a7f955ba85b..ecc81c93c6ce 100644
@@ -89,8 +89,11 @@ static int vendor_command(struct cypress *dev, unsigned char request,
 				 address, data, iobuf, CYPRESS_MAX_REQSIZE,
 				 USB_CTRL_GET_TIMEOUT);
 	/* we must not process garbage */
-	if (retval < 2)
+	if (retval < 2) {
+		if (retval >= 0)
+			retval = -EIO;
 		goto err_buf;
+	}
 
 	/* store returned data (more READs to be added) */
 	switch (request) {
@@ -175,8 +178,9 @@ static ssize_t read_port(struct device *dev, struct device_attribute *attr,
 	dev_dbg(&cyp->udev->dev, "READ_PORT%d called\n", port_num);
 
 	result = vendor_command(cyp, CYPRESS_READ_PORT, read_id, 0);
-
 	dev_dbg(&cyp->udev->dev, "Result of vendor_command: %d\n\n", result);
+	if (result < 0)
+		return result;
 
 	return sprintf(buf, "%d", cyp->port[port_num]);
 }
Signature · 1 line
2.54.0