diff options
Diffstat (limited to 'drivers/usb/mon/mon_bin.c')
| -rw-r--r-- | drivers/usb/mon/mon_bin.c | 40 | 
1 files changed, 34 insertions, 6 deletions
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 44cb37b5a4d..9a62e89d6dc 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c @@ -11,11 +11,11 @@  #include <linux/types.h>  #include <linux/fs.h>  #include <linux/cdev.h> +#include <linux/export.h>  #include <linux/usb.h>  #include <linux/poll.h>  #include <linux/compat.h>  #include <linux/mm.h> -#include <linux/smp_lock.h>  #include <linux/scatterlist.h>  #include <linux/slab.h> @@ -437,6 +437,28 @@ static unsigned int mon_bin_get_data(const struct mon_reader_bin *rp,  	return length;  } +/* + * This is the look-ahead pass in case of 'C Zi', when actual_length cannot + * be used to determine the length of the whole contiguous buffer. + */ +static unsigned int mon_bin_collate_isodesc(const struct mon_reader_bin *rp, +    struct urb *urb, unsigned int ndesc) +{ +	struct usb_iso_packet_descriptor *fp; +	unsigned int length; + +	length = 0; +	fp = urb->iso_frame_desc; +	while (ndesc-- != 0) { +		if (fp->actual_length != 0) { +			if (fp->offset + fp->actual_length > length) +				length = fp->offset + fp->actual_length; +		} +		fp++; +	} +	return length; +} +  static void mon_bin_get_isodesc(const struct mon_reader_bin *rp,      unsigned int offset, struct urb *urb, char ev_type, unsigned int ndesc)  { @@ -479,6 +501,10 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,  	/*  	 * Find the maximum allowable length, then allocate space.  	 */ +	urb_length = (ev_type == 'S') ? +	    urb->transfer_buffer_length : urb->actual_length; +	length = urb_length; +  	if (usb_endpoint_xfer_isoc(epd)) {  		if (urb->number_of_packets < 0) {  			ndesc = 0; @@ -487,14 +513,16 @@ static void mon_bin_event(struct mon_reader_bin *rp, struct urb *urb,  		} else {  			ndesc = urb->number_of_packets;  		} +		if (ev_type == 'C' && usb_urb_dir_in(urb)) +			length = mon_bin_collate_isodesc(rp, urb, ndesc);  	} else {  		ndesc = 0;  	}  	lendesc = ndesc*sizeof(struct mon_bin_isodesc); -	urb_length = (ev_type == 'S') ? -	    urb->transfer_buffer_length : urb->actual_length; -	length = urb_length; +	/* not an issue unless there's a subtle bug in a HCD somewhere */ +	if (length >= urb->transfer_buffer_length) +		length = urb->transfer_buffer_length;  	if (length >= rp->b_size/5)  		length = rp->b_size/5; @@ -1074,7 +1102,7 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg  		nevents = mon_bin_queued(rp);  		sp = (struct mon_bin_stats __user *)arg; -		if (put_user(rp->cnt_lost, &sp->dropped)) +		if (put_user(ndropped, &sp->dropped))  			return -EFAULT;  		if (put_user(nevents, &sp->queued))  			return -EFAULT; @@ -1219,7 +1247,7 @@ static int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma)  {  	/* don't do anything here: "fault" will set up page table entries */  	vma->vm_ops = &mon_bin_vm_ops; -	vma->vm_flags |= VM_RESERVED; +	vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;  	vma->vm_private_data = filp->private_data;  	mon_bin_vma_open(vma);  	return 0;  | 
