diff mbox series

[U-Boot] cmd: mdio: prevent data abort when no mdio bus is found

Message ID 20190712185818.24237-1-simon.k.r.goldschmidt@gmail.com
State Accepted
Commit cb58d18beb3cd65b66c20f913cb55c38c322457b
Delegated to: Joe Hershberger
Headers show
Series [U-Boot] cmd: mdio: prevent data abort when no mdio bus is found | expand

Commit Message

Simon Goldschmidt July 12, 2019, 6:58 p.m. UTC
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 <simon.k.r.goldschmidt@gmail.com>
---

 cmd/mdio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Vladimir Oltean July 13, 2019, 12:03 p.m. UTC | #1
On Fri, 12 Jul 2019 at 21:58, Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com> wrote:
>
> 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 <simon.k.r.goldschmidt@gmail.com>
> ---

Tested-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

>
>  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
>
Joe Hershberger July 15, 2019, 6:12 p.m. UTC | #2
On Fri, Jul 12, 2019 at 1:59 PM Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com> wrote:
>
> 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 <simon.k.r.goldschmidt@gmail.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger July 18, 2019, 9:40 p.m. UTC | #3
Hi Simon,

https://patchwork.ozlabs.org/patch/1131508/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

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();