From: Ethan Tidmore <ethantidmore06@gmail.com>
To: gregkh@linuxfoundation.org, sigmaepsilon92@gmail.com
Cc: peter@korsgaard.com, mhklinux@outlook.com,
linuxhid@cosmicgizmosystems.com, danisjiang@gmail.com,
kees@kernel.org, hoff.benjamin.k@gmail.com,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Ethan Tidmore <ethantidmore06@gmail.com>
Subject: [PATCH] usb: gadget: f_hid: Add missing error code
Date: Thu, 2 Apr 2026 13:00:08 -0500 [thread overview]
Message-ID: <20260402180008.64233-1-ethantidmore06@gmail.com> (raw)
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
next reply other threads:[~2026-04-02 18:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 18:00 Ethan Tidmore [this message]
2026-04-02 18:40 ` [PATCH] usb: gadget: f_hid: Add missing error code Peter Korsgaard
2026-04-07 8:14 ` Michael Zimmermann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260402180008.64233-1-ethantidmore06@gmail.com \
--to=ethantidmore06@gmail.com \
--cc=danisjiang@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hoff.benjamin.k@gmail.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linuxhid@cosmicgizmosystems.com \
--cc=mhklinux@outlook.com \
--cc=peter@korsgaard.com \
--cc=sigmaepsilon92@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox