UPSTREAM: 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. Change-Id: I0d19180ae8524eb240f4afd6ea55d5d0f2907798 Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com> Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com> (cherry picked from commit 64b69f8c89352975c25730bcca4bf8af2296297f)
This commit is contained in:
parent
1bac1f3947
commit
37a5e4d859
|
|
@ -100,7 +100,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);
|
||||
|
||||
|
|
@ -111,7 +111,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);
|
||||
|
||||
|
|
@ -122,7 +122,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);
|
||||
|
||||
|
|
@ -133,7 +133,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);
|
||||
|
||||
|
|
@ -144,7 +144,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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue