linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource()
@ 2021-06-03  5:10 Yang Yingliang
  2021-06-03  5:49 ` Vinod Koul
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-06-03  5:10 UTC (permalink / raw)
  To: linux-kernel, linux-phy; +Cc: vkoul, steen.hegelund

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/phy/microchip/sparx5_serdes.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/phy/microchip/sparx5_serdes.c b/drivers/phy/microchip/sparx5_serdes.c
index c8a7d0927ced..4076580fc2cd 100644
--- a/drivers/phy/microchip/sparx5_serdes.c
+++ b/drivers/phy/microchip/sparx5_serdes.c
@@ -2470,6 +2470,10 @@ static int sparx5_serdes_probe(struct platform_device *pdev)
 	priv->coreclock = clock;
 
 	iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!iores) {
+		dev_err(priv->dev, "Invalid resource\n");
+		return -EINVAL;
+	}
 	iomem = devm_ioremap(priv->dev, iores->start, resource_size(iores));
 	if (IS_ERR(iomem)) {
 		dev_err(priv->dev, "Unable to get serdes registers: %s\n",
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource()
  2021-06-03  5:10 [PATCH -next] phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource() Yang Yingliang
@ 2021-06-03  5:49 ` Vinod Koul
  0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2021-06-03  5:49 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-phy, steen.hegelund

On 03-06-21, 13:10, Yang Yingliang wrote:
> It will cause null-ptr-deref if platform_get_resource() returns NULL,
> we need check the return value.

Applied, thanks

-- 
~Vinod

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-03  5:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03  5:10 [PATCH -next] phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource() Yang Yingliang
2021-06-03  5:49 ` Vinod Koul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).