Commit 85bc081f44d53e3ac268c59275cc3b9b5afae04a

Authored by Julia Lawall
Committed by Linus Torvalds
1 parent d8187b945a

drivers/scsi/aic94xx/aic94xx_init.c: correct the size argument to kmalloc

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>

Showing 2 changed files with 3 additions and 3 deletions Side-by-side Diff

drivers/scsi/aic94xx/aic94xx_init.c
... ... @@ -688,9 +688,9 @@
688 688 {
689 689 int i;
690 690 struct asd_sas_phy **sas_phys =
691   - kmalloc(ASD_MAX_PHYS * sizeof(struct asd_sas_phy), GFP_KERNEL);
  691 + kcalloc(ASD_MAX_PHYS, sizeof(*sas_phys), GFP_KERNEL);
692 692 struct asd_sas_port **sas_ports =
693   - kmalloc(ASD_MAX_PHYS * sizeof(struct asd_sas_port), GFP_KERNEL);
  693 + kcalloc(ASD_MAX_PHYS, sizeof(*sas_ports), GFP_KERNEL);
694 694  
695 695 if (!sas_phys || !sas_ports) {
696 696 kfree(sas_phys);
... ... @@ -352,7 +352,7 @@
352 352 }
353 353  
354 354 /* look up the devices of the data transfer elements */
355   - ch->dt = kmalloc(ch->counts[CHET_DT]*sizeof(struct scsi_device),
  355 + ch->dt = kcalloc(ch->counts[CHET_DT], sizeof(*ch->dt),
356 356 GFP_KERNEL);
357 357  
358 358 if (!ch->dt) {