From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754957AbbJGQLo (ORCPT ); Wed, 7 Oct 2015 12:11:44 -0400 Received: from mail-ig0-f169.google.com ([209.85.213.169]:36839 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754296AbbJGQLm (ORCPT ); Wed, 7 Oct 2015 12:11:42 -0400 Subject: Re: [PATCH v9 1/4] perf,kvm/{x86,s390}: Remove dependency on uapi/kvm_perf.h To: Hemant Kumar , linux-kernel@vger.kernel.org References: <1444184711-8559-1-git-send-email-hemant@linux.vnet.ibm.com> Cc: linuxppc-dev@lists.ozlabs.org, acme@kernel.org, scottwood@freescale.com, sukadev@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com, mpe@ellerman.id.au, paulus@samba.org, mingo@redhat.com, yarygin@linux.vnet.ibm.com, borntraeger@de.ibm.com, srikar@linux.vnet.ibm.com From: David Ahern Message-ID: <5615443F.7030909@gmail.com> Date: Wed, 7 Oct 2015 10:11:43 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1444184711-8559-1-git-send-email-hemant@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/6/15 8:25 PM, Hemant Kumar wrote: > @@ -358,7 +357,12 @@ static bool handle_end_event(struct perf_kvm_stat *kvm, > time_diff = sample->time - time_begin; > > if (kvm->duration && time_diff > kvm->duration) { > - char decode[DECODE_STR_LEN]; > + char *decode = zalloc(decode_str_len); decode can still be a stack variable even with variable length. > + > + if (!decode) { > + pr_err("Not enough memory\n"); > + return false; > + } > > kvm->events_ops->decode_key(kvm, &event->key, decode); > if (!skip_event(decode)) { > @@ -366,6 +370,7 @@ static bool handle_end_event(struct perf_kvm_stat *kvm, > sample->time, sample->pid, vcpu_record->vcpu_id, > decode, time_diff/1000); > } > + free(decode); > } > > return update_kvm_event(event, vcpu, time_diff); > @@ -386,7 +391,8 @@ struct vcpu_event_record *per_vcpu_record(struct thread *thread, -----8<----- > @@ -575,7 +581,7 @@ static void show_timeofday(void) > > static void print_result(struct perf_kvm_stat *kvm) > { > - char decode[DECODE_STR_LEN]; > + char *decode; and a stack variable here too. David