Skip to content

Commit

Permalink
gma500: fix an incorrect NULL check on list iterator
Browse files Browse the repository at this point in the history
commit bdef417 upstream.

The bug is here:
	return crtc;

The list iterator value 'crtc' will *always* be set and non-NULL by
list_for_each_entry(), so it is incorrect to assume that the iterator
value will be NULL if the list is empty or no element is found.

To fix the bug, return 'crtc' when found, otherwise return NULL.

Cc: stable@vger.kernel.org
fixes: 89c7813 ("gma500: Add Poulsbo support")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Signed-off-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220327052028.2013-1-xiam0nd.tong@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xiaomeng Tong authored and gregkh committed Jun 9, 2022
1 parent c521f42 commit 591c348
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions drivers/gpu/drm/gma500/psb_intel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,14 +536,15 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,

struct drm_crtc *psb_intel_get_crtc_from_pipe(struct drm_device *dev, int pipe)
{
struct drm_crtc *crtc = NULL;
struct drm_crtc *crtc;

list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
struct gma_crtc *gma_crtc = to_gma_crtc(crtc);

if (gma_crtc->pipe == pipe)
break;
return crtc;
}
return crtc;
return NULL;
}

int gma_connector_clones(struct drm_device *dev, int type_mask)
Expand Down

0 comments on commit 591c348

Please sign in to comment.