* [PATCH] scsi: aic7xxx: Use kmemdup in two places
@ 2020-09-09 18:58 Alex Dewar
2020-09-16 2:00 ` Martin K. Petersen
2020-09-22 3:56 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Alex Dewar @ 2020-09-09 18:58 UTC (permalink / raw)
Cc: Alex Dewar, Hannes Reinecke, James E.J. Bottomley,
Martin K. Petersen, linux-scsi, linux-kernel
kmemdup can be used instead of kmalloc+memcpy. Replace two occurrences
of this pattern.
Issue identified with Coccinelle.
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
drivers/scsi/aic7xxx/aic79xx_core.c | 3 +--
drivers/scsi/aic7xxx/aic7xxx_core.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 1c617c0d5899..98b02e7d38bb 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -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);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 2231c4afa531..725bb7f58054 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -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);
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: aic7xxx: Use kmemdup in two places
2020-09-09 18:58 [PATCH] scsi: aic7xxx: Use kmemdup in two places Alex Dewar
@ 2020-09-16 2:00 ` Martin K. Petersen
2020-09-22 3:56 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-09-16 2:00 UTC (permalink / raw)
To: Alex Dewar
Cc: Hannes Reinecke, James E.J. Bottomley, Martin K. Petersen,
linux-scsi, linux-kernel
Alex,
> 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!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: aic7xxx: Use kmemdup in two places
2020-09-09 18:58 [PATCH] scsi: aic7xxx: Use kmemdup in two places Alex Dewar
2020-09-16 2:00 ` Martin K. Petersen
@ 2020-09-22 3:56 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2020-09-22 3:56 UTC (permalink / raw)
To: Alex Dewar
Cc: Martin K . Petersen, linux-scsi, linux-kernel, Hannes Reinecke,
James E.J. Bottomley
On Wed, 9 Sep 2020 19:58:55 +0100, Alex Dewar wrote:
> 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
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-22 3:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 18:58 [PATCH] scsi: aic7xxx: Use kmemdup in two places Alex Dewar
2020-09-16 2:00 ` Martin K. Petersen
2020-09-22 3:56 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).