Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161592AbbKTBqa (ORCPT ); Thu, 19 Nov 2015 20:46:30 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:49900 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753420AbbKTBq3 convert rfc822-to-8bit (ORCPT ); Thu, 19 Nov 2015 20:46:29 -0500 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.203 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Fri, 20 Nov 2015 10:46:22 +0900 From: Namhyung Kim To: =?utf-8?B?5bmz5p2+6ZuF5bezIC8gSElSQU1BVFXvvIxNQVNBTUk=?= CC: Arnaldo Carvalho de Melo , Peter Zijlstra , "linux-kernel@vger.kernel.org" , Adrian Hunter , Ingo Molnar , Jiri Olsa Subject: Re: [PATCH perf/core 01/13] perf probe: Fix to free temporal Dwarf_Frame Message-ID: <20151120014622.GE23310@sejong> References: <20151118064009.30709.74354.stgit@localhost.localdomain> <20151118064011.30709.65674.stgit@localhost.localdomain> <20151118223639.GB22729@kernel.org> <50399556C9727B4D88A595C8584AAB3752624A21@GSjpTKYDCembx32.service.hitachi.net> MIME-Version: 1.0 In-Reply-To: <50399556C9727B4D88A595C8584AAB3752624A21@GSjpTKYDCembx32.service.hitachi.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/11/20 10:46:24, Serialize by Router on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2015/11/20 10:46:24 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2693 Lines: 82 Hi Masami, On Thu, Nov 19, 2015 at 03:12:37AM +0000, 平松雅巳 / HIRAMATU,MASAMI wrote: > From: Namhyung Kim [mailto:namhyung@gmail.com] > >On November 19, 2015 7:36:39 AM GMT+09:00, Arnaldo Carvalho de Melo wrote: > >>Em Wed, Nov 18, 2015 at 03:40:12PM +0900, Masami Hiramatsu escreveu: > >>> Since dwarf_cfi_addrframe returns malloc'd Dwarf_Frame > >>> object, it has to be freed after used. > >> > >>Applied to perf/urgent > >> > >>> Signed-off-by: Masami Hiramatsu > >>> --- > >>> tools/perf/util/probe-finder.c | 9 ++++++--- > >>> 1 file changed, 6 insertions(+), 3 deletions(-) > >>> > >>> diff --git a/tools/perf/util/probe-finder.c > >>b/tools/perf/util/probe-finder.c > >>> index 63993d7..4d7d4f4 100644 > >>> --- a/tools/perf/util/probe-finder.c > >>> +++ b/tools/perf/util/probe-finder.c > >>> @@ -683,21 +683,24 @@ static int call_probe_finder(Dwarf_Die *sc_die, > >>struct probe_finder *pf) > >>> ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, > >>&nops, 1); > >>> if (ret <= 0 || nops == 0) { > >>> pf->fb_ops = NULL; > >>> + ret = 0; > >>> #if _ELFUTILS_PREREQ(0, 142) > >>> } else if (nops == 1 && pf->fb_ops[0].atom == DW_OP_call_frame_cfa > >>&& > >>> pf->cfi != NULL) { > >>> - Dwarf_Frame *frame; > >>> + Dwarf_Frame *frame = NULL; > >>> if (dwarf_cfi_addrframe(pf->cfi, pf->addr, &frame) != 0 || > >>> dwarf_frame_cfa(frame, &pf->fb_ops, &nops) != 0) { > > > >What if dwarf_cfi_addrframe() succeeded but > >dwarf_frame_cfa() failed? It seems that the frame > >still can be leaked.. > > No, it is also caught by free(). Please see below, > > > >>> pr_warning("Failed to get call frame on 0x%jx\n", > >>> (uintmax_t)pf->addr); > >>> - return -ENOENT; > >>> + ret = -ENOENT; > > I've replaced "return -ENOENT" with "ret = -ENOENT", so this fall down Ah, missed that. Thank you. Namhyung > > >>> } > >>> + free(frame); > > and free the frame :) (and if frame == NULL, it is just ignored) > > Thank you! > > > >>> #endif > >>> } > >>> > >>> /* Call finder's callback handler */ > >>> - ret = pf->callback(sc_die, pf); > >>> + if (ret >= 0) > >>> + ret = pf->callback(sc_die, pf); > >>> > >>> /* *pf->fb_ops will be cached in libdw. Don't free it. */ > >>> pf->fb_ops = NULL; > > > >Hi Arnaldo and Masami, > >-- > >Sent from my Android device with K-9 Mail. Please excuse my brevity. -- 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/