diff options
author | Will Deacon <will.deacon@arm.com> | 2017-12-01 15:29:39 +0000 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2017-12-04 20:51:12 +0100 |
commit | 4ce413d1840b25b101be3c0559161db8891f3360 (patch) | |
tree | 969656d510deb1d314d44055b2daf840ba0cf9f7 /kernel | |
parent | bb5c43428252f27b875c764451321a83a531d6e5 (diff) | |
download | linux-4ce413d1840b25b101be3c0559161db8891f3360.tar.bz2 |
irqdesc: Use bool return type instead of int
The irq_balancing_disabled and irq_is_percpu{,_devid} functions are
clearly intended to return bool like the functions in
kernel/irq/settings.h, but actually return an int containing a masked
value of desc->status_use_accessors. This can lead to subtle breakage
if, for example, the return value is subsequently truncated when
assigned to a narrower type.
As Linus points out:
| In particular, what can (and _has_ happened) is that people end up
| using these functions that return true or false, and they assign the
| result to something like a bitfield (or a char) or whatever.
|
| And the code looks *obviously* correct, when you have things like
|
| dev->percpu = irq_is_percpu_devid(dev->irq);
|
| and that "percpu" thing is just one status bit among many. It may even
| *work*, because maybe that "percpu" flag ends up not being all that
| important, or it just happens to never be set on the particular
| hardware that people end up testing.
|
| But while it looks obviously correct, and might even work, it's really
| fundamentally broken. Because that "true or false" function didn't
| actually return 0/1, it returned 0 or 0x20000.
|
| And 0x20000 may not fit in a bitmask or a "char" or whatever.
Fix the problem by consistently using bool as the return type for these
functions.
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: marc.zyngier@arm.com
Link: https://lkml.kernel.org/r/1512142179-24616-1-git-send-email-will.deacon@arm.com
Diffstat (limited to 'kernel')
0 files changed, 0 insertions, 0 deletions