* [PATCH -next] usb: gadget: hid: fix error return code
@ 2021-06-17 6:56 Yang Yingliang
2021-06-17 13:30 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-06-17 6:56 UTC (permalink / raw)
To: linux-kernel, linux-usb; +Cc: balbi, gregkh
Fix to return a negative error code from the error handling
case instead of 0.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
drivers/usb/gadget/legacy/hid.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index c4eda7fe7ab4..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);
@@ -171,8 +173,10 @@ static int hid_bind(struct usb_composite_dev *cdev)
struct usb_descriptor_header *usb_desc;
usb_desc = usb_otg_descriptor_alloc(gadget);
- if (!usb_desc)
+ if (!usb_desc) {
+ status = -ENOMEM;
goto put;
+ }
usb_otg_descriptor_init(gadget, usb_desc);
otg_desc[0] = usb_desc;
otg_desc[1] = NULL;
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH -next] usb: gadget: hid: fix error return code
2021-06-17 6:56 [PATCH -next] usb: gadget: hid: fix error return code Yang Yingliang
@ 2021-06-17 13:30 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-06-17 13:30 UTC (permalink / raw)
To: Yang Yingliang; +Cc: linux-kernel, linux-usb, balbi
On Thu, Jun 17, 2021 at 02:56:25PM +0800, Yang Yingliang wrote:
> Fix to return a negative error code from the error handling
> case instead of 0.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/usb/gadget/legacy/hid.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
> index c4eda7fe7ab4..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);
Are you _SURE_ that you now want to return an error? This code has
never done this, what is going to break now that it will?
> goto put;
> + }
> status = usb_add_function(c, e->f);
> if (status < 0) {
> usb_put_function(e->f);
> @@ -171,8 +173,10 @@ static int hid_bind(struct usb_composite_dev *cdev)
> struct usb_descriptor_header *usb_desc;
>
> usb_desc = usb_otg_descriptor_alloc(gadget);
> - if (!usb_desc)
> + if (!usb_desc) {
> + status = -ENOMEM;
This looks correct, can you resend just this chunk, and then go test the
above change to verify it doesn't break things?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-17 13:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 6:56 [PATCH -next] usb: gadget: hid: fix error return code Yang Yingliang
2021-06-17 13:30 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.