diff mbox series

usb: gadget: hid: fix error code in do_config()

Message ID 20211011123739.GC15188@kili (mailing list archive)
State Accepted
Commit 68e7c510fdf4f6167404609da52e1979165649f6
Headers show
Series usb: gadget: hid: fix error code in do_config() | expand

Commit Message

Dan Carpenter Oct. 11, 2021, 12:37 p.m. UTC
Return an error code if usb_get_function() fails.  Don't return success.

Fixes: 4bc8a33f2407 ("usb: gadget: hid: convert to new interface of f_hid")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/gadget/legacy/hid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Felipe Balbi Oct. 11, 2021, 1:03 p.m. UTC | #1
Hi,

Dan Carpenter <dan.carpenter@oracle.com> writes:

> Return an error code if usb_get_function() fails.  Don't return success.
>
> Fixes: 4bc8a33f2407 ("usb: gadget: hid: convert to new interface of f_hid")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/usb/gadget/legacy/hid.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
> index 5b27d289443f..3912cc805f3a 100644
> --- a/drivers/usb/gadget/legacy/hid.c
> +++ b/drivers/usb/gadget/legacy/hid.c
> @@ -99,8 +99,10 @@ static int do_config(struct usb_configuration *c)
>  
>  	list_for_each_entry(e, &hidg_func_list, node) {
>  		e->f = usb_get_function(e->fi);
> -		if (IS_ERR(e->f))
> +		if (IS_ERR(e->f)) {
> +			status = PTR_ERR(e->f);

nice catch! :-)

Acked-by: Felipe Balbi <balbi@kernel.org>
diff mbox series

Patch

diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index 5b27d289443f..3912cc805f3a 100644
--- a/drivers/usb/gadget/legacy/hid.c
+++ b/drivers/usb/gadget/legacy/hid.c
@@ -99,8 +99,10 @@  static int do_config(struct usb_configuration *c)
 
 	list_for_each_entry(e, &hidg_func_list, node) {
 		e->f = usb_get_function(e->fi);
-		if (IS_ERR(e->f))
+		if (IS_ERR(e->f)) {
+			status = PTR_ERR(e->f);
 			goto put;
+		}
 		status = usb_add_function(c, e->f);
 		if (status < 0) {
 			usb_put_function(e->f);