[PATCH] phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()

Jinjie Ruan posted 1 patch 3 weeks, 3 days ago
drivers/phy/mscc/phy-ocelot-serdes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Jinjie Ruan 3 weeks, 3 days ago
dev_get_regmap() return NULL and never return ERR_PTR().
check NULL to fix it.

Cc: stable@vger.kernel.org
Fixes: 672faa7bbf60 ("phy: phy-ocelot-serdes: add ability to be used in a non-syscon configuration")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
 drivers/phy/mscc/phy-ocelot-serdes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/mscc/phy-ocelot-serdes.c b/drivers/phy/mscc/phy-ocelot-serdes.c
index 1cd1b5db2ad7..77ca67ce6e91 100644
--- a/drivers/phy/mscc/phy-ocelot-serdes.c
+++ b/drivers/phy/mscc/phy-ocelot-serdes.c
@@ -512,8 +512,8 @@ static int serdes_probe(struct platform_device *pdev)
 						    res->name);
 	}
 
-	if (IS_ERR(ctrl->regs))
-		return PTR_ERR(ctrl->regs);
+	if (!ctrl->regs)
+		return -EINVAL;
 
 	for (i = 0; i < SERDES_MAX; i++) {
 		ret = serdes_phy_create(ctrl, i, &ctrl->phys[i]);
-- 
2.34.1
Re: [PATCH] phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Markus Elfring 3 weeks, 3 days ago
> dev_get_regmap() return NULL and never return ERR_PTR().

                   call can return a null pointer.
It will not return error pointers.


> check NULL to fix it.

Thus apply a null pointer check instead.


Regards,
Markus
Re: [PATCH] phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Colin Foster 3 weeks, 3 days ago
On Thu, Oct 31, 2024 at 08:38:47PM +0800, Jinjie Ruan wrote:
> dev_get_regmap() return NULL and never return ERR_PTR().
> check NULL to fix it.
> 
> Cc: stable@vger.kernel.org
> Fixes: 672faa7bbf60 ("phy: phy-ocelot-serdes: add ability to be used in a non-syscon configuration")
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  drivers/phy/mscc/phy-ocelot-serdes.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/mscc/phy-ocelot-serdes.c b/drivers/phy/mscc/phy-ocelot-serdes.c
> index 1cd1b5db2ad7..77ca67ce6e91 100644
> --- a/drivers/phy/mscc/phy-ocelot-serdes.c
> +++ b/drivers/phy/mscc/phy-ocelot-serdes.c
> @@ -512,8 +512,8 @@ static int serdes_probe(struct platform_device *pdev)
>  						    res->name);
>  	}
>  
> -	if (IS_ERR(ctrl->regs))
> -		return PTR_ERR(ctrl->regs);
> +	if (!ctrl->regs)
> +		return -EINVAL;
>  
>  	for (i = 0; i < SERDES_MAX; i++) {
>  		ret = serdes_phy_create(ctrl, i, &ctrl->phys[i]);
> -- 
> 2.34.1
> 

Good find.

Acked-by: colin.foster@in-advantage.com
Revieved-by: colin.foster@in-advantage.com
Re: phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Markus Elfring 3 weeks, 3 days ago
> Good find.
>
> Acked-by: colin.foster@in-advantage.com
> Revieved-by: colin.foster@in-advantage.com

Please reconsider the usage of these tags once more.

* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc5#n456

* Should a personal name be mentioned (besides the email address)?


Regards,
Markus
Re: phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Colin Foster 3 weeks, 3 days ago
On Thu, Oct 31, 2024 at 06:15:09PM +0100, Markus Elfring wrote:
> > Good find.
> >
> > Acked-by: colin.foster@in-advantage.com
> > Revieved-by: colin.foster@in-advantage.com
> 
> Please reconsider the usage of these tags once more.
> 
> * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc5#n456
> 
> * Should a personal name be mentioned (besides the email address)?
> 

You're absolutely right. Apologies.

Acked-by: Colin Foster <colin.foster@in-advantage.com>
Revieved-by: Colin Foster <colin.foster@in-advantage.com>

> 
> Regards,
> Markus
Re: phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Markus Elfring 3 weeks, 3 days ago
> You're absolutely right. Apologies.
>
> Acked-by: Colin Foster <colin.foster@in-advantage.com>
> Revieved-by: Colin Foster <colin.foster@in-advantage.com>
Please choose one of these tags (without a typo).

Regards,
Markus
Re: phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe()
Posted by Colin Foster 3 weeks, 3 days ago
On Thu, Oct 31, 2024 at 07:09:17PM +0100, Markus Elfring wrote:
> > You're absolutely right. Apologies.
> >
> > Acked-by: Colin Foster <colin.foster@in-advantage.com>
> > Revieved-by: Colin Foster <colin.foster@in-advantage.com>
> Please choose one of these tags (without a typo).

Sigh... Today is not my day. I don't know if there are any actions for
me at this point. If there are please let me know.