From: Dan Carpenter <error27@gmail.com>
To: Michael Zimmermann <sigmaepsilon92@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: gadget: f_hid: don't call cdev_init while cdev in use
Date: Fri, 10 Apr 2026 13:15:02 +0300 [thread overview]
Message-ID: <adjNpgyF8W5Aen7Q@stanley.mountain> (raw)
Hello Michael Zimmermann,
Commit 81ebd43cc0d6 ("usb: gadget: f_hid: don't call cdev_init while
cdev in use") from Mar 27, 2026 (linux-next), leads to the following
Smatch static checker warning:
drivers/usb/gadget/function/f_hid.c:1282 hidg_bind()
warn: missing error code here? 'cdev_alloc()' failed. 'status' = '0'
drivers/usb/gadget/function/f_hid.c
1263 if (status)
1264 goto fail;
1265
1266 hidg->write_pending = 1;
1267 hidg->req = NULL;
1268
1269 INIT_WORK(&hidg->work, get_report_workqueue_handler);
1270 hidg->workqueue = alloc_workqueue("report_work",
1271 WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_PERCPU,
1272 1);
1273
1274 if (!hidg->workqueue) {
1275 status = -ENOMEM;
1276 goto fail_free_descs;
1277 }
1278
1279 /* create char device */
1280 hidg->cdev = cdev_alloc();
1281 if (!hidg->cdev)
--> 1282 goto fail_free_all;
status = -ENOMEM;
1283 hidg->cdev->ops = &f_hidg_fops;
1284
1285 status = cdev_device_add(hidg->cdev, &hidg->dev);
1286 if (status)
1287 goto fail_free_all;
1288
1289 return 0;
1290 fail_free_all:
1291 destroy_workqueue(hidg->workqueue);
1292 fail_free_descs:
1293 usb_free_all_descriptors(f);
1294 fail:
1295 ERROR(f->config->cdev, "hidg_bind FAILED\n");
1296 if (hidg->req != NULL)
1297 free_ep_req(hidg->in_ep, hidg->req);
1298
1299 usb_ep_free_request(c->cdev->gadget->ep0, hidg->get_req);
1300 hidg->get_req = NULL;
1301
1302 return status;
1303 }
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
reply other threads:[~2026-04-10 10:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=adjNpgyF8W5Aen7Q@stanley.mountain \
--to=error27@gmail.com \
--cc=linux-usb@vger.kernel.org \
--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