Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3438920imu; Sun, 11 Nov 2018 15:06:57 -0800 (PST) X-Google-Smtp-Source: AJdET5cY4l5BVFLA4kkPE05O/tRM4E63UP+M1Mk0UaX8vkvuq05U5GSAL+2iktOOILySnLmWddMc X-Received: by 2002:aa7:8603:: with SMTP id p3-v6mr17918503pfn.247.1541977617458; Sun, 11 Nov 2018 15:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977617; cv=none; d=google.com; s=arc-20160816; b=O8Dq1sevi0J6KjEW0jk5bBJxYPU0yuxdn+zeoLLWlWXCTj02+4QCLuBqFhtTHEWpaL R9yiXw0oGJVlf/8s9uLVEW3+FRV6i+AtNsJS2G9v+XY0SVdngOgpeHsXDt/uM1jdtXEh TbO+K4ulpmWBz7X5DEezgG1egAFT9Abo2ckod+jjYxjicoOiTW47ES7Yr5KDgJxzGiqz h9d7Gm4151xiRUuu+6fC7cOjqwp3pSsBPsMUWBvFPHxw265JBdIBziov6uRsweFjqmqL 27BKCGs6adhyOQ5qZkKMBz9TVHtriJhz1oGLIRad4+9Qlq6YqpFpwJ8Lkp3a8GYna0Lr 5vqw== 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=pn2b4Hmc01ZtU9TP/8qxe4NQPlGLWxz09UQ3wUfTpuQ=; b=My17lie9BPYN4OZ4T6dklzXcz+f16ZEESlU3xtp15AgBmT2L6tZAtg2z6b2Im7HQKL zpRRn+0lkhUoLp8JpXZZHCi0Oo89mZaoEEAhIMldu/kTT0WnqAd3njtOlER6qSUpJV3N NrI2guaJcxPnTbOsfrsf1EvgI9XxLHkJproWtJilw5yfv96APh65pPvSEd//WbjaVe1b vizlxWFzvg5LBfTc4HlIPET0uxJSJLRTtCV0+6KgRdKIvaPfe9D3TGTI0c9mAAt2CoZJ S4hu4P1qGVVcnxkZF3EG2yA8Vgb69+ITAGY2BGhLeV7sbpjdR70B7uitgra7cl/RrLzo gAMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KjSbvQwc; 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 h19si14339656pgb.231.2018.11.11.15.06.42; Sun, 11 Nov 2018 15:06:57 -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=KjSbvQwc; 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 S2390394AbeKLIWN (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:51836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390366AbeKLIWM (ORCPT ); Mon, 12 Nov 2018 03:22:12 -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 30E39224B3; Sun, 11 Nov 2018 22:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975535; bh=0umfxAfnRNxXMuAW+CtMWxftLgRySqbAVloy5B8AQtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KjSbvQwctWkt10DjDxTobHnFxrA9yTPLflvEhOxQHYF1LrCuzs6xk1AadVL6GFFoh zMzYMhZIm53kssvnvlMFg0mJvf06BXf1o9Xr+t8fEbYuRh03DT/5xjSTf4ofwAiG86 toX3s9DLpe54nLveCmmnQbNlcmF2jwo63Nes8yHA= 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.14 050/222] perf strbuf: Match va_{add,copy} with va_end Date: Sun, 11 Nov 2018 14:22:27 -0800 Message-Id: <20181111221652.585159577@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@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.14-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); }