From: Ethan Tidmore Date: Thu, 2 Apr 2026 18:00:08 +0000 (-0500) Subject: usb: gadget: f_hid: Add missing error code X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2c863dbbeac7b919d4634ad886978a6731916de3;p=thirdparty%2Fkernel%2Flinux.git usb: gadget: f_hid: Add missing error code Currently in cdev_alloc() error path no error code is assigned. Assign error code '-ENOMEM'. Detected by Smatch: drivers/usb/gadget/function/f_hid.c:1291 hidg_bind() warn: missing error code 'status' Fixes: 81ebd43cc0d6d ("usb: gadget: f_hid: don't call cdev_init while cdev in use") Signed-off-by: Ethan Tidmore Acked-by: Peter Korsgaard Reviewed-by: Michael Zimmermann Link: https://patch.msgid.link/20260402180008.64233-1-ethantidmore06@gmail.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c index e0c3f39ee95e..c5a12a6760ea 100644 --- a/drivers/usb/gadget/function/f_hid.c +++ b/drivers/usb/gadget/function/f_hid.c @@ -1278,8 +1278,10 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) /* create char device */ hidg->cdev = cdev_alloc(); - if (!hidg->cdev) + if (!hidg->cdev) { + status = -ENOMEM; goto fail_free_all; + } hidg->cdev->ops = &f_hidg_fops; status = cdev_device_add(hidg->cdev, &hidg->dev);