From e5deb794dff06a759f6413f78eeb92f72ba5f253 Mon Sep 17 00:00:00 2001 From: Nidhin MS Date: Fri, 24 Apr 2026 17:45:30 +0530 Subject: [PATCH] mctpd: init response header before early returns Fixes zeroed ctrl_hdr in Endpoint Discovery error response Signed-off-by: Nidhin MS --- src/mctpd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mctpd.c b/src/mctpd.c index cd2b527..4d532e3 100644 --- a/src/mctpd.c +++ b/src/mctpd.c @@ -1233,6 +1233,10 @@ handle_control_endpoint_discovery(struct ctx *ctx, int sd, return 0; } + req = (void *)buf; + resp = (void *)resp; + mctp_ctrl_msg_hdr_init_resp(&resp->ctrl_hdr, *req); + if (link_data->discovered == DISCOVERY_UNSUPPORTED) { resp->completion_code = MCTP_CTRL_CC_ERROR_INVALID_DATA; return reply_message(ctx, sd, resp, @@ -1244,10 +1248,6 @@ handle_control_endpoint_discovery(struct ctx *ctx, int sd, return 0; } - req = (void *)buf; - resp = (void *)resp; - mctp_ctrl_msg_hdr_init_resp(&resp->ctrl_hdr, *req); - // we need to send using physical addressing, no entry in routing table yet return reply_message_phys(ctx, sd, resp, sizeof(*resp), addr); }