Message ID | 20211210044129.12422-1-harshit.m.mogalapalli@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm: i915: display: intel_dmc: Fixes an unsigned subtraction which can never be negative. | expand |
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 >
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; }
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(-)