Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f3d2d9e authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Christoph Hellwig
Browse files

aic7xxx: Use kstrdup



Use kstrdup when the goal of an allocation is copy a string into the
allocated region.

The Coccinelle semantic patch that makes this change is as follows:

// <smpl>
@@
expression from,to;
expression flag,E1,E2;
statement S;
@@

-  to = kmalloc(strlen(from) + 1,flag);
+  to = kstrdup(from, flag);
   ... when != \(from = E1 \| to = E1 \)
   if (to==NULL || ...) S
   ... when != \(from = E2 \| to = E2 \)
-  strcpy(to, from);
// </smpl>

Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent c21a2c1a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -85,10 +85,9 @@ aic7770_probe(struct device *dev)
	int	error;

	sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
	name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
	name = kstrdup(buf, GFP_ATOMIC);
	if (name == NULL)
		return (ENOMEM);
	strcpy(name, buf);
	ahc = ahc_alloc(&aic7xxx_driver_template, name);
	if (ahc == NULL)
		return (ENOMEM);
+1 −2
Original line number Diff line number Diff line
@@ -178,10 +178,9 @@ ahd_linux_pci_dev_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
		ahd_get_pci_bus(pci),
		ahd_get_pci_slot(pci),
		ahd_get_pci_function(pci));
	name = kmalloc(strlen(buf) + 1, GFP_ATOMIC);
	name = kstrdup(buf, GFP_ATOMIC);
	if (name == NULL)
		return (-ENOMEM);
	strcpy(name, buf);
	ahd = ahd_alloc(NULL, name);
	if (ahd == NULL)
		return (-ENOMEM);
+1 −2
Original line number Diff line number Diff line
@@ -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);