Skip to content

drivers: mdio: shell: Fix argument count #93257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

clamattia
Copy link
Contributor

@clamattia clamattia commented Jul 17, 2025

Need to have correct argument count to avoid crash.

Fixes: #93254

@clamattia
Copy link
Contributor Author

Related: #93254

etienne-lms
etienne-lms previously approved these changes Jul 17, 2025
if (ret < 0) {
return ret;
}

if (argc < 5) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this and the below new checks are not needed as the commands take no optional arguments and therefore this is already checked by the shell.

* @note If a command will be called with wrong number of arguments shell will
* print an error message and command handler will not be called.

Copy link
Contributor

@tpambor tpambor left a comment

Choose a reason for hiding this comment

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

I think the number of mandatory arguments for the scan command should be fixed, currently 1 but should be 2, scan and device.

	SHELL_CMD_ARG(scan, &dsub_device_name,
		"Scan MDIO bus for devices: scan <device> [<reg_addr>]",
		cmd_mdio_scan, 1, 1),

Need to have correct argument count to avoid crash.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
@clamattia clamattia force-pushed the hotfix/mdio_shell_buffer_overflow branch from 1b4dd13 to 30e1d6f Compare July 24, 2025 11:42
Copy link

@clamattia
Copy link
Contributor Author

Fixed according to @tpambor suggestion
Rebased

@clamattia clamattia requested review from tpambor and etienne-lms July 24, 2025 11:49
@clamattia clamattia changed the title drivers: mdio: shell: Fix various buffer overflows drivers: mdio: shell: Fix argument count Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ethernet: mdio: Shell Usability: list devices on error
5 participants