From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753140AbaEZPV2 (ORCPT ); Mon, 26 May 2014 11:21:28 -0400 Received: from isis.lip6.fr ([132.227.60.2]:57163 "EHLO isis.lip6.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085AbaEZPVZ (ORCPT ); Mon, 26 May 2014 11:21:25 -0400 X-pt: isis.lip6.fr From: Benoit Taine To: Hannes Reinecke Cc: benoit.taine@lip6.fr, "James E.J. Bottomley" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH 12/18] aic7xxx: Use kmemdup instead of kmalloc + memcpy Date: Mon, 26 May 2014 17:21:21 +0200 Message-Id: <1401117687-28911-13-git-send-email-benoit.taine@lip6.fr> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1401117687-28911-1-git-send-email-benoit.taine@lip6.fr> References: <1401117687-28911-1-git-send-email-benoit.taine@lip6.fr> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (isis.lip6.fr [132.227.60.2]); Mon, 26 May 2014 17:20:42 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This issue was reported by coccicheck using the semantic patch at scripts/coccinelle/api/memdup.cocci Signed-off-by: Benoit Taine --- Tested by compilation without errors. drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++-- drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 0bcacf7..01353b1 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c @@ -9494,10 +9494,10 @@ 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 10172a3..f09337a 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c @@ -6941,10 +6941,10 @@ 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);