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 2A2A733ADAC for ; Mon, 26 Jan 2026 13:52:56 +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=1769435579; cv=none; b=F26LPW6RFKIbuzQFDRh79NFpk69ZSRUsNe0MbBz4g3LZ2VtuPO6NvXPZxQfhyMXcqMYbQJDMjP11iBdzXbwgEiIQLE38sY30ql1zwpxPmvg+KQXOz9dFmZu1hJgktLueAVxDhe6kgnZM0UGGKlLwvkghnt3RDOO2ifxXa9fhUnw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435579; c=relaxed/simple; bh=DTF22SZMe66CIYK4lzqxzWYf/sXtAO+3p0iCWw5x/m4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eQGPHoLRVfjQ2flX7UBXuGYIbLd1P9dvKPLFF2jtlGD3WHMdcPlxnPa/vGubEr4uIDDK0yXdMj/V8wDuLiQFcMIaf4ojksbr/SOHkiCdD7Qz8ITgmd1GCBNCYxwlrUCaKMTeDFMs+ApWRZr3dQk6U2yAhBFtXuRh1dyPQEYy0QM= 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 19C77497; Mon, 26 Jan 2026 05:52:49 -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 D97963F632; Mon, 26 Jan 2026 05:52:53 -0800 (PST) From: Leo Yan Date: Mon, 26 Jan 2026 13:52:08 +0000 Subject: [PATCH v2 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: <20260126-arm_coresight_refactor_dev_register-v2-8-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=2294; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=DTF22SZMe66CIYK4lzqxzWYf/sXtAO+3p0iCWw5x/m4=; b=EEbd/ybBNWTr2Z3VfrBCyH9ZM/rDxeLQ7++72xI76/+xEIBMEpyxYXcZwB/68Yx6FItImmKAn H0cU//t0Aa4C6VEVX9TSapPYa41e9Euu0PSc1FIn78JropPLmc6pIsr 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 c2b5a6efd1c01b0fbfbc289cf27232ccc731ba34..0aa64ee36dd06f86d3f6be1cab3067bf91467686 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1323,7 +1323,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) { @@ -1377,7 +1376,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); @@ -1387,12 +1387,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) @@ -1412,11 +1408,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