From 2531e9187699b043d36082876228d197460c2c7c Mon Sep 17 00:00:00 2001 From: Nidhin MS Date: Fri, 24 Apr 2026 17:45:30 +0530 Subject: [PATCH] mctpd: fix zeroed ctrl_hdr in endpoint discovery In handle_control_endpoint_discovery(), the response header initialization (mctp_ctrl_msg_hdr_init_resp) was placed after the DISCOVERY_UNSUPPORTED check. When the interface has discovery unsupported, the function would call reply_message() with a zeroed ctrl_hdr, sending a response with no command code and no instance ID Move the req/resp pointer setup and mctp_ctrl_msg_hdr_init_resp() call so that response carries a correctly initialized control header. Signed-off-by: Nidhin MS --- src/mctpd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mctpd.c b/src/mctpd.c index cd2b527..523cda5 100644 --- a/src/mctpd.c +++ b/src/mctpd.c @@ -1233,6 +1233,9 @@ handle_control_endpoint_discovery(struct ctx *ctx, int sd, return 0; } + req = (void *)buf; + 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 +1247,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); }