Re: [PATCH 02/03] USB: make transfer_buffer_lengths in struct urb field u32

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

 



Greg KH wrote:
> From: Greg Kroah-Hartman <gregkh@xxxxxxx>
> 
> Roel Kluin pointed out that transfer_buffer_lengths in struct urb was
> declared as an 'int'.  This patch changes this field to be 'u32' to
> prevent any potential negative conversion and comparison errors.
> 
> This triggered a few compiler warning messages when these fields were
> being used with the min macro, so they have also been fixed up in this
> patch.


> --- a/include/linux/usb.h
> +++ b/include/linux/usb.h
> @@ -1177,7 +1177,7 @@ struct urb {
>  	unsigned int transfer_flags;	/* (in) URB_SHORT_NOT_OK | ...*/
>  	void *transfer_buffer;		/* (in) associated data buffer */
>  	dma_addr_t transfer_dma;	/* (in) dma addr for transfer_buffer */
> -	int transfer_buffer_length;	/* (in) data buffer length */
> +	u32 transfer_buffer_length;	/* (in) data buffer length */
>  	int actual_length;		/* (return) actual transfer length */
>  	unsigned char *setup_packet;	/* (in) setup packet (control only) */
>  	dma_addr_t setup_dma;		/* (in) dma addr for setup_packet */

After this the test below does no longer make sense.
maybe more sense would make:

if (urb->transfer_buffer_length != 0)

Then ask and I'll send a different patch.
------------------------------>8-------------8<---------------------------------
Now transfer_buffer_length has become unsigned, this test below will always
fail, remove it.

Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
---
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 58bc5e3..e03cad1 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -369,10 +369,6 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
 		}
 	}
 
-	/* the I/O buffer must be mapped/unmapped, except when length=0 */
-	if (urb->transfer_buffer_length < 0)
-		return -EMSGSIZE;
-
 #ifdef DEBUG
 	/* stuff that drivers shouldn't do, but which shouldn't
 	 * cause problems in HCDs if they get it wrong.

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