Re: [PATCH] usb: gadget: f_hid: drop ERROR() on copy_from_user() failure

From: Peter Korsgaard

Date: Tue Aug 18 2026 - 02:33:12 EST


>>>>> "Linkai" == Linkai Gong <gonglinkai@xxxxxxxxxx> writes:

> A failed copy_from_user() is a userspace error and should not spam the
> kernel log. Just free the temporary entry and return.

> Suggested-by: David Laight <david.laight.linux@xxxxxxxxx>
> Signed-off-by: Linkai Gong <gonglinkai@xxxxxxxxxx>

Acked-by: Peter Korsgaard <peter@xxxxxxxxxxxxx>

> ---
> drivers/usb/gadget/function/f_hid.c | 1 -
> 1 file changed, 1 deletion(-)

> diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c
> index 3c6b43d06a6d..5c39da1ac7a6 100644
> --- a/drivers/usb/gadget/function/f_hid.c
> +++ b/drivers/usb/gadget/function/f_hid.c
> @@ -656,7 +656,6 @@ static int f_hidg_get_report(struct file *file, struct usb_hidg_report __user *b

> if (copy_from_user(&entry->report_data, buffer,
> sizeof(struct usb_hidg_report))) {
> - ERROR(cdev, "copy_from_user error\n");
> kfree(entry);
> return -EINVAL;
> }
> --

> 2.25.1


--
Bye, Peter Korsgaard