summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/nouveau/dispnv50/atom.h
diff options
context:
space:
mode:
authorXiaomeng Tong <xiam0nd.tong@gmail.com>2022-03-27 15:39:25 +0800
committerLyude Paul <lyude@redhat.com>2022-03-28 17:31:27 -0400
commit6ce4431c7ba7954c4fa6a96ce16ca1b2943e1a83 (patch)
treeb3e460a7b3a1a4411b3b73afe631855b08ad9127 /drivers/gpu/drm/nouveau/dispnv50/atom.h
parentb0e2c9ea5afc769476fd85a6a28cc370ddd44ee8 (diff)
drm/nouveau/kms/nv50-: atom: fix an incorrect NULL check on list iterator
The bug is here: return encoder; The list iterator value 'encoder' will *always* be set and non-NULL by drm_for_each_encoder_mask(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element found. Otherwise it will bypass some NULL checks and lead to invalid memory access passing the check. To fix this bug, just return 'encoder' when found, otherwise return NULL. Cc: stable@vger.kernel.org Fixes: 12885ecbfe62d ("drm/nouveau/kms/nvd9-: Add CRC support") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Reviewed-by: Lyude Paul <lyude@redhat.com> [Changed commit title] Signed-off-by: Lyude Paul <lyude@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220327073925.11121-1-xiam0nd.tong@gmail.com
Diffstat (limited to 'drivers/gpu/drm/nouveau/dispnv50/atom.h')
-rw-r--r--drivers/gpu/drm/nouveau/dispnv50/atom.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/gpu/drm/nouveau/dispnv50/atom.h b/drivers/gpu/drm/nouveau/dispnv50/atom.h
index 3d82b3c67dec..93f8f4f64578 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/atom.h
+++ b/drivers/gpu/drm/nouveau/dispnv50/atom.h
@@ -160,14 +160,14 @@ nv50_head_atom_get(struct drm_atomic_state *state, struct drm_crtc *crtc)
static inline struct drm_encoder *
nv50_head_atom_get_encoder(struct nv50_head_atom *atom)
{
- struct drm_encoder *encoder = NULL;
+ struct drm_encoder *encoder;
/* We only ever have a single encoder */
drm_for_each_encoder_mask(encoder, atom->state.crtc->dev,
atom->state.encoder_mask)
- break;
+ return encoder;
- return encoder;
+ return NULL;
}
#define nv50_wndw_atom(p) container_of((p), struct nv50_wndw_atom, state)