Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp372332pxk; Fri, 11 Sep 2020 09:10:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaYEluKSUY6ODkIGoCgWD9bcSPN2VS8LPtcwQGrcuvnRp/3wUetB3hYnqJdDGbXEPQsHRb X-Received: by 2002:a17:906:4cd6:: with SMTP id q22mr2702791ejt.139.1599840605097; Fri, 11 Sep 2020 09:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599840605; cv=none; d=google.com; s=arc-20160816; b=Ag3oC+7aZwI1q/CoZ6Yh0h7oKWCK3drLdMVKfEZT09O4Ro0BBrCtXFopuvn17RQHcQ 1IdgiWMssugnefwgpfLD/jmHhR24/wW6Wds4MYOP+lOckHG4Q+ACCyZw2TmYY5BfZiyi 5BpAwraV8MIZOEy1AXN94P+phlIJPMFo0d2TAyWEG2u8RX3gjCeWOWgYqftLCG2Marn3 SFwdgPwzsZ4myIgb72YgB1IuD4TzhPACFeL0Op6TZm/jeftAzhDVaZn7LUtraKQTjdbs zRMcjunFYFIyABJez0aRaYKrwKtJZWVFw65DN5q4KVqB/W/gFocRMimTNvzkkRVV23I5 aHvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=37GJ2l/cIpSqG/GVcBjS5vVvXUj5KVKGa939Da1YqWQ=; b=VZ6zII58h8KilG2Kd0P+yH5L7WAnsPLJSLNPORHlAYAKExIrc4CYOv1TYV8+AP1z7L r2cKhcF5/A/58zkosurGjkjKIul6V/0Mh2DZjLkR/35/POt4KKA+oUij02eH/0cfcotm JWJjlN+r93N85/L1Q5Vcf3POuEZFpBG9UoiuWBE33w+q38K1Hcs/wwBlXtRF1T3zXu8i NYJ7InKswkzE7sAU5w0x8IiFyC9Cia1s2EakdKQYfG3sDos2Y02Dux5ZwU8kMm+t3nWH x2IJuCrtKgm6omZ9f+n+ey1DqVKg6PL1B4BvhfBz4QYeqBH3Pw+PYy6AeOk/u8bWDRya wXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="LzluMK/4"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m27si1558157eja.40.2020.09.11.09.09.41; Fri, 11 Sep 2020 09:10:05 -0700 (PDT) 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=@kernel.org header.s=default header.b="LzluMK/4"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbgIKQIS (ORCPT + 99 others); Fri, 11 Sep 2020 12:08:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:49908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbgIKQII (ORCPT ); Fri, 11 Sep 2020 12:08:08 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (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 67F69206CA; Fri, 11 Sep 2020 16:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599840488; bh=iLPXQfche2cl2UNFwVe5Cn0pwE5wjPTc1yMcibij3Cc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LzluMK/42p47BOEhqCg9J+En60njQGbHwN2+0wRwyoosXXO2/pLvAVJsq5zMFx1qz uVCU9qpfDRiLxjKRXW38CC0EKI1OyvSsyZJDC+z8P1OI+d9DW/uqyNEGwC2oXnpu1u AzDXcFsZscFOuTMQXVm2IWUukA/pz77wIuMh5Q60= Date: Fri, 11 Sep 2020 17:08:04 +0100 From: Will Deacon To: Mark Salter Cc: Mark Rutland , Khuong Dinh , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drivers/perf: xgene_pmu: Fix uninitialized resource struct Message-ID: <20200911160802.GB20802@willie-the-truck> References: <20200902182729.27415-1-msalter@redhat.com> <20200907135026.GC12551@willie-the-truck> <489a7918b244e83736feff79c59a4b74d4e5cad0.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <489a7918b244e83736feff79c59a4b74d4e5cad0.camel@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 08, 2020 at 02:37:22PM -0400, Mark Salter wrote: > On Mon, 2020-09-07 at 14:50 +0100, Will Deacon wrote: > > On Wed, Sep 02, 2020 at 02:27:29PM -0400, Mark Salter wrote: > > > diff --git a/drivers/perf/xgene_pmu.c b/drivers/perf/xgene_pmu.c > > > index edac28cd25dd..fdbbd0804b92 100644 > > > --- a/drivers/perf/xgene_pmu.c > > > +++ b/drivers/perf/xgene_pmu.c > > > @@ -1483,6 +1483,7 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu, > > > return NULL; > > > > > > INIT_LIST_HEAD(&resource_list); > > > + memset(&res, 0, sizeof(res)); > > > rc = acpi_dev_get_resources(adev, &resource_list, > > > acpi_pmu_dev_add_resource, &res); > > > acpi_dev_free_resource_list(&resource_list); > > > > Hmm, to be honest, I'm not sure we should be calling devm_ioremap_resource() > > at all here. The resource is clearly bogus, even with this change: the name > > and the resource hierarchy pointers will all be NULL. I think it would be > > better to follow the TX2 PMU driver (drivers/perf/thunderx2_pmu.c) which > > appears to assign the resource directly in tx2_uncore_pmu_init_dev(). > > > > Is there a reason we can't do that? > > > > Will > > > > There's no difference between xgene and tx2 wrt resouce name/hierarchy. > They both call devm_ioresource_remap() which ends up setting the name > and hierarchy. The difference is that xgene calls acpi_dev_resource_memory() > directly from the acpi_dev_get_resources() callback. TX2 doesn't use such a > callback and in that case, acpi_dev_resource_memory() gets called with a > zeroed struct. > > That said, changing xgene to avoid the callback like TX2 does would fix the > problem as well. If you'd rather go that route, I can send a patch for it. Yes please Will