From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753909AbdFMSzO (ORCPT ); Tue, 13 Jun 2017 14:55:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46012 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753886AbdFMSzN (ORCPT ); Tue, 13 Jun 2017 14:55:13 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E8FE67EAB Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6E8FE67EAB Date: Tue, 13 Jun 2017 20:54:54 +0200 From: Jiri Olsa To: David Carrillo-Cisneros Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Andi Kleen , Simon Que , Wang Nan , Jiri Olsa , He Kuang , Masami Hiramatsu , Stephane Eranian , Paul Turner Subject: Re: [PATCH v4 15/16] perf tools: add feature header record to pipe-mode Message-ID: <20170613185454.GE6092@krava> References: <20170613042932.141842-1-davidcc@google.com> <20170613042932.141842-16-davidcc@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170613042932.141842-16-davidcc@google.com> User-Agent: Mutt/1.8.0 (2017-02-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 13 Jun 2017 18:54:57 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 12, 2017 at 09:29:31PM -0700, David Carrillo-Cisneros wrote: SNIP > > void perf_event__print_totals(void); > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index ddfaf157913d..6f6a54c15cb0 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -34,6 +34,7 @@ > #include "data.h" > #include > #include "asm/bug.h" > +#include "tool.h" > > #include "sane_ctype.h" > > @@ -97,11 +98,14 @@ static int __do_write_buf(struct feat_fd *ff, const void *buf, size_t size) > > retry: > if (size > (ff->size - ff->offset)) { > - addr = realloc(ff->buf, ff->size << 1); > + size = ff->size << 1; > + if (size > page_size) event size could be 0xffff - sizeof(struct perf_event_header) also the initial size is most likely > page_size anyway please put this into the patch that introduced __do_write_buf jirka