Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Bai, Zongyao" <zongyao.bai@intel.com>
To: Shuicheng Lin <shuicheng.lin@intel.com>,
	<intel-xe@lists.freedesktop.org>,
	 <dri-devel@lists.freedesktop.org>
Cc: Riana Tauro <riana.tauro@intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [PATCH] drm/ras: Fix memory leak in doit_reply_value() error path
Date: Thu, 26 Mar 2026 16:08:53 -0700	[thread overview]
Message-ID: <2d569d28-12bf-4f8e-b662-282c9cad0556@intel.com> (raw)
In-Reply-To: <20260307184541.257941-1-shuicheng.lin@intel.com>

LGTM

Reviewed-by: Zongyao Bai <zongyao.bai@intel.com>

On 3/7/2026 10:45 AM, Shuicheng Lin wrote:
> If get_node_error_counter() fails after genlmsg_iput() has succeeded,
> the allocated msg sk_buff is leaked. Refactor the error paths to use
> goto labels, fixing the leak and eliminating duplicate cleanup code.
>
> Fixes: c36218dc49f5 ("drm/ras: Introduce the DRM RAS infrastructure over generic netlink")
> Cc: Riana Tauro <riana.tauro@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com>
> ---
>   drivers/gpu/drm/drm_ras.c | 19 +++++++++++--------
>   1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ras.c b/drivers/gpu/drm/drm_ras.c
> index b2fa5ab86d87..e98a9e74cfd3 100644
> --- a/drivers/gpu/drm/drm_ras.c
> +++ b/drivers/gpu/drm/drm_ras.c
> @@ -195,25 +195,28 @@ static int doit_reply_value(struct genl_info *info, u32 node_id,
>   
>   	hdr = genlmsg_iput(msg, info);
>   	if (!hdr) {
> -		nlmsg_free(msg);
> -		return -EMSGSIZE;
> +		ret = -EMSGSIZE;
> +		goto err_free_msg;
>   	}
>   
>   	ret = get_node_error_counter(node_id, error_id,
>   				     &error_name, &value);
>   	if (ret)
> -		return ret;
> +		goto err_cancel_msg;
>   
>   	ret = msg_reply_value(msg, error_id, error_name, value);
> -	if (ret) {
> -		genlmsg_cancel(msg, hdr);
> -		nlmsg_free(msg);
> -		return ret;
> -	}
> +	if (ret)
> +		goto err_cancel_msg;
>   
>   	genlmsg_end(msg, hdr);
>   
>   	return genlmsg_reply(msg, info);
> +
> +err_cancel_msg:
> +	genlmsg_cancel(msg, hdr);
> +err_free_msg:
> +	nlmsg_free(msg);
> +	return ret;
>   }
>   
>   /**

      parent reply	other threads:[~2026-03-26 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07 18:45 [PATCH] drm/ras: Fix memory leak in doit_reply_value() error path Shuicheng Lin
2026-03-07 18:52 ` ✓ CI.KUnit: success for " Patchwork
2026-03-07 19:38 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-08 10:59 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-03-10  3:34   ` Lin, Shuicheng
2026-03-26 23:08 ` Bai, Zongyao [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=2d569d28-12bf-4f8e-b662-282c9cad0556@intel.com \
    --to=zongyao.bai@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=shuicheng.lin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox