linux-stable/include
Jani Nikula 373701b1fc drm: fix potential dangling else problems in for_each_ macros
We have serious dangling else bugs waiting to happen in our for_each_
style macros with ifs. Consider, for example,

 #define drm_for_each_plane_mask(plane, dev, plane_mask) \
         list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \
                 if ((plane_mask) & (1 << drm_plane_index(plane)))

If this is used in context:

	if (condition)
		drm_for_each_plane_mask(plane, dev, plane_mask);
	else
		foo();

foo() will be called for each plane *not* in plane_mask, if condition
holds, and not at all if condition doesn't hold.

Fix this by reversing the conditions in the macros, and adding an else
branch for the "for each" block, so that other if/else blocks can't
interfere. Provide a "for_each_if" helper macro to make it easier to get
this right.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1448392916-2281-1-git-send-email-jani.nikula@intel.com
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-11-25 09:29:21 +01:00
..
acpi Merge branch 'acpi-pci' 2015-11-07 01:30:10 +01:00
asm-generic h8300 update for v4.4 2015-11-12 15:26:39 -08:00
clocksource
crypto Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2015-11-05 15:32:38 -08:00
drm drm: fix potential dangling else problems in for_each_ macros 2015-11-25 09:29:21 +01:00
dt-bindings ARM: DT updates for v4.4 2015-11-10 15:06:26 -08:00
keys
kvm s390: A bunch of fixes and optimizations for interrupt and time 2015-11-05 16:26:26 -08:00
linux Merge branch 'akpm' (patches from Andrew) 2015-11-22 15:21:40 -08:00
math-emu
media
memory
misc
net net: switchdev: fix return code of fdb_dump stub 2015-11-16 15:24:37 -05:00
pcmcia
ras
rdma
rxrpc
scsi scsi: use host wide tags by default 2015-11-09 17:11:57 -08:00
soc ARM: SoC driver updates for v4.4 2015-11-10 15:00:03 -08:00
sound
target Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending 2015-11-13 20:04:17 -08:00
trace Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux 2015-11-11 09:03:01 -08:00
uapi VFIO updates for v4.4-rc1 2015-11-13 17:05:32 -08:00
video drm/exynos/decon5433: add support for DECON-TV 2015-11-03 11:46:37 +09:00
xen
Kbuild