From: Simon Goldschmidt Date: Fri, 12 Jul 2019 20:58:18 +0200 Subject: [U-Boot] [PATCH] cmd: mdio: prevent data abort when no mdio bus is found Message-ID: <20190712185818.24237-1-simon.k.r.goldschmidt@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Calling 'mdio read ...' currently leads to a data abort when no mdio bus is found. To fix this, check if 'bus' is a valid pointer before accessing it. Signed-off-by: Simon Goldschmidt --- cmd/mdio.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/mdio.c b/cmd/mdio.c index 5e219f699d..e1f771d3ed 100644 --- a/cmd/mdio.c +++ b/cmd/mdio.c @@ -263,6 +263,11 @@ static int do_mdio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; } + if (!bus) { + puts("No MDIO bus found\n"); + return CMD_RET_FAILURE; + } + if (op[0] == 'l') { mdio_list_devices(); -- 2.20.1