s390/tape: Use memdup_user() rather than duplicating its implementation
Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
This commit is contained in:
committed by
Martin Schwidefsky
parent
bd3a172557
commit
2ccb5bf0e2
@ -312,15 +312,10 @@ static int tape_3592_ioctl_kekl_set(struct tape_device *device,
|
|||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
if (!crypt_enabled(device))
|
if (!crypt_enabled(device))
|
||||||
return -EUNATCH;
|
return -EUNATCH;
|
||||||
ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
|
ext_kekls = memdup_user((char __user *)arg, sizeof(*ext_kekls));
|
||||||
if (!ext_kekls)
|
if (IS_ERR(ext_kekls))
|
||||||
return -ENOMEM;
|
return PTR_ERR(ext_kekls);
|
||||||
if (copy_from_user(ext_kekls, (char __user *)arg, sizeof(*ext_kekls))) {
|
|
||||||
rc = -EFAULT;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
rc = tape_3592_kekl_set(device, ext_kekls);
|
rc = tape_3592_kekl_set(device, ext_kekls);
|
||||||
out:
|
|
||||||
kfree(ext_kekls);
|
kfree(ext_kekls);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user