Re: [PATCH V6 8/9] usb: return error when fail to get usb device descriptor in the usb_get_configuration()

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

 



On 2012年07月05日 03:00, Alan Stern wrote:
On Wed, 4 Jul 2012, Lan Tianyu wrote:

Since port may power off, usb device descriptor can't be get
at that time and usb_get_configuration() should return error.

Signed-off-by: Lan Tianyu<tianyu.lan@xxxxxxxxx>
---
  drivers/usb/core/config.c |    4 +---
  1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index f4bdd0c..072e8a2 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -702,9 +702,7 @@ int usb_get_configuration(struct usb_device *dev)
  		if (result<  0) {
  			dev_err(ddev, "unable to read config index %d "
  			    "descriptor/%s: %d\n", cfgno, "start", result);
-			dev_err(ddev, "chopping to %d config(s)\n", cfgno);
-			dev->descriptor.bNumConfigurations = cfgno;
-			break;
+			goto err;

I really would prefer it if you goto err only when result != -EPIPE.
Otherwise, do the same thing as the existing code.
Oh sorry. I miss your comment at your last mail. I get it. But return error is -71 (EPROTO)
How about this?
			dev_err(ddev, "unable to read config index %d "
  			    "descriptor/%s: %d\n", cfgno, "start", result)
			if (result == -EPROTO)
				goto err;		
			dev_err(ddev, "chopping to %d config(s)\n", cfgno);
			dev->descriptor.bNumConfigurations = cfgno;
			break;
Why did you suggest "result != -EPIPE"?
And if we use it, the judgement should be before dev_err("chopping to %d config(s)\n"...).
Becasue the error info is not necessary. Right?
	

Think about what happens if a USB device has a mistake in its device
descriptor and sets bNumConfigurations higher than the actual number
of configs.

Alan Stern


--
Best Regards
Tianyu Lan
linux kernel enabling team
--
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