Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754308AbdDKKQZ (ORCPT ); Tue, 11 Apr 2017 06:16:25 -0400 Received: from mga01.intel.com ([192.55.52.88]:45426 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752046AbdDKKQV (ORCPT ); Tue, 11 Apr 2017 06:16:21 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,185,1488873600"; d="asc'?scan'208";a="954697922" Date: Tue, 11 Apr 2017 18:13:17 +0800 From: "Du, Changbin" To: Jiri Olsa Cc: "Du, Changbin" , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] perf: fix double free at function perf_hpp__reset_output_field Message-ID: <20170411101317.GA10733@intel.com> References: <20170315021631.31980-1-changbin.du@intel.com> <20170327062255.27309-1-changbin.du@intel.com> <20170404151940.GD12903@kernel.org> <20170410083950.GD25354@krava> <20170410102111.GA6437@intel.com> <20170410113325.GE25354@krava> <20170411030614.GA9155@intel.com> <20170411073545.GA13796@krava> <20170411082550.GA5894@intel.com> <20170411100531.GC21238@krava> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="6c2NcOVqGQ03X4Wi" Content-Disposition: inline In-Reply-To: <20170411100531.GC21238@krava> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2062 Lines: 71 --6c2NcOVqGQ03X4Wi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > > > =20 > > yes, this is an option. But for safety, I sugguest do not rely on list_= del_init. > > No rule rather than create one. > >=20 > > But anyway, both are ok for me. What's your options? >=20 > hum, also I dont think we need to touch that bit at all > if we are going to remove it right away.. how about the > change below? >=20 > jirka >=20 >=20 > --- > diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c > index 5d632dca672a..0ee7db43dd7d 100644 > --- a/tools/perf/ui/hist.c > +++ b/tools/perf/ui/hist.c > @@ -613,15 +613,15 @@ void perf_hpp__reset_output_field(struct perf_hpp_l= ist *list) > =20 > /* reset output fields */ > perf_hpp_list__for_each_format_safe(list, fmt, tmp) { > - list_del_init(&fmt->list); > - list_del_init(&fmt->sort_list); > + list_del(&fmt->list); > + /* Remove the fmt from next loop processing. */ > + list_del(&fmt->sort_list); > fmt_free(fmt); What if the fmt is not linked to sort_list? I see it is possible (please checking perf_hpp__setup_output_field()). I am not sure if we really has sunch case currently, just concern :) > } > =20 > /* reset sort keys */ > perf_hpp_list__for_each_sort_list_safe(list, fmt, tmp) { > - list_del_init(&fmt->list); > - list_del_init(&fmt->sort_list); > + list_del(&fmt->sort_list); > fmt_free(fmt); > } > } --=20 Thanks, Changbin Du --6c2NcOVqGQ03X4Wi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJY7Kw9AAoJEAanuZwLnPNUvesH+gIcXN/WlnMTv8l2X49nZHwi 973Y83VEoyti4VUPnmrH+HEBMhcnkDqwIb1/ZZ9AeY2fCATYLSaYUy97C3aU8g/Y /KQiOj03xhiH4ZS1bxfHvkrLFN145mRY0yzno9EbOCAlLlX65/kvoVJZFH65XVzq 8Nmr8N3oCTwiYQzptlc3W1HD2Hxjg5GhOHpq5INeJuEcU3Ulvl1e28DtHYiom/BE HZF5ga82WIsTbCNVKxLmTAHTbxk60kKJq4MuaulXtWK8QEcTgJXFHBCdJbHBmZek ONB/+lCr6RU/N0JPyvkMyvPFzViVJ4G/RKrOxghrK0AaZQ79pD8I+KMPliihLVE= =QYYL -----END PGP SIGNATURE----- --6c2NcOVqGQ03X4Wi--