Skip to contentSkip to conversation

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

PATCH In review Dan Carpenter 2 participants 2 messages Oct 11, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: hid: fix error code in do_config()

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")
---
 drivers/usb/gadget/legacy/hid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/hid.c +3 -1
index 5b27d289443f..3912cc805f3a 100644
@@ -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);
Signature · 1 line
2.20.1
Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 13 lines · Dan Carpenter

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")
---
 drivers/usb/gadget/legacy/hid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/legacy/hid.c +0 -0
index 5b27d289443f..3912cc805f3a 100644

drivers/usb/gadget/legacy/hid.c static int do_config(struct usb_configuration *c) · line 103

Quoted 6 lines
drivers/usb/gadget/legacy/hid.c +2 -1
@@ -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! :-)

Signature · 1 line
balbi