Skip to contentSkip to conversation

usb: gadget: fix error handling

PATCH New Sudip Mukherjee 1 participant 1 message Jan 9, 2016 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 usb: gadget: fix error handling

We are doing PTR_ERR() of NULL, and that will actually make ret = 0. So in case of both error and success we are actually returning the success code.

---

v2: spelling of incase in commit message

 drivers/usb/gadget/composite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/composite.c +2 -2
index 8b14c2a..17ce6b5 100644
@@ -2017,14 +2017,14 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,
 
 	cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL);
 	if (!cdev->os_desc_req) {
-		ret = PTR_ERR(cdev->os_desc_req);
+		ret = -ENOMEM;
 		goto end;
 	}
 
 	/* OS feature descriptor length <= 4kB */
 	cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
 	if (!cdev->os_desc_req->buf) {
-		ret = PTR_ERR(cdev->os_desc_req->buf);
+		ret = -ENOMEM;
 		kfree(cdev->os_desc_req);
 		goto end;
 	}
Signature · 1 line
1.9.1