Re: [RFC Patch] USB: Add check for portnum in the usb_acpi_find_device()

2013-06-02 Thread Lan Tianyu

On 2013/5/31 19:18 Greg KH wrote the following:

On Fri, May 31, 2013 at 02:18:06PM +0800, Lan Tianyu wrote:

This patch is to add a check of portnum which from the usb
port dev's name.


Why do we need this now?


The portnum will be used as array index
for struct usb_hub-ports in the usb_set_hub_port_connect_type().


Is something failing today without this check?  We don't add code to the
kernel until we need it...

No, actually current code will not fail. The patch is the result of
analysis tools Klockwork which is pushed by some QAs. I just notice 
you have said to be over-eager in checking parameters that we have full 
control of is not needed at all. So please ignore this. Sorry for noise.


http://marc.info/?l=linux-usbm=136984950910015w=2


thanks,

greg k-h



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


[RFC Patch] USB: Add check for portnum in the usb_acpi_find_device()

2013-05-31 Thread Lan Tianyu
This patch is to add a check of portnum which from the usb
port dev's name. The portnum will be used as array index
for struct usb_hub-ports in the usb_set_hub_port_connect_type().

Signed-off-by: Lan Tianyu tianyu@intel.com
---
 drivers/usb/core/usb-acpi.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/core/usb-acpi.c b/drivers/usb/core/usb-acpi.c
index 255c144..ec0e7cf 100644
--- a/drivers/usb/core/usb-acpi.c
+++ b/drivers/usb/core/usb-acpi.c
@@ -183,6 +183,9 @@ static int usb_acpi_find_device(struct device *dev, 
acpi_handle *handle)
/* Get the struct usb_device point of port's hub */
udev = to_usb_device(dev-parent-parent);
 
+   if (port_num == 0 || port_num  udev-maxchild)
+   return -EINVAL;
+
/*
 * The root hub ports' parent is the root hub. The non-root-hub
 * ports' parent is the parent hub port which the hub is
-- 
1.7.10.4

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


Re: [RFC Patch] USB: Add check for portnum in the usb_acpi_find_device()

2013-05-31 Thread Greg KH
On Fri, May 31, 2013 at 02:18:06PM +0800, Lan Tianyu wrote:
 This patch is to add a check of portnum which from the usb
 port dev's name.

Why do we need this now?

 The portnum will be used as array index
 for struct usb_hub-ports in the usb_set_hub_port_connect_type().

Is something failing today without this check?  We don't add code to the
kernel until we need it...

thanks,

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