]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
net: ethernet: eqos: fix NULL pointer dereference
authorBhadram Varka <vbhadram@nvidia.com>
Mon, 9 Jan 2017 05:39:59 +0000 (11:09 +0530)
committerJani Uusi-Rantala <juusirantala@nvidia.com>
Wed, 11 Jan 2017 12:48:22 +0000 (04:48 -0800)
Few PHY drivers does not support lower power mode support.
Its better to check PHY dev and lower power function
pointer before deferencing them.

Coverity ID:489976
Bug 200192398

Change-Id: I586018664d66975692829768f98dd0a4590861c9
Signed-off-by: Bhadram Varka <vbhadram@nvidia.com>
Reviewed-on: http://git-master/r/1281948
Reviewed-by: Narayan Reddy <narayanr@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/net/ethernet/nvidia/eqos/drv.c

index 7adcee3e4f0f7a24afb962e3b285cb7224a4f58c..148c38cbf0aa8ff9e4cc37929897a0fe567f4f65 100644 (file)
@@ -29,7 +29,7 @@
  * DAMAGE.
  * ========================================================================= */
 /*
- * Copyright (c) 2015-2016, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2015-2017, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -5792,7 +5792,8 @@ void eqos_stop_dev(struct eqos_prv_data *pdata)
        /* disable MAC TX */
        hw_if->stop_mac_tx();
 
-       if (pdata->phydev->drv->low_power_mode) {
+       if (pdata->phydev && pdata->phydev->drv &&
+           pdata->phydev->drv->low_power_mode) {
                pdata->phydev->drv->low_power_mode(pdata->phydev, true);
                if (!pdata->suspended)
                        phy_stop_interrupts(pdata->phydev);