mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3] drm/mgag200: Apply upper limit for clock variable
@ 2024-11-15 14:14 Murad Masimov
  2024-11-15 14:35 ` Jocelyn Falempe
  0 siblings, 1 reply; 2+ messages in thread
From: Murad Masimov @ 2024-11-15 14:14 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Murad Masimov, Thomas Zimmermann, Jocelyn Falempe,
	Maarten Lankhorst, Maxime Ripard, David Airlie, Simona Vetter,
	Mathieu Larouche, dri-devel, linux-kernel, lvc-project

If the value of the clock variable is higher than 800000, the value of the
variable m, which is used as a divisor, will remain zero, because
(clock * testp) will be higher than vcomax in every loop iteration, which
leads to skipping every iteration and leaving variable m unmodified.

Return -EINVAL just after the loop, if m is still 0.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: e829d7ef9f17 ("drm/mgag200: Add support for a new rev of G200e")
Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
---
 drivers/gpu/drm/mgag200/mgag200_g200se.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c
index 7a32d3b1d226..4d65ead63d66 100644
--- a/drivers/gpu/drm/mgag200/mgag200_g200se.c
+++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c
@@ -249,6 +249,9 @@ static int mgag200_g200se_04_pixpllc_atomic_check(struct drm_crtc *crtc,
 		}
 	}

+	if (m == 0)
+		return -EINVAL;
+
 	fvv = pllreffreq * n / m;
 	fvv = (fvv - 800000) / 50000;
 	if (fvv > 15)
--
2.39.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] drm/mgag200: Apply upper limit for clock variable
  2024-11-15 14:14 [PATCH v3] drm/mgag200: Apply upper limit for clock variable Murad Masimov
@ 2024-11-15 14:35 ` Jocelyn Falempe
  0 siblings, 0 replies; 2+ messages in thread
From: Jocelyn Falempe @ 2024-11-15 14:35 UTC (permalink / raw)
  To: Murad Masimov, Dave Airlie
  Cc: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard,
	David Airlie, Simona Vetter, Mathieu Larouche, dri-devel,
	linux-kernel, lvc-project

On 15/11/2024 15:14, Murad Masimov wrote:
> If the value of the clock variable is higher than 800000, the value of the
> variable m, which is used as a divisor, will remain zero, because
> (clock * testp) will be higher than vcomax in every loop iteration, which
> leads to skipping every iteration and leaving variable m unmodified.
> 
> Return -EINVAL just after the loop, if m is still 0.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.

Thanks for this patch.

Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>

> 
> Fixes: e829d7ef9f17 ("drm/mgag200: Add support for a new rev of G200e")
> Signed-off-by: Murad Masimov <m.masimov@maxima.ru>
> ---
>   drivers/gpu/drm/mgag200/mgag200_g200se.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c
> index 7a32d3b1d226..4d65ead63d66 100644
> --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c
> +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c
> @@ -249,6 +249,9 @@ static int mgag200_g200se_04_pixpllc_atomic_check(struct drm_crtc *crtc,
>   		}
>   	}
> 
> +	if (m == 0)
> +		return -EINVAL;
> +
>   	fvv = pllreffreq * n / m;
>   	fvv = (fvv - 800000) / 50000;
>   	if (fvv > 15)
> --
> 2.39.2
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-15 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-15 14:14 [PATCH v3] drm/mgag200: Apply upper limit for clock variable Murad Masimov
2024-11-15 14:35 ` Jocelyn Falempe

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®