[Intel-gfx] [PATCH] drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative.

Lucas De Marchi lucas.demarchi at intel.com
Fri Dec 10 17:25:05 UTC 2021


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 at oracle.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi at 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
>


More information about the Intel-gfx mailing list