* [PATCH] gma500: fix an incorrect NULL check on list iterator
@ 2022-03-27 5:20 Xiaomeng Tong
2022-03-29 9:36 ` Patrik Jakobsson
0 siblings, 1 reply; 2+ messages in thread
From: Xiaomeng Tong @ 2022-03-27 5:20 UTC (permalink / raw)
To: patrik.r.jakobsson
Cc: airlied, daniel, dri-devel, linux-kernel, Xiaomeng Tong, stable
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: 89c78134cc54d ("gma500: Add Poulsbo support")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
---
drivers/gpu/drm/gma500/psb_intel_display.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c
index d5f95212934e..42d1a733e124 100644
--- a/drivers/gpu/drm/gma500/psb_intel_display.c
+++ b/drivers/gpu/drm/gma500/psb_intel_display.c
@@ -535,14 +535,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)
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gma500: fix an incorrect NULL check on list iterator
2022-03-27 5:20 [PATCH] gma500: fix an incorrect NULL check on list iterator Xiaomeng Tong
@ 2022-03-29 9:36 ` Patrik Jakobsson
0 siblings, 0 replies; 2+ messages in thread
From: Patrik Jakobsson @ 2022-03-29 9:36 UTC (permalink / raw)
To: Xiaomeng Tong
Cc: David Airlie, Daniel Vetter, dri-devel, linux-kernel, stable
On Sun, Mar 27, 2022 at 7:20 AM Xiaomeng Tong <xiam0nd.tong@gmail.com> wrote:
>
> 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: 89c78134cc54d ("gma500: Add Poulsbo support")
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Thanks for the patch
Applied to drm-misc-next
-Patrik
> ---
> drivers/gpu/drm/gma500/psb_intel_display.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/psb_intel_display.c b/drivers/gpu/drm/gma500/psb_intel_display.c
> index d5f95212934e..42d1a733e124 100644
> --- a/drivers/gpu/drm/gma500/psb_intel_display.c
> +++ b/drivers/gpu/drm/gma500/psb_intel_display.c
> @@ -535,14 +535,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)
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-29 9:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-27 5:20 [PATCH] gma500: fix an incorrect NULL check on list iterator Xiaomeng Tong
2022-03-29 9:36 ` Patrik Jakobsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®