Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3755291pxk; Tue, 22 Sep 2020 01:28:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDnAi9zO8CMj7GGYP5PcCsk7eBEzwckjxmfRa4t5ovMHXsvtYzUh+97cdbRnvKcSk8FYlP X-Received: by 2002:a17:906:ae8f:: with SMTP id md15mr3518195ejb.131.1600763300497; Tue, 22 Sep 2020 01:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600763300; cv=none; d=google.com; s=arc-20160816; b=NSlp9w9tuoASArVW+z8xRZRwoLDwfqi5G9260FwD88x7fCyfI2Swcwv4JbyDhQ6+Rv noggmdsi/tWoZI2ajvdutmX3wTnJNrSs73cwwe5to/CKpuo3fhD7PHy4wCqIanz2hdZZ TkYgTyCkkZZ3e9UoyQPNBvY/5uBpITCrq4R9BItyaP9cEvwzOP+ZBJi1aQZkSl6di6WU lnRRrMEebL/zl+N7X8sYdmcjw4EnbUWAq0BxgFNA7mLlwivLH+wDHGR4hws77OfiAwkh /JhZhIykZO+Tl1fwlmvFTuyRGc2PNDxX3o44E9+ZEQt1qDxweXKva1+lSXQTEfd3W5Rt wM0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YtWt5LT1rZHUieitxqoZL94pXE9Kni8HrVa9DLq6ra8=; b=bwHmonBKhua2CI/ot3Q0RYEGfs+F6TaZieiiJ2Nkobe6dsp9DS12QxZJc0B9LDJiEP v9eDALuNwzfndCE76zmu6Y3Hd7JNMJcjFCVHLhYropMArIOOpSSSlGO0sqW5hKwpSniO z3WWP7HU/velou0G9VeUi6NR+Y3ekeWJxteCkr0Aoa+OApEM32CIqaR0M4SZl6tcV9K6 cL1kW7tlNp6rFllp1QarhTR2ukbJRIFT9BGZOHQgvZy5fZicyzwUqYl2fiK6Mxnvr39U TnolvgVD+SpsRWALzuxHdC6QoBygHxUFrz10X+kCxB1nAjeTFlI/BClKjOND03zV0sUX f5YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iuUH7P98; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si11573458edi.348.2020.09.22.01.27.56; Tue, 22 Sep 2020 01:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iuUH7P98; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbgIVGH5 (ORCPT + 99 others); Tue, 22 Sep 2020 02:07:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbgIVGH5 (ORCPT ); Tue, 22 Sep 2020 02:07:57 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210C7C061755; Mon, 21 Sep 2020 23:07:57 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id cr8so8908585qvb.10; Mon, 21 Sep 2020 23:07:57 -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=oGZDQWGrmItyu9iwgVTrB/b7P1W8R8ccSyLxPHDB6eGzDxyWwu6kLGvV7+m1Z2fWzB ZhSJNfntZxni5jWn/EfXlUkekefEheQ4wlDTmE+JzuWWSZdLYX5IQ0VfNgDPTBpvpdcd cfyPQNQQq9X6CjfdGMeqnPXeB/GtSULner2DhRsO2WTKn6wHR3chfNJ5+0POo454lt9w JQLlH4fifPeIdK5FEXhODDYb+Lt+IpYUqK1D0+9wnTE9OhTQE99F7BJfnw1JSz3UnuIO 4mmmYRJnRE6ZTO5tNnU5dMvy4Ns+SF0pS6V+qhGUYJFAyKTWRXrepZUPjJRWRFq2dco7 ZNCQ== X-Gm-Message-State: AOAM531fUmhp3xVMW/Hvw06mxLba0JQRikiSEPSarFJlHbKAJ/xutVOL MC4ltG8NrtozdsZgPyyLjTQ= 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) 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); base-commit: 40ee82f47bf297e31d0c47547cd8f24ede52415a -- 2.28.0