diff mbox

aic7xxx: replace kmalloc/strcpy by kstrdup

Message ID 4159f01e6450cee8093e7d6a0d979bbeab8243d0.1436858599.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe JAILLET July 14, 2015, 7:25 a.m. UTC
This replaces kmalloc + strcpy by an equivalent call to kstrdup.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/scsi/aic7xxx/aic79xx_osm.c | 3 +--
 drivers/scsi/aic7xxx/aic7xxx_osm.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Dan Carpenter July 14, 2015, 9:08 a.m. UTC | #1
On Tue, Jul 14, 2015 at 09:25:16AM +0200, Christophe JAILLET wrote:
> --- a/drivers/scsi/aic7xxx/aic79xx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
> @@ -1250,9 +1250,8 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
>  	ahd_set_unit(ahd, ahd_linux_unit++);
>  	ahd_unlock(ahd, &s);
>  	sprintf(buf, "scsi%d", host->host_no);
> -	new_name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
> +	new_name = kstrdup(buf, GFP_ATOMIC);
>  	if (new_name != NULL) {
> -		strcpy(new_name, buf);
>  		ahd_set_name(ahd, new_name);
>  	}

Remove the curly braces.  And below as well.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index ce96a0b..ae78e6d 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1250,9 +1250,8 @@  ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
 	ahd_set_unit(ahd, ahd_linux_unit++);
 	ahd_unlock(ahd, &s);
 	sprintf(buf, "scsi%d", host->host_no);
-	new_name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
+	new_name = kstrdup(buf, GFP_ATOMIC);
 	if (new_name != NULL) {
-		strcpy(new_name, buf);
 		ahd_set_name(ahd, new_name);
 	}
 	host->unique_id = ahd->unit;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index a2f2c77..ba59947 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1114,9 +1114,8 @@  ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
 	ahc_set_unit(ahc, ahc_linux_unit++);
 	ahc_unlock(ahc, &s);
 	sprintf(buf, "scsi%d", host->host_no);
-	new_name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
+	new_name = kstrdup(buf, GFP_ATOMIC);
 	if (new_name != NULL) {
-		strcpy(new_name, buf);
 		ahc_set_name(ahc, new_name);
 	}
 	host->unique_id = ahc->unit;