From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761006AbcALHG0 (ORCPT ); Tue, 12 Jan 2016 02:06:26 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:56094 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbcALHGZ (ORCPT ); Tue, 12 Jan 2016 02:06:25 -0500 Message-ID: <5694A54B.3090209@huawei.com> Date: Tue, 12 Jan 2016 15:03:39 +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: Arnaldo Carvalho de Melo CC: , , , , , Jiri Olsa , Masami Hiramatsu , Namhyung Kim Subject: Re: [PATCH 13/53] perf tools: Prevent calling machine__delete() on non-allocated machine References: <1452520124-2073-1-git-send-email-wangnan0@huawei.com> <1452520124-2073-14-git-send-email-wangnan0@huawei.com> <20160111154202.GE18367@kernel.org> In-Reply-To: <20160111154202.GE18367@kernel.org> 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.0A090204.5694A5E4.003F,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: 34bef0450bae1d3f5f34d63e726e1a2e Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/11 23:42, Arnaldo Carvalho de Melo wrote: > Em Mon, Jan 11, 2016 at 01:48:04PM +0000, Wang Nan escreveu: >> To prevent futher commits calling machine__delete() on non-allocated >> 'struct machine' (which would cause memory corruption), this patch >> enforces machine__init(), record whether a machine structure is >> dynamically allocated or not, and warn if machine__delete() is called >> on incorrect object. > Not sure on this one, I think I voiced this before, this seems like > something to be tested using some static analysis tool or even checking > if the address for the struct hitting machine__delete() is from malloc > or not. > > I.e. if we do it here, we may have to do it to any other struct where we > allocate it in the stack or via malloc, and furthermore there are cases > where we embed a struct in another, when we would free just the main > struct but not the second, embedded one, that would need just calling > foo__exit() and not foo__delete(). > > - Arnaldo > OK. Let's drop this one. Thank you.