From patchwork Tue Sep 22 06:07:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11791561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50FC216BC for ; Tue, 22 Sep 2020 06:07:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EA83D23A84 for ; Tue, 22 Sep 2020 06:07:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iuUH7P98" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA83D23A84 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0ADF6900024; Tue, 22 Sep 2020 02:07:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 05CAD900012; Tue, 22 Sep 2020 02:07:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E6806900024; Tue, 22 Sep 2020 02:07:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id C9D5C900012 for ; Tue, 22 Sep 2020 02:07:57 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 88E9D181AEF07 for ; Tue, 22 Sep 2020 06:07:57 +0000 (UTC) X-FDA: 77289666594.02.hose09_3701edf2714b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 63435100BC970 for ; Tue, 22 Sep 2020 06:07:57 +0000 (UTC) X-Spam-Summary: 1,0,0,d3f33e33750d879f,d41d8cd98f00b204,natechancellor@gmail.com,,RULES_HIT:41:355:379:541:800:960:967:973:988:989:1260:1311:1314:1345:1359:1437:1515:1535:1542:1711:1730:1747:1777:1792:1801:2393:2525:2559:2563:2682:2685:2693:2859:2902:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3865:3867:3868:3872:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4605:5007:6261:6653:6742:7514:8603:8957:9025:9121:9149:9413:10004:11026:11232:11658:11914:12043:12114:12266:12297:12438:12517:12519:12555:12679:12895:13255:13894:14096:14181:14394:14687:14721:21067:21080:21324:21365:21444:21451:21627:21666:21939:21987:30054,0,RBL:209.85.219.68:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yfrjdobnrkpbckgxckdwwi4nfs5ocfw8i9nowiuidzjfbadnhbe8uw7xttj7z.siaff1655de983k96xq5nf5z5tbyc9x9tdj9ydprfyk4kr1jw9d63unb3eofhrt.r-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSB L:neutra X-HE-Tag: hose09_3701edf2714b X-Filterd-Recvd-Size: 5451 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Sep 2020 06:07:56 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id p15so8883064qvk.5 for ; Mon, 21 Sep 2020 23:07:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YtWt5LT1rZHUieitxqoZL94pXE9Kni8HrVa9DLq6ra8=; b=iuUH7P98MAjsRlYJLK0TJlVvZeCzmYl9RV4YJokXxQqlQv7Wl7kR5ZHCp9MtlOlzKk /1RP01X5p+SM3kTFYgEvk62jz44d/piRqzh8EXdfCfQmyBgRRa3jZ0xJgGBfL2TYW6tn ede/YsJq2RHhP6OjTLHxVUg/RHQ1nexItE8RxNdloYtrMpaYRUzbXPWF7VnOLjpzZums CY/p2InTF6IIF4O6CRVc14nFUBzT4GmCjfKIYzruKsehGb+bT4uXZzhSESh7tX6yA1Cj L4hsw6xW7izWpTL7qRTsyjLb9Wnwa1exn47NZ3C9KFSk/ArtkDmN9SScS3ZUa1kEKfmM R/1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YtWt5LT1rZHUieitxqoZL94pXE9Kni8HrVa9DLq6ra8=; b=aHbshZ6KKm1K6EHq0wMWZAvFYAZHpRwRfsYXIQlHtsdlCwNoxIUP/onQN0NEnELOsp 1F4DuPSBRtl7iCLGhuJjSoEI3pj+KE9SNa3KIlm+axfAMEG+KOResqjP3+u0YCKqMOZJ L2djm0Slgcw/XmqrhYbndK9aaelaO5hNO+TnhuuW26tWqd7Falsgwi0r+9ute/2NWZ24 2dkB+jtgf5T5nv5cO/kjt1e6Npy3TGEMLAnWbLf7PH+EuaS638vV7X/uiOpzaIpqU73s Al8rM4Dgk/ILrquWbdX8E5ydgWJKJnaS3yBec0pL5eGsmXMC/ohwr2DhuH8Aphn61UrE RKlA== X-Gm-Message-State: AOAM530HndTk3O5Ec92L9PPnvY2wWVm3v+vmpEEeZdyhAGJKARG918ls RIw92rZMNYBgfciLUn1gkSM= X-Google-Smtp-Source: ABdhPJzYAkkRErXQKS5nPd9e9nFfwFnEtBGJUL1AQh/5PWzM/3iOlyBSVL9xx1MY6K5RCdOgRUtuYQ== X-Received: by 2002:a0c:8b02:: with SMTP id q2mr4425388qva.48.1600754876169; Mon, 21 Sep 2020 23:07:56 -0700 (PDT) Received: from localhost.localdomain ([2604:1380:45d1:2600::1]) by smtp.gmail.com with ESMTPSA id x3sm12523533qta.53.2020.09.21.23.07.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 23:07:55 -0700 (PDT) From: Nathan Chancellor To: david@redhat.com Cc: akpm@linux-foundation.org, ardb@kernel.org, bhe@redhat.com, dan.j.williams@intel.com, jgg@ziepe.ca, keescook@chromium.org, linux-acpi@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, linux-s390@vger.kernel.org, mhocko@suse.com, pankaj.gupta.linux@gmail.com, richardw.yang@linux.intel.com, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH] kernel/resource: Fix use of ternary condition in release_mem_region_adjustable Date: Mon, 21 Sep 2020 23:07:48 -0700 Message-Id: <20200922060748.2452056-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911103459.10306-2-david@redhat.com> References: <20200911103459.10306-2-david@redhat.com> MIME-Version: 1.0 X-Patchwork-Bot: notify X-Bogosity: Ham, tests=bogofilter, spamicity=0.000050, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Clang warns: kernel/resource.c:1281:53: warning: operator '?:' has lower precedence than '|'; '|' will be evaluated first [-Wbitwise-conditional-parentheses] new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ kernel/resource.c:1281:53: note: place parentheses around the '|' expression to silence this warning new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ kernel/resource.c:1281:53: note: place parentheses around the '?:' expression to evaluate it first new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); ^ ( ) 1 warning generated. Add the parentheses as it was clearly intended for the ternary condition to be evaluated first. Fixes: 5fd23bd0d739 ("kernel/resource: make release_mem_region_adjustable() never fail") Link: https://github.com/ClangBuiltLinux/linux/issues/1159 Signed-off-by: Nathan Chancellor Reviewed-by: David Hildenbrand Reviewed-by: Wei Yang --- Presumably, this will be squashed but I included a fixes tag nonetheless. Apologies if this has already been noticed and fixed already, I did not find anything on LKML. kernel/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 40ee82f47bf297e31d0c47547cd8f24ede52415a diff --git a/kernel/resource.c b/kernel/resource.c index ca2a666e4317..3ae2f56cc79d 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -1278,7 +1278,7 @@ void release_mem_region_adjustable(resource_size_t start, resource_size_t size) * similarly). */ retry: - new_res = alloc_resource(GFP_KERNEL | alloc_nofail ? __GFP_NOFAIL : 0); + new_res = alloc_resource(GFP_KERNEL | (alloc_nofail ? __GFP_NOFAIL : 0)); p = &parent->child; write_lock(&resource_lock);