Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1001468rwb; Wed, 28 Sep 2022 11:49:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM65WRwlWo1GvZ0Hqg5tMlN1JlSiRR8E4ASzx0sOXcG9iciiaCRvNkXWHyWzBzMJcyDMGk0o X-Received: by 2002:a50:d79a:0:b0:457:d209:c09c with SMTP id w26-20020a50d79a000000b00457d209c09cmr7624163edi.14.1664390957964; Wed, 28 Sep 2022 11:49:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664390957; cv=none; d=google.com; s=arc-20160816; b=izd+E9XLmy06vnz7lmUYrU8RxpnisZjvpHy1QP5y32HB4jd2UjTZ4e1o+JZCrnBxPm e3jgs0tksc6plsDD/tg71zmTGnvITqVpzPuUiF6IsWPvW5dwI9sg1XclsiavThVflKJX fZl+r5MWNhQMJ3t4qu62GwaiK7Cz5aoEP+6KI5za18tpfCXcDRhVOdECmAaXGAM/AG8s SOjY74a7ftDANRF3fYPY84HzVj6V0tFQOJttO8GEnSbADf4yoq3m0g0UgEtP7jLGa0I0 hUZ1X923kYJuXLIfSpVSX475a/CYjqH7eWYHQrSrT30jcPVoRLJI8kyw4gRVd3Sq3qkQ +k+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=3935bCieyFmPbWCFJjhpDhrqHj3m5qA7eEIiW2Mb31M=; b=lik1/NHmC/jxF8/033dW4+IahJ4joLYbaNh/ZRUOTQIhbSQU9ZBwE6Cy8WhzFgnUDc IzcE8OaFKN6hbZmv5qZ2aH92IqFtJ46y9Jfis8F/OUpJHnqXh8TI8sRiGuzFLXhR4N6p /R7gUE8aeUnCSbvcJ9iy6Im3Qe9TJbEI4Tv2TLKQNqksncOqAaKFgS9bq0Eak5x8yR1u wHdjgf5GiEe+7d1yf3YGEIEbkNv1lPoVhDkLOkDtOLx1jE/elUMjfLswqKE3zzGfgx75 jNZfvCUBFV20btLh3ObmEY5x42usGLMeU9BxyA9Kva7mNqfo7sx7VnnhVVi2DkB7DNqM 3aAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YqI1WESs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y2-20020a170906524200b007413ed9efb1si4817451ejm.543.2022.09.28.11.48.52; Wed, 28 Sep 2022 11:49:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YqI1WESs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231419AbiI1Sk6 (ORCPT + 99 others); Wed, 28 Sep 2022 14:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbiI1Sky (ORCPT ); Wed, 28 Sep 2022 14:40:54 -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 5EF9872B42 for ; Wed, 28 Sep 2022 11:40:53 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-35076702654so127688977b3.17 for ; Wed, 28 Sep 2022 11:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date; bh=3935bCieyFmPbWCFJjhpDhrqHj3m5qA7eEIiW2Mb31M=; b=YqI1WESsX1JN1SX3EDdN3t0+z5lQnLgO9roDEXa88xtna+McONc24ekfKMWcVHWJ5k 8Y3BBVp6ZbMUC36mkMgaACQm8lPSjK3jEBA5eV+NVzee9UrbJYCZLEW7gEyLiMhq+KKD k+OU2BaH5ZeeLJITqT2dD5Wv5mv+bMGOuRAoDMdTbV8pghU+FM8NRdRbnkp3WLs5sYKp Ap+lhwb0ObAUkLzOP3wjhV0hUSSNaU8ft7dQrcxSlvMfC64iyuBsYOafnO6xyjZ+YK/y iKEzhpb5PWnlchhpVYALvW4zSxN4DpUTWFhMXg3In4DaE3tBOcC9926kfa/krO/KW+bh mn/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=3935bCieyFmPbWCFJjhpDhrqHj3m5qA7eEIiW2Mb31M=; b=O/M8n+K4fmJd74998RvPO3rb4ABpOGX00ixn59a6hofVG6XdZjRRPrqaS9OdwvavWw B7Fb71kmGqFOLfE8n9Tl4DKbEZ3yyP8M0aETZXSmltIZbKk5dDdlJafSFgMbzJuh8FhQ llxuyCYOTcmDTrCwZp5NxxqRzXINBNii48JfHhUc0znqk8+2L83A8v8Ryvj3dgwgPWXZ DA4fGlMczWiANhW8BD4MMpd9gpNeb8kPefZzp+uJxQofOFGUpouEiXLBGucca0/pTxJF GMk5IxyS6nnTE8WpSQyb+/LPCE398/c2EM4Wm8duxmJWAOJFpoG6fbqsimcoDZnv6R52 6XBQ== X-Gm-Message-State: ACrzQf3tLmC4x8KZzggtweK1cZ3QSWYOn8wJ6O5yyU24XedU6aPZm71g s6PSf7d61e03sQLIjysqQdYSlQ2IDjGAEs9IZkm1VGVn1QE7fFPMYb6QUpCZ8ATYzx9HhitW8yx xgpnX29mdDbFKbMDLt3SI0mldj8tSFrVUcbo2qg1kuvYfJ9GQO/aN1X4I/WM7j2RMGVxtAOUq X-Received: from uluru3.svl.corp.google.com ([2620:15c:2d4:203:d508:baac:7b11:f912]) (user=eranian job=sendgmr) by 2002:a0d:f201:0:b0:335:4933:6683 with SMTP id b1-20020a0df201000000b0033549336683mr30829921ywf.23.1664390452599; Wed, 28 Sep 2022 11:40:52 -0700 (PDT) Date: Wed, 28 Sep 2022 11:40:42 -0700 In-Reply-To: <20220928184043.408364-1-eranian@google.com> Message-Id: <20220928184043.408364-2-eranian@google.com> Mime-Version: 1.0 References: <20220928184043.408364-1-eranian@google.com> X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog Subject: [PATCH 1/2] perf/x86/utils: fix uninitialized var in get_branch_type() From: Stephane Eranian To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, sandipan.das@amd.com, ananth.narayan@amd.com, ravi.bangoria@amd.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org offset is passed as a pointer and on certain call path is not set by the function. If the caller does not re-initialize offset between calls, value could be inherited between calls. Prevent this by initializing offset on each call. This impacts the code in amd_pmu_lbr_filter() which does for(i=0; ...) { ret = get_branch_type_fused(..., &offset); if (offset) lbr_entries[i].from += offset; } Signed-off-by: Stephane Eranian --- arch/x86/events/utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/events/utils.c b/arch/x86/events/utils.c index 5f5617afde79..76b1f8bb0fd5 100644 --- a/arch/x86/events/utils.c +++ b/arch/x86/events/utils.c @@ -94,6 +94,10 @@ static int get_branch_type(unsigned long from, unsigned long to, int abort, u8 buf[MAX_INSN_SIZE]; int is64 = 0; + /* make sure we initialize offset */ + if (offset) + *offset = 0; + to_plm = kernel_ip(to) ? X86_BR_KERNEL : X86_BR_USER; from_plm = kernel_ip(from) ? X86_BR_KERNEL : X86_BR_USER; -- 2.37.3.998.g577e59143f-goog