linux-stable/drivers/gpu/drm
Arnd Bergmann 287980e49f remove lots of IS_ERR_VALUE abuses
Most users of IS_ERR_VALUE() in the kernel are wrong, as they
pass an 'int' into a function that takes an 'unsigned long'
argument. This happens to work because the type is sign-extended
on 64-bit architectures before it gets converted into an
unsigned type.

However, anything that passes an 'unsigned short' or 'unsigned int'
argument into IS_ERR_VALUE() is guaranteed to be broken, as are
8-bit integers and types that are wider than 'unsigned long'.

Andrzej Hajda has already fixed a lot of the worst abusers that
were causing actual bugs, but it would be nice to prevent any
users that are not passing 'unsigned long' arguments.

This patch changes all users of IS_ERR_VALUE() that I could find
on 32-bit ARM randconfig builds and x86 allmodconfig. For the
moment, this doesn't change the definition of IS_ERR_VALUE()
because there are probably still architecture specific users
elsewhere.

Almost all the warnings I got are for files that are better off
using 'if (err)' or 'if (err < 0)'.
The only legitimate user I could find that we get a warning for
is the (32-bit only) freescale fman driver, so I did not remove
the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
For 9pfs, I just worked around one user whose calling conventions
are so obscure that I did not dare change the behavior.

I was using this definition for testing:

 #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
       unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

which ends up making all 16-bit or wider types work correctly with
the most plausible interpretation of what IS_ERR_VALUE() was supposed
to return according to its users, but also causes a compile-time
warning for any users that do not pass an 'unsigned long' argument.

I suggested this approach earlier this year, but back then we ended
up deciding to just fix the users that are obviously broken. After
the initial warning that caused me to get involved in the discussion
(fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
asked me to send the whole thing again.

[ Updated the 9p parts as per Al Viro  - Linus ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.org/lkml/2016/1/7/363
Link: https://lkml.org/lkml/2016/5/27/486
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-05-27 15:26:11 -07:00
..
amd Merge branch 'drm-next-4.7' of git://people.freedesktop.org/~agd5f/linux into drm-next 2016-05-27 16:03:48 +10:00
arc drm/arcpgu: use dedicated memory area for frame buffer 2016-04-29 14:22:32 +03:00
arm drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
armada drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
ast drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
atmel-hlcdc drm: Drop crtc argument from __drm_atomic_helper_crtc_destroy_state 2016-05-17 08:56:41 +02:00
bochs drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
bridge drm/bridge: Add Analogix anx78xx support 2016-05-12 11:32:14 +02:00
cirrus drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
etnaviv Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-05-23 11:48:48 -07:00
exynos drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
fsl-dcu drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
gma500 drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
hisilicon drm/hisilicon: Fix DRM_INFO printed issue 2016-05-11 19:05:36 +08:00
i2c
i810
i915 Merge tag 'drm-fixes-v4.7-rc1' of git://people.freedesktop.org/~airlied/linux 2016-05-27 14:08:56 -07:00
imx imx-drm probing fix 2016-05-25 12:36:20 +10:00
mediatek drm: mediatek: fixup drm_gem_object_lookup API change 2016-05-18 19:16:16 +02:00
mga
mgag200 drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
msm Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-05-23 11:48:48 -07:00
nouveau Merge branch 'linux-4.7' of git://github.com/skeggsb/linux into drm-next 2016-05-21 06:12:13 +10:00
omapdrm drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
panel drm/panel: simple: Add support for TPK U.S.A. LLC Fusion 7" and 10.1" panels 2016-05-12 11:32:14 +02:00
qxl qxl: catch qxlfb_create_pinned_object failures 2016-05-17 09:11:23 +02:00
r128
radeon Merge branch 'drm-next-4.7' of git://people.freedesktop.org/~agd5f/linux into drm-next 2016-05-27 16:03:48 +10:00
rcar-du drm: Drop plane argument from __drm_atomic_helper_plane_destroy_state 2016-05-17 08:56:55 +02:00
rockchip drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
savage
shmobile drm/shmobile: use drm_crtc_send_vblank_event() 2016-05-02 17:04:50 +02:00
sis
sti remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
sun4i drm: sun4i: tv: Add NTSC output standard 2016-04-28 10:30:05 +02:00
tdfx
tegra Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-05-23 11:48:48 -07:00
tilcdc remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
ttm Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
udl drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vc4 Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux 2016-05-23 11:48:48 -07:00
vgem drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
via
virtio drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
vmwgfx drm/vmwgfx: Report vmwgfx version to vmware.log 2016-05-20 17:40:07 +02:00
ati_pcigart.c
drm_agpsupport.c drm: Give drm_agp_clear drm_legacy_ prefix 2016-04-27 08:41:34 +02:00
drm_atomic.c drm: Avoid connector reference imbalance on error path 2016-05-18 10:42:01 +02:00
drm_atomic_helper.c drm: Drop connector argument from __drm_atomic_helper_connector_destroy_state 2016-05-17 08:57:05 +02:00
drm_auth.c
drm_bridge.c
drm_bufs.c drm: Hide master MAP cleanup in drm_bufs.c 2016-04-27 10:14:17 +02:00
drm_cache.c
drm_context.c
drm_crtc.c drm: Fix error handling in drm_connector_register 2016-05-18 12:24:51 +02:00
drm_crtc_helper.c drm: Make drm_encoder_helper_funcs optional 2016-05-10 08:54:09 +02:00
drm_crtc_internal.h
drm_debugfs.c
drm_dma.c
drm_dp_aux_dev.c drm/dp: Allow signals to interrupt drm_aux-dev reads/writes 2016-04-28 11:48:09 +02:00
drm_dp_dual_mode_helper.c drm: Add helper for DP++ adaptors 2016-05-23 11:10:46 +03:00
drm_dp_helper.c drm/dp_helper: Perform throw-away read before actual read in drm_dp_dpcd_read() 2016-04-22 18:52:24 +02:00
drm_dp_mst_topology.c Linux 4.6-rc7 2016-05-09 13:49:56 +10:00
drm_drv.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_edid.c drm/edid: add displayid detailed 1 timings to the modelist. (v1.1) 2016-05-23 11:35:31 +10:00
drm_edid_load.c
drm_encoder_slave.c
drm_fb_cma_helper.c drm/fb-cma-helper: Add function drm_fb_cma_create_with_funcs() 2016-05-17 09:08:32 +02:00
drm_fb_helper.c drm/fb_helper: Fix references to dev->mode_config.num_connector 2016-05-17 15:44:41 +02:00
drm_flip_work.c
drm_fops.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_gem.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_gem_cma_helper.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_global.c
drm_hashtab.c
drm_info.c drm: Protect dev->filelist with its own mutex 2016-04-27 10:16:17 +02:00
drm_internal.h drm: Make drm_vm_open/close_locked private to drm_vm.c 2016-04-27 10:15:56 +02:00
drm_ioc32.c
drm_ioctl.c drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix 2016-04-27 08:42:48 +02:00
drm_irq.c drm: Nuke ->vblank_disable_allowed 2016-05-21 07:03:31 +10:00
drm_kms_helper_common.c
drm_legacy.h drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix 2016-04-27 08:42:48 +02:00
drm_lock.c
drm_memory.c
drm_mipi_dsi.c
drm_mm.c
drm_modes.c
drm_modeset_lock.c
drm_of.c
drm_panel.c drm/panel: Flesh out kerneldoc 2016-05-06 16:04:48 +02:00
drm_pci.c drm: Give drm_agp_clear drm_legacy_ prefix 2016-04-27 08:41:34 +02:00
drm_plane_helper.c
drm_platform.c
drm_prime.c drm: Remove unused drm_device from drm_gem_object_lookup() 2016-05-17 08:47:30 +02:00
drm_probe_helper.c
drm_rect.c
drm_scatter.c
drm_sysfs.c drm/sysfs: Annote lockless show functions with READ_ONCE 2016-04-26 13:23:24 +02:00
drm_trace.h
drm_trace_points.c
drm_vm.c drm: Make drm_vm_open/close_locked private to drm_vm.c 2016-04-27 10:15:56 +02:00
drm_vma_manager.c
Kconfig drm/mediatek: Add DRM Driver for Mediatek SoC MT8173. 2016-05-06 17:47:35 +02:00
Makefile Merge tag 'drm-intel-next-fixes-2016-05-25' of git://anongit.freedesktop.org/drm-intel into drm-next 2016-05-27 16:08:38 +10:00