aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices/block2mtd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices/block2mtd.c')
-rw-r--r--drivers/mtd/devices/block2mtd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 519d942e7940..7b72a1b36115 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -241,6 +241,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
241{ 241{
242 struct block_device *bdev; 242 struct block_device *bdev;
243 struct block2mtd_dev *dev; 243 struct block2mtd_dev *dev;
244 char *name;
244 245
245 if (!devname) 246 if (!devname)
246 return NULL; 247 return NULL;
@@ -279,12 +280,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
279 280
280 /* Setup the MTD structure */ 281 /* Setup the MTD structure */
281 /* make the name contain the block device in */ 282 /* make the name contain the block device in */
282 dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname), 283 name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
283 GFP_KERNEL); 284 GFP_KERNEL);
284 if (!dev->mtd.name) 285 if (!name)
285 goto devinit_err; 286 goto devinit_err;
286 287
287 sprintf(dev->mtd.name, "block2mtd: %s", devname); 288 sprintf(name, "block2mtd: %s", devname);
289 dev->mtd.name = name;
288 290
289 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; 291 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
290 dev->mtd.erasesize = erase_size; 292 dev->mtd.erasesize = erase_size;