U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Maxin B. John" <maxin.john@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: trini@konsulko.com
Subject: [PATCH] cmd: mdio: check argc for extended mode
Date: Sat, 24 Oct 2026 01:01:33 +0300	[thread overview]
Message-ID: <20261023220133.1396280-1-maxin.john@gmail.com> (raw)

Check argc before accessing argv[2] in extended MDIO operations
(rx/wx).

Return CMD_RET_USAGE if the PHY device name is missing.

Signed-off-by: Maxin B. John <maxin.john@gmail.com>
---
 cmd/mdio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmd/mdio.c b/cmd/mdio.c
index c0a87087d315..1d73a77ece35 100644
--- a/cmd/mdio.c
+++ b/cmd/mdio.c
@@ -230,6 +230,9 @@ static int do_mdio(struct cmd_tbl *cmdtp, int flag, int argc,
 	if (strlen(argv[1]) > 1) {
 		op[1] = argv[1][1];
 		if (op[1] == 'x') {
+			if (argc < 3)
+				return CMD_RET_USAGE;
+
 			phydev = mdio_phydev_for_ethname(argv[2]);
 
 			if (phydev) {
-- 
2.47.3


             reply	other threads:[~2026-10-23 22:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 22:01 Maxin B. John [this message]
2026-10-26 16:14 ` [PATCH] cmd: mdio: check argc for extended mode Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261023220133.1396280-1-maxin.john@gmail.com \
    --to=maxin.john@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.u-boot-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox