linux/drivers
Linus Torvalds d652d5f1ee drm/edid: fix objtool warning in drm_cvt_modes()
Commit 991fcb77f4 ("drm/edid: Fix uninitialized variable in
drm_cvt_modes()") just replaced one warning with another.

The original warning about a possibly uninitialized variable was due to
the compiler not being smart enough to see that the case statement
actually enumerated all possible cases.  And the initial fix was just to
add a "default" case that had a single "unreachable()", just to tell the
compiler that that situation cannot happen.

However, that doesn't actually fix the fundamental reason for the
problem: the compiler still doesn't see that the existing case
statements enumerate all possibilities, so the compiler will still
generate code to jump to that unreachable case statement.  It just won't
complain about an uninitialized variable any more.

So now the compiler generates code to our inline asm marker that we told
it would not fall through, and end end result is basically random.  We
have created a bridge to nowhere.

And then, depending on the random details of just exactly what the
compiler ends up doing, 'objtool' might end up complaining about the
conditional branches (for conditions that cannot happen, and that thus
will never be taken - but if the compiler was not smart enough to figure
that out, we can't expect objtool to do so) going off in the weeds.

So depending on how the compiler has laid out the result, you might see
something like this:

    drivers/gpu/drm/drm_edid.o: warning: objtool: do_cvt_mode() falls through to next function drm_mode_detailed.isra.0()

and now you have a truly inscrutable warning that makes no sense at all
unless you start looking at whatever random code the compiler happened
to generate for our bare "unreachable()" statement.

IOW, don't use "unreachable()" unless you have an _active_ operation
that generates code that actually makes it obvious that something is not
reachable (ie an UD instruction or similar).

Solve the "compiler isn't smart enough" problem by just marking one of
the cases as "default", so that even when the compiler doesn't otherwise
see that we've enumerated all cases, the compiler will feel happy and
safe about there always being a valid case that initializes the 'width'
variable.

This also generates better code, since now the compiler doesn't generate
comparisons for five different possibilities (the four real ones and the
one that can't happen), but just for the three real ones and "the rest"
(which is that last one).

A smart enough compiler that sees that we cover all the cases won't care.

Cc: Lyude Paul <lyude@redhat.com>
Cc: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-12-17 09:27:57 -08:00
..
accessibility speakup: fix uninitialized flush_lock 2020-12-09 15:38:13 +01:00
acpi ACPI updates for 5.11-rc1 2020-12-15 16:39:06 -08:00
amba
android Merge branch 'exec-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2020-12-15 19:29:43 -08:00
ata
atm
auxdisplay
base Power management updates for 5.11-rc1 2020-12-15 16:30:31 -08:00
bcma
block for-5.11/drivers-2020-12-14 2020-12-16 13:09:32 -08:00
bluetooth Bluetooth: btusb: Add workaround for remote-wakeup issues with Barrot 8041a02 fake CSR controllers 2020-12-07 17:01:54 +02:00
bus ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
cdrom cdrom: Reset sector_size back it is not 2048. 2020-12-12 11:12:25 -07:00
char Some very minor changes 2020-12-16 14:54:39 -08:00
clk ARM: SoC updates for OMAP GenPD 2020-12-16 16:53:54 -08:00
clocksource asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
connector
counter
cpufreq Merge branch 'pm-cpufreq' 2020-12-15 15:24:52 +01:00
cpuidle ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
crypto Networking updates for 5.11 2020-12-15 13:22:29 -08:00
dax vm_ops: rename .split() callback to .may_split() 2020-12-15 12:13:41 -08:00
dca
devfreq Merge branches 'pm-devfreq' and 'pm-tools' 2020-12-15 15:27:16 +01:00
dio
dma
dma-buf Merge branch 'akpm' (patches from Andrew) 2020-12-15 12:53:37 -08:00
edac Merge branch 'akpm' (patches from Andrew) 2020-12-15 12:53:37 -08:00
eisa
extcon extcon: max77693: Fix modalias string 2020-12-11 17:18:10 +09:00
firewire
firmware ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
fpga Merge 5.10-rc7 into char-misc-next 2020-12-07 10:08:14 +01:00
fsi hwmon patches for v5.11 2020-12-15 16:06:14 -08:00
gnss
gpio - New Drivers 2020-12-16 14:48:32 -08:00
gpu drm/edid: fix objtool warning in drm_cvt_modes() 2020-12-17 09:27:57 -08:00
greybus
hid Merge branch 'for-5.11/wacom' into for-linus 2020-12-16 11:44:38 +01:00
hsi
hv hyperv-next for 5.11 2020-12-16 11:49:46 -08:00
hwmon ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
hwspinlock hwspinlock: sirf: Remove the redundant 'of_match_ptr' 2020-12-10 13:34:40 -06:00
hwtracing Char / Misc driver updates for 5.11-rc1 2020-12-15 14:10:09 -08:00
i2c Power management updates for 5.11-rc1 2020-12-15 16:30:31 -08:00
i3c
ide for-5.11/block-2020-12-14 2020-12-16 12:57:51 -08:00
idle
iio Staging / IIO driver patches for 5.11-rc1 2020-12-15 14:18:40 -08:00
infiniband RDMA 5.11 pull request 2020-12-16 13:42:26 -08:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2020-12-15 16:18:23 -08:00
interconnect ARM: device tree updates for 5.11 2020-12-16 16:27:35 -08:00
iommu IOMMU updates for 5.11 2020-12-16 13:58:47 -08:00
ipack
irqchip irqchip/qcom-pdc: Fix phantom irq when changing between rising/falling 2020-12-12 10:46:02 +00:00
isdn
leds
lightnvm drivers/lightnvm: fix a null-ptr-deref bug in pblk-core.c 2020-12-08 10:02:45 -07:00
macintosh macintosh/adb-iop: Send correct poll command 2020-12-07 10:48:16 +01:00
mailbox
mcb
md for-5.11/drivers-2020-12-14 2020-12-16 13:09:32 -08:00
media ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
memory Merge tag 'memory-controller-drv-tegra-5.11-3' of git://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-mem-ctrl into arm/drivers 2020-12-09 00:40:02 +01:00
memstick
message SCSI misc on 20201216 2020-12-16 13:34:31 -08:00
mfd
misc drivers/misc/lkdtm/lkdtm.h: correct wrong filenames in comment 2020-12-15 22:46:16 -08:00
mmc MMC core: 2020-12-15 15:57:25 -08:00
most
mtd MTD core: 2020-12-16 14:58:35 -08:00
mux
net xen: branch for v5.11-rc1 2020-12-16 11:53:09 -08:00
nfc Networking updates for 5.11 2020-12-15 13:22:29 -08:00
ntb
nubus
nvdimm
nvme RDMA 5.11 pull request 2020-12-16 13:42:26 -08:00
nvmem
of Driver core updates for 5.11-rc1 2020-12-15 14:02:26 -08:00
opp Merge branch 'pm-cpufreq' 2020-12-15 15:24:52 +01:00
oprofile
parisc
parport
pci RDMA 5.11 pull request 2020-12-16 13:42:26 -08:00
pcmcia
perf perf/imx_ddr: Add system PMU identifier for userspace 2020-12-09 14:14:02 +00:00
phy Char / Misc driver updates for 5.11-rc1 2020-12-15 14:10:09 -08:00
pinctrl This is the bulk of pin control changes for the v5.11 kernel: 2020-12-16 15:02:49 -08:00
platform Merge tag 'thermal-v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux 2020-12-15 16:21:37 -08:00
pnp
power
powercap Merge branches 'pm-sleep', 'pm-acpi', 'pm-domains' and 'powercap' 2020-12-15 15:26:14 +01:00
pps
ps3
ptp ptp: clockmatrix: deprecate firmware older than 4.8.7 2020-12-09 15:00:55 -08:00
pwm
rapidio rapidio: remove unused rio_get_asm() and rio_get_device() 2020-12-15 22:46:18 -08:00
ras
regulator Merge remote-tracking branch 'regulator/for-5.11' into regulator-next 2020-12-11 17:48:32 +00:00
remoteproc ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
reset ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
rpmsg
rtc ntp: Make the RTC sync offset less obscure 2020-12-11 10:40:53 +01:00
s390 VFIO updates for v5.11-rc1 2020-12-16 15:51:15 -08:00
sbus
scsi SCSI misc on 20201216 2020-12-16 13:34:31 -08:00
sfi
sh
siox siox: Make remove callback return void 2020-12-10 16:17:15 +01:00
slimbus slimbus: qcom: fix potential NULL dereference in qcom_slim_prg_slew() 2020-12-10 16:23:56 +01:00
soc ARM: SoC updates for OMAP GenPD 2020-12-16 16:53:54 -08:00
soundwire soundwire: intel: fix another unused-function warning 2020-12-05 13:11:54 +05:30
spi Merge remote-tracking branch 'spi/for-5.11' into spi-next 2020-12-11 17:49:01 +00:00
spmi spmi: Add driver shutdown support 2020-12-10 10:45:36 +01:00
ssb
staging ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
target SCSI misc on 20201216 2020-12-16 13:34:31 -08:00
tc
tee ARM: SoC drivers for v5.11 2020-12-16 16:38:41 -08:00
thermal Merge tag 'thermal-v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux 2020-12-15 16:21:37 -08:00
thunderbolt thunderbolt: Changes for v5.11 merge window 2020-12-08 13:41:45 +01:00
tty printk changes for 5.11 2020-12-16 10:45:11 -08:00
uio uio: uio_hv_generic: use devm_kzalloc() for private data alloc 2020-12-09 19:59:00 +01:00
usb for-5.11/block-2020-12-14 2020-12-16 12:57:51 -08:00
vdpa Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux 2020-12-07 18:36:21 -08:00
vfio VFIO updates for v5.11-rc1 2020-12-16 15:51:15 -08:00
vhost vhost: vringh: use krealloc_array() 2020-12-15 12:13:37 -08:00
video - Bug Fixes 2020-12-16 14:52:37 -08:00
virt
virtio mm, page_poison: remove CONFIG_PAGE_POISONING_NO_SANITY 2020-12-15 12:13:46 -08:00
visorbus
vlynq
vme vme: switch from 'pci_' to 'dma_' API 2020-12-09 19:44:34 +01:00
w1
watchdog
xen xen: branch for v5.11-rc1 2020-12-16 11:53:09 -08:00
zorro
Kconfig
Makefile asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00