linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikita Shubin <nikita.shubin@maquefel.me>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: "Atish Patra" <atishp@atishpatra.org>,
	"Anup Patel" <anup@brainfault.org>,
	"João Mário Domingos" <joao.mario@tecnico.ulisboa.pt>,
	linux@yadro.com, "Nikita Shubin" <n.shubin@yadro.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v4 2/5] perf tools riscv: Add support for get_cpuid_str function
Date: Sat, 25 Jun 2022 08:28:13 +0300	[thread overview]
Message-ID: <20220625082813.3b70727c@redslave.neermore.group> (raw)
In-Reply-To: <YrXnFAaT/B1In/+t@kernel.org>

Hello Arnaldo!

On Fri, 24 Jun 2022 13:32:20 -0300
Arnaldo Carvalho de Melo <acme@kernel.org> wrote:

> > +	if (mimpid)
> > +		free(mimpid);  
> 
> just use:
> 
> 	
> 	free(mvendorid);
> 	free(marchid);
> 	free(mimpid);
> 
> fewer lines, free() accepts NULL.
> 
> > +
> > +	return cpuid;
> > +}
> > +
> > +int get_cpuid(char *buffer, size_t sz)
> > +{
> > +	char *cpuid = _get_cpuid();
> > +
> > +	if (sz < strlen(cpuid)) {
> > +		free(cpuid);
> > +		return -EINVAL;
> > +	}
> > +
> > +	scnprintf(buffer, sz, "%s", cpuid);  
> 
> You're leaking cpuid here.

Agree with both.

Thank you for pointing it out.

> 
> > +	return 0;
> > +}
> > +
> > +char *
> > +get_cpuid_str(struct perf_pmu *pmu __maybe_unused)
> > +{
> > +	return _get_cpuid();
> > +}
> > -- 
> > 2.35.1  
> 


  reply	other threads:[~2022-06-25  5:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 16:00 [PATCH v4 0/5] RISC-V: Create unique identification for SoC PMU Nikita Shubin
2022-06-24 16:00 ` [PATCH v4 2/5] perf tools riscv: Add support for get_cpuid_str function Nikita Shubin
2022-06-24 16:32   ` Arnaldo Carvalho de Melo
2022-06-25  5:28     ` Nikita Shubin [this message]
2022-06-24 16:00 ` [PATCH v4 3/5] perf arch events: riscv arch std event files Nikita Shubin
2022-06-24 17:01   ` Atish Patra
2022-06-25  5:32     ` Nikita Shubin
2022-06-24 16:00 ` [PATCH v4 4/5] perf arch events: riscv sbi firmware " Nikita Shubin
2022-06-24 16:00 ` [PATCH v4 5/5] perf vendor events riscv: add Sifive U74 JSON file Nikita Shubin
2022-06-24 17:05 ` [PATCH v4 0/5] RISC-V: Create unique identification for SoC PMU Atish Patra
2022-06-25  5:39   ` Nikita Shubin

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=20220625082813.3b70727c@redslave.neermore.group \
    --to=nikita.shubin@maquefel.me \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=atishp@atishpatra.org \
    --cc=joao.mario@tecnico.ulisboa.pt \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@yadro.com \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=n.shubin@yadro.com \
    --cc=namhyung@kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=peterz@infradead.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;
as well as URLs for NNTP newsgroup(s).