Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2638500pxa; Mon, 17 Aug 2020 15:09:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1eSDLCuCLKMVIVnH+Nq90oeNy/TTvo1BacpcO7okVrQErp36wH1v7PaFwCePIPqgSR53i X-Received: by 2002:a50:88a4:: with SMTP id d33mr17253457edd.43.1597702163768; Mon, 17 Aug 2020 15:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597702163; cv=none; d=google.com; s=arc-20160816; b=BSggDkWL2OLWkvK/XcMB78T/hXH3ERdJwlwuiBLtajb6wqq/Gj2MC+kWRQsOzIM6hT vxwSf93FtbQ+JrHNBVDIyu0X5H9b3q40ASmrOm07g7eQNKjTr2b+qb0ZWBIb9RQYqt3J hXmzHQXMapLdROg9XsoI3eooyS0sAlbbdl12z29sNFsHSmHbrmiA7PaNwRGqKYCitPqB NcwMnYwH75Z5K4z30hjDEbdPPTMZEkORlngUiWqPYeEL8RXKyAd2DpKPMNANkbFXUWaQ KXBuVqLAG8UMWPUGvP29MG9S7VAq9W/FVqC/+dETKJq64wJBRNQaYudnv/lV5jbjKTmU bqgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5NMrFArS24ZvNJQhYPcifSLPJe+g7/to74QKtm0uw08=; b=D822VqhHhrTvQCG4JdeADeUJXYUDgZXl7pVsQtVrrrF7DZNp7qHFqIcjlllP4vzoLC NcyIqUH/HiOC4ubEvsZ6X6E1AXUGjMHxlSr3UzN8v8i7Ir6bD0g6b4Xc9Cg5TnWckRmD 050ycOI/A7lE9LARB+foJTd8plzFZAAfEETqZ9QWKNzj8gwGOC9oGwapUAGtrO2TonRy 1Rjt+JS3QLRXKy8PRQQ/qlpYV9uRVrOCA4aMvnUria4XUJgHhxA5j6xKszhwmHg7WtiM PJQVeLDeNCUevxdnDWWEGha/Mt/9ioxvIKF1Kr8co+ZEk/Wflk5gCJVXta+C0dXMOE8C IixQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G1xWicIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si12646740ejy.685.2020.08.17.15.09.00; Mon, 17 Aug 2020 15:09:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G1xWicIH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388708AbgHQQ06 (ORCPT + 99 others); Mon, 17 Aug 2020 12:26:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:37666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387827AbgHQPv5 (ORCPT ); Mon, 17 Aug 2020 11:51:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 475B720885; Mon, 17 Aug 2020 15:51:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679517; bh=S8mB5wGiY4l6snnRcf9CxVcHFjqZAemJdqLwKa3CuD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1xWicIHPXJDhiESVsHFQOFzuDH/fnoTsp090scp+CYxfc72F+B+fO/EOd8uqz09x FocvNFFDgaJa/RqokIJil2Bb43x9ORYWST1tui3Zrg0GR8VIj6FoJEEAOEKfA0DQHj kTrWaMhIlvnnyzM6YJ0oYq4aZ/Z6HdCsmlTcxwH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, YueHaibing , Alexei Starovoitov , Quentin Monnet , Sasha Levin Subject: [PATCH 5.7 239/393] tools/bpftool: Fix error handing in do_skeleton() Date: Mon, 17 Aug 2020 17:14:49 +0200 Message-Id: <20200817143831.211722384@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: YueHaibing [ Upstream commit 956fcfcd359512f15b19bcd157fa8206ed26605b ] Fix pass 0 to PTR_ERR, also dump more err info using libbpf_strerror. Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton") Signed-off-by: YueHaibing Signed-off-by: Alexei Starovoitov Reviewed-by: Quentin Monnet Link: https://lore.kernel.org/bpf/20200717123059.29624-1-yuehaibing@huawei.com Signed-off-by: Sasha Levin --- tools/bpf/bpftool/gen.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c index f5960b48c8615..5ff951e08c740 100644 --- a/tools/bpf/bpftool/gen.c +++ b/tools/bpf/bpftool/gen.c @@ -307,8 +307,11 @@ static int do_skeleton(int argc, char **argv) opts.object_name = obj_name; obj = bpf_object__open_mem(obj_data, file_sz, &opts); if (IS_ERR(obj)) { + char err_buf[256]; + + libbpf_strerror(PTR_ERR(obj), err_buf, sizeof(err_buf)); + p_err("failed to open BPF object file: %s", err_buf); obj = NULL; - p_err("failed to open BPF object file: %ld", PTR_ERR(obj)); goto out; } -- 2.25.1