public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lib/string_helpers: Use passed in GFP_ flags
@ 2023-07-21 14:57 Dan Carpenter
  2023-07-21 15:08 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-07-21 14:57 UTC (permalink / raw)
  To: Michal Hocko
  Cc: Andy Shevchenko, Andrew Morton, Stephen Rothwell, Mel Gorman,
	Vlastimil Babka, linux-kernel, kernel-janitors

This patch doesn't affect runtime because all the callers pass GFP_KERNEL
as the allocation flags.  However, it should use the passed in "gfp" as
the allocation flags.

Fixes: 0ee931c4e31a ("mm: treewide: remove GFP_TEMPORARY allocation flag")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 lib/string_helpers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/string_helpers.c b/lib/string_helpers.c
index d3b1dd718daf..be517c25737d 100644
--- a/lib/string_helpers.c
+++ b/lib/string_helpers.c
@@ -668,7 +668,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
 	char *buffer, *quoted;
 	int i, res;
 
-	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
+	buffer = kmalloc(PAGE_SIZE, gfp);
 	if (!buffer)
 		return NULL;
 
@@ -704,7 +704,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
 		return kstrdup("<unknown>", gfp);
 
 	/* We add 11 spaces for ' (deleted)' to be appended */
-	temp = kmalloc(PATH_MAX + 11, GFP_KERNEL);
+	temp = kmalloc(PATH_MAX + 11, gfp);
 	if (!temp)
 		return kstrdup("<no_memory>", gfp);
 
-- 
2.39.2


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

* Re: [PATCH] lib/string_helpers: Use passed in GFP_ flags
  2023-07-21 14:57 [PATCH] lib/string_helpers: Use passed in GFP_ flags Dan Carpenter
@ 2023-07-21 15:08 ` Andy Shevchenko
  2023-07-21 17:05   ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-07-21 15:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Michal Hocko, Andrew Morton, Stephen Rothwell, Mel Gorman,
	Vlastimil Babka, linux-kernel, kernel-janitors

On Fri, Jul 21, 2023 at 05:57:00PM +0300, Dan Carpenter wrote:
> This patch doesn't affect runtime because all the callers pass GFP_KERNEL
> as the allocation flags.  However, it should use the passed in "gfp" as
> the allocation flags.

Please, Cc Kees Cook as he stepped in as a maintainer of this in particular.

Reviewed-by: Andy Shevchenko <andy@kernel.org>

> Fixes: 0ee931c4e31a ("mm: treewide: remove GFP_TEMPORARY allocation flag")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  lib/string_helpers.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
> index d3b1dd718daf..be517c25737d 100644
> --- a/lib/string_helpers.c
> +++ b/lib/string_helpers.c
> @@ -668,7 +668,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
>  	char *buffer, *quoted;
>  	int i, res;
>  
> -	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +	buffer = kmalloc(PAGE_SIZE, gfp);
>  	if (!buffer)
>  		return NULL;
>  
> @@ -704,7 +704,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
>  		return kstrdup("<unknown>", gfp);
>  
>  	/* We add 11 spaces for ' (deleted)' to be appended */
> -	temp = kmalloc(PATH_MAX + 11, GFP_KERNEL);
> +	temp = kmalloc(PATH_MAX + 11, gfp);
>  	if (!temp)
>  		return kstrdup("<no_memory>", gfp);
>  
> -- 
> 2.39.2
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH] lib/string_helpers: Use passed in GFP_ flags
  2023-07-21 15:08 ` Andy Shevchenko
@ 2023-07-21 17:05   ` Christophe JAILLET
  0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-07-21 17:05 UTC (permalink / raw)
  To: Andy Shevchenko, Dan Carpenter
  Cc: Michal Hocko, Andrew Morton, Stephen Rothwell, Mel Gorman,
	Vlastimil Babka, linux-kernel, kernel-janitors

Le 21/07/2023 à 17:08, Andy Shevchenko a écrit :
> On Fri, Jul 21, 2023 at 05:57:00PM +0300, Dan Carpenter wrote:
>> This patch doesn't affect runtime because all the callers pass GFP_KERNEL
>> as the allocation flags.  However, it should use the passed in "gfp" as
>> the allocation flags.
> 
> Please, Cc Kees Cook as he stepped in as a maintainer of this in particular.
> 
> Reviewed-by: Andy Shevchenko <andy@kernel.org>

Hi,
just for the records, see [1].
Another approach was proposed by Michal Hocko in [2].

CJ

[1]: 
https://lore.kernel.org/all/1ec96b6e4f2e35599931d7516c6938c4a8845bf0.1642337606.git.christophe.jaillet@wanadoo.fr/

[2]: https://lore.kernel.org/all/YeWOd2G69LyR3PVZ@dhcp22.suse.cz/

> 
>> Fixes: 0ee931c4e31a ("mm: treewide: remove GFP_TEMPORARY allocation flag")
>> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>> ---
>>   lib/string_helpers.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
>> index d3b1dd718daf..be517c25737d 100644
>> --- a/lib/string_helpers.c
>> +++ b/lib/string_helpers.c
>> @@ -668,7 +668,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
>>   	char *buffer, *quoted;
>>   	int i, res;
>>   
>> -	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
>> +	buffer = kmalloc(PAGE_SIZE, gfp);
>>   	if (!buffer)
>>   		return NULL;
>>   
>> @@ -704,7 +704,7 @@ char *kstrdup_quotable_file(struct file *file, gfp_t gfp)
>>   		return kstrdup("<unknown>", gfp);
>>   
>>   	/* We add 11 spaces for ' (deleted)' to be appended */
>> -	temp = kmalloc(PATH_MAX + 11, GFP_KERNEL);
>> +	temp = kmalloc(PATH_MAX + 11, gfp);
>>   	if (!temp)
>>   		return kstrdup("<no_memory>", gfp);
>>   
>> -- 
>> 2.39.2
>>
> 


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

end of thread, other threads:[~2023-07-21 17:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-21 14:57 [PATCH] lib/string_helpers: Use passed in GFP_ flags Dan Carpenter
2023-07-21 15:08 ` Andy Shevchenko
2023-07-21 17:05   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox