USB: core: Avoid WARNings for 0-length descriptor requests
authorAlan Stern <stern@rowland.harvard.edu>
Mon, 7 Jun 2021 15:23:07 +0000 (11:23 -0400)
committerSasha Levin <sashal@kernel.org>
Thu, 26 Aug 2021 12:35:34 +0000 (08:35 -0400)
commitba6c1b004ac5aaee418ce84acbecdc4d89a67bbe
treece2b64638200e70ff83d4771b8f175db1337ff9b
parent8e100c72b6ded07d5900c20ca5ee5d0c6d9c4293
USB: core: Avoid WARNings for 0-length descriptor requests

[ Upstream commit 60dfe484cef45293e631b3a6e8995f1689818172 ]

The USB core has utility routines to retrieve various types of
descriptors.  These routines will now provoke a WARN if they are asked
to retrieve 0 bytes (USB "receive" requests must not have zero
length), so avert this by checking the size argument at the start.

CC: Johan Hovold <johan@kernel.org>
Reported-and-tested-by: syzbot+7dbcd9ff34dc4ed45240@syzkaller.appspotmail.com
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20210607152307.GD1768031@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/core/message.c