All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Das, Nirmoy" <nirmoy.das@linux.intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH i-g-t] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU
Date: Fri, 20 Jan 2023 15:29:43 +0100	[thread overview]
Message-ID: <46f7db49-eb5c-515f-b450-75cac53d770e@linux.intel.com> (raw)
In-Reply-To: <20230119155428.3260937-1-tvrtko.ursulin@linux.intel.com>

Hi Tvrtko,

On 1/19/2023 4:54 PM, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> Avoid trying to dereference null engines on exit when there are either
> none which are supported, or kernel does not have i915 PMU support.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   tools/intel_gpu_top.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 7aa233570463..517dc2995d26 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -448,6 +448,9 @@ static void free_engines(struct engines *engines)
>   	};
>   	unsigned int i;
>   
> +	if (!engines)
> +		return;
> +


This check should happen before the  struct pmu_counter free_list 
generation.


Regards,

Nirmoy

>   	for (pmu = &free_list[0]; *pmu; pmu++) {
>   		if ((*pmu)->present)
>   			free((char *)(*pmu)->units);
> @@ -2568,7 +2571,7 @@ int main(int argc, char **argv)
>   			"Failed to detect engines! (%s)\n(Kernel 4.16 or newer is required for i915 PMU support.)\n",
>   			strerror(errno));
>   		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_engines;
>   	}
>   
>   	ret = pmu_init(engines);
> @@ -2585,7 +2588,7 @@ int main(int argc, char **argv)
>   "More information can be found at 'Perf events and tool security' document:\n"
>   "https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html\n");
>   		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_pmu;
>   	}
>   
>   	ret = EXIT_SUCCESS;
> @@ -2699,8 +2702,9 @@ int main(int argc, char **argv)
>   		free_clients(clients);
>   
>   	free(codename);
> -err:
> +err_pmu:
>   	free_engines(engines);
> +err_engines:
>   	free(pmu_device);
>   exit:
>   	igt_devices_free();

WARNING: multiple messages have this Message-ID (diff)
From: "Das, Nirmoy" <nirmoy.das@linux.intel.com>
To: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org
Subject: Re: [igt-dev] [Intel-gfx] [PATCH i-g-t] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU
Date: Fri, 20 Jan 2023 15:29:43 +0100	[thread overview]
Message-ID: <46f7db49-eb5c-515f-b450-75cac53d770e@linux.intel.com> (raw)
In-Reply-To: <20230119155428.3260937-1-tvrtko.ursulin@linux.intel.com>

Hi Tvrtko,

On 1/19/2023 4:54 PM, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> Avoid trying to dereference null engines on exit when there are either
> none which are supported, or kernel does not have i915 PMU support.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   tools/intel_gpu_top.c | 10 +++++++---
>   1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
> index 7aa233570463..517dc2995d26 100644
> --- a/tools/intel_gpu_top.c
> +++ b/tools/intel_gpu_top.c
> @@ -448,6 +448,9 @@ static void free_engines(struct engines *engines)
>   	};
>   	unsigned int i;
>   
> +	if (!engines)
> +		return;
> +


This check should happen before the  struct pmu_counter free_list 
generation.


Regards,

Nirmoy

>   	for (pmu = &free_list[0]; *pmu; pmu++) {
>   		if ((*pmu)->present)
>   			free((char *)(*pmu)->units);
> @@ -2568,7 +2571,7 @@ int main(int argc, char **argv)
>   			"Failed to detect engines! (%s)\n(Kernel 4.16 or newer is required for i915 PMU support.)\n",
>   			strerror(errno));
>   		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_engines;
>   	}
>   
>   	ret = pmu_init(engines);
> @@ -2585,7 +2588,7 @@ int main(int argc, char **argv)
>   "More information can be found at 'Perf events and tool security' document:\n"
>   "https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html\n");
>   		ret = EXIT_FAILURE;
> -		goto err;
> +		goto err_pmu;
>   	}
>   
>   	ret = EXIT_SUCCESS;
> @@ -2699,8 +2702,9 @@ int main(int argc, char **argv)
>   		free_clients(clients);
>   
>   	free(codename);
> -err:
> +err_pmu:
>   	free_engines(engines);
> +err_engines:
>   	free(pmu_device);
>   exit:
>   	igt_devices_free();

  parent reply	other threads:[~2023-01-20 14:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-19 15:54 [Intel-gfx] [PATCH i-g-t] intel_gpu_top: Fix cleanup on old kernels / unsupported GPU Tvrtko Ursulin
2023-01-19 15:54 ` [igt-dev] " Tvrtko Ursulin
2023-01-19 16:18 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2023-01-20 13:53 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2023-01-20 14:29 ` Das, Nirmoy [this message]
2023-01-20 14:29   ` [igt-dev] [Intel-gfx] [PATCH i-g-t] " Das, Nirmoy
2023-01-23 10:24   ` Tvrtko Ursulin
2023-01-23 10:24     ` [igt-dev] " Tvrtko Ursulin
2023-01-23 11:09     ` Das, Nirmoy
2023-01-23 11:09       ` [igt-dev] " Das, Nirmoy
2023-01-23 11:13       ` Das, Nirmoy
2023-01-23 11:13         ` [igt-dev] " Das, Nirmoy
2023-01-23 11:15 ` Das, Nirmoy
2023-01-23 11:15   ` [igt-dev] " Das, Nirmoy
2023-01-23 11:31 ` [Intel-gfx] [PATCH i-g-t v2] " Tvrtko Ursulin
2023-01-23 11:31   ` [igt-dev] " Tvrtko Ursulin
2023-01-23 14:48 ` [igt-dev] ✓ Fi.CI.BAT: success for intel_gpu_top: Fix cleanup on old kernels / unsupported GPU (rev2) Patchwork
2023-01-24  2:53 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46f7db49-eb5c-515f-b450-75cac53d770e@linux.intel.com \
    --to=nirmoy.das@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tvrtko.ursulin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.