diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-06-10 19:48:47 +0530 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-07-25 17:16:54 -0400 |
commit | 1f3d2d9edc832bdd5507130446abf1c8d2923ac5 (patch) | |
tree | bda354a1ad74f1c49fe80eed0d9b5fc13b053695 /drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | |
parent | c21a2c1a4973c8dde32557970fdb44eaa9489aeb (diff) | |
download | linux-stable-1f3d2d9edc832bdd5507130446abf1c8d2923ac5.tar.gz linux-stable-1f3d2d9edc832bdd5507130446abf1c8d2923ac5.tar.bz2 linux-stable-1f3d2d9edc832bdd5507130446abf1c8d2923ac5.zip |
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: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/aic7xxx/aic7xxx_osm_pci.c')
-rw-r--r-- | drivers/scsi/aic7xxx/aic7xxx_osm_pci.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c index ee05e8410754..0fc14dac7070 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +++ b/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c @@ -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); |