Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3675059rdb; Wed, 13 Sep 2023 21:44:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IER35xDkkFM/gw7Bef0esDHlpt6AcXUZhwtHcquSpo9aOhZRipVDq1GMMjmNlIfdk9ovlHg X-Received: by 2002:a05:6a20:549d:b0:153:c9fa:4ed2 with SMTP id i29-20020a056a20549d00b00153c9fa4ed2mr4984861pzk.11.1694666690188; Wed, 13 Sep 2023 21:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694666690; cv=none; d=google.com; s=arc-20160816; b=1DiOiN8AxNb8NJ3JUssveGI9f3SCr6cPSSYukycmESsnbf6zF7D/9afaZbW2iW+wZH Kfw8KO8LDo4o9VouJlTPnMJtC1o33Qq0BnQkbXuxC38BXqaaE+vDuOo7odWoXIYL4xAB 2cueXl/a4kFd3yhN8Ccnr4mCsYf8ene2MOBYbZYnZi8hf2Eds6Ul/qQuncPCJKSSXGqq ZaCinWaLywqpGpWuQZP0BVNmZHEMaOEXhrRDPa342T3t/JQQRreV/YcxGnKjL3qZu9kw nv7sIS/sj1ZiVOzVhcf7y6fjIoeBZo4+6km4QcKkEPfQ75mi49Uv+nM0jF27BCLBThMC umKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:mime-version:message-id:date :dkim-signature; bh=1HUitirtv3MlkOjFE/+m21aYPcp7zNtjHMHmwF7qUUE=; fh=vg0KQy2UsEIKH+sWPNXFCb46N9glUkHdXMkUcTdv+l8=; b=HiXrkVEdCr5XmqKs6PBgg3aDFVdbH/RS42HUFs9Pcx+EcW+Ej/ph/RWS7IjLW7cjCQ CPGBxh9X7ZdbeAQGHo2qfUBMF2z6h+NFvd3ZORjk+//uLdDenSjln9zg6tp29hVXlp4t UtxhK7Rnjmt1rTWWba2By/yiAP/fpsNuON5KasjNpcOv7Ib3SV6bqX1Zk+WfZUP9Tuhc KVv2V/ab20HI9apXgv/nXZSCWAWVxVzVRyas5HveWX++0UzYQtPQPvc8f8a77zgM9Zfd OmwEUEjcsc/lDl3liAImaYauIxXTdVZ/fpLZ1vfJIQmIK2rPN9bcBJ9x2tHDpVZIZfwS hLMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4FaOT++M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i6-20020a17090acf8600b0027455f4ca15si1703040pju.1.2023.09.13.21.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 21:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=4FaOT++M; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id 9D23280A95AE; Wed, 13 Sep 2023 21:42:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234230AbjINEms (ORCPT + 99 others); Thu, 14 Sep 2023 00:42:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233796AbjINEmr (ORCPT ); Thu, 14 Sep 2023 00:42:47 -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 70AA31998 for ; Wed, 13 Sep 2023 21:42:42 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-592210fe8easo8343857b3.3 for ; Wed, 13 Sep 2023 21:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694666561; x=1695271361; darn=vger.kernel.org; h=to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=1HUitirtv3MlkOjFE/+m21aYPcp7zNtjHMHmwF7qUUE=; b=4FaOT++M4mmbE8qmGg8bcDu+h0LN9B+B2pvwcCdu+D03RNGyM48D5Dc17pnj5WMQp5 c4Xq0wmUu2kQtrHLEvtmdFFNiz+qjfDnE5EKLIWBYR2V+WofBdbYOboS7o+y3ftz/5mS nqBMJKMOBueGIraN6Z/8TGjIOuVJVqSn81m07W22Mmz3uRWFf4TN1Hd3I2G6Kiv0yfmq SFy9bjhq3S28s8jtYYGwKbfshamAPrsJy6uXuygz393MWzwvdsB6PtsoiEZtEa7SI9KF lm7TLr2+lxsVrhRcRr3+uxd7g5M6RTQCdnfoHjJ9HLgKJqA+bq+gVXEmbdPI1xLyPZse IPCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694666561; x=1695271361; h=to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1HUitirtv3MlkOjFE/+m21aYPcp7zNtjHMHmwF7qUUE=; b=doNyfiHmHgGx+8YYm8dNEJSMVJMTFGeQF9cKqeq9ibVGBwN+yWdTvoFeYLnrpDmPL2 KU8Y3BJeadDbNQZqtd8OFYbHXCY102fib5pQwOVpa75cZERZCEMAD7s/doV7Na/l4GFf jVtPr0oYwNDC0gSBis5nr0j8VerAgcskrXM12UtgIPD6ZEtaBQxurT8xkRMXBNcQPzhv SyDRRzsHo9vz1duvs2t+pvC14tSJa9t/ZHlSAEii2eg2WOaK7E6FZvp1gb075LfASzKF W60WFQhZn+gjb5BMIKKoMFnPcC0me2ad2qk2hmUYXgQj3C7RxH8f6MdWNJqL/cmRurQq kVtA== X-Gm-Message-State: AOJu0YzXxnEdVx82HfYQ/tQNYiXdpoeS0uFbWnq9YJaEXFzotOSrAfyf 1Iex7vKxjxKQTMe9aJdLSsh+Cnr0Bge3 X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:7612:4bb6:bcf1:779c]) (user=irogers job=sendgmr) by 2002:a25:26c4:0:b0:d47:5cc3:9917 with SMTP id m187-20020a2526c4000000b00d475cc39917mr96593ybm.9.1694666561603; Wed, 13 Sep 2023 21:42:41 -0700 (PDT) Date: Wed, 13 Sep 2023 21:42:32 -0700 Message-Id: <20230914044233.1550195-1-irogers@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Subject: [PATCH v1] perf symbol: Avoid an undefined behavior warning From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 (morse.vger.email [0.0.0.0]); Wed, 13 Sep 2023 21:42:49 -0700 (PDT) X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email The node (nd) may be NULL and pointer arithmetic on NULL is undefined behavior. Move the computation of next below the NULL check on the node. Signed-off-by: Ian Rogers --- tools/perf/util/symbol.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 3f36675b7c8f..5b54d2639df4 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -202,11 +202,10 @@ void symbols__fixup_duplicate(struct rb_root_cached *symbols) curr = rb_entry(nd, struct symbol, rb_node); again: nd = rb_next(&curr->rb_node); - next = rb_entry(nd, struct symbol, rb_node); - if (!nd) break; + next = rb_entry(nd, struct symbol, rb_node); if (curr->start != next->start) continue; -- 2.42.0.459.ge4e396fd5e-goog