From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Sanskriti Sharma <sansharm@redhat.com>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@redhat.com>,
Joe Lawrence <joe.lawrence@redhat.com>,
acme@kernel.org
Subject: Re: [PATCH 1/5] perf strbuf: match va_{add,copy} with va_end
Date: Tue, 2 Oct 2018 12:45:13 -0300 [thread overview]
Message-ID: <20181002154513.GB9457@redhat.com> (raw)
In-Reply-To: <1538490554-8161-2-git-send-email-sansharm@redhat.com>
Em Tue, Oct 02, 2018 at 10:29:10AM -0400, Sanskriti Sharma escreveu:
> Ensure that all code paths in strbuf_addv() call va_end() on the
> ap_saved copy that was made.
>
> Fixes the following coverity complaint:
>
> Error: VARARGS (CWE-237): [#def683]
> tools/perf/util/strbuf.c:106: missing_va_end: va_end was not called
> for "ap_saved".
Thanks, applied to perf/core
- Arnaldo
> Signed-off-by: Sanskriti Sharma <sansharm@redhat.com>
> ---
> tools/perf/util/strbuf.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
> index 3d1cf5b..9005fbe 100644
> --- a/tools/perf/util/strbuf.c
> +++ b/tools/perf/util/strbuf.c
> @@ -98,19 +98,25 @@ static int strbuf_addv(struct strbuf *sb, const char *fmt, va_list ap)
>
> va_copy(ap_saved, ap);
> len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap);
> - if (len < 0)
> + if (len < 0) {
> + va_end(ap_saved);
> return len;
> + }
> if (len > strbuf_avail(sb)) {
> ret = strbuf_grow(sb, len);
> - if (ret)
> + if (ret) {
> + va_end(ap_saved);
> return ret;
> + }
> len = vsnprintf(sb->buf + sb->len, sb->alloc - sb->len, fmt, ap_saved);
> va_end(ap_saved);
> if (len > strbuf_avail(sb)) {
> pr_debug("this should not happen, your vsnprintf is broken");
> + va_end(ap_saved);
> return -EINVAL;
> }
> }
> + va_end(ap_saved);
> return strbuf_setlen(sb, sb->len + len);
> }
>
> --
> 1.8.3.1
next prev parent reply other threads:[~2018-10-02 15:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 14:29 [PATCH 0/5] perf tool: small coverity clean ups Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 1/5] perf strbuf: match va_{add,copy} with va_end Sanskriti Sharma
2018-10-02 15:45 ` Arnaldo Carvalho de Melo [this message]
2018-10-09 5:29 ` [tip:perf/core] perf strbuf: Match " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 2/5] perf tools: cleanup trace-event-info 'tdata' leak Sanskriti Sharma
2018-10-02 15:47 ` Arnaldo Carvalho de Melo
2018-10-09 5:29 ` [tip:perf/core] perf tools: Cleanup " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 3/5] perf tools: free 'printk' string in parse_ftrace_printk() Sanskriti Sharma
2018-10-02 15:47 ` Arnaldo Carvalho de Melo
2018-10-09 5:30 ` [tip:perf/core] perf tools: Free " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 4/5] perf tools: avoid double free in read_event_file() Sanskriti Sharma
2018-10-02 15:48 ` Arnaldo Carvalho de Melo
2018-10-09 5:31 ` [tip:perf/core] perf tools: Avoid " tip-bot for Sanskriti Sharma
2018-10-02 14:29 ` [PATCH 5/5] perf tools: free temporary 'sys' string in read_event_files() Sanskriti Sharma
2018-10-02 15:50 ` Arnaldo Carvalho de Melo
2018-10-09 5:31 ` [tip:perf/core] perf tools: Free " tip-bot for Sanskriti Sharma
2018-10-02 16:02 ` [PATCH 0/5] perf tool: small coverity clean ups Jiri Olsa
2018-10-02 16:14 ` Arnaldo Carvalho de Melo
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=20181002154513.GB9457@redhat.com \
--to=acme@redhat.com \
--cc=acme@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sansharm@redhat.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;
as well as URLs for NNTP newsgroup(s).