Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753083AbbB0N5d (ORCPT ); Fri, 27 Feb 2015 08:57:33 -0500 Received: from mail.kernel.org ([198.145.29.136]:40763 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750777AbbB0N5c (ORCPT ); Fri, 27 Feb 2015 08:57:32 -0500 Date: Fri, 27 Feb 2015 10:57:27 -0300 From: Arnaldo Carvalho de Melo To: Yunlong Song Cc: a.p.zijlstra@chello.nl, paulus@samba.org, mingo@redhat.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com Subject: Re: [PATCH v3 1/7] perf list: Sort the output of 'perf list' to view more clearly Message-ID: <20150227135727.GH13373@kernel.org> References: <1425032491-20224-1-git-send-email-yunlong.song@huawei.com> <1425032491-20224-2-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1425032491-20224-2-git-send-email-yunlong.song@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1549 Lines: 48 Em Fri, Feb 27, 2015 at 06:21:25PM +0800, Yunlong Song escreveu: > Sort the output according to ASCII character list (using strcmp), which > supports both number sequence and alphabet sequence. That is a great feature to have, thanks! But you are not calling closedir() if zalloc fails, I am fixing that for you this time, please check those kinds of things in the future. - Arnaldo > @@ -1100,11 +1108,21 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob, > struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; > char evt_path[MAXPATHLEN]; > char dir_path[MAXPATHLEN]; > + char **evt_list = NULL; > + unsigned int evt_i = 0, evt_num = 0; > + bool evt_num_known = false; > > +restart: > sys_dir = opendir(tracing_events_path); > if (!sys_dir) > return; > > + if (evt_num_known) { > + evt_list = zalloc(sizeof(char *) * evt_num); > + if (!evt_list) > + goto out_enomem; Here, zalloc fails, goto out_enomem, closedir() not called. > +out_free: > + evt_num = evt_i; > + for (evt_i = 0; evt_i < evt_num; evt_i++) > + zfree(&evt_list[evt_i]); > + zfree(&evt_list); > + return; > + > +out_enomem: > + printf("FATAL: not enough memory to print %s\n", > + event_type_descriptors[PERF_TYPE_TRACEPOINT]); > + if (evt_list) > + goto out_free; > } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/