Re: [syzbot] [input?] [usb?] KMSAN: uninit-value in asus_report_fixup

From: Dan Carpenter
Date: Fri May 31 2024 - 04:53:52 EST


On Thu, May 30, 2024 at 08:16:59PM +0530, Harshit Mogalapalli wrote:
> > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> > index a90ed2ceae84..9f0e09f667b1 100644
> > --- a/drivers/hid/usbhid/hid-core.c
> > +++ b/drivers/hid/usbhid/hid-core.c
> > @@ -1029,7 +1029,7 @@ static int usbhid_parse(struct hid_device *hid)
> > return -EINVAL;
> > }
> > - rdesc = kmalloc(rsize, GFP_KERNEL);
> > + rdesc = kzalloc(rsize, GFP_KERNEL);

This kzalloc() is unnecessary because hid_get_class_descriptor() has
a memset() built in:

memset(buf, 0, size);

I'm not a huge fan of how if hid_get_class_descriptor() runs out of
retries, we return the number of bytes in a partial read. Then the
caller pretends it was a success instead of using the result. But
that's a different issue.

regards,
dan carpenter