Commit 97560787 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] md: Silence a warning in md.c

->major_name is "const char *" so we need to sprintf into the kmalloced
space *before* assigning that space to ->major_name.
parent bbc58779
...@@ -1345,6 +1345,8 @@ static int do_md_run(mddev_t * mddev) ...@@ -1345,6 +1345,8 @@ static int do_md_run(mddev_t * mddev)
struct list_head *tmp; struct list_head *tmp;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct gendisk *disk; struct gendisk *disk;
char *major_name;
if (list_empty(&mddev->disks)) { if (list_empty(&mddev->disks)) {
MD_BUG(); MD_BUG();
...@@ -1454,15 +1456,16 @@ static int do_md_run(mddev_t * mddev) ...@@ -1454,15 +1456,16 @@ static int do_md_run(mddev_t * mddev)
if (!disk) if (!disk)
return -ENOMEM; return -ENOMEM;
memset(disk, 0, sizeof(struct gendisk)); memset(disk, 0, sizeof(struct gendisk));
disk->major_name = kmalloc(6, GFP_KERNEL); major_name = kmalloc(6, GFP_KERNEL);
if (!disk->major_name) { if (!major_name) {
kfree(disk); kfree(disk);
return -ENOMEM; return -ENOMEM;
} }
disk->major = MD_MAJOR; disk->major = MD_MAJOR;
disk->first_minor = mdidx(mddev); disk->first_minor = mdidx(mddev);
disk->minor_shift = 0; disk->minor_shift = 0;
sprintf(disk->major_name, "md%d", mdidx(mddev)); sprintf(major_name, "md%d", mdidx(mddev));
disk->major_name = major_name;
disk->part = md_hd_struct + mdidx(mddev); disk->part = md_hd_struct + mdidx(mddev);
disk->nr_real = 1; disk->nr_real = 1;
disk->fops = &md_fops; disk->fops = &md_fops;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment