diff mbox series

[U-Boot,4/7] net: mvpp2: no deref null

Message ID 20190802175435.10441-5-nhed+uboot@starry.com
State Superseded, archived
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/7] net: mvpp2x: fix traffic stuck after PHY start error | expand

Commit Message

Nevo Hed Aug. 2, 2019, 5:54 p.m. UTC
From: Nevo Hed <nhed+github@starry.com>

phy_dev ptr is set from return of phy_connect() and is used before
test to see if NULL.  Obviously since the test already sxists someoen
made the determination that this NULL is possible.

Signed-off-by: Nevo Hed <nhed+github@starry.com>
---

 drivers/net/mvpp2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Joe Hershberger Aug. 14, 2019, 3:45 p.m. UTC | #1
On Fri, Aug 2, 2019 at 12:54 PM <nhed+uboot@starry.com> wrote:
>
> From: Nevo Hed <nhed+github@starry.com>
>
> phy_dev ptr is set from return of phy_connect() and is used before
> test to see if NULL.  Obviously since the test already sxists someoen
> made the determination that this NULL is possible.
>
> Signed-off-by: Nevo Hed <nhed+github@starry.com>
> ---
>
>  drivers/net/mvpp2.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
> index fae7090121..5f908113f2 100644
> --- a/drivers/net/mvpp2.c
> +++ b/drivers/net/mvpp2.c
> @@ -4494,7 +4494,8 @@ static void mvpp2_phy_connect(struct udevice *dev, struct mvpp2_port *port)
>                  * an option because it is required for the phy_fw_down
>                  * procedure.
>                  */
> -               if (phy_dev->drv->uid == 0xffffffff) {/* Generic phy */
> +               if (phy_dev &&
> +                   phy_dev->drv->uid == 0xffffffff) {/* Generic phy */

This should be squashed into the previous patch.

>                         netdev_warn(port->dev,
>                                     "Marking phy as invalid, link will not be checked\n");
>                         /* set phy_addr to invalid value */
> --
> 2.21.0
>
diff mbox series

Patch

diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c
index fae7090121..5f908113f2 100644
--- a/drivers/net/mvpp2.c
+++ b/drivers/net/mvpp2.c
@@ -4494,7 +4494,8 @@  static void mvpp2_phy_connect(struct udevice *dev, struct mvpp2_port *port)
 		 * an option because it is required for the phy_fw_down
 		 * procedure.
 		 */
-		if (phy_dev->drv->uid == 0xffffffff) {/* Generic phy */
+		if (phy_dev &&
+		    phy_dev->drv->uid == 0xffffffff) {/* Generic phy */
 			netdev_warn(port->dev,
 				    "Marking phy as invalid, link will not be checked\n");
 			/* set phy_addr to invalid value */