[PATCH v1 7/8] x86/virt/tdx: Clean up error handling in get_tdx_sys_info()

From: Chao Gao

Date: Tue Aug 04 2026 - 07:36:13 EST


get_tdx_sys_info() chains its calls with

ret = ret ?: get_tdx_sys_info_foo(...);

so that the remaining reads are skipped once one fails. That is an artifact
of the code generator rather than the usual kernel idiom. Use plain early
returns instead.

The version is still printed before the error from reading it is checked,
so a failed read is reported with whatever the print shows.

No functional change intended.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>
---
arch/x86/virt/vmx/tdx/tdx.c | 24 +++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 1b8cd7656f36..4bf21848df62 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -529,21 +529,31 @@ static __init int get_tdx_sys_info_td_conf(struct tdx_sys_info_td_conf *td_conf)

static __init int get_tdx_sys_info(struct tdx_sys_info *sysinfo)
{
- int ret = 0;
+ int ret;

- ret = ret ?: get_tdx_sys_info_version(&sysinfo->version);
+ ret = get_tdx_sys_info_version(&sysinfo->version);

pr_info("Module version: " TDX_VERSION_FMT "\n",
sysinfo->version.major_version,
sysinfo->version.minor_version,
sysinfo->version.update_version);

- ret = ret ?: get_tdx_sys_info_features(&sysinfo->features);
- ret = ret ?: get_tdx_sys_info_tdmr(&sysinfo->tdmr);
- ret = ret ?: get_tdx_sys_info_td_ctrl(&sysinfo->td_ctrl);
- ret = ret ?: get_tdx_sys_info_td_conf(&sysinfo->td_conf);
+ if (ret)
+ return ret;

- return ret;
+ ret = get_tdx_sys_info_features(&sysinfo->features);
+ if (ret)
+ return ret;
+
+ ret = get_tdx_sys_info_tdmr(&sysinfo->tdmr);
+ if (ret)
+ return ret;
+
+ ret = get_tdx_sys_info_td_ctrl(&sysinfo->td_ctrl);
+ if (ret)
+ return ret;
+
+ return get_tdx_sys_info_td_conf(&sysinfo->td_conf);
}

static __init int check_features(struct tdx_sys_info *sysinfo)
--
2.52.0