Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dsi: check msm_dsi and dsi pointers before use

Move null checks of pointer arguments to the beginning of the
modeset init function since they are referenced immediately
instead of after they have already been used.

Signed-off-by: Lloyd Atkinson <latkinso@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>

authored by

Lloyd Atkinson and committed by
Rob Clark
3f0689e6 6e1787cf

+11 -13
+11 -13
drivers/gpu/drm/msm/dsi/dsi.c
··· 196 196 struct drm_bridge *ext_bridge; 197 197 int ret; 198 198 199 - if (WARN_ON(!encoder)) 199 + if (WARN_ON(!encoder) || WARN_ON(!msm_dsi) || WARN_ON(!dev)) 200 200 return -EINVAL; 201 201 202 202 msm_dsi->dev = dev; ··· 245 245 246 246 return 0; 247 247 fail: 248 - if (msm_dsi) { 249 - /* bridge/connector are normally destroyed by drm: */ 250 - if (msm_dsi->bridge) { 251 - msm_dsi_manager_bridge_destroy(msm_dsi->bridge); 252 - msm_dsi->bridge = NULL; 253 - } 254 - 255 - /* don't destroy connector if we didn't make it */ 256 - if (msm_dsi->connector && !msm_dsi->external_bridge) 257 - msm_dsi->connector->funcs->destroy(msm_dsi->connector); 258 - 259 - msm_dsi->connector = NULL; 248 + /* bridge/connector are normally destroyed by drm: */ 249 + if (msm_dsi->bridge) { 250 + msm_dsi_manager_bridge_destroy(msm_dsi->bridge); 251 + msm_dsi->bridge = NULL; 260 252 } 253 + 254 + /* don't destroy connector if we didn't make it */ 255 + if (msm_dsi->connector && !msm_dsi->external_bridge) 256 + msm_dsi->connector->funcs->destroy(msm_dsi->connector); 257 + 258 + msm_dsi->connector = NULL; 261 259 262 260 return ret; 263 261 }