The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "José Expósito" <jose.exposito89@gmail.com>
Cc: airlied@linux.ie, daniel@ffwll.ch, lee.jones@linaro.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/selftests/test-drm_dp_mst_helper: Fix memory leak in sideband_msg_req_encode_decode
Date: Wed, 19 Jan 2022 16:13:33 +0100	[thread overview]
Message-ID: <YegqnfDXHmxUBWxI@phenom.ffwll.local> (raw)
In-Reply-To: <20220108165812.46797-1-jose.exposito89@gmail.com>

On Sat, Jan 08, 2022 at 05:58:12PM +0100, José Expósito wrote:
> Avoid leaking the "out" variable if it is not possible to allocate
> the "txmsg" variable.
> 
> Fixes: 09234b88ef55 ("drm/selftests/test-drm_dp_mst_helper: Move 'sideband_msg_req_encode_decode' onto the heap")
> Addresses-Coverity-ID: 1475685 ("Resource leak")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> 
> ---
> 
> v2: Improve commit message

Applied to drm-misc-next, thanks.
-Daniel

> ---
>  drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> index 6b4759ed6bfd..c491429f1a02 100644
> --- a/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> +++ b/drivers/gpu/drm/selftests/test-drm_dp_mst_helper.c
> @@ -131,8 +131,10 @@ sideband_msg_req_encode_decode(struct drm_dp_sideband_msg_req_body *in)
>  		return false;
>  
>  	txmsg = kzalloc(sizeof(*txmsg), GFP_KERNEL);
> -	if (!txmsg)
> +	if (!txmsg) {
> +		kfree(out);
>  		return false;
> +	}
>  
>  	drm_dp_encode_sideband_req(in, txmsg);
>  	ret = drm_dp_decode_sideband_req(txmsg, out);
> -- 
> 2.25.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

      reply	other threads:[~2022-01-19 15:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08 16:58 [PATCH v2] drm/selftests/test-drm_dp_mst_helper: Fix memory leak in sideband_msg_req_encode_decode José Expósito
2022-01-19 15:13 ` Daniel Vetter [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=YegqnfDXHmxUBWxI@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jose.exposito89@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    /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