add null pointer check to USB gadget driver

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

 



Hi all,
we use a USB gadget driver on a MPC8247 based board. We use the connection for
serial emulation. In the past we used Kernel 2.6.28. During our upgrade to
2.6.33 we see a kernel crash if we plug in the USB connector.
After investigating the code I saw that this was introduced due to the commit
USB gadget: Handle endpoint requests at the function level
I made a patch which solves the problem for our board. It can be seen below.
Maybe this null pointer check should also be done in the mainline kernel.

Best regards
Holger Brunck

[PATCH] USB gadget: check descriptors pointer before dereferencing

Signed-off-by: Holger Brunck <holger.brunck@xxxxxxxxxxx>
---
 drivers/usb/gadget/composite.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index 09289bb..bda5cdb 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -436,7 +436,7 @@ static int set_config(struct usb_composite_dev *cdev,
 		else
 			descriptors = f->descriptors;

-		for (; *descriptors; ++descriptors) {
+		for (; descriptors && *descriptors; ++descriptors) {
 			struct usb_endpoint_descriptor *ep;
 			int addr;

-- 
1.7.0.5

--
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