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=-5.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C0212C43461 for ; Mon, 14 Sep 2020 13:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A3BB206DB for ; Mon, 14 Sep 2020 13:22:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SVL49iGq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726711AbgINNWV (ORCPT ); Mon, 14 Sep 2020 09:22:21 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:25617 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726671AbgINNNv (ORCPT ); Mon, 14 Sep 2020 09:13:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600089225; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rHosvbjE+qxesSMeQdFmkgpnqKzDeColCCFxXxMS9zE=; b=SVL49iGqOvZHjoR11lAdpBwcmMg7U07wGBaM7fy6j59KQq2vzWcHsRPTkPYIpRK/eRX7Yt Fz84kTE5LyztdIdcnV50NIBy8QPrOTfusXPaIsiWSX4ywP4yBpB3aj20ISglszdTu77aob ADcH+NDJLanlmFuYdxe4lcY+kI0380k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-5fIobcj3O96clNvJiYWhmQ-1; Mon, 14 Sep 2020 09:13:41 -0400 X-MC-Unique: 5fIobcj3O96clNvJiYWhmQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F8D2190A3F0; Mon, 14 Sep 2020 13:13:40 +0000 (UTC) Received: from ovpn-119-163.rdu2.redhat.com (ovpn-119-163.rdu2.redhat.com [10.10.119.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86A8960C0F; Mon, 14 Sep 2020 13:13:39 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] drivers/perf: xgene_pmu: Fix uninitialized resource struct From: Mark Salter To: Will Deacon Cc: Mark Rutland , Khuong Dinh , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Mon, 14 Sep 2020 09:13:39 -0400 In-Reply-To: <20200914112803.GA24312@willie-the-truck> References: <20200913174536.207265-1-msalter@redhat.com> <20200914112803.GA24312@willie-the-truck> Organization: Red Hat, Inc Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Mark 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=-5.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 139CCC433E2 for ; Mon, 14 Sep 2020 13:15:04 +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 8C0E3208DB for ; Mon, 14 Sep 2020 13:15:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ejvJu7so"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="XR+DG4Df" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8C0E3208DB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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:MIME-Version:References:In-Reply-To:Date:To:From: Subject:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ORiYPU1hljryDvpeJpwDvQc2R26JJDLj1kC9g9ZRDno=; b=ejvJu7so0fsKEQwpvGybkPEph TAnghW74Oc59vsoCOLQCujy3tYjX/WTq9ZxtzZL0L4vUKbFTg/HMYA05uXk+qhI3W7AQ/wqjECnMx 4n2Mg4ud7u2LHLivdAfauqGqvPlN2YuJwal+IlcwerWkNpyAlLrnYQKazHtF6VDaXrwFvpATmbDc2 qxwG2Bcx1/UjHWo/FP0WoidmZGOo8AF7ejOYQUXoSd+h9wHy3zSUH2WPKNtKL61uwvuJp5S6dkkq5 /kF6vD8Dp0IykVu0pmfE4jqtX6f5fMZep+7HgkLHESyTDjdBXK9axilQ6y0XMiKIP9SHMi1O98Ot2 d52imrBRQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHoIk-0005qX-Ej; Mon, 14 Sep 2020 13:13:46 +0000 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120] helo=us-smtp-1.mimecast.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kHoIi-0005pd-6v for linux-arm-kernel@lists.infradead.org; Mon, 14 Sep 2020 13:13:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600089223; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rHosvbjE+qxesSMeQdFmkgpnqKzDeColCCFxXxMS9zE=; b=XR+DG4DfrwYQ+iZhRyuT5sGfCRd7v9bRY+yGOUmlebfwiXBtbVcn0elNKtxADGmagSaRp6 PZm2GxlY5/Js3l4YHLkmQTJyD+H6qojnZWwqx31wovNAxV0tDsw2j4MnAY7uBuyJ5k+YeC 5WBdBVd/jXz19Zk/pF45BCWyrL0gDRc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-5fIobcj3O96clNvJiYWhmQ-1; Mon, 14 Sep 2020 09:13:41 -0400 X-MC-Unique: 5fIobcj3O96clNvJiYWhmQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0F8D2190A3F0; Mon, 14 Sep 2020 13:13:40 +0000 (UTC) Received: from ovpn-119-163.rdu2.redhat.com (ovpn-119-163.rdu2.redhat.com [10.10.119.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86A8960C0F; Mon, 14 Sep 2020 13:13:39 +0000 (UTC) Message-ID: Subject: Re: [PATCH v2] drivers/perf: xgene_pmu: Fix uninitialized resource struct From: Mark Salter To: Will Deacon Date: Mon, 14 Sep 2020 09:13:39 -0400 In-Reply-To: <20200914112803.GA24312@willie-the-truck> References: <20200913174536.207265-1-msalter@redhat.com> <20200914112803.GA24312@willie-the-truck> Organization: Red Hat, Inc User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200914_091344_286768_1BC838C5 X-CRM114-Status: GOOD ( 18.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, 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. Mark _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel