All of lore.kernel.org
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>
Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf namespaces: check newns before free
Date: Wed, 4 Sep 2024 21:10:30 -0700	[thread overview]
Message-ID: <ZtkvNsNvIDQkKTFt@google.com> (raw)
In-Reply-To: <20240903091208.7152-1-zhangjiao2@cmss.chinamobile.com>

Hello,

On Tue, Sep 03, 2024 at 05:12:08PM +0800, zhangjiao2 wrote:
> From: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> 
> Since newns can be NULL, check it before free
> 
> Signed-off-by: zhang jiao <zhangjiao2@cmss.chinamobile.com>
> ---
>  tools/perf/util/namespaces.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/namespaces.c b/tools/perf/util/namespaces.c
> index cb185c5659d6..49e20e0a567a 100644
> --- a/tools/perf/util/namespaces.c
> +++ b/tools/perf/util/namespaces.c
> @@ -135,7 +135,8 @@ int nsinfo__init(struct nsinfo *nsi)
>  			       &RC_CHK_ACCESS(nsi)->in_pidns, spath);
>  
>  out:
> -	free(newns);
> +	if (newns)
> +		free(newns);

It's ok to call free(NULL).

Thanks,
Namhyung


>  	return rv;
>  }
>  
> -- 
> 2.33.0
> 
> 
> 

  reply	other threads:[~2024-09-05  4:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-03  9:12 [PATCH] perf namespaces: check newns before free zhangjiao2
2024-09-05  4:10 ` Namhyung Kim [this message]
2024-09-09 14:12 ` Thomas Richter

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=ZtkvNsNvIDQkKTFt@google.com \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=zhangjiao2@cmss.chinamobile.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.