diff options
author | Vignesh Raghavendra <vigneshr@ti.com> | 2020-05-20 20:05:41 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-05-25 18:54:53 +0300 |
commit | 64b69f8c89352975c25730bcca4bf8af2296297f (patch) | |
tree | e71eef532b4a2786c13d2533581bedc3afc5ecf0 /drivers/phy | |
parent | f4c1f705aa6e686bdb68b7092583be17a7bccebf (diff) | |
download | u-boot-64b69f8c89352975c25730bcca4bf8af2296297f.tar.xz |
phy: Fix possible NULL pointer deference
It is possible that users of generic_phy_*() APIs may pass a valid
struct phy pointer but phy->dev can be NULL, leading to NULL pointer
deference in phy_dev_ops().
So call generic_phy_valid() to verify that phy and phy->dev are both
valid.
Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
Diffstat (limited to 'drivers/phy')
-rw-r--r-- | drivers/phy/phy-uclass.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c index 65b5316834..db7f39cd0b 100644 --- a/drivers/phy/phy-uclass.c +++ b/drivers/phy/phy-uclass.c @@ -118,7 +118,7 @@ int generic_phy_init(struct phy *phy) { struct phy_ops const *ops; - if (!phy) + if (!generic_phy_valid(phy)) return 0; ops = phy_dev_ops(phy->dev); @@ -129,7 +129,7 @@ int generic_phy_reset(struct phy *phy) { struct phy_ops const *ops; - if (!phy) + if (!generic_phy_valid(phy)) return 0; ops = phy_dev_ops(phy->dev); @@ -140,7 +140,7 @@ int generic_phy_exit(struct phy *phy) { struct phy_ops const *ops; - if (!phy) + if (!generic_phy_valid(phy)) return 0; ops = phy_dev_ops(phy->dev); @@ -151,7 +151,7 @@ int generic_phy_power_on(struct phy *phy) { struct phy_ops const *ops; - if (!phy) + if (!generic_phy_valid(phy)) return 0; ops = phy_dev_ops(phy->dev); @@ -162,7 +162,7 @@ int generic_phy_power_off(struct phy *phy) { struct phy_ops const *ops; - if (!phy) + if (!generic_phy_valid(phy)) return 0; ops = phy_dev_ops(phy->dev); |