linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org,
	Grant Grundler <grundler@chromium.org>,
	Greg Hackmann <ghackmann@google.com>,
	Michael Davidson <md@google.com>,
	Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y
Date: Tue, 11 Apr 2017 16:52:17 -0700	[thread overview]
Message-ID: <20170411235217.71604-1-mka@chromium.org> (raw)

With CONFIG_CPUMASK_OFFSTACK=y cpumask_var_t is a struct cpumask
pointer, otherwise a struct cpumask array with a single element.

irq_thread_check_affinity() validates the cpumask_var_t field in the
interrupt descriptor by checking if it is not NULL. This works for
both CONFIG_CPUMASK_OFFSTACK=y/n, however clang raises the following
warning with CONFIG_CPUMASK_OFFSTACK=n:

kernel/irq/manage.c:839:28: error: address of array
'desc->irq_common_data.affinity' will always evaluate to 'true'
[-Werror,-Wpointer-bool-conversion]

To get rid of the warning only validate the cpumask_var_t field when
CONFIG_CPUMASK_OFFSTACK=y.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 kernel/irq/manage.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index a4afe5cc5af1..5d38fe85122b 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -848,14 +848,14 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action)
 	}
 
 	raw_spin_lock_irq(&desc->lock);
-	/*
-	 * This code is triggered unconditionally. Check the affinity
-	 * mask pointer. For CPU_MASK_OFFSTACK=n this is optimized out.
-	 */
-	if (desc->irq_common_data.affinity)
-		cpumask_copy(mask, desc->irq_common_data.affinity);
-	else
+
+#ifdef CONFIG_CPUMASK_OFFSTACK
+	if (!desc->irq_common_data.affinity)
 		valid = false;
+	else
+#endif
+	cpumask_copy(mask, desc->irq_common_data.affinity);
+
 	raw_spin_unlock_irq(&desc->lock);
 
 	if (valid)
-- 
2.12.2.715.g7642488e1d-goog

             reply	other threads:[~2017-04-11 23:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11 23:52 Matthias Kaehlcke [this message]
2017-04-12  7:23 ` [PATCH] kernel/irq: Limit validation of cpumask_var_t to CONFIG_CPUMASK_OFFSTACK=y Thomas Gleixner
2017-04-12 16:43   ` Matthias Kaehlcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170411235217.71604-1-mka@chromium.org \
    --to=mka@chromium.org \
    --cc=ghackmann@google.com \
    --cc=grundler@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=md@google.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).