Skip to content

Commit

Permalink
cciss: switch to memdup_user_nul()
Browse files Browse the repository at this point in the history
all we do to buffer is strncmp()...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Jan 4, 2016
1 parent f0fc869 commit e4e85bb
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,9 @@ cciss_proc_write(struct file *file, const char __user *buf,
if (!buf || length > PAGE_SIZE - 1)
return -EINVAL;

buffer = (char *)__get_free_page(GFP_KERNEL);
if (!buffer)
return -ENOMEM;

err = -EFAULT;
if (copy_from_user(buffer, buf, length))
goto out;
buffer[length] = '\0';
buffer = memdup_user_nul(buf, length);
if (IS_ERR(buffer))
return PTR_ERR(buffer);

#ifdef CONFIG_CISS_SCSI_TAPE
if (strncmp(ENGAGE_SCSI, buffer, sizeof ENGAGE_SCSI - 1) == 0) {
Expand All @@ -537,8 +532,7 @@ cciss_proc_write(struct file *file, const char __user *buf,
/* might be nice to have "disengage" too, but it's not
safely possible. (only 1 module use count, lock issues.) */

out:
free_page((unsigned long)buffer);
kfree(buffer);
return err;
}

Expand Down

0 comments on commit e4e85bb

Please sign in to comment.