Re: [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 31 Mar 2015, Dhere, Chaitanya (C.) wrote:

> This patch replaces kzalloc and copy_from_user with memdup_user call
> This change was detected with coccinelle tool
>
> Signed-off-by: Chaitanya Dhere <cvijaydh@xxxxxxxxxxx>
> ---
>  drivers/staging/lustre/lustre/llite/file.c |   11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
> index 85e74d1..85b5567 100644
> --- a/drivers/staging/lustre/lustre/llite/file.c
> +++ b/drivers/staging/lustre/lustre/llite/file.c
> @@ -2368,14 +2368,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>  		struct hsm_state_set	*hss;
>  		int			 rc;
>
> -		hss = kzalloc(sizeof(*hss), GFP_NOFS);
> -		if (!hss)
> -			return -ENOMEM;
> -
> -		if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
> -			OBD_FREE_PTR(hss);
> -			return -EFAULT;
> -		}
> +		hss = memdup_user((char *)arg, sizeof(*hss));

memdup_user will use the flag GFP_KERNEL, ie (__GFP_WAIT | __GFP_IO |
__GFP_FS), rather than the flag GFP_NOFS, ie (__GFP_WAIT | __GFP_IO), that
is specified.  I don't know if this is a problem here.

julia

> +		if (IS_ERR(hss))
> +			return PTR_ERR(hss);
>
>  		rc = ll_hsm_state_set(inode, hss);
>
> --
> 1.7.9.5
>
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux