xen-blkfront: replace kmalloc and then memcpy with kmemdup
authorMihnea Dobrescu-Balaur <mihneadb@gmail.com>
Mon, 11 Mar 2013 11:23:36 +0000 (13:23 +0200)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Mon, 18 Mar 2013 20:31:31 +0000 (16:31 -0400)
The benefits are:
* code is cleaner
* kmemdup adds additional debugging info useful for tracking the real
place where memory was allocated (CONFIG_DEBUG_SLAB).

Signed-off-by: Mihnea Dobrescu-Balaur <mihneadb@gmail.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
drivers/block/xen-blkfront.c

index c3dae2e0f290e8ad64b4f3e6c869c2fca14cd1a1..962064487ef7f32fa0e5efa982c20f8c7955fb0b 100644 (file)
@@ -1203,11 +1203,10 @@ static int blkif_recover(struct blkfront_info *info)
        int j;
 
        /* Stage 1: Make a safe copy of the shadow state. */
-       copy = kmalloc(sizeof(info->shadow),
+       copy = kmemdup(info->shadow, sizeof(info->shadow),
                       GFP_NOIO | __GFP_REPEAT | __GFP_HIGH);
        if (!copy)
                return -ENOMEM;
-       memcpy(copy, info->shadow, sizeof(info->shadow));
 
        /* Stage 2: Set up free list. */
        memset(&info->shadow, 0, sizeof(info->shadow));