Re: [PATCH] USB: more u32 conversion after transfer_buffer_length and actual_length

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

 



On Sun, 8 Mar 2009, Roel Kluin wrote:

> I think this is what you wanted? It compiles with defconfig, checkpatch doesn't
> complain, nor sparse anymore, but please review anyways.

One thing could be changed; otherwise it looks okay.

> urb->dev->maxchild is an int, shuld it be converted to unsigned as well?

One thing at a time!  :-)  You can submit another patch to change 
maxchild, if you want.  Since its value is never bigger than 1000 and 
usually is considerably smaller than 32, the signedness doesn't 
matter.

> transfer_buffer_length and actual_length have become unsigned, therefore some
> additional conversion of local variables, function arguments and print
> specifications is desired. A test for a negative urb->transfer_buffer_length has
> become obsolete as well.

> usb_internal_control_msg() returns both error values and a length. To ensure
> that it does not return an unsigned length that is converted into a negative,
> the returned length is limited to INT_MAX.

Instead of doing it this way, it would be simpler and more robust to
change the test for a negative urb->transfer_buffer_length in
submit_urb() into a test for urb->transfer_buffer_length > INT_MAX.  
(Strictly speaking, this shouldn't be INT_MAX -- it should be the
largest possible 32-bit signed integer.  But until 64-bit integers
become the default we will be safe...)  Then we would know that the
length returned by usb_internal_control_msg() could never be too large.

Alan Stern

--
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