usb: gadget: f_hid: Add missing error code
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")
Signed-off-by Ethan Tidmore <[email protected]>
--- drivers/usb/gadget/function/f_hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/function/f_hid.c +3 -1
@@ -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
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:1291hidg_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 <[email protected]>
Acked-by Peter Korsgaard <[email protected]>
Signature · 1 line
Bye, Peter Korsgaard
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:1291hidg_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 <[email protected]>--- drivers/usb/gadget/function/f_hid.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/usb/gadget/function/f_hid.c +3
-2@@ -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
Reviewed-by Michael Zimmermann <[email protected]>