Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp4532752rwb; Mon, 31 Jul 2023 08:14:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGOilqOEW109h6CxSTN8v7A9NxWQ5zQlUC2OTfDQUpTnMmFVONvgJ5P1dNKGNMtTulg7wS1 X-Received: by 2002:a17:902:d2cd:b0:1bc:239:a7bd with SMTP id n13-20020a170902d2cd00b001bc0239a7bdmr6802658plc.6.1690816478875; Mon, 31 Jul 2023 08:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690816478; cv=none; d=google.com; s=arc-20160816; b=OenXoolgi6dFYEkkQV11xwFUN0+U7r8dmTR9YojGz2g3Q6kqcrQXGSqKaMh2sMA9qG 5XRCgjp7YjshrBPuB0srZfC3GRleKnzyvUZyVOVE2Zajnkd5Czl00oM6UNt7SAIkRkQJ A6fT3FPuOkSp91sFeFQNu/m66cjOR26pas6VAYqKt+6ptt95NoW+NTvfFrSfx3Z+DXa0 QlaGIlB/pZDqR3KSGd+cCtECH5QUna8Nk25wCG9bw1jYROigNGqAgtANWRzcXfbMNlvQ TzBdzTtogmSNiSXxOff2uhAMxt3851EHq+KSZGjuDbRS/VjithjT4/VurYeFXjHbj/yN ZXUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=jVofOz3VT1bQnr8xu1RDy35EyD2aqiFt2kuYsdTNoh8=; fh=oI7AE0e1U6gD0gYYuPwN5/ZRJriGTTuaSN5V+kaDmss=; b=XhV/RKL7D3YRj+8ji9w8/HB7bIY7BJUEQMCOXyrj55ECWTPYE+jm5dNwIAxPXqOF85 hEuYySVCEVWP879mFfKLOucilay6udSyoS1Lr/LpbwwWl8Dmchn6QJNuovHCsp21i6RB zFpW0ne5jtKVnJR11hxG3byC5r0R4HFgjsHjmyYvqeimDUgK1miTAIj6JtuAuoQma64u rXa3NTumDvq/CvyqX+rC868y41boUPkG4et3a+f+sJqQvPF4vnM9V8UWmXwU9Q/W6MR+ lly7O9JRby8RKcAionInVYVkXBSd0tMzXcM7pf6+X4/pq/A+SDQOPKxZ0fwJNvl8vFdy uQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=R25t1+CR; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r11-20020a1709028bcb00b001bba5626215si7142577plo.333.2023.07.31.08.14.25; Mon, 31 Jul 2023 08:14:38 -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=@intel.com header.s=Intel header.b=R25t1+CR; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233197AbjGaOHP (ORCPT + 99 others); Mon, 31 Jul 2023 10:07:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbjGaOGx (ORCPT ); Mon, 31 Jul 2023 10:06:53 -0400 Received: from mgamail.intel.com (unknown [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AC711BF4; Mon, 31 Jul 2023 07:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690812259; x=1722348259; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=8c5Y6r6nrV+imaXJ+aq3XZpGq4sAW8zp+bZ99Ugqtkg=; b=R25t1+CRDueyhGdvrQx7QllY8prcerUGKXKI5dd8TzVe9yhFRvN3Y68H 7JUEQVbCdh6ve8r7eETu6Tn80VXAAwEf3hyNcT8EgqUGrB1VzGUd2lIiN hUKwdPuT/zSUjyz07i+x8McHL4tanqLe9EjBkIqq4ngiE7i+hBRy6R6+n A0wmVNCtDR6s4TB5jQftGbr5mZ+QzbfkCqff6e3nxzHGz6lc7FtGMFy2z +mqmWuT+StG07XZnx7l0cpUmruy396xRluNUwEGapTsUGnuseqDaXxBc5 kPMB+5vEdIMa4eQFaVdCA+EJhPcfLi+Drk992GABRNiNksMSRe6Z/njJy g==; X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="435335660" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="435335660" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 07:03:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10788"; a="1058942779" X-IronPort-AV: E=Sophos;i="6.01,244,1684825200"; d="scan'208";a="1058942779" Received: from aantonov-mobl1.ger.corp.intel.com (HELO [10.252.37.78]) ([10.252.37.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2023 07:03:26 -0700 Message-ID: <9fa13591-38dc-5dbf-5271-5c2bd364f16f@linux.intel.com> Date: Mon, 31 Jul 2023 16:02:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: potential return of uninitialized variable ret in function skx_upi_topology_cb To: "Colin King (gmail)" Cc: linux-perf-users@vger.kernel.org, "linux-kernel@vger.kernel.org" References: <21e2ea66-9524-8e34-a2f0-8e16b9617d68@gmail.com> Content-Language: en-US From: Alexander Antonov In-Reply-To: <21e2ea66-9524-8e34-a2f0-8e16b9617d68@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 Hi Colin, Thank you so much for reporting the issue. Seems fix wasn't picked up before, I will resend it. Thank you On 7/27/2023 3:55 PM, Colin King (gmail) wrote: > Hi, > > Static analysis with cppcheck has detected a potential return of an > uninitialized variable in function skx_upi_topology_cb. The issue was > introduced with commit: > > commit 4cfce57fa42d277497cd2c425021312eae2f223c > Author: Alexander Antonov > Date:   Thu Nov 17 12:28:28 2022 +0000 > >     perf/x86/intel/uncore: Enable UPI topology discovery for Skylake > Server > > static int skx_upi_topology_cb(struct intel_uncore_type *type, int > segment, >                                 int die, u64 cpu_bus_msr) > { >         int idx, ret; > > ^^ ret is not initialized > >         struct intel_uncore_topology *upi; >         unsigned int devfn; >         struct pci_dev *dev = NULL; >         u8 bus = cpu_bus_msr >> (3 * BUS_NUM_STRIDE); > >         for (idx = 0; idx < type->num_boxes; idx++) { >                 upi = &type->topology[die][idx]; >                 devfn = PCI_DEVFN(SKX_UPI_REGS_ADDR_DEVICE_LINK0 + idx, >                                   SKX_UPI_REGS_ADDR_FUNCTION); >                 dev = pci_get_domain_bus_and_slot(segment, bus, devfn); > > ^^ dev may be null, so ret is never assigned > >                 if (dev) { >                         ret = upi_fill_topology(dev, upi, idx); >                         if (ret) >                                 break; >                 } >         } > >         pci_dev_put(dev); >         return ret; > } > > I suspect this probably is very unlikely, but it would be useful to > have ret initialized to some value to avoid garbage being returned. > Not sure what the best value is to set as as default in this corner case. > > Colin