Skip to contentSkip to conversation

aic7xxx: replaced string duplication code with kstrdup

PATCH New Dragos Foianu 1 participant 1 message Jul 13, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic7xxx: replaced string duplication code with kstrdup

Modified ahc_linux_pci_dev_probe function to use kstrdup instead of duplicating its implementation.

Found using coccinelle.

---
 drivers/scsi/aic7xxx/aic7xxx_osm_pci.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +1 -2
index ee05e84..0fc14da 100644
@@ -225,10 +225,9 @@ ahc_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 		ahc_get_pci_bus(pci),
 		ahc_get_pci_slot(pci),
 		ahc_get_pci_function(pci));
-	name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
+	name = kstrdup(buf, GFP_ATOMIC);
 	if (name == NULL)
 		return (-ENOMEM);
-	strcpy(name, buf);
 	ahc = ahc_alloc(NULL, name);
 	if (ahc == NULL)
 		return (-ENOMEM);
Signature · 1 line
1.7.10.4