aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/mpt2sas/mpt2sas_scsih.c
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@stratus.com>2014-06-25 17:03:14 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:16:56 -0400
commitfeafe7c596f62123e1d24f1399e1d40c61e9d9d6 (patch)
tree3bbef29d58a741b19bbc5c25b33d73e3dc3170b1 /drivers/scsi/mpt2sas/mpt2sas_scsih.c
parent4bfaa5c4b99ddec00907e854d70453bd2aef39a0 (diff)
mpt2sas: correct scsi_{target,device} hostdata allocation
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 MPT2SAS_DEVICE (24 bytes) struct scsi_target (760 bytes) > struct MPT2SAS_TARGET (40 bytes) This fixes the following smatch warnings: drivers/scsi/mpt2sas/mpt2sas_scsih.c:1295 _scsih_target_alloc() warn: struct type mismatch 'MPT2SAS_TARGET vs scsi_target' drivers/scsi/mpt2sas/mpt2sas_scsih.c:1409 _scsih_slave_alloc() warn: struct type mismatch 'MPT2SAS_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>
Diffstat (limited to 'drivers/scsi/mpt2sas/mpt2sas_scsih.c')
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 5055f925d2cd..13e49c31d19b 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -1292,7 +1292,8 @@ _scsih_target_alloc(struct scsi_target *starget)
1292 unsigned long flags; 1292 unsigned long flags;
1293 struct sas_rphy *rphy; 1293 struct sas_rphy *rphy;
1294 1294
1295 sas_target_priv_data = kzalloc(sizeof(struct scsi_target), GFP_KERNEL); 1295 sas_target_priv_data = kzalloc(sizeof(*sas_target_priv_data),
1296 GFP_KERNEL);
1296 if (!sas_target_priv_data) 1297 if (!sas_target_priv_data)
1297 return -ENOMEM; 1298 return -ENOMEM;
1298 1299
@@ -1406,7 +1407,8 @@ _scsih_slave_alloc(struct scsi_device *sdev)
1406 struct _sas_device *sas_device; 1407 struct _sas_device *sas_device;
1407 unsigned long flags; 1408 unsigned long flags;
1408 1409
1409 sas_device_priv_data = kzalloc(sizeof(struct scsi_device), GFP_KERNEL); 1410 sas_device_priv_data = kzalloc(sizeof(*sas_device_priv_data),
1411 GFP_KERNEL);
1410 if (!sas_device_priv_data) 1412 if (!sas_device_priv_data)
1411 return -ENOMEM; 1413 return -ENOMEM;
1412 1414