Received: by 2002:a05:7412:bb8d:b0:d7:7d3a:4fe2 with SMTP id js13csp1655016rdb; Wed, 16 Aug 2023 19:52:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGWxG/2j3TEPOqwIDDRLuIvNmwVXVUy+dbTx57F8sSLpd1nJYPywPO9WiC0KZglTH3wngqx X-Received: by 2002:a05:6a21:778a:b0:11f:c1a1:8c with SMTP id bd10-20020a056a21778a00b0011fc1a1008cmr4194239pzc.54.1692240772273; Wed, 16 Aug 2023 19:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692240772; cv=none; d=google.com; s=arc-20160816; b=roSUPBpNgycJDDsGqPDG8uGR7z6HylcunqSY9+woP6EDofuvxIRAwuDmEsQcgp71WY KmWC6NrjaEjfo02HqfEvCobALZeJt3FhsCwdVzCFLhU0cSkGwkqnBJdINb4g5MFGXa08 BWy9TttCLaXxQL1Q3w3k2aIKmGky7tJv0HS47ZD2adGotDZcMQIhwJvEyKe8i9qV4t/N +6t/nKd4C+PZu/uATXU6TOyBTcAp32Btz7FNTFK2fClRjh7xlgAc2A2G+zgHrrt6YhtX JQGguS1qmkSj1Ixtrca0w3KOY76RokuIOek1CCz5FJiHTZD7Mm+So/C4sDJC2xm5+kug /sDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VBDHQ0XFZoCSRy7Lgdiy2fGkD6OUSpMY2PzEAPtL+BY=; fh=eT3oZfkiC2Ug0ZOw+bbHPGDmilib+Q+m99wdfHpgLWQ=; b=si3PFaIX7G2aVT9D1hDOsw6nrtpLx5HGdAmXoMMOGHl9DDGZK3AdyRR0cmWcJm0op2 s4yT98RUsCQrL6UICjut9Czl9ZXDmWj/C6JFxcmddMlnVOtJDpYdSF8x56PoRnTskDYN z+KplDvvqSA4QBMV/O+ir/vwwixKQo7bl7nGGr3MB2780HSSaa3DEkbHKiZBQ+PkJr4z veTMnqA/SLIR+a2Bz3XWtoV0xNhbLG/2JEroYUa5LN593jorq4eR0mm3T8XgQXOHxAW4 t8elzUXkkpFxWnL3B+tuARmb87w3XuedJI6mfulQdD/9EMC7iVJWMokWrc1G5cTjjxa8 q5zg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j65-20020a638b44000000b00565e5651c6dsi3199631pge.766.2023.08.16.19.52.29; Wed, 16 Aug 2023 19:52:52 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245461AbjHPOK2 (ORCPT + 99 others); Wed, 16 Aug 2023 10:10:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343573AbjHPOK0 (ORCPT ); Wed, 16 Aug 2023 10:10:26 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AAAEF26B5 for ; Wed, 16 Aug 2023 07:10:24 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A2F2E1063; Wed, 16 Aug 2023 07:11:05 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 999E93F762; Wed, 16 Aug 2023 07:10:22 -0700 (PDT) From: Suzuki K Poulose To: hejunhao3@huawei.com Cc: coresight@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jonathan.cameron@huawei.com, leo.yan@linaro.org, mike.leach@linaro.org, james.clark@arm.com, linuxarm@huawei.com, yangyicong@huawei.com, prime.zeng@hisilicon.com, Suzuki K Poulose , Anshuman Khandual Subject: [PATCH 2/2] coresight: trbe: Allocate platform data per device Date: Wed, 16 Aug 2023 15:10:08 +0100 Message-Id: <20230816141008.535450-2-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816141008.535450-1-suzuki.poulose@arm.com> References: <20230814093813.19152-1-hejunhao3@huawei.com> <20230816141008.535450-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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 Coresight TRBE driver shares a single platform data (which is empty btw). However, with the commit 4e8fe7e5c3a5 ("coresight: Store pointers to connections rather than an array of them") the coresight core would free up the pdata, resulting in multiple attempts to free the same pdata for TRBE instances. Fix this by allocating a pdata per coresight_device. Fixes: 3fbf7f011f24 ("coresight: sink: Add TRBE driver") Link: https://lore.kernel.org/r/20230814093813.19152-3-hejunhao3@huawei.com Reported-by: Junhao He Cc: Anshuman Khandual Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-trbe.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 025f70adee47..d3d34a833f01 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -1255,10 +1255,13 @@ static void arm_trbe_register_coresight_cpu(struct trbe_drvdata *drvdata, int cp if (!desc.name) goto cpu_clear; + desc.pdata = coresight_get_platform_data(dev); + if (IS_ERR(desc.pdata)) + goto cpu_clear; + desc.type = CORESIGHT_DEV_TYPE_SINK; desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_PERCPU_SYSMEM; desc.ops = &arm_trbe_cs_ops; - desc.pdata = dev_get_platdata(dev); desc.groups = arm_trbe_groups; desc.dev = dev; trbe_csdev = coresight_register(&desc); @@ -1482,7 +1485,6 @@ static void arm_trbe_remove_irq(struct trbe_drvdata *drvdata) static int arm_trbe_device_probe(struct platform_device *pdev) { - struct coresight_platform_data *pdata; struct trbe_drvdata *drvdata; struct device *dev = &pdev->dev; int ret; @@ -1497,12 +1499,7 @@ static int arm_trbe_device_probe(struct platform_device *pdev) if (!drvdata) return -ENOMEM; - pdata = coresight_get_platform_data(dev); - if (IS_ERR(pdata)) - return PTR_ERR(pdata); - dev_set_drvdata(dev, drvdata); - dev->platform_data = pdata; drvdata->pdev = pdev; ret = arm_trbe_probe_irq(pdev, drvdata); if (ret) -- 2.34.1