diff mbox series

[10/37] lustre: kernelcomm: pass correct gfp_t to kmalloc.

Message ID 155053494542.24125.3526135915611952378.stgit@noble.brown (mailing list archive)
State New, archived
Headers show
Series More lustre patches from obdclass | expand

Commit Message

NeilBrown Feb. 19, 2019, 12:09 a.m. UTC
Passing 0 as the gfp_t for kmalloc() is not meaningful, and
could change behaviour.
Use an explicit GFP_KERNEL instead.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/lustre/obdclass/kernelcomm.c    |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

James Simmons Feb. 24, 2019, 5:05 p.m. UTC | #1
> Passing 0 as the gfp_t for kmalloc() is not meaningful, and
> could change behaviour.
> Use an explicit GFP_KERNEL instead.

Why did it every do this ??????

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/lustre/obdclass/kernelcomm.c    |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> index 925ba52c53b4..09d0b1ab8d1c 100644
> --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
> @@ -133,7 +133,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,
>  		return -EBADF;
>  
>  	/* freed in group_rem */
> -	reg = kmalloc(sizeof(*reg) + data_len, 0);
> +	reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL);
>  	if (!reg)
>  		return -ENOMEM;
>  
> 
> 
>
Andreas Dilger Feb. 25, 2019, 6:16 p.m. UTC | #2
On Feb 24, 2019, at 09:05, James Simmons <jsimmons@infradead.org> wrote:
> 
> 
>> Passing 0 as the gfp_t for kmalloc() is not meaningful, and
>> could change behaviour.
>> Use an explicit GFP_KERNEL instead.
> 
> Why did it every do this ??????

This is a defect introduced by commit 1b254784381 "LU-1346 libcfs: replace cfs_ memory wrappers".
It replaced cfs_alloc(), which internally supplied the GFP_* mask with kmalloc(), which does not.

Cheers, Andreas
---
Andreas Dilger
Principal Lustre Architect
Whamcloud
diff mbox series

Patch

diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
index 925ba52c53b4..09d0b1ab8d1c 100644
--- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
+++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c
@@ -133,7 +133,7 @@  int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,
 		return -EBADF;
 
 	/* freed in group_rem */
-	reg = kmalloc(sizeof(*reg) + data_len, 0);
+	reg = kmalloc(sizeof(*reg) + data_len, GFP_KERNEL);
 	if (!reg)
 		return -ENOMEM;