Skip to contentSkip to conversation

usb: gadget: f_hid: Add missing error code

PATCH In review Ethan Tidmore 3 participants 3 messages Apr 2 – Apr 7 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/usb/gadget/function/f_hid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_hid.c +3 -1
index e0c3f39ee95e..c5a12a6760ea 100644
@@ -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);
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ethan" == Ethan Tidmore <[email protected]> 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")
Signature · 1 line
Bye, Peter Korsgaard
Reviewed-by on v1 1/1
#2 lore raw
In reply to Ethan Tidmore
Quoted 32 lines · 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")
---
 drivers/usb/gadget/function/f_hid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_hid.c +3 -2
index e0c3f39ee95e..c5a12a6760ea 100644
@@ -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);
--
Quoted 2 lines

2.53.0