]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
[SCSI] zfcp: Use memdup_user and kstrdup
authorChristof Schmitt <christof.schmitt@de.ibm.com>
Fri, 16 Jul 2010 13:37:34 +0000 (15:37 +0200)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 28 Jul 2010 14:48:45 +0000 (09:48 -0500)
Use the functions memdup_user and kstrdup to allocate memory and copy
the data in one step, saving some lines of code.

Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/s390/scsi/zfcp_aux.c
drivers/s390/scsi/zfcp_cfdc.c

index 6e9c7f33e276e9d86453a01dcb5c3e69c7d6a999..7c01c4c3f6b94c158be99e42fa9a464817ce86d4 100644 (file)
@@ -98,13 +98,11 @@ static void __init zfcp_init_device_setup(char *devstr)
        u64 wwpn, lun;
 
        /* 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;
        if (!str)
                return;
 
-       strcpy(str, devstr);
-
        token = strsep(&str, ",");
        if (!token || strlen(token) >= ZFCP_BUS_ID_SIZE)
                goto err_out;
index 1a2db0a35737480647406c55d1808e3372889b61..fcbd2b756da4caf97f32c72348281110c1716d8b 100644 (file)
@@ -189,18 +189,12 @@ static long zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command,
        if (!fsf_cfdc)
                return -ENOMEM;
 
-       data = kmalloc(sizeof(struct zfcp_cfdc_data), GFP_KERNEL);
-       if (!data) {
-               retval = -ENOMEM;
+       data = memdup_user(data_user, sizeof(*data_user));
+       if (IS_ERR(data)) {
+               retval = PTR_ERR(data);
                goto no_mem_sense;
        }
 
-       retval = copy_from_user(data, data_user, sizeof(*data));
-       if (retval) {
-               retval = -EFAULT;
-               goto free_buffer;
-       }
-
        if (data->signature != 0xCFDCACDF) {
                retval = -EINVAL;
                goto free_buffer;