Skip to content

mctpd: fix zeroed ctrl_hdr in endpoint discovery#151

Merged
jk-ozlabs merged 1 commit intoCodeConstruct:mainfrom
msnidhin:fix_endpoint_discovery
Apr 28, 2026
Merged

mctpd: fix zeroed ctrl_hdr in endpoint discovery#151
jk-ozlabs merged 1 commit intoCodeConstruct:mainfrom
msnidhin:fix_endpoint_discovery

Conversation

@msnidhin
Copy link
Copy Markdown
Contributor

@msnidhin msnidhin commented Apr 24, 2026

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.

@msnidhin msnidhin force-pushed the fix_endpoint_discovery branch from bb0fd09 to e5deb79 Compare April 24, 2026 12:33
@jk-ozlabs
Copy link
Copy Markdown
Member

mctpd: init response header before early returns

Fixes zeroed ctrl_hdr in Endpoint Discovery error response

Signed-off-by: Nidhin MS <nidhin.ms@intel.com>

Can we have a little explanation about the error here? For example, what behaviour are you seeing that this fixes?

Comment thread src/mctpd.c Outdated
}

req = (void *)buf;
resp = (void *)resp;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This resp assignment (from the original) doesn't seem to do anything. May as well remove it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi.
In mctp_ctrl_msg_hdr_init_resp(&resp->ctrl_hdr, *req); both variables are used.

Please confirm.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More that the statement

    resp = (void *)resp

does not do anything

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, removed the redundant line.

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 <nidhin.ms@intel.com>
@msnidhin
Copy link
Copy Markdown
Contributor Author

mctpd: init response header before early returns

Fixes zeroed ctrl_hdr in Endpoint Discovery error response

Signed-off-by: Nidhin MS <nidhin.ms@intel.com>

Can we have a little explanation about the error here? For example, what behaviour are you seeing that this fixes?

Updated PR description

@msnidhin msnidhin requested a review from mkj April 28, 2026 02:48
@jk-ozlabs
Copy link
Copy Markdown
Member

Can we have a little explanation about the error here? For example, what behaviour are you seeing that this fixes?

Updated PR description

I was more after an update to the commit message; so we have a better chance of correlating fixes to their behaviours in future.

@msnidhin msnidhin force-pushed the fix_endpoint_discovery branch from e5deb79 to aa65d0a Compare April 28, 2026 02:53
@msnidhin msnidhin changed the title mctpd: init response header before early returns mctpd: fix zeroed ctrl_hdr in endpoint discovery Apr 28, 2026
@msnidhin
Copy link
Copy Markdown
Contributor Author

Can we have a little explanation about the error here? For example, what behaviour are you seeing that this fixes?

Updated PR description

I was more after an update to the commit message; so we have a better chance of correlating fixes to their behaviours in future.

Hi. Updated commit message.

@msnidhin msnidhin force-pushed the fix_endpoint_discovery branch 2 times, most recently from 0a9d89a to 2531e91 Compare April 28, 2026 02:59
Copy link
Copy Markdown
Member

@jk-ozlabs jk-ozlabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@jk-ozlabs jk-ozlabs merged commit 2531e91 into CodeConstruct:main Apr 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants