linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store
@ 2018-01-25  2:29 Jia-Ju Bai
  2018-01-25  2:49 ` Joe Perches
  2018-02-13 18:07 ` Ingo Molnar
  0 siblings, 2 replies; 4+ messages in thread
From: Jia-Ju Bai @ 2018-01-25  2:29 UTC (permalink / raw)
  To: matt, ard.biesheuvel, tglx, mingo, hpa
  Cc: x86, linux-efi, linux-kernel, Jia-Ju Bai

The function kzalloc here is not called in atomic context.
If nonblocking in efi_query_variable_store is true, 
namely it is in atomic context, efi_query_variable_store will return before
this kzalloc is called.
Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 arch/x86/platform/efi/quirks.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 8a99a2e..b6dcb52 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -177,7 +177,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
 		 * that by attempting to use more space than is available.
 		 */
 		unsigned long dummy_size = remaining_size + 1024;
-		void *dummy = kzalloc(dummy_size, GFP_ATOMIC);
+		void *dummy = kzalloc(dummy_size, GFP_KERNEL);
 
 		if (!dummy)
 			return EFI_OUT_OF_RESOURCES;
-- 
1.7.9.5

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

* Re: [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store
  2018-01-25  2:29 [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store Jia-Ju Bai
@ 2018-01-25  2:49 ` Joe Perches
  2018-02-13 18:07 ` Ingo Molnar
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2018-01-25  2:49 UTC (permalink / raw)
  To: Jia-Ju Bai, matt, ard.biesheuvel, tglx, mingo, hpa
  Cc: x86, linux-efi, linux-kernel

On Thu, 2018-01-25 at 10:29 +0800, Jia-Ju Bai wrote:
> The function kzalloc here is not called in atomic context.
> If nonblocking in efi_query_variable_store is true, 
> namely it is in atomic context, efi_query_variable_store will return before
> this kzalloc is called.
> Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.
> 
> This is found by a static analysis tool named DCNS written by myself.
[]
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
[]
> @@ -177,7 +177,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
>  		 * that by attempting to use more space than is available.
>  		 */
>  		unsigned long dummy_size = remaining_size + 1024;
> -		void *dummy = kzalloc(dummy_size, GFP_ATOMIC);
> +		void *dummy = kzalloc(dummy_size, GFP_KERNEL);

trivially, kzalloc takes a size_t not an unsigned long
and this _could_, though probably doesn't, lose precision.

It might be nicer to convert to size_t where appropriate.

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

* Re: [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store
  2018-01-25  2:29 [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store Jia-Ju Bai
  2018-01-25  2:49 ` Joe Perches
@ 2018-02-13 18:07 ` Ingo Molnar
  2018-02-13 18:40   ` Ard Biesheuvel
  1 sibling, 1 reply; 4+ messages in thread
From: Ingo Molnar @ 2018-02-13 18:07 UTC (permalink / raw)
  To: Jia-Ju Bai
  Cc: matt, ard.biesheuvel, tglx, mingo, hpa, x86, linux-efi, linux-kernel


* Jia-Ju Bai <baijiaju1990@gmail.com> wrote:

> The function kzalloc here is not called in atomic context.
> If nonblocking in efi_query_variable_store is true, 
> namely it is in atomic context, efi_query_variable_store will return before
> this kzalloc is called.
> Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.
> 
> This is found by a static analysis tool named DCNS written by myself.
> 
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  arch/x86/platform/efi/quirks.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> index 8a99a2e..b6dcb52 100644
> --- a/arch/x86/platform/efi/quirks.c
> +++ b/arch/x86/platform/efi/quirks.c
> @@ -177,7 +177,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
>  		 * that by attempting to use more space than is available.
>  		 */
>  		unsigned long dummy_size = remaining_size + 1024;
> -		void *dummy = kzalloc(dummy_size, GFP_ATOMIC);
> +		void *dummy = kzalloc(dummy_size, GFP_KERNEL);

Looks good to me!

Reviewed-by: Ingo Molnar <mingo@kernel.org>

Thanks,

	Ingo

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

* Re: [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store
  2018-02-13 18:07 ` Ingo Molnar
@ 2018-02-13 18:40   ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2018-02-13 18:40 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Jia-Ju Bai, Matt Fleming, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, the arch/x86 maintainers, linux-efi,
	Linux Kernel Mailing List

On 13 February 2018 at 18:07, Ingo Molnar <mingo@kernel.org> wrote:
>
> * Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
>
>> The function kzalloc here is not called in atomic context.
>> If nonblocking in efi_query_variable_store is true,
>> namely it is in atomic context, efi_query_variable_store will return before
>> this kzalloc is called.
>> Thus GFP_ATOMIC is not necessary, and it can be replaced with GFP_KERNEL.
>>
>> This is found by a static analysis tool named DCNS written by myself.
>>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>>  arch/x86/platform/efi/quirks.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
>> index 8a99a2e..b6dcb52 100644
>> --- a/arch/x86/platform/efi/quirks.c
>> +++ b/arch/x86/platform/efi/quirks.c
>> @@ -177,7 +177,7 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size,
>>                * that by attempting to use more space than is available.
>>                */
>>               unsigned long dummy_size = remaining_size + 1024;
>> -             void *dummy = kzalloc(dummy_size, GFP_ATOMIC);
>> +             void *dummy = kzalloc(dummy_size, GFP_KERNEL);
>
> Looks good to me!
>
> Reviewed-by: Ingo Molnar <mingo@kernel.org>
>

Queued in linux-efi/next

Thanks all.

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

end of thread, other threads:[~2018-02-13 18:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25  2:29 [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store Jia-Ju Bai
2018-01-25  2:49 ` Joe Perches
2018-02-13 18:07 ` Ingo Molnar
2018-02-13 18:40   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).