Skip to content

Commit

Permalink
usb: usbtest: fix a type promotion bug
Browse files Browse the repository at this point in the history
The "len" here is sometimes negative error codes from
usb_get_descriptor(), so we don't want to type promote them to unsigned
long.

This bug pre-dates the invention of git.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/506f7935-2cba-41d9-ab5d-ddb6ad6320bd@moroto.mountain
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Oct 8, 2023
1 parent b8aaf63 commit 0f5aa1b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/misc/usbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ static int is_good_config(struct usbtest_dev *tdev, int len)
{
struct usb_config_descriptor *config;

if (len < sizeof(*config))
if (len < (int)sizeof(*config))
return 0;
config = (struct usb_config_descriptor *) tdev->buf;

Expand Down

0 comments on commit 0f5aa1b

Please sign in to comment.