dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative.
@ 2021-12-10  4:41 Harshit Mogalapalli
  2021-12-10 17:25 ` Lucas De Marchi
  0 siblings, 1 reply; 2+ messages in thread
From: Harshit Mogalapalli @ 2021-12-10  4:41 UTC (permalink / raw)
  Cc: dri-devel, Tvrtko Ursulin, Anusha Srivatsa, David Airlie,
	Lucas De Marchi, intel-gfx, kernel-janitors, linux-kernel,
	Chris Wilson, José Roberto de Souza, harshit.m.mogalapalli,
	Rodrigo Vivi, dan.carpenter

smatch warning:
drivers/gpu/drm/i915/display/intel_dmc.c:601 parse_dmc_fw() warn:
unsigned 'fw->size - offset' is never less than zero

Firmware size is size_t and offset is u32. So the subtraction is
unsigned which can never be less than zero.

Fixes: 3d5928a168a9 ("drm/i915/xelpd: Pipe A DMC plugging")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
 drivers/gpu/drm/i915/display/intel_dmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
index 0cab18f972d1..2f477c298b00 100644
--- a/drivers/gpu/drm/i915/display/intel_dmc.c
+++ b/drivers/gpu/drm/i915/display/intel_dmc.c
@@ -598,7 +598,7 @@ static void parse_dmc_fw(struct drm_i915_private *dev_priv,
 			continue;
 
 		offset = readcount + dmc->dmc_info[id].dmc_offset * 4;
-		if (fw->size - offset < 0) {
+		if (offset > fw->size) {
 			drm_err(&dev_priv->drm, "Reading beyond the fw_size\n");
 			continue;
 		}
-- 
2.27.0


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

* Re: [PATCH] drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative.
  2021-12-10  4:41 [PATCH] drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative Harshit Mogalapalli
@ 2021-12-10 17:25 ` Lucas De Marchi
  0 siblings, 0 replies; 2+ messages in thread
From: Lucas De Marchi @ 2021-12-10 17:25 UTC (permalink / raw)
  To: Harshit Mogalapalli
  Cc: Tvrtko Ursulin, Anusha Srivatsa, David Airlie, intel-gfx,
	kernel-janitors, linux-kernel, dri-devel, Chris Wilson,
	José Roberto de Souza, Rodrigo Vivi, dan.carpenter

On Thu, Dec 09, 2021 at 08:41:24PM -0800, Harshit Mogalapalli wrote:
>smatch warning:
>drivers/gpu/drm/i915/display/intel_dmc.c:601 parse_dmc_fw() warn:
>unsigned 'fw->size - offset' is never less than zero
>
>Firmware size is size_t and offset is u32. So the subtraction is
>unsigned which can never be less than zero.
>
>Fixes: 3d5928a168a9 ("drm/i915/xelpd: Pipe A DMC plugging")
>Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

"s|drm: i915: display: Fixes|drm/i915/display: Fix|" in the subject,
that I will do when applying after we have the CI results.

thanks
Lucas De Marchi

>---
> drivers/gpu/drm/i915/display/intel_dmc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
>index 0cab18f972d1..2f477c298b00 100644
>--- a/drivers/gpu/drm/i915/display/intel_dmc.c
>+++ b/drivers/gpu/drm/i915/display/intel_dmc.c
>@@ -598,7 +598,7 @@ static void parse_dmc_fw(struct drm_i915_private *dev_priv,
> 			continue;
>
> 		offset = readcount + dmc->dmc_info[id].dmc_offset * 4;
>-		if (fw->size - offset < 0) {
>+		if (offset > fw->size) {
> 			drm_err(&dev_priv->drm, "Reading beyond the fw_size\n");
> 			continue;
> 		}
>-- 
>2.27.0
>

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

end of thread, other threads:[~2021-12-10 17:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10  4:41 [PATCH] drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative Harshit Mogalapalli
2021-12-10 17:25 ` Lucas De Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).