Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3887db5c authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Felipe Balbi
Browse files

usb: gadget: composite: Fix return value in case of error



In 'composite_os_desc_req_prepare', if one of the memory allocations fail,
0 will be returned, which means success.
We should return -ENOMEM instead.

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent bd610c5a
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2126,14 +2126,14 @@ int composite_os_desc_req_prepare(struct usb_composite_dev *cdev,


	cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL);
	cdev->os_desc_req = usb_ep_alloc_request(ep0, GFP_KERNEL);
	if (!cdev->os_desc_req) {
	if (!cdev->os_desc_req) {
		ret = PTR_ERR(cdev->os_desc_req);
		ret = -ENOMEM;
		goto end;
		goto end;
	}
	}


	/* OS feature descriptor length <= 4kB */
	/* OS feature descriptor length <= 4kB */
	cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
	cdev->os_desc_req->buf = kmalloc(4096, GFP_KERNEL);
	if (!cdev->os_desc_req->buf) {
	if (!cdev->os_desc_req->buf) {
		ret = PTR_ERR(cdev->os_desc_req->buf);
		ret = -ENOMEM;
		kfree(cdev->os_desc_req);
		kfree(cdev->os_desc_req);
		goto end;
		goto end;
	}
	}