diff mbox series

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

Message ID 20241031123847.1356808-1-ruanjinjie@huawei.com
State New
Headers show
Series phy: ocelot-serdes: Fix IS_ERR vs NULL bug in serdes_probe() | expand

Commit Message

Jinjie Ruan Oct. 31, 2024, 12:38 p.m. UTC
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(-)

Comments

Colin Foster Oct. 31, 2024, 2:31 p.m. UTC | #1
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
Markus Elfring Oct. 31, 2024, 4:59 p.m. UTC | #2
> 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
Markus Elfring Oct. 31, 2024, 5:15 p.m. UTC | #3
> 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
Colin Foster Oct. 31, 2024, 5:46 p.m. UTC | #4
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
Markus Elfring Oct. 31, 2024, 6:09 p.m. UTC | #5
> 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
Colin Foster Oct. 31, 2024, 6:22 p.m. UTC | #6
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.
diff mbox series

Patch

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]);