Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4293270pxu; Tue, 1 Dec 2020 01:02:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJwe+5LTS6jF54CPlJFQi518JPJzPSoge26z/DaWQ+iztvdAU+/es04/4SpkMlXQl/HYiHk3 X-Received: by 2002:a50:dac9:: with SMTP id s9mr1917464edj.75.1606813353417; Tue, 01 Dec 2020 01:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606813353; cv=none; d=google.com; s=arc-20160816; b=v41+CAoym/At/fUL7T6hn/Dj9+pYToX/LGMGb4TY38FGA6AZ8Fb2Wl01/RPWH8kdZi piUcSYbXmdMg0jTZEKt0oItjOQnkyboNfCd1KEXQO1JKeFnvZI+S/9ET7Fbf5RRBAbMp 2Qz95h65v/Mk8o0yJJ/2DI9xYm03vbeXM8nY7DhBXxgybFlsGTEg0rI6SJMcxZEzAAnz JPJf+aALpqwKGjwimjTveJ6fnt2hr9nVxjvVNJtS+9GDNt/V2Cy/wTqYUh3OFhK9/pzd s48nZXQ0/V9fCCwuLWJl+JZO00XEwJETHnGbjfRaW0lNUfRPmFRgOOTS7gXkn7htdByi aEyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L5+8AoKdz7tpDseqVwXWgqI6NrNfcMCQ16l1vvE939Y=; b=ZNEUBwHaRdU8pJc2a85U45z/aqMCa4X4y+JoXdeKXIbwpJmt9DK/NvW/CMTBJt0c84 SAzOQWjQpkMQHOrDdFVuxHNVbgZuLUnwc/v/zGbG5eo12yKG19GZK6HvwmDw7WQ9sQJq OEnLWZ7DGYxOPMVpUPxfpZy/ToW1KQCNAxXrIUGNVAa4dYkylbk21Z83lLhkS0fXFMyC nPk5Ca7LtbqOPklwq7EACBWXSgTD9Akt42HiVPjTPdY3in3zhemImqh3odJdqFFDPiZl MNjW6L7pDgKA1fYq83FsUmvjovlboFc/fv2Kxv8z8Vu5tc6wm60jeovbAMNYGPDHYSUG avZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=w8EbF7mh; 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=pass (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 z22si503609ejo.390.2020.12.01.01.02.10; Tue, 01 Dec 2020 01:02:33 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=w8EbF7mh; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388102AbgLAI7P (ORCPT + 99 others); Tue, 1 Dec 2020 03:59:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:33962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388046AbgLAI7D (ORCPT ); Tue, 1 Dec 2020 03:59:03 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 96A41217A0; Tue, 1 Dec 2020 08:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606813128; bh=96W6HpKPwJcjWkKM+SXn3e4faqXjMxeVabRykQNdRDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w8EbF7mhCuZJx4+kL+hPcij7wi3aPz0SftjTXqn+qpG02FyMqAJfddvGhBW55hRxw MF46L0Y9EmfaKSeK8MA6vsXjI3xkHurB+FC+V7lnZWoe9NAUVAtNhXojRTBUpVKhtY +LeAfb3xPgWtUhXUesyG55G90TWcRdw6fDkyURdA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Sumanth Korikkar , Thomas Richter , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 42/50] perf probe: Fix to die_entrypc() returns error correctly Date: Tue, 1 Dec 2020 09:53:41 +0100 Message-Id: <20201201084650.223717431@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084644.803812112@linuxfoundation.org> References: <20201201084644.803812112@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Masami Hiramatsu [ Upstream commit ab4200c17ba6fe71d2da64317aae8a8aa684624c ] Fix die_entrypc() to return error correctly if the DIE has no DW_AT_ranges attribute. Since dwarf_ranges() will treat the case as an empty ranges and return 0, we have to check it by ourselves. Fixes: 91e2f539eeda ("perf probe: Fix to show function entry line as probe-able") Signed-off-by: Masami Hiramatsu Cc: Sumanth Korikkar Cc: Thomas Richter Link: http://lore.kernel.org/lkml/160645612634.2824037.5284932731175079426.stgit@devnote2 Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/dwarf-aux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c index 289ef63208fb6..7514aa9c68c99 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -332,6 +332,7 @@ bool die_is_func_def(Dwarf_Die *dw_die) int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr) { Dwarf_Addr base, end; + Dwarf_Attribute attr; if (!addr) return -EINVAL; @@ -339,6 +340,13 @@ int die_entrypc(Dwarf_Die *dw_die, Dwarf_Addr *addr) if (dwarf_entrypc(dw_die, addr) == 0) return 0; + /* + * Since the dwarf_ranges() will return 0 if there is no + * DW_AT_ranges attribute, we should check it first. + */ + if (!dwarf_attr(dw_die, DW_AT_ranges, &attr)) + return -ENOENT; + return dwarf_ranges(dw_die, 0, &base, addr, &end) < 0 ? -ENOENT : 0; } -- 2.27.0