Skip to contentSkip to conversation

i2o: replaced string duplication code with kstrdup

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

lore
Share & tools
lore
#0 lore raw

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

i2o_pool_alloc now uses kstrdup instead of duplicating its implementation.

Found usinc coccinelle.

---
 drivers/message/i2o/memory.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/message/i2o/memory.c +1 -2
index 292b41e..1741a59 100644
@@ -270,10 +270,9 @@ EXPORT_SYMBOL_GPL(i2o_dma_realloc);
 int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
 				 size_t size, int min_nr)
 {
-	pool->name = kmalloc(strlen(name) + 1, GFP_KERNEL);
+	pool->name = kstrdup(name, GFP_KERNEL);
 	if (!pool->name)
 		goto exit;
-	strcpy(pool->name, name);
 
 	pool->slab =
 	    kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
Signature · 1 line
1.7.10.4