From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B180C433E2 for ; Mon, 14 Sep 2020 14:02:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D6D0520E65 for ; Mon, 14 Sep 2020 14:02:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600092128; bh=L0mDfxQsitxWKkVEy61huFFBlVpZdenmKB6RQVodr3U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=TNT5uMlNUeUOMiBV10nfuSzZnbV/tng0JsUoXoEg3XHf6OPju5JlQUhqzPYvGDek5 /7xPGlv1Pwv9SEDyNEgbLH7zMKUEpdtL0M1toGThPsDA7J7fdtgJ1hTfaGBwDnGmuW eKegSNl4DqKcuaIuEWd58LakL4ou1r+NiUBhFOAU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbgINOBl (ORCPT ); Mon, 14 Sep 2020 10:01:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:54410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726721AbgINN7W (ORCPT ); Mon, 14 Sep 2020 09:59:22 -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 9D322208E4; Mon, 14 Sep 2020 13:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600091962; bh=L0mDfxQsitxWKkVEy61huFFBlVpZdenmKB6RQVodr3U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DSGroWHvU+TtVCjWoy6vQ28a2g1JAVIDAN75mlAVpumcN06r/WRqh4sJKcG1xwtLs AmJblMeO6bCyStmzhZWNHmxmJ5XsnJQnC+r3IhtG9Gv8muyCJPne6Yf09LAD3ws7O0 gQCEfzPcpwi6JVVhENi49u2Z0I9XHwE2UmEhr4Gs= Date: Mon, 14 Sep 2020 14:59:18 +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 v2] drivers/perf: xgene_pmu: Fix uninitialized resource struct Message-ID: <20200914135917.GF24441@willie-the-truck> References: <20200913174536.207265-1-msalter@redhat.com> <20200914112803.GA24312@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Mon, Sep 14, 2020 at 09:13:39AM -0400, Mark Salter wrote: > On Mon, 2020-09-14 at 12:28 +0100, Will Deacon wrote: > > On Sun, Sep 13, 2020 at 01:45:36PM -0400, Mark Salter wrote: > > > @@ -1483,11 +1473,23 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu, > > > return NULL; > > > > > > INIT_LIST_HEAD(&resource_list); > > > - rc = acpi_dev_get_resources(adev, &resource_list, > > > - acpi_pmu_dev_add_resource, &res); > > > + rc = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); > > > + if (rc <= 0) { > > > + dev_err(dev, "PMU type %d: No resources found\n", type); > > > + return NULL; > > > + } > > > + > > > + list_for_each_entry(rentry, &resource_list, node) { > > > + if (resource_type(rentry->res) == IORESOURCE_MEM) { > > > + res = *rentry->res; > > > + rentry = NULL; > > > + break; > > > + } > > > + } > > > acpi_dev_free_resource_list(&resource_list); > > > - if (rc < 0) { > > > - dev_err(dev, "PMU type %d: No resource address found\n", type); > > > + > > > + if (rentry) { > > > > I'm curious as to why you've had to change the failure logic here, setting > > rentry to NULL instead of checking 'rentry->res' like the TX2 driver (which > > I don't immediately understand at first glance). > > > > Will > > > > I don't fully understand the tx2 logic. I do see there's a memory leak if > that (!rentry->res) is true. I was going to dig deeper and follow up with > a patch for tx2. I suspect that rentry->res should never be true. And tx2 > won't detect if no memory resource is in the table. Ah good, so it wasn't just me then! In which case, please send the two patches as a series fixing both drivers, and I'll queue them both together. Ta, Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C13A7C43461 for ; Mon, 14 Sep 2020 14:01:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5ACB520EDD for ; Mon, 14 Sep 2020 14:01:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LG1SrCyR"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="DSGroWHv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ACB520EDD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uzFL+f68mYdvDnw+IVEHiQEDy9oXhQLFc13193zsoyM=; b=LG1SrCyRaK59qIEzjxtm2XAPj hDm6c+28R+VkzRAf24/Uw+RNXq5PCqAA0J4texmh5W71qpmQ5M+kOgWiKLgCpO1K/rqJaPTkGnrFW MX1iWD3l2r/CtEqMieyn0Y0oKjiAiDihz893IfauViQrhF4/HldqoGsN5mc+7pzPtoKb863ZjxQfL 9WAb+3y3DWn3TTWK803e0qsnHSWGuDWNAmFSv7NFhFYZhNNJUl2+CZkdL7RycZZptxdWyil4ghEJf k6gqzMTgIreo/HeeNnbg91/NYrqHgdPZWDVe/iqXjBqU4u2FZkS+IzrAiMOXNpNWhvolF+VXlIFkd VohytV0zw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHp0v-00034X-V5; Mon, 14 Sep 2020 13:59:25 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHp0t-00034B-K1 for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 13:59:24 +0000 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 9D322208E4; Mon, 14 Sep 2020 13:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600091962; bh=L0mDfxQsitxWKkVEy61huFFBlVpZdenmKB6RQVodr3U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DSGroWHvU+TtVCjWoy6vQ28a2g1JAVIDAN75mlAVpumcN06r/WRqh4sJKcG1xwtLs AmJblMeO6bCyStmzhZWNHmxmJ5XsnJQnC+r3IhtG9Gv8muyCJPne6Yf09LAD3ws7O0 gQCEfzPcpwi6JVVhENi49u2Z0I9XHwE2UmEhr4Gs= Date: Mon, 14 Sep 2020 14:59:18 +0100 From: Will Deacon To: Mark Salter Subject: Re: [PATCH v2] drivers/perf: xgene_pmu: Fix uninitialized resource struct Message-ID: <20200914135917.GF24441@willie-the-truck> References: <20200913174536.207265-1-msalter@redhat.com> <20200914112803.GA24312@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_095923_751385_66C015AC X-CRM114-Status: GOOD ( 22.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Khuong Dinh , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Sep 14, 2020 at 09:13:39AM -0400, Mark Salter wrote: > On Mon, 2020-09-14 at 12:28 +0100, Will Deacon wrote: > > On Sun, Sep 13, 2020 at 01:45:36PM -0400, Mark Salter wrote: > > > @@ -1483,11 +1473,23 @@ xgene_pmu_dev_ctx *acpi_get_pmu_hw_inf(struct xgene_pmu *xgene_pmu, > > > return NULL; > > > > > > INIT_LIST_HEAD(&resource_list); > > > - rc = acpi_dev_get_resources(adev, &resource_list, > > > - acpi_pmu_dev_add_resource, &res); > > > + rc = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); > > > + if (rc <= 0) { > > > + dev_err(dev, "PMU type %d: No resources found\n", type); > > > + return NULL; > > > + } > > > + > > > + list_for_each_entry(rentry, &resource_list, node) { > > > + if (resource_type(rentry->res) == IORESOURCE_MEM) { > > > + res = *rentry->res; > > > + rentry = NULL; > > > + break; > > > + } > > > + } > > > acpi_dev_free_resource_list(&resource_list); > > > - if (rc < 0) { > > > - dev_err(dev, "PMU type %d: No resource address found\n", type); > > > + > > > + if (rentry) { > > > > I'm curious as to why you've had to change the failure logic here, setting > > rentry to NULL instead of checking 'rentry->res' like the TX2 driver (which > > I don't immediately understand at first glance). > > > > Will > > > > I don't fully understand the tx2 logic. I do see there's a memory leak if > that (!rentry->res) is true. I was going to dig deeper and follow up with > a patch for tx2. I suspect that rentry->res should never be true. And tx2 > won't detect if no memory resource is in the table. Ah good, so it wasn't just me then! In which case, please send the two patches as a series fixing both drivers, and I'll queue them both together. Ta, Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel