[PATCH] checkstack fix for isd200.c: isd200_srb_set_bufflen()

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

 



When doing a checkstack compile the following error is seen

drivers/usb/storage/isd200.c: In function 'isd200_action':
drivers/usb/storage/isd200.c:580: warning: the frame size of 2192 bytes is larger than 2048 bytes

This is because a scsi_device struct is allocated on the stack.  This patch
makes the allocation dynamic.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index fdba2f6..b3bd50d 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -486,19 +486,21 @@ static void isd200_srb_set_bufflen(struct scsi_cmnd *srb, unsigned bufflen)
  * RETURNS:
  *    ISD status code
  */
-static int isd200_action( struct us_data *us, int action, 
+static int isd200_action( struct us_data *us, int action,
 			  void* pointer, int value )
 {
 	union ata_cdb ata;
-	struct scsi_device srb_dev;
+	struct scsi_device *srb_dev;
 	struct isd200_info *info = (struct isd200_info *)us->extra;
 	struct scsi_cmnd *srb = &info->srb;
 	int status;
 
+	srb_dev = kzalloc(sizeof(*srb_dev), GFP_KERNEL);
+	if (!srb_dev)
+		return ISD200_ERROR;
 	memset(&ata, 0, sizeof(ata));
-	memset(&srb_dev, 0, sizeof(srb_dev));
 	srb->cmnd = info->cmnd;
-	srb->device = &srb_dev;
+	srb->device = srb_dev;
 	++srb->serial_number;
 
 	ata.generic.SignatureByte0 = info->ConfigData.ATAMajorCommand;
@@ -562,6 +564,7 @@ static int isd200_action( struct us_data *us, int action,
 
 	default:
 		US_DEBUGP("Error: Undefined action %d\n",action);
+		kfree(srb_dev);
 		return ISD200_ERROR;
 	}
 
@@ -576,6 +579,7 @@ static int isd200_action( struct us_data *us, int action,
 		/* need to reset device here */
 	}
 
+	kfree(srb_dev);
 	return status;
 }
 
--
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