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

Commit 88f950a6 authored by Peter Chen's avatar Peter Chen Committed by Felipe Balbi
Browse files

usb: gadget: f_uac2: improve error handling



If it is out of memory, we should return -ENOMEM;

Signed-off-by: default avatarPeter Chen <peter.chen@nxp.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 07423fd8
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1098,6 +1098,7 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
	if (!prm->rbuf) {
		prm->max_psize = 0;
		ret = -ENOMEM;
		goto err_free_descs;
	}

@@ -1106,20 +1107,21 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
	if (!prm->rbuf) {
		prm->max_psize = 0;
		goto err;
		ret = -ENOMEM;
		goto err_no_memory;
	}

	ret = alsa_uac2_init(agdev);
	if (ret)
		goto err;
		goto err_no_memory;
	return 0;

err:
err_no_memory:
	kfree(agdev->uac2.p_prm.rbuf);
	kfree(agdev->uac2.c_prm.rbuf);
err_free_descs:
	usb_free_all_descriptors(fn);
	return -EINVAL;
	return ret;
}

static int