scsi: aic7xxx: Use kmemdup() in two places
authorAlex Dewar <alex.dewar90@gmail.com>
Wed, 9 Sep 2020 18:58:55 +0000 (19:58 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 16 Sep 2020 01:59:06 +0000 (21:59 -0400)
kmemdup() can be used instead of kmalloc()+memcpy(). Replace two
occurrences of this pattern.

Issue identified with Coccinelle.

Link: https://lore.kernel.org/r/20200909185855.151964-1-alex.dewar90@gmail.com
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/aic7xxx/aic79xx_core.c
drivers/scsi/aic7xxx/aic7xxx_core.c

index c912d29..906d3d4 100644 (file)
@@ -9402,10 +9402,9 @@ ahd_loadseq(struct ahd_softc *ahd)
        if (cs_count != 0) {
 
                cs_count *= sizeof(struct cs);
-               ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+               ahd->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC);
                if (ahd->critical_sections == NULL)
                        panic("ahd_loadseq: Could not malloc");
-               memcpy(ahd->critical_sections, cs_table, cs_count);
        }
        ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
 
index 3d4df90..e9a2cea 100644 (file)
@@ -6879,10 +6879,9 @@ ahc_loadseq(struct ahc_softc *ahc)
        if (cs_count != 0) {
 
                cs_count *= sizeof(struct cs);
-               ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+               ahc->critical_sections = kmemdup(cs_table, cs_count, GFP_ATOMIC);
                if (ahc->critical_sections == NULL)
                        panic("ahc_loadseq: Could not malloc");
-               memcpy(ahc->critical_sections, cs_table, cs_count);
        }
        ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);