Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: <yaolu@kylinos.cn>
Cc: <matthew.brost@intel.com>, <thomas.hellstrom@linux.intel.com>,
	<umesh.nerlige.ramappa@intel.com>, <jose.souza@intel.com>,
	<ashutosh.dixit@intel.com>, <intel-xe@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/xe/oa: Remove sysfs entry on idr_alloc failure in xe_oa_add_config_ioctl()
Date: Fri, 28 Aug 2026 11:50:25 -0400	[thread overview]
Message-ID: <apGuQY7vZRIUZghZ@intel.com> (raw)
In-Reply-To: <20260828060812.163548-1-yaolu@kylinos.cn>

On Fri, Aug 28, 2026 at 02:08:12PM +0800, yaolu@kylinos.cn wrote:
> From: Lu Yao <yaolu@kylinos.cn>
> 
> If idr_alloc() fails after create_dynamic_oa_sysfs_entry() has
> succeeded, the error path frees the OA config without removing the
> metrics sysfs group.
> 
> Remove the sysfs group before releasing the config, and fix up the
> misleading error message copied from the sysfs creation failure path.
> 
> Fixes: cdf02fe1a94a ("drm/xe/oa/uapi: Add/remove OA config perf ops")
> Signed-off-by: Lu Yao <yaolu@kylinos.cn>
> ---
>  drivers/gpu/drm/xe/xe_oa.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> index 9c5384b95c63..73e51db13f56 100644
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
> @@ -2435,8 +2435,9 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
>  
>  	oa_config->id = idr_alloc(&oa->metrics_idr, oa_config, 1, 0, GFP_KERNEL);
>  	if (oa_config->id < 0) {
> -		drm_dbg(&oa->xe->drm, "Failed to create sysfs entry for OA config\n");
> +		drm_dbg(&oa->xe->drm, "Failed to allocate id for OA config\n");
>  		err = oa_config->id;
> +		sysfs_remove_group(oa->metrics_kobj, &oa_config->sysfs_metric);

good catch, but instead of adding this removal here, could you please
create a new goto so the error handling keeps consistent?

something like:

-		drm_dbg(&oa->xe->drm, "Failed to create sysfs entry for OA config\n");
+		drm_dbg(&oa->xe->drm, "Failed to allocate id for OA config\n");
  		err = oa_config->id;
-		goto sysfs_err;
+		goto id_alloc_err;

...

+id_alloc_err:
+		sysfs_remove_group(oa->metrics_kobj, &oa_config->sysfs_metric);
sysfs_err:

>  		goto sysfs_err;
>  	}
>  
> -- 
> 2.25.1
> 

      parent reply	other threads:[~2026-08-28 15:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  6:08 [PATCH] drm/xe/oa: Remove sysfs entry on idr_alloc failure in xe_oa_add_config_ioctl() yaolu
2026-08-28  6:18 ` sashiko-bot
2026-08-28 12:55 ` ✓ CI.KUnit: success for " Patchwork
2026-08-28 13:35 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-28 14:42 ` ✓ Xe.CI.FULL: " Patchwork
2026-08-28 15:50 ` Rodrigo Vivi [this message]

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=apGuQY7vZRIUZghZ@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=ashutosh.dixit@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jose.souza@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=thomas.hellstrom@linux.intel.com \
    --cc=umesh.nerlige.ramappa@intel.com \
    --cc=yaolu@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox