Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754502AbbLPBhz (ORCPT ); Tue, 15 Dec 2015 20:37:55 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:2775 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306AbbLPBhy (ORCPT ); Tue, 15 Dec 2015 20:37:54 -0500 Message-ID: <5670C04E.3080802@huawei.com> Date: Wed, 16 Dec 2015 09:37:18 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jiri Olsa CC: , , , , , , Arnaldo Carvalho de Melo , Namhyung Kim Subject: Re: [PATCH v5 02/14] perf tools: Prevent calling machine__delete() on non-allocated machine References: <1450089563-122430-1-git-send-email-wangnan0@huawei.com> <1450089563-122430-3-git-send-email-wangnan0@huawei.com> <20151215123658.GC20514@krava.brq.redhat.com> In-Reply-To: <20151215123658.GC20514@krava.brq.redhat.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5670C05D.016C,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d57fe1b795a9322872fd0a38ee25a6fd Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1078 Lines: 39 On 2015/12/15 20:36, Jiri Olsa wrote: > On Mon, Dec 14, 2015 at 10:39:11AM +0000, Wang Nan wrote: > > SNIP > >> @@ -137,12 +138,15 @@ void machine__exit(struct machine *machine) >> void machine__delete(struct machine *machine) >> { >> machine__exit(machine); >> - free(machine); >> + if (machine->allocated) >> + free(machine); >> + else >> + pr_warning("WARNING: delete a non-allocated machine. Skip.\n"); > we used WARN_ONCE several times already in similar cases > > jirka Will switch to: @@ -136,13 +138,13 @@ void machine__exit(struct machine *machine) void machine__delete(struct machine *machine) { - machine__exit(machine); - free(machine); + WARN_ONCE((machine->allocated ? free(machine), 0 : -1), + "WARNING: deleting a non-allocated machine. Skip.\n"); } Thank you. -- 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/