Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2076862rdb; Mon, 9 Oct 2023 11:40:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHH7oEYiMDEWhMqaDxU+DuB2wBBqZOFFfzv9ahB8Jmm2CeDPV0jIR/EmpbWhdLAdfU2Sit X-Received: by 2002:a17:90b:38cb:b0:274:729a:bcd9 with SMTP id nn11-20020a17090b38cb00b00274729abcd9mr13703571pjb.43.1696876843400; Mon, 09 Oct 2023 11:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876843; cv=none; d=google.com; s=arc-20160816; b=zfMJivjym5LiAJD7+cs6R+aLZSoLaRx+NGzEZEDx24ukYU0JYUHQ/Bhl/kH7zZJbTl ZR7Hv11ewlfYLJ8hbX5F/VURLNAebytQOUwFyeukqmwXCb9KEU6B684EvKs6K88/u6Oi Wih2CF68WLBFi7OwOjFS4F9ibunUxoEMEqD6CKu7kJNnP0ZGVCxOUijlOtEViv7B3Imx jSInHw4QYr2WXohp5cMnQJT9A8as2fU8cMB9ZX54QJXkXBQTF/tw2LcqF9DvB4jxuMLW 3RNHXpNjUeRy1CEKJ8sVBZYGOm8OB4GqKqDBxAoxQUH7UeXzwXIX8XS4haD5dWjqJJMW emdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=Btc8+OmE4IzA7UOP/eGTa4MmLZMG3XazqMQBeE66ZYs=; fh=8uoRd8OfBKdrcgzCS0TCbKG83gg6rx5b6zeE6Tx82zI=; b=tGtkIu2j0gMvwAmSZyFsugJEiQ+BZtHZle7L6aB1kqS0diN+MW4ndZtDosxAwSIyLv /k1DR06UX7nW2G/+vexiYA2vWQ5aKN6CCIfAY348HljngYOGkxkqJIsk29/li2Icyq1z A2eVowt6sNe3E+t94e00jXPtXphrJrsDvWsuI4CC0yDetWVAz1vmgZGYlU9xs4ld6uww FaGUnyQW1JVV720/hUPE+L39mOXtR8/OKeN7ZFsfxrFACbBv57liDFTPpJWAq5tX+BX/ ZDXgsEgvedtZIhsF5m+Hp/xtJix7TeiR6VlHZ9Ci1/YDs8/JYnrjGD7IEOCYCQXo9yHQ hCCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SRdA35YG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id em19-20020a17090b015300b0027762fed4a0si436648pjb.11.2023.10.09.11.40.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:40:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=SRdA35YG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id BF28881CA3EF; Mon, 9 Oct 2023 11:40:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378332AbjJISkS (ORCPT + 99 others); Mon, 9 Oct 2023 14:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378347AbjJISjz (ORCPT ); Mon, 9 Oct 2023 14:39:55 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA0E192 for ; Mon, 9 Oct 2023 11:39:50 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-59c0dd156e5so81021157b3.3 for ; Mon, 09 Oct 2023 11:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876789; x=1697481589; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=Btc8+OmE4IzA7UOP/eGTa4MmLZMG3XazqMQBeE66ZYs=; b=SRdA35YGOoLAZL9O7PKWBNf2JQLBzTaG1UsHWDN0YNJOyeWnXFklTqJ8LfGovInDPq S1OCCbjXHolGeHnjnsHfSXHjwWsWYKFaev8MFgJoOMqVdc7w5Eeoxrxg7RYFhnvHkjSk 4h2Qdn4hFlf38ZRwAxN6WIoUBZvxHGlnUMkD5TiJpTAbjDJinzlN+vp51u0Q8nom8aSy eGDGjaOQxExOs8pJrvIqbKaSc5GTt+PZtW9QWv3xdfAfsQywBsmHezeLcnZhmn8s8mSu CZyIYAWyiaGBDXGW+rjm+XBx5D6Vbf/Z5kCyVWWrjpYzQa0ZfhQQJmls6rbALsQGqB+x SaWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876789; x=1697481589; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Btc8+OmE4IzA7UOP/eGTa4MmLZMG3XazqMQBeE66ZYs=; b=MSn85qlKavJk/a9fEn/c+VIRDFiHrh/DxpN+N/qX8yK9bikTLoT2JYpTTr6oDGGoQk iB8ai+qAMOyY5R3Ymo7z9tKt3Av6zuRlU8FCyxnMyEDAJbAWGHcNOf/mNh4RyYx/VCTV DIhdQeCDS2B3UhGMQ2G+FHrKOUvTZXTJj0Fwp6fjtec68wFuWLA6QH7ME1r7vfjC8cGC YBKqGfa9IT6sK5nOx4EskmZM0NR9QL1/mMANi9F2EwtR01/pUo5+PSGueLUSurgPPjHF DkfSiQAhTJjsfsAbSAG85dYxVQyt2K1Gh7YZj/IP8QDlwHECJiJZzNH8ymKLpmDziJbu ejXA== X-Gm-Message-State: AOJu0Ywowt6QQYjzSU0Km1/72si3TBcXitqrU6R6vHe+1+jiAyAjQcDO dsgWjTAXOeXyFvmy95JqP85F9L0p19T0 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:ac4a:9b94:7158:3f4e]) (user=irogers job=sendgmr) by 2002:a05:690c:70b:b0:565:9bee:22e0 with SMTP id bs11-20020a05690c070b00b005659bee22e0mr297980ywb.0.1696876789191; Mon, 09 Oct 2023 11:39:49 -0700 (PDT) Date: Mon, 9 Oct 2023 11:39:11 -0700 In-Reply-To: <20231009183920.200859-1-irogers@google.com> Message-Id: <20231009183920.200859-11-irogers@google.com> Mime-Version: 1.0 References: <20231009183920.200859-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Subject: [PATCH v3 09/18] perf dlfilter: Be defensive against potential NULL dereference From: Ian Rogers To: Nathan Chancellor , Nick Desaulniers , Tom Rix , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Yang Jihong , Huacai Chen , Ming Wang , Kan Liang , Ravi Bangoria , llvm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, bpf@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:40:39 -0700 (PDT) In the unlikely case of having a symbol without a mapping, avoid a NULL dereference that clang-tidy warns about. Signed-off-by: Ian Rogers --- tools/perf/util/dlfilter.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/dlfilter.c b/tools/perf/util/dlfilter.c index 1dbf27822ee2..5e54832137a9 100644 --- a/tools/perf/util/dlfilter.c +++ b/tools/perf/util/dlfilter.c @@ -52,8 +52,10 @@ static void al_to_d_al(struct addr_location *al, struct perf_dlfilter_al *d_al) d_al->sym_end = sym->end; if (al->addr < sym->end) d_al->symoff = al->addr - sym->start; - else + else if (al->map) d_al->symoff = al->addr - map__start(al->map) - sym->start; + else + d_al->symoff = 0; d_al->sym_binding = sym->binding; } else { d_al->sym = NULL; -- 2.42.0.609.gbb76f46606-goog