diff options
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r-- | drivers/md/md.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 5438834bf54d..bddecc01c333 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -5502,7 +5502,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg) | |||
5502 | static int get_bitmap_file(struct mddev *mddev, void __user * arg) | 5502 | static int get_bitmap_file(struct mddev *mddev, void __user * arg) |
5503 | { | 5503 | { |
5504 | mdu_bitmap_file_t *file = NULL; /* too big for stack allocation */ | 5504 | mdu_bitmap_file_t *file = NULL; /* too big for stack allocation */ |
5505 | char *ptr, *buf = NULL; | 5505 | char *ptr; |
5506 | int err = -ENOMEM; | 5506 | int err = -ENOMEM; |
5507 | 5507 | ||
5508 | file = kmalloc(sizeof(*file), GFP_NOIO); | 5508 | file = kmalloc(sizeof(*file), GFP_NOIO); |
@@ -5516,23 +5516,19 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg) | |||
5516 | goto copy_out; | 5516 | goto copy_out; |
5517 | } | 5517 | } |
5518 | 5518 | ||
5519 | buf = kmalloc(sizeof(file->pathname), GFP_KERNEL); | ||
5520 | if (!buf) | ||
5521 | goto out; | ||
5522 | |||
5523 | ptr = d_path(&mddev->bitmap->storage.file->f_path, | 5519 | ptr = d_path(&mddev->bitmap->storage.file->f_path, |
5524 | buf, sizeof(file->pathname)); | 5520 | file->pathname, sizeof(file->pathname)); |
5525 | if (IS_ERR(ptr)) | 5521 | if (IS_ERR(ptr)) |
5526 | goto out; | 5522 | goto out; |
5527 | 5523 | ||
5528 | strcpy(file->pathname, ptr); | 5524 | memmove(file->pathname, ptr, |
5525 | sizeof(file->pathname)-(ptr-file->pathname)); | ||
5529 | 5526 | ||
5530 | copy_out: | 5527 | copy_out: |
5531 | err = 0; | 5528 | err = 0; |
5532 | if (copy_to_user(arg, file, sizeof(*file))) | 5529 | if (copy_to_user(arg, file, sizeof(*file))) |
5533 | err = -EFAULT; | 5530 | err = -EFAULT; |
5534 | out: | 5531 | out: |
5535 | kfree(buf); | ||
5536 | kfree(file); | 5532 | kfree(file); |
5537 | return err; | 5533 | return err; |
5538 | } | 5534 | } |