From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5477BC43381 for ; Fri, 8 Mar 2019 16:45:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 191A120868 for ; Fri, 8 Mar 2019 16:45:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="G5SgHjap"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="fvF2bW2+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbfCHQp5 (ORCPT ); Fri, 8 Mar 2019 11:45:57 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:52282 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726342AbfCHQp4 (ORCPT ); Fri, 8 Mar 2019 11:45:56 -0500 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.27/8.16.0.27) with SMTP id x28Gj08a014006; Fri, 8 Mar 2019 08:45:33 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=URk0M5zweLCmh5WyFJV/z38q4sd3jnhWJgA5jtYk2SI=; b=G5SgHjapy7jYl3hE9doNatH4AAZ8yLM+47WDTxDG9msbP4s61eddZGQiFCiAakLQ4FUb vmGNiNQNou+x+IUtxpspWWxpi8LG7bJB5SqY/mPCC6Osil5Im74ofSYvEQFiw0GwJVCE 1bsUjx2ALjfUUplqTC1uVHtxmdyj0bqcLRc= Received: from maileast.thefacebook.com ([199.201.65.23]) by m0089730.ppops.net with ESMTP id 2r3t1b8ehe-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 08 Mar 2019 08:45:33 -0800 Received: from frc-mbx05.TheFacebook.com (2620:10d:c0a1:f82::29) by frc-hub02.TheFacebook.com (2620:10d:c021:18::172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 8 Mar 2019 08:45:29 -0800 Received: from frc-hub02.TheFacebook.com (2620:10d:c021:18::172) by frc-mbx05.TheFacebook.com (2620:10d:c0a1:f82::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 8 Mar 2019 08:45:29 -0800 Received: from NAM03-CO1-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Fri, 8 Mar 2019 08:45:29 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=URk0M5zweLCmh5WyFJV/z38q4sd3jnhWJgA5jtYk2SI=; b=fvF2bW2+dIDi78ubevLePqqmHF492SFL+U9viZAU/laA447cpdsAF6jTDe/+wHSWrpp7zqjUDEKO2+qcFnn/iTe+hZT5AopuXT1rIndlMe9ndEC11CZmmqpoUq/SdnpFAz5gO18njV5DIVEPvcQaaGGR9u1lQShO0oetImRCSyw= Received: from MWHPR15MB1790.namprd15.prod.outlook.com (10.174.255.19) by MWHPR15MB1263.namprd15.prod.outlook.com (10.175.3.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1665.18; Fri, 8 Mar 2019 16:45:27 +0000 Received: from MWHPR15MB1790.namprd15.prod.outlook.com ([fe80::28ff:27f2:89b9:efbe]) by MWHPR15MB1790.namprd15.prod.outlook.com ([fe80::28ff:27f2:89b9:efbe%4]) with mapi id 15.20.1686.019; Fri, 8 Mar 2019 16:45:27 +0000 From: Martin Lau To: "Nikita V. Shirokov" CC: Alexei Starovoitov , Daniel Borkmann , Yonghong Song , "netdev@vger.kernel.org" Subject: Re: [PATCH v3 bpf]: libbpf: fixing leak when kernel does not support btf Thread-Topic: [PATCH v3 bpf]: libbpf: fixing leak when kernel does not support btf Thread-Index: AQHU1W5pFtHXZHp1PEqRS4CgS7f7i6YB8coA Date: Fri, 8 Mar 2019 16:45:27 +0000 Message-ID: <20190308164524.esibgk5yd7a5vq2o@kafai-mbp.dhcp.thefacebook.com> References: <20190308051814.19218-1-tehnerd@tehnerd.com> In-Reply-To: <20190308051814.19218-1-tehnerd@tehnerd.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: CO2PR04CA0136.namprd04.prod.outlook.com (2603:10b6:104::14) To MWHPR15MB1790.namprd15.prod.outlook.com (2603:10b6:301:4e::19) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:10d:c090:200::2:1920] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 22916d7f-4e2b-4b73-78a6-08d6a3e57773 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MWHPR15MB1263; x-ms-traffictypediagnostic: MWHPR15MB1263: x-microsoft-exchange-diagnostics: 1;MWHPR15MB1263;20:7yM6IJIXjYPAGmKvMkLaXlxd2pkkvGYrIP78wRglgAlAde43v+eq+uhLx3WpowgYcHE2wbONgp5Qqp3Q9s7eUwWx2jA5rtqVUaTN3gzIvSPTiBwxD4tZZPjryHVqH/bDwxUGDIBAqlN2Uj2TmuiVfRMFX0LIEu6z8XqTmxOGILA= x-microsoft-antispam-prvs: x-forefront-prvs: 0970508454 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(346002)(366004)(39860400002)(396003)(136003)(199004)(189003)(102836004)(6512007)(81156014)(305945005)(106356001)(68736007)(8936002)(81166006)(256004)(71190400001)(6246003)(54906003)(8676002)(316002)(229853002)(105586002)(9686003)(14454004)(2906002)(6116002)(6436002)(14444005)(25786009)(97736004)(6486002)(53936002)(71200400001)(46003)(6916009)(4326008)(76176011)(486006)(6506007)(99286004)(446003)(476003)(11346002)(1076003)(478600001)(52116002)(7736002)(186003)(86362001)(5660300002)(386003);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR15MB1263;H:MWHPR15MB1790.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: kScyQsn22ZL4A0whnSASQv0fxyyBrzmvHzdDFm1cZ8iH/E18G+S/SU0NUsrH6eOnlMpbwSjKMkSKmw/gp/cpGhS68R5fpaW1d7Wb8mngHr2e7a42uK1+RDjvS7KUmonTrbaXMSeBKdGn/dNyDc5TWjn8zhYbhFj3+oEwk0hJTCDJqY354yJX29iKqyIQouTZLAPzQ2mJnHxZEuBaotdqI5L/onowc7olEyaE5pWLbeLZZxl+lpn+X/YbVvt+AOEw57kyXuCp7AyE8fXabOX9HLMvu5elYJhUWuHxfEcnCug2Bza03Es7QrdIaYLpOsTWD3RwEgUUemN8ZTrmQTJwoJ1JojqoSgQshCsy8/cIWu2SRF2VJd1SsiG5BstQ3U3SWrA+UmGLH5m06cmFp7WGfMZtVOHl1Svcp0i9xJHX/5I= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 22916d7f-4e2b-4b73-78a6-08d6a3e57773 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Mar 2019 16:45:27.2673 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1263 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-08_14:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Fri, Mar 08, 2019 at 05:18:14AM +0000, Nikita V. Shirokov wrote: > we could end up in situation when we have object file w/ all btf > info but kernel does not support btf yet. in this situation currently > libbpf just set obj->btf to NULL w/o freeing it first. > this patch if fixing it by making sure to run btf__free first >=20 > v2->v3: > - adding "Fixes" tag >=20 > v1->v2: > - adding netdev to cc >=20 > Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") I think the Fixes tag should belong to a later patch, just in case there will be an issue when pulling into stable: Fixes: d29d87f7e612 ("btf: separate btf creation and loading") > Signed-off-by: Nikita V. Shirokov > --- > tools/lib/bpf/libbpf.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index f5eb60379c8d..d5b830d60601 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -838,6 +838,8 @@ static int bpf_object__elf_collect(struct bpf_object = *obj, int flags) > if (IS_ERR(obj->btf) || btf__load(obj->btf)) { > pr_warning("Error loading ELF section %s: %ld. Ignored and continue.= \n", > BTF_ELF_SEC, PTR_ERR(obj->btf)); Printing this PTR_ERR(obj->btf) seems not very correct also if btf__load() was the one failing. > + if (!IS_ERR(obj->btf)) > + btf__free(obj->btf); > obj->btf =3D NULL; > } > } else if (strcmp(name, BTF_EXT_ELF_SEC) =3D=3D 0) { > --=20 > 2.17.1 >=20