Skip to content

Commit

Permalink
[PATCH] USB: negative index in drivers/usb/host/isp116x-hcd.c
Browse files Browse the repository at this point in the history
From: Eric Sesterhenn <snakebyte@gmx.de>

This fixes coverity Bug #390.

With the following code

	ret = ep->branch = balance(isp116x, ep->period, ep->load);
	if (ret < 0)
		goto fail;

the problem is that ret and balance are of the type int, and ep->branch is u16.
so the int balance() returns gets reduced to u16 and then converted to an int again,
which removes the sign. Maybe the following little c program can explain it better:
  • Loading branch information
Eric Sesterhenn authored and Greg Kroah-Hartman committed Jun 21, 2006
1 parent b10cee9 commit d5ce137
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/host/isp116x-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
if (ep->branch < PERIODIC_SIZE)
break;

ret = ep->branch = balance(isp116x, ep->period, ep->load);
ep->branch = ret = balance(isp116x, ep->period, ep->load);
if (ret < 0)
goto fail;
ret = 0;
Expand Down

0 comments on commit d5ce137

Please sign in to comment.