From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DC45E33ADAD for ; Mon, 26 Jan 2026 13:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435566; cv=none; b=bhDMTZzy+GsFanpurBOr4J+H7TjDLJsDdNOFo5Uk0AXR2cJQp73QJltTZdrkWVLbqTYC2NLHyp0YrLS1oQ1h86KlWMp4NfNO55e3iYu+CSeRtEOTLarHHYO9PeYVBH+eqs+2/OqJ1SKxObPWoPAldjQsM0L5c8+J1SYC3Znl+uo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435566; c=relaxed/simple; bh=sU9u6OCx/Fy2Hv6Til4Fd08SgN9HV1pojJ6aLoovuyk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WZxBxa9BiSOE6pGWBr10Mzl+T8eFwNJ9UvHoS612rA7L9tmIYlSgOfKBxbptUIIwufkpPbsQe9QGf0UYmaeSQGnwM6CPUroQT7nX25/G8SH99sHBQrsn5R60LRHfI9W6+G8MBoeXqJsLDiA4BjWsNvd3I4D1d59kPxLovMc3ppY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 B44911515; Mon, 26 Jan 2026 05:52:36 -0800 (PST) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7FA5D3F632; Mon, 26 Jan 2026 05:52:41 -0800 (PST) From: Leo Yan Date: Mon, 26 Jan 2026 13:52:02 +0000 Subject: [PATCH v2 2/8] coresight: Get parent device reference after sink ID map allocation Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260126-arm_coresight_refactor_dev_register-v2-2-b5a3c0441c15@arm.com> References: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com> In-Reply-To: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Greg Kroah-Hartman , Mathieu Poirier , Mao Jinlong Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1769435557; l=1925; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=sU9u6OCx/Fy2Hv6Til4Fd08SgN9HV1pojJ6aLoovuyk=; b=nTeSFJqqhHh7Q4Jhm630XBz7DPukiHgXZaCTrQgI4Aoosj8Dr9ElkKoO0p2xadl4zHsBT1Gw4 WkV/K7PILW0DtJ/OE1OZLtas74C/k1I5EUxeqllmJAheGQYp+5dFNRC X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= The parent device's reference count is incremented before allocating the sink ID map. If the allocation fails, the reference count is not decremented, preventing proper cleanup. Fix this by incrementing the reference count only after the sink ID map is successfully allocated. Fixes: 5ad628a76176 ("coresight: Use per-sink trace ID maps for Perf sessions") Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-core.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index ed304f292b7b02e89c59053d43f88fbf663cc993..6f21925a4913330a27db5d5836f34f13382339e7 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1346,12 +1346,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) csdev->dev.parent = desc->dev; csdev->dev.release = coresight_device_release; csdev->dev.bus = &coresight_bustype; - /* - * Hold the reference to our parent device. This will be - * dropped only in coresight_device_release(). - */ - csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev)); - dev_set_name(&csdev->dev, "%s", desc->name); if (csdev->type == CORESIGHT_DEV_TYPE_SINK || csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) { @@ -1363,6 +1357,14 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) goto err_out; } } + + /* + * Hold the reference to our parent device. This will be + * dropped only in coresight_device_release(). + */ + csdev->dev.fwnode = fwnode_handle_get(dev_fwnode(desc->dev)); + dev_set_name(&csdev->dev, "%s", desc->name); + /* * Make sure the device registration and the connection fixup * are synchronised, so that we don't see uninitialised devices -- 2.34.1