On Fri, 2021-11-19 at 12:59 +0000, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursu...@intel.com>
> 
> Adding a cross-check with ABI config name space and not just relying
> on
> sysfs names.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursu...@intel.com>
> Cc: Dmitry Rogozhkin <dmitry.v.rogozh...@intel.com>
> ---
>  tools/intel_gpu_top.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 41c59a72c09d..81c724d1fe1c 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -376,6 +376,12 @@ static struct engines *discover_engines(char
> *device)
>                       break;
>               }
>  
> +             /* Double check config is an engine config. */
> +             if (engine->busy.config >= __I915_PMU_OTHER(0)) {
> +                     free((void *)engine->name);
> +                     continue;
> +             }
> +
>               engine->class = (engine->busy.config &
>                                (__I915_PMU_OTHER(0) - 1)) >>
>                               I915_PMU_CLASS_SHIFT;

This works for me.
Acked-by: Dmitry Rogozhkin <dmitry.v.rogozh...@intel.com>

However, looking to the existing code down below the place where you've
added a fix, it seems to me that 'free((void *)engine->name)' might be
missing on a number of other error paths and on non-error exit path as
well.

Reply via email to