Re: [PATCH] USB: do not convert negative transfer_buffer_lengths to positive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 3 Mar 2009, Greg KH wrote:

> And here's the patch that I just applied to the usb patch queue to
> resolve this issue.
> 
> Any objections?

> --- a/drivers/usb/host/uhci-q.c
> +++ b/drivers/usb/host/uhci-q.c
> @@ -1498,7 +1498,7 @@ __acquires(uhci->lock)
>  		 * complete successfully.  Either it failed or the URB was
>  		 * unlinked first.  Regardless, don't confuse people with a
>  		 * negative length. */
> -		urb->actual_length = max(urb->actual_length, 0);
> +		urb->actual_length = max(urb->actual_length, (u32)0);
>  	}
>  
>  	/* When giving back the first URB in an Isochronous queue,

As other people have noticed, this change makes no sense.  The 
appropriate change is given below.

Alan Stern



Index: usb-2.6/drivers/usb/host/uhci-q.c
===================================================================
--- usb-2.6.orig/drivers/usb/host/uhci-q.c
+++ usb-2.6/drivers/usb/host/uhci-q.c
@@ -900,7 +900,7 @@ static int uhci_submit_control(struct uh
 	if (qh->state != QH_STATE_ACTIVE)
 		qh->skel = skel;
 
-	urb->actual_length = -8;	/* Account for the SETUP packet */
+	urb->actual_length = (u32) -8;	/* Account for the SETUP packet */
 	return 0;
 
 nomem:
@@ -1494,11 +1494,13 @@ __acquires(uhci->lock)
 
 	if (qh->type == USB_ENDPOINT_XFER_CONTROL) {
 
-		/* urb->actual_length < 0 means the setup transaction didn't
-		 * complete successfully.  Either it failed or the URB was
-		 * unlinked first.  Regardless, don't confuse people with a
-		 * negative length. */
-		urb->actual_length = max(urb->actual_length, 0);
+		/* If the setup transaction didn't complete successfully
+		 * then urb->actual_length will have a bogus value >=
+		 * (u32) -8.  Don't confuse people with this value; change
+		 * it to 0.
+		 */
+		if (unlikely(urb->actual_length >= (u32) -8))
+			urb->actual_length = 0;
 	}
 
 	/* When giving back the first URB in an Isochronous queue,

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux