scsi: aic7xxx: Use kmemdup in two places
Subsystems (2)
PATCH 1/1 scsi: aic7xxx: Use kmemdup in two places
kmemdup can be used instead of kmalloc+memcpy. Replace two occurrences of this pattern.
Issue identified with Coccinelle.
Signed-off-by Alex Dewar <[email protected]>
--- drivers/scsi/aic7xxx/aic79xx_core.c | 3 +-- drivers/scsi/aic7xxx/aic7xxx_core.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/aic7xxx/aic79xx_core.c +1 -2
@@ -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 );
drivers/scsi/aic7xxx/aic7xxx_core.c +1 -2
@@ -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 );
Signature · 1 line
2.28.0
Martin K. Petersen
AppliedAlex,
Quoted 4 lines
kmemdup can be used instead of kmalloc+memcpy. Replace two occurrences of this pattern.
Issue identified with Coccinelle.
Applied to 5.10/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 4 lines · Alex Dewar
kmemdup can be used instead of kmalloc+memcpy. Replace two occurrences of this pattern.
Issue identified with Coccinelle.
Applied to 5.10/scsi-queue, thanks!
[1/1] scsi: aic7xxx: Use kmemdup() in two places
https://git.kernel.org/mkp/scsi/c/f97e6e1eabbf
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering