public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [bug report] usb: gadget: f_hid: don't call cdev_init while cdev in use
@ 2026-04-10 10:15 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2026-04-10 10:15 UTC (permalink / raw)
  To: Michael Zimmermann; +Cc: linux-usb

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-04-10 10:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-10 10:15 [bug report] usb: gadget: f_hid: don't call cdev_init while cdev in use Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox