Skip to content

Commit

Permalink
md: remove unnecessary 'buf' from get_bitmap_file.
Browse files Browse the repository at this point in the history
'buf' is only used because d_path fills from the end of the
buffer instead of from the start.
We don't need a separate buf to handle that, we just need to use
memmove() to move the string to the start.

Signed-off-by: NeilBrown <neilb@suse.de>
  • Loading branch information
NeilBrown committed Feb 5, 2015
1 parent 758bfc8 commit f4ad3d3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -5502,7 +5502,7 @@ static int get_array_info(struct mddev *mddev, void __user *arg)
static int get_bitmap_file(struct mddev *mddev, void __user * arg)
{
mdu_bitmap_file_t *file = NULL; /* too big for stack allocation */
char *ptr, *buf = NULL;
char *ptr;
int err = -ENOMEM;

file = kmalloc(sizeof(*file), GFP_NOIO);
Expand All @@ -5516,23 +5516,19 @@ static int get_bitmap_file(struct mddev *mddev, void __user * arg)
goto copy_out;
}

buf = kmalloc(sizeof(file->pathname), GFP_KERNEL);
if (!buf)
goto out;

ptr = d_path(&mddev->bitmap->storage.file->f_path,
buf, sizeof(file->pathname));
file->pathname, sizeof(file->pathname));
if (IS_ERR(ptr))
goto out;

strcpy(file->pathname, ptr);
memmove(file->pathname, ptr,
sizeof(file->pathname)-(ptr-file->pathname));

copy_out:
err = 0;
if (copy_to_user(arg, file, sizeof(*file)))
err = -EFAULT;
out:
kfree(buf);
kfree(file);
return err;
}
Expand Down

0 comments on commit f4ad3d3

Please sign in to comment.