From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933249AbeAYCt2 (ORCPT ); Wed, 24 Jan 2018 21:49:28 -0500 Received: from smtprelay0083.hostedemail.com ([216.40.44.83]:41220 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932698AbeAYCt1 (ORCPT ); Wed, 24 Jan 2018 21:49:27 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:355:379:541:599:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3868:3870:3871:3872:3874:4250:4321:5007:6117:7903:8603:10004:10400:10848:11026:11232:11657:11658:11914:12043:12048:12114:12296:12438:12740:12760:12895:13069:13255:13311:13357:13439:14659:14721:14819:21080:21433:21627:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: heat90_5249ead9aa809 X-Filterd-Recvd-Size: 1947 Message-ID: <1516848563.8378.60.camel@perches.com> Subject: Re: [PATCH] x86: efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store From: Joe Perches To: Jia-Ju Bai , matt@codeblueprint.co.uk, ard.biesheuvel@linaro.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com Cc: x86@kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 24 Jan 2018 18:49:23 -0800 In-Reply-To: <1516847386-5291-1-git-send-email-baijiaju1990@gmail.com> References: <1516847386-5291-1-git-send-email-baijiaju1990@gmail.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.26.1-1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.