Commit 674c3a99 authored by Christof Schmitt's avatar Christof Schmitt Committed by James Bottomley

[SCSI] zfcp: Use memdup_user and kstrdup

Use the functions memdup_user and kstrdup to allocate memory and copy
the data in one step, saving some lines of code.
Reviewed-by: default avatarSwen Schillig <swen@vnet.ibm.com>
Signed-off-by: default avatarChristof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent f7bd7c36
...@@ -98,13 +98,11 @@ static void __init zfcp_init_device_setup(char *devstr) ...@@ -98,13 +98,11 @@ static void __init zfcp_init_device_setup(char *devstr)
u64 wwpn, lun; u64 wwpn, lun;
/* duplicate devstr and keep the original for sysfs presentation*/ /* duplicate devstr and keep the original for sysfs presentation*/
str_saved = kmalloc(strlen(devstr) + 1, GFP_KERNEL); str_saved = kstrdup(devstr, GFP_KERNEL);
str = str_saved; str = str_saved;
if (!str) if (!str)
return; return;
strcpy(str, devstr);
token = strsep(&str, ","); token = strsep(&str, ",");
if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE) if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
goto err_out; goto err_out;
......
...@@ -189,18 +189,12 @@ static long zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command, ...@@ -189,18 +189,12 @@ static long zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command,
if (!fsf_cfdc) if (!fsf_cfdc)
return -ENOMEM; return -ENOMEM;
data = kmalloc(sizeof(struct zfcp_cfdc_data), GFP_KERNEL); data = memdup_user(data_user, sizeof(*data_user));
if (!data) { if (IS_ERR(data)) {
retval = -ENOMEM; retval = PTR_ERR(data);
goto no_mem_sense; goto no_mem_sense;
} }
retval = copy_from_user(data, data_user, sizeof(*data));
if (retval) {
retval = -EFAULT;
goto free_buffer;
}
if (data->signature != 0xCFDCACDF) { if (data->signature != 0xCFDCACDF) {
retval = -EINVAL; retval = -EINVAL;
goto free_buffer; goto free_buffer;
......
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