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 A226B33B97D for ; Mon, 26 Jan 2026 13:52:54 +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=1769435577; cv=none; b=K2Ov8NtxKLRyHGaMoYhOXtyjMWlYkHXIRDDofqoN5Q7uXWTf4z5REjb7wpom5+YSBeFxXMMdaC0qjsS5dHmwcD3VUeS5k3dhOR/R98ccE/3pnmcjX7gm+VqdTm0JZ4pCkhxBP70EhEgfToxiIFkIhj9db4kHeLtU8hm8bT/0eiY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435577; c=relaxed/simple; bh=880QgqoGJpM76WHGJPVeV8CTB+waFSOBrewKHx10yEo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ae8Yg8fAaMYFxTgGt9I6sWz1hjVZVOE4Jd0El7Ty2xzutftmqmTYjz06ipQpiRBhn1hROeMr+q8el5xOtswrs9R7UIj48ZKQqkW6EYyRxLA813M/akHhfdXDHEbcMnr/c92A3bYWfy+3d3fQr2wVJJ5J18AtoHDowbn8iSZEQvQ= 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 0C025153B; Mon, 26 Jan 2026 05:52:47 -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 CA9C63F632; Mon, 26 Jan 2026 05:52:51 -0800 (PST) From: Leo Yan Date: Mon, 26 Jan 2026 13:52:07 +0000 Subject: [PATCH v2 7/8] coresight: Do not mix success path with failure handling 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-7-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=1351; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=880QgqoGJpM76WHGJPVeV8CTB+waFSOBrewKHx10yEo=; b=+F97SOQYNgFkPNvp4D35ZRyz3QF5wqUu0aiD3Fp88rR4E0hqReaOaSpE7zw9xdieG7ZE2RXuj YkIT7K1ZtSFAq6VkN1Z3ku4x3xfFauCvGrxetG6esUzFlQoUSdrU8Zx X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Separate the failure handling path from the successful case. Use the 'out_unlock' label only for failure handling. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-core.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 5c29f78de7f115d61f550dea62b6538940ec9182..c2b5a6efd1c01b0fbfbc289cf27232ccc731ba34 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1395,17 +1395,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) registered = true; ret = coresight_create_conns_sysfs_group(csdev); - if (!ret) - ret = coresight_fixup_orphan_conns(csdev); + if (ret) + goto out_unlock; + + ret = coresight_fixup_orphan_conns(csdev); + if (ret) + goto out_unlock; + + mutex_unlock(&coresight_mutex); + + if (cti_assoc_ops && cti_assoc_ops->add) + cti_assoc_ops->add(csdev); + + return csdev; out_unlock: mutex_unlock(&coresight_mutex); - /* Success */ - if (!ret) { - if (cti_assoc_ops && cti_assoc_ops->add) - cti_assoc_ops->add(csdev); - return csdev; - } /* Unregister the device if needed */ if (registered) { -- 2.34.1