From: Thomas Richter <tmricht@linux.ibm.com>
To: zhangjiao2 <zhangjiao2@cmss.chinamobile.com>, peterz@infradead.org
Cc: mingo@redhat.com, acme@kernel.org, namhyung@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf namespaces: check newns before free
Date: Mon, 9 Sep 2024 16:12:02 +0200 [thread overview]
Message-ID: <b2d634a5-0a28-4044-b654-74607c457dab@linux.ibm.com> (raw)
In-Reply-To: <20240903091208.7152-1-zhangjiao2@cmss.chinamobile.com>
On 9/3/24 11:12, 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);
> return rv;
> }
>
Ins't zfree() to proper function to use? Also zfree() calls free()
from the C library which can handle a NULL pointer?
Just my opinion.
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany
--
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
prev parent reply other threads:[~2024-09-09 14:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-03 9:12 zhangjiao2
2024-09-05 4:10 ` Namhyung Kim
2024-09-09 14:12 ` Thomas Richter [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=b2d634a5-0a28-4044-b654-74607c457dab@linux.ibm.com \
--to=tmricht@linux.ibm.com \
--cc=acme@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®