[PATCH 6/7] uas: Use proper packet size when submitting reponse urbs

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

 



Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/usb/storage/uas.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index c618c01..c543bdb 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -431,7 +431,8 @@ static struct urb *uas_alloc_data_urb(struct uas_dev_info *devinfo, gfp_t gfp,
 	return urb;
 }
 
-static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
+static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo,
+				       int size, gfp_t gfp,
 				       struct Scsi_Host *shost, u16 stream_id)
 {
 	struct usb_device *udev = devinfo->udev;
@@ -441,11 +442,11 @@ static struct urb *uas_alloc_sense_urb(struct uas_dev_info *devinfo, gfp_t gfp,
 	if (!urb)
 		goto out;
 
-	iu = kzalloc(sizeof(*iu), gfp);
+	iu = kzalloc(size, gfp);
 	if (!iu)
 		goto free;
 
-	usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, sizeof(*iu),
+	usb_fill_bulk_urb(urb, udev, devinfo->status_pipe, iu, size,
 						uas_stat_cmplt, shost);
 	urb->stream_id = stream_id;
 	urb->transfer_flags |= URB_FREE_BUFFER;
@@ -550,13 +551,13 @@ err:
  * daft to me.
  */
 
-static int uas_submit_sense_urb(struct Scsi_Host *shost,
+static int uas_submit_sense_urb(struct Scsi_Host *shost, int size,
 				gfp_t gfp, unsigned int stream)
 {
 	struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
 	struct urb *urb;
 
-	urb = uas_alloc_sense_urb(devinfo, gfp, shost, stream);
+	urb = uas_alloc_sense_urb(devinfo, size, gfp, shost, stream);
 	if (!urb)
 		return SCSI_MLQUEUE_DEVICE_BUSY;
 	usb_anchor_urb(urb, &devinfo->sense_urbs);
@@ -578,7 +579,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 
 	WARN_ON_ONCE(!spin_is_locked(&devinfo->lock));
 	if (cmdinfo->state & SUBMIT_STATUS_URB) {
-		err = uas_submit_sense_urb(cmnd->device->host, gfp,
+		err = uas_submit_sense_urb(cmnd->device->host,
+					   sizeof(struct sense_iu), gfp,
 					   cmdinfo->stream);
 		if (err) {
 			return err;
@@ -726,10 +728,13 @@ static int uas_eh_task_mgmt(struct scsi_cmnd *cmnd,
 	struct uas_dev_info *devinfo = (void *)shost->hostdata[0];
 	u16 tag = devinfo->qdepth - 1;
 	unsigned long flags;
+	int r;
 
 	spin_lock_irqsave(&devinfo->lock, flags);
 	memset(&devinfo->response, 0, sizeof(devinfo->response));
-	if (uas_submit_sense_urb(shost, GFP_ATOMIC, tag)) {
+	r = uas_submit_sense_urb(shost, sizeof(struct response_iu),
+				 GFP_ATOMIC, tag);
+	if (r != 0) {
 		shost_printk(KERN_INFO, shost,
 			     "%s: %s: submit sense urb failed\n",
 			     __func__, fname);
-- 
1.8.3.1

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