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 79CD434D3AA for ; Mon, 2 Feb 2026 09:34:41 +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=1770024883; cv=none; b=FTewr6nN6ZEayVQpiJ42S4TQ9Ot93yJijQLvhBZekuR6+q5CQQsW1G9NEQINHxigxOagEX9jeacVD2Jcs7uMiJrUkC9iG59RI5gCRL4ihbJ4g/ujvxJuwKwMBMAP1+Iq7doRdom/Nt/SKKbY4GPFgxIeGTrx445lYDhUST8cPQo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770024883; c=relaxed/simple; bh=FKzkEQ0j6Pfh7Y1ApXM5Be0GTYJUKxqz4/lXxfvmDms=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nlxYULRklboKwJLRMUAtzRsFMZ41HWCYWDVkpFNMiWroUi/UJUuSqK4AWQCpSWxKWvfjSUMfHchuSPlZ12MKeCI2JD3QNzM+D6BiQN/g6Jxrus5rF/7Vq1B1DVxBeif6xXtmx70AlbFEaXdnyHlREOI9XczRKtwoLpvoU8w7T64= 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 87164339; Mon, 2 Feb 2026 01:34:34 -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 3A7673F740; Mon, 2 Feb 2026 01:34:39 -0800 (PST) From: Leo Yan Date: Mon, 02 Feb 2026 09:34:04 +0000 Subject: [PATCH v3 8/8] coresight: Unify error handling in coresight_register() 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: <20260202-arm_coresight_refactor_dev_register-v3-8-03292470c48c@arm.com> References: <20260202-arm_coresight_refactor_dev_register-v3-0-03292470c48c@arm.com> In-Reply-To: <20260202-arm_coresight_refactor_dev_register-v3-0-03292470c48c@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=1770024862; l=2294; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=FKzkEQ0j6Pfh7Y1ApXM5Be0GTYJUKxqz4/lXxfvmDms=; b=8pyHcAVQuLvHeini3qOEsN8lnterXQqsp9ycDWXbCQYNHBblwuihlQl3z5PVE+oKi9tyYJ+WR F+v5QN/4Eg7DVH/Umlb9QRx3MiZTWW0m0TNf1K+rncQLk1NTdw7tiT0 X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Unify error handling during registration: 1) Failures before device registration are handled by err_out, which releases platform data. 2) Jump to the out_unlock label on failures after device registration to unwind the flow via coresight_unregister(). The "registered" variable is no longer used, remove it. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-core.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 955af43010446803030973c72f07315492b2fcf3..65cf975493c86de42515845147d90497aa20c595 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1326,7 +1326,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) { int ret; struct coresight_device *csdev; - bool registered = false; csdev = kzalloc(sizeof(*csdev), GFP_KERNEL); if (!csdev) { @@ -1380,7 +1379,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) * All resources are free'd explicitly via * coresight_device_release(), triggered from put_device(). */ - goto out_unlock; + mutex_unlock(&coresight_mutex); + goto err_out; } ret = etm_perf_add_symlink_sink(csdev); @@ -1390,12 +1390,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) * coresight_device_release() triggered from put_device(), which is in * turn called from function device_unregister(). */ - if (ret && ret != -EOPNOTSUPP) { - device_unregister(&csdev->dev); + if (ret && ret != -EOPNOTSUPP) goto out_unlock; - } - /* Device is now registered */ - registered = true; ret = coresight_create_conns_sysfs_group(csdev); if (ret) @@ -1415,11 +1411,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) out_unlock: mutex_unlock(&coresight_mutex); - /* Unregister the device if needed */ - if (registered) { - coresight_unregister(csdev); - return ERR_PTR(ret); - } + coresight_unregister(csdev); + return ERR_PTR(ret); err_out: coresight_release_platform_data(desc->dev, desc->pdata); -- 2.34.1