Message ID | 20211117074843.GE5237@kili |
---|---|
State | Accepted |
Commit | f0ae8685b2858fc1dabf5ea743642abb5f242375 |
Headers | show |
Series | phy: HiSilicon: Fix copy and paste bug in error handling | expand |
Em Wed, 17 Nov 2021 10:48:43 +0300 Dan Carpenter <dan.carpenter@oracle.com> escreveu: > This should check ">pmctrl" instead of "->sysctrl". This bug could > potentially lead to a crash if we dereference the error pointer. > > Fixes: 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> > --- > drivers/phy/hisilicon/phy-hi3670-pcie.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilicon/phy-hi3670-pcie.c > index c64c6679b1b9..0ac9634b398d 100644 > --- a/drivers/phy/hisilicon/phy-hi3670-pcie.c > +++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c > @@ -757,8 +757,8 @@ static int hi3670_pcie_phy_get_resources(struct hi3670_pcie_phy *phy, > return PTR_ERR(phy->sysctrl); > > phy->pmctrl = syscon_regmap_lookup_by_compatible("hisilicon,hi3670-pmctrl"); > - if (IS_ERR(phy->sysctrl)) > - return PTR_ERR(phy->sysctrl); > + if (IS_ERR(phy->pmctrl)) > + return PTR_ERR(phy->pmctrl); > > /* clocks */ > phy->phy_ref_clk = devm_clk_get(dev, "phy_ref");
On 17-11-21, 10:48, Dan Carpenter wrote: > This should check ">pmctrl" instead of "->sysctrl". This bug could > potentially lead to a crash if we dereference the error pointer. Applied, thanks
diff --git a/drivers/phy/hisilicon/phy-hi3670-pcie.c b/drivers/phy/hisilicon/phy-hi3670-pcie.c index c64c6679b1b9..0ac9634b398d 100644 --- a/drivers/phy/hisilicon/phy-hi3670-pcie.c +++ b/drivers/phy/hisilicon/phy-hi3670-pcie.c @@ -757,8 +757,8 @@ static int hi3670_pcie_phy_get_resources(struct hi3670_pcie_phy *phy, return PTR_ERR(phy->sysctrl); phy->pmctrl = syscon_regmap_lookup_by_compatible("hisilicon,hi3670-pmctrl"); - if (IS_ERR(phy->sysctrl)) - return PTR_ERR(phy->sysctrl); + if (IS_ERR(phy->pmctrl)) + return PTR_ERR(phy->pmctrl); /* clocks */ phy->phy_ref_clk = devm_clk_get(dev, "phy_ref");
This should check ">pmctrl" instead of "->sysctrl". This bug could potentially lead to a crash if we dereference the error pointer. Fixes: 73075011ffff ("phy: HiSilicon: Add driver for Kirin 970 PCIe PHY") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/phy/hisilicon/phy-hi3670-pcie.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)