usb: gadget: f_hid: fix refcount leak on error path
[platform/kernel/linux-starfive.git] / drivers / usb / gadget / function / f_hid.c
index 8b8bbea..6be6009 100644 (file)
@@ -1292,6 +1292,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)
                                                 GFP_KERNEL);
                if (!hidg->report_desc) {
                        put_device(&hidg->dev);
+                       --opts->refcnt;
                        mutex_unlock(&opts->lock);
                        return ERR_PTR(-ENOMEM);
                }