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

Commit 63406087 authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi
Browse files

usb: gadget: f_hid: check return value of device_create



device_create() might fail, so check its return value and react
appropriately.

Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 06529407
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -556,6 +556,7 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
{
{
	struct usb_ep		*ep;
	struct usb_ep		*ep;
	struct f_hidg		*hidg = func_to_hidg(f);
	struct f_hidg		*hidg = func_to_hidg(f);
	struct device		*device;
	int			status;
	int			status;
	dev_t			dev;
	dev_t			dev;


@@ -623,10 +624,16 @@ static int __init hidg_bind(struct usb_configuration *c, struct usb_function *f)
	if (status)
	if (status)
		goto fail_free_descs;
		goto fail_free_descs;


	device_create(hidg_class, NULL, dev, NULL, "%s%d", "hidg", hidg->minor);
	device = device_create(hidg_class, NULL, dev, NULL,
			       "%s%d", "hidg", hidg->minor);
	if (IS_ERR(device)) {
		status = PTR_ERR(device);
		goto del;
	}


	return 0;
	return 0;

del:
	cdev_del(&hidg->cdev);
fail_free_descs:
fail_free_descs:
	usb_free_all_descriptors(f);
	usb_free_all_descriptors(f);
fail:
fail: