Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3487824imu; Sun, 11 Nov 2018 16:13:16 -0800 (PST) X-Google-Smtp-Source: AJdET5dAmXaQtS2/0Nn5LCIE+Kl/BHR49cs+7uXFMX5RCjtq/zBUGRioCYjGzsTDcz4CbST5EI0Z X-Received: by 2002:a63:5d55:: with SMTP id o21mr15321336pgm.92.1541981596261; Sun, 11 Nov 2018 16:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981596; cv=none; d=google.com; s=arc-20160816; b=LNWCDt6L3Dz42rQvfWinbUPjwsSXvhDcm6VCEKqDyT7u8FlUyAu0aFHxb2r2KBMmOC Dg+iglwavwha0EvUUidVFjIs4mAXkBeBqig8TrVt+U8gAUCFbXsRvR+aMqwdkrm839kg fScybLrPEoueA3yaBLmjSSbRDdyM6rktRZfIvrxja+s7UaS1L3LQB9mu4i44/2KLbjY2 rOX8hxgUMF1axYdenpfM3rXVXcAqpgOota4iUTCU/CauEvxUjHEz5mnoECiipBDRyS1V OqUfPIIHahH7McHK/eAd+ABFoptUCwd2PQUAB8Q6VG8rXrhvfCBxc2zb+h4ZVQmcdy4L tGQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=65Bdpc2NsvYPTsn7a4qZNORKr91sXtUEd3LuSDdfS0E=; b=d1g0la+6LlFhjQnFmEjQC85NwxZRkQrsJfgrSyyQW72D55/PmvlxEWXpA3pk9U6UQB T/u84E91j3UaeBmCw8b9iyhcMtoKXe74o0ct19BNB1fj/CMZ0MvjTup0dQbawzAKNzml CYh1HlDJoKPtjOukFwDFvzoXzl4ISoRuz/LhKZCbgHEWsldO2VTHHDnYxEzsHbVW+vq9 XQTDFl1D4jUifCbtmjpGtZcQ7UCJdqkO/kL9iPrR+vYMV+gkt0Z6KtTK+G4vaEEoKLMz /yyN2kItEv457I4F8+4Gi5dQiHWlXe+jUC80No3Y1F0ipyEWYAa/Tg627acv91pA9C+q nq9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dEZ1IC77; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d189si4575641pgc.393.2018.11.11.16.13.01; Sun, 11 Nov 2018 16:13:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dEZ1IC77; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731304AbeKLKBx (ORCPT + 99 others); Mon, 12 Nov 2018 05:01:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:60706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730601AbeKLIRW (ORCPT ); Mon, 12 Nov 2018 03:17:22 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8BE65208A3; Sun, 11 Nov 2018 22:27:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975246; bh=j3JN7QI56ABj/bA4OfriFR3EeislfXctw8H2E05+acM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dEZ1IC77PLUsQaEpxAmMpDx7Ksjq89WL9trcCqu240RECveonBPNIdNubPIblFQxU AUBlrt7yYwjvaT/m7XP+M16y7EV5lWsqDPPzFPuQ41RJVM7/B+gXMEJoJqoe3IcQ+3 an8YDqfY4NGT6eSBl3XcU2vhiiPEGchG16DhOmbs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sanskriti Sharma , Jiri Olsa , Joe Lawrence , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 067/361] perf strbuf: Match va_{add,copy} with va_end Date: Sun, 11 Nov 2018 14:16:54 -0800 Message-Id: <20181111221629.441014188@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sanskriti Sharma [ Upstream commit ce49d8436cffa9b7a6a5f110879d53e89dbc6746 ] 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". Signed-off-by: Sanskriti Sharma Reviewed-by: Jiri Olsa Cc: Joe Lawrence Link: http://lkml.kernel.org/r/1538490554-8161-2-git-send-email-sansharm@redhat.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/strbuf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c @@ -98,19 +98,25 @@ static int strbuf_addv(struct strbuf *sb 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); }