Skip to content

Commit

Permalink
drivers/scsi/aic94xx/aic94xx_init.c: correct the size argument to kma…
Browse files Browse the repository at this point in the history
…lloc

In each case, the destination of the allocation has type struct **, so the
elements of the array should have pointer type, not structure type.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@disable sizeof_type_expr@
type T;
T **x;
@@

  x =
  <+...sizeof(
- T
+ *x
  )...+>
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Rolf Eike Beer <eike-kernel@sf-tec.de>
Cc: Joe Perches <joe@perches.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Julia Lawall authored and Linus Torvalds committed Aug 11, 2010
1 parent d8187b9 commit 85bc081
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/scsi/aic94xx/aic94xx_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ static int asd_register_sas_ha(struct asd_ha_struct *asd_ha)
{
int i;
struct asd_sas_phy **sas_phys =
kmalloc(ASD_MAX_PHYS * sizeof(struct asd_sas_phy), GFP_KERNEL);
kcalloc(ASD_MAX_PHYS, sizeof(*sas_phys), GFP_KERNEL);
struct asd_sas_port **sas_ports =
kmalloc(ASD_MAX_PHYS * sizeof(struct asd_sas_port), GFP_KERNEL);
kcalloc(ASD_MAX_PHYS, sizeof(*sas_ports), GFP_KERNEL);

if (!sas_phys || !sas_ports) {
kfree(sas_phys);
Expand Down
2 changes: 1 addition & 1 deletion drivers/scsi/ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ ch_readconfig(scsi_changer *ch)
}

/* look up the devices of the data transfer elements */
ch->dt = kmalloc(ch->counts[CHET_DT]*sizeof(struct scsi_device),
ch->dt = kcalloc(ch->counts[CHET_DT], sizeof(*ch->dt),
GFP_KERNEL);

if (!ch->dt) {
Expand Down

0 comments on commit 85bc081

Please sign in to comment.