aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/devices
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/devices')
-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 303ea9b8cfe4..91fbba767635 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -236,6 +236,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
236{ 236{
237 struct block_device *bdev; 237 struct block_device *bdev;
238 struct block2mtd_dev *dev; 238 struct block2mtd_dev *dev;
239 char *name;
239 240
240 if (!devname) 241 if (!devname)
241 return NULL; 242 return NULL;
@@ -274,12 +275,13 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
274 275
275 /* Setup the MTD structure */ 276 /* Setup the MTD structure */
276 /* make the name contain the block device in */ 277 /* make the name contain the block device in */
277 dev->mtd.name = kmalloc(sizeof("block2mtd: ") + strlen(devname), 278 name = kmalloc(sizeof("block2mtd: ") + strlen(devname) + 1,
278 GFP_KERNEL); 279 GFP_KERNEL);
279 if (!dev->mtd.name) 280 if (!name)
280 goto devinit_err; 281 goto devinit_err;
281 282
282 sprintf(dev->mtd.name, "block2mtd: %s", devname); 283 sprintf(name, "block2mtd: %s", devname);
284 dev->mtd.name = name;
283 285
284 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; 286 dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
285 dev->mtd.erasesize = erase_size; 287 dev->mtd.erasesize = erase_size;