public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail•com>
To: Alok Tiwari <alok.a.tiwari@oracle•com>
Cc: hkallweit1@gmail•com, andrew@lunn•ch, kuba@kernel•org,
	davem@davemloft•net, edumazet@google•com, pabeni@redhat•com,
	horms@kernel•org, netdev@vger•kernel.org,
	alok.a.tiwarilinux@gmail•com
Subject: Re: [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap()
Date: Tue, 4 Nov 2025 13:01:15 +0100	[thread overview]
Message-ID: <6909eb0d.df0a0220.3d8529.c3fb@mx.google.com> (raw)
In-Reply-To: <20251031161607.58581-1-alok.a.tiwari@oracle.com>

On Fri, Oct 31, 2025 at 09:15:53AM -0700, Alok Tiwari wrote:
> The call to device_node_to_regmap() in airoha_mdio_probe() can return
> an ERR_PTR() if regmap initialization fails. Currently, the driver
> stores the pointer without validation, which could lead to a crash
> if it is later dereferenced.
> 
> Add an IS_ERR() check and return the corresponding error code to make
> the probe path more robust.
> 
> Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle•com>

Thanks for taking care. It goes against the schema but yep it's a corner
case that should be handled.

> ---
>  drivers/net/mdio/mdio-airoha.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
> index 1dc9939c8d7d..52e7475121ea 100644
> --- a/drivers/net/mdio/mdio-airoha.c
> +++ b/drivers/net/mdio/mdio-airoha.c
> @@ -219,6 +219,8 @@ static int airoha_mdio_probe(struct platform_device *pdev)
>  	priv = bus->priv;
>  	priv->base_addr = addr;
>  	priv->regmap = device_node_to_regmap(dev->parent->of_node);
> +	if (IS_ERR(priv->regmap))
> +		return PTR_ERR(priv->regmap);
>  
>  	priv->clk = devm_clk_get_enabled(dev, NULL);
>  	if (IS_ERR(priv->clk))
> -- 
> 2.50.1
> 

-- 
	Ansuel

      parent reply	other threads:[~2025-11-04 12:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31 16:15 [PATCH net] net: mdio: Check regmap pointer returned by device_node_to_regmap() Alok Tiwari
2025-10-31 16:32 ` Andrew Lunn
2025-11-04  1:10 ` patchwork-bot+netdevbpf
2025-11-04 12:01 ` Christian Marangi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6909eb0d.df0a0220.3d8529.c3fb@mx.google.com \
    --to=ansuelsmth@gmail$(echo .)com \
    --cc=alok.a.tiwari@oracle$(echo .)com \
    --cc=alok.a.tiwarilinux@gmail$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=hkallweit1@gmail$(echo .)com \
    --cc=horms@kernel$(echo .)org \
    --cc=kuba@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=pabeni@redhat$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox