Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4322181pxu; Tue, 1 Dec 2020 01:58:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8Kbs9FS+lX8kUM87q0ts2/pClTjYpKGd1vXwHZbUTMQo7Xd/ASNnKs59fjnd6tNPaNnok X-Received: by 2002:a17:906:4c82:: with SMTP id q2mr2089923eju.285.1606816739097; Tue, 01 Dec 2020 01:58:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606816739; cv=none; d=google.com; s=arc-20160816; b=tmWC+9UbIJ2U0mj9TtflRXaX+6n2KGSVxE9uUE8zCiJmSbSZbcrdaGpEoM6EBU/z2g sJTcRoXGRvvjM49QNHb7ZM0+dEg93KBackSq4c8F83N+kgjxGRzbct4eKYxsqKWS+UoB imn/pTgl9NvP/0jPoGNiu/BK6g+s+nvwDNdUQICfb9swtsXFZADL3YPxO1Li3VYzfbhn Q98lzNnv4XiPgpkr79dHlpj+MlnGALaUiGCxdJA90wncmY1NYVFH4KJluIjj1JZwbmTd ntfhWN88cKqX+2gt0kBRJAvCUTtggr1u8u8RUWQe3kgSFmKzCE27ZtXE1Sz71IKYeGIW 7NwQ== 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=N5eeoeEOE/Jhv4QHP3nEBTUSS7lEe+vlVPb6ndHzcR8=; b=qd9zcx8t34k5iVHh5gBdbYbSMiwwwTyp3S0xg9rYs7ieFPOGNSbOnji9XHUI0qw3+K QJ/OyKXcjcPBV5ts4nGK9PiEo5FTA4bS0Vf4buyJW1/2fychUbrkwyqhaF8skDPLlx/m 5YXSD/zGHTFXmMLg9okVKR6ukvqUVvJpoNFZLT5wXXy04g/B6ZghzKh2EMFXco/UhuzR /X3Rb4ZGLBSUamQMgwX68ujTatTyRdgi97zK5WSZOTLOmww5AE/YHRsVHFmpbMkUXr53 1p4/RepZzHMUeOoZ/vziF/l6e2LHlDeKaA2I3eYnTb+aRQ1O1/zZwRnqxdLSAw6nTeoW nf5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OuyHnlVC; 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 f7si617339ejf.108.2020.12.01.01.58.36; Tue, 01 Dec 2020 01:58:59 -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=OuyHnlVC; 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 S2387918AbgLAJya (ORCPT + 99 others); Tue, 1 Dec 2020 04:54:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:58620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387811AbgLAJya (ORCPT ); Tue, 1 Dec 2020 04:54:30 -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 C461620657; Tue, 1 Dec 2020 09:53:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606816429; bh=SB/Hk7R0n+b3SjIUqJI7XY22RvV/OORb7UXI9hQY3E0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OuyHnlVCOlV+J2ZPhQ8cnBDVj6iIzbdubLInB+q4p/xK3CchWlhMvk7VED05AjS9I atYl/aPkL5NLgOPPZLWB98h3sUVUvWe0euDm3epPzixreJ3DaiRFEoTSlt7u+JpRCe JpcCs2sbpsmyem3IsN4HuHTBhuvOusbH5SUXtYAQ= 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.9 34/42] perf probe: Fix to die_entrypc() returns error correctly Date: Tue, 1 Dec 2020 09:53:32 +0100 Message-Id: <20201201084645.128091107@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201201084642.194933793@linuxfoundation.org> References: <20201201084642.194933793@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 fb4e1d2839c5f..cbbacc3467494 100644 --- a/tools/perf/util/dwarf-aux.c +++ b/tools/perf/util/dwarf-aux.c @@ -329,6 +329,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; @@ -336,6 +337,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