All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Use vmemdup_user to replace the open code
@ 2018-08-13 12:22 zhong jiang
  2018-08-13 12:50 ` zhong jiang
  0 siblings, 1 reply; 2+ messages in thread
From: zhong jiang @ 2018-08-13 12:22 UTC (permalink / raw)
  To: don.brace, jejb, martin.petersen; +Cc: linux-kernel

vmemdup_user is better than duplicating its implementation, So just
replace the open code.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/scsi/hpsa.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 58bb70b..948576a 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -6381,13 +6381,9 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
 		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
-	if (!ioc) {
-		status = -ENOMEM;
-		goto cleanup1;
-	}
-	if (copy_from_user(ioc, argp, sizeof(*ioc))) {
-		status = -EFAULT;
+	ioc = vmemdup_user(argp, sizeof(*ioc));
+	if (IS_ERR(ioc)) {
+		status = PTR_ERR(ioc);
 		goto cleanup1;
 	}
 	if ((ioc->buf_size < 1) &&
-- 
1.7.12.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi: Use vmemdup_user to replace the open code
  2018-08-13 12:22 [PATCH] scsi: Use vmemdup_user to replace the open code zhong jiang
@ 2018-08-13 12:50 ` zhong jiang
  0 siblings, 0 replies; 2+ messages in thread
From: zhong jiang @ 2018-08-13 12:50 UTC (permalink / raw)
  To: don.brace, jejb, martin.petersen; +Cc: linux-kernel

Please ignore the patch, will repost . Thanks
On 2018/8/13 20:22, zhong jiang wrote:
> vmemdup_user is better than duplicating its implementation, So just
> replace the open code.
>
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  drivers/scsi/hpsa.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> index 58bb70b..948576a 100644
> --- a/drivers/scsi/hpsa.c
> +++ b/drivers/scsi/hpsa.c
> @@ -6381,13 +6381,9 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
>  		return -EINVAL;
>  	if (!capable(CAP_SYS_RAWIO))
>  		return -EPERM;
> -	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
> -	if (!ioc) {
> -		status = -ENOMEM;
> -		goto cleanup1;
> -	}
> -	if (copy_from_user(ioc, argp, sizeof(*ioc))) {
> -		status = -EFAULT;
> +	ioc = vmemdup_user(argp, sizeof(*ioc));
> +	if (IS_ERR(ioc)) {
> +		status = PTR_ERR(ioc);
>  		goto cleanup1;
>  	}
>  	if ((ioc->buf_size < 1) &&



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-13 12:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-13 12:22 [PATCH] scsi: Use vmemdup_user to replace the open code zhong jiang
2018-08-13 12:50 ` zhong jiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.