* [PATCH] usb: gadget: f_hid: Add missing error code
@ 2026-04-02 18:00 Ethan Tidmore
2026-04-02 18:40 ` Peter Korsgaard
2026-04-07 8:14 ` Michael Zimmermann
0 siblings, 2 replies; 3+ messages in thread
From: Ethan Tidmore @ 2026-04-02 18:00 UTC (permalink / raw)
To: gregkh, sigmaepsilon92
Cc: peter, mhklinux, linuxhid, danisjiang, kees, hoff.benjamin.k,
linux-usb, linux-kernel, Ethan Tidmore
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 <ethantidmore06@gmail.com>
---
drivers/usb/gadget/function/f_hid.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] usb: gadget: f_hid: Add missing error code
2026-04-02 18:00 [PATCH] usb: gadget: f_hid: Add missing error code Ethan Tidmore
@ 2026-04-02 18:40 ` Peter Korsgaard
2026-04-07 8:14 ` Michael Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Peter Korsgaard @ 2026-04-02 18:40 UTC (permalink / raw)
To: Ethan Tidmore
Cc: gregkh, sigmaepsilon92, mhklinux, linuxhid, danisjiang, kees,
hoff.benjamin.k, linux-usb, linux-kernel
>>>>> "Ethan" == Ethan Tidmore <ethantidmore06@gmail.com> writes:
> 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 <ethantidmore06@gmail.com>
Acked-by: Peter Korsgaard <peter@korsgaard.com>
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] usb: gadget: f_hid: Add missing error code
2026-04-02 18:00 [PATCH] usb: gadget: f_hid: Add missing error code Ethan Tidmore
2026-04-02 18:40 ` Peter Korsgaard
@ 2026-04-07 8:14 ` Michael Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Michael Zimmermann @ 2026-04-07 8:14 UTC (permalink / raw)
To: Ethan Tidmore
Cc: gregkh, peter, mhklinux, linuxhid, danisjiang, kees,
hoff.benjamin.k, linux-usb, linux-kernel
On Thu, Apr 2, 2026 at 8:00 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> 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 <ethantidmore06@gmail.com>
> ---
> drivers/usb/gadget/function/f_hid.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> 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);
> --
> 2.53.0
>
Reviewed-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-07 8:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 18:00 [PATCH] usb: gadget: f_hid: Add missing error code Ethan Tidmore
2026-04-02 18:40 ` Peter Korsgaard
2026-04-07 8:14 ` Michael Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox