mpt3sas: correct scsi_{target,device} hostdata allocation
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 25 Jun 2014 21:04:22 +0000 (17:04 -0400)
committerChristoph Hellwig <hch@lst.de>
Fri, 25 Jul 2014 21:16:57 +0000 (17:16 -0400)
In _scsih_{slave,target}_alloc, an incorrect structure type is passed
to sizeof() when allocating storage for hostdata.  Luckily larger
structure types were used, so at least the wrong sizes were safe:

  struct scsi_device (1784 bytes) > struct MPT3SAS_DEVICE (24 bytes)
  struct scsi_target (760 bytes)  > struct MPT3SAS_TARGET (32 bytes)

This fixes the following smatch warnings:

  drivers/scsi/mpt3sas/mpt3sas_scsih.c:1166 _scsih_target_alloc()
    warn: struct type mismatch 'MPT3SAS_TARGET vs scsi_target'

  drivers/scsi/mpt3sas/mpt3sas_scsih.c:1280 _scsih_slave_alloc()
    warn: struct type mismatch 'MPT3SAS_DEVICE vs scsi_device'

Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com>
Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/mpt3sas/mpt3sas_scsih.c

index 0274ac3c533b00c3f8d0a1a5c2884a07a9489053..08a95b2a2f2ed630aeac9a9318e43b5108adb01c 100644 (file)
@@ -1163,7 +1163,8 @@ _scsih_target_alloc(struct scsi_target *starget)
        unsigned long flags;
        struct sas_rphy *rphy;
 
-       sas_target_priv_data = kzalloc(sizeof(struct scsi_target), GFP_KERNEL);
+       sas_target_priv_data = kzalloc(sizeof(*sas_target_priv_data),
+                                      GFP_KERNEL);
        if (!sas_target_priv_data)
                return -ENOMEM;
 
@@ -1277,7 +1278,8 @@ _scsih_slave_alloc(struct scsi_device *sdev)
        struct _sas_device *sas_device;
        unsigned long flags;
 
-       sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
+       sas_device_priv_data = kzalloc(sizeof(*sas_device_priv_data),
+                                      GFP_KERNEL);
        if (!sas_device_priv_data)
                return -ENOMEM;
 
This page took 0.028894 seconds and 5 git commands to generate.