[PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

Subsystems: arm/mediatek usb3 phy driver, drm drivers for mediatek, generic phy framework, the rest

STALE1669d LANDED

Landed in mainline as 399c91c3f305 on 2021-12-27.

5 messages, 4 authors, 2022-01-06 · open the first message on its own page

[PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

From: Miaoqian Lin <hidden>
Date: 2021-12-24 08:21:12

The of_device_get_match_data() function may return NULL.
Add check to prevent potential null dereference.

Signed-off-by: Miaoqian Lin <redacted>
---
 drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 28ad9403c441..67b005d5b9e3 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	mipi_tx->driver_data = of_device_get_match_data(dev);
+	if (!mipi_tx->driver_data)
+		return -ENODEV;
 
 	mipi_tx->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(mipi_tx->regs))
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Date: 2021-12-24 09:55:09

Il 24/12/21 09:21, Miaoqian Lin ha scritto:
The of_device_get_match_data() function may return NULL.
Add check to prevent potential null dereference.

Signed-off-by: Miaoqian Lin <redacted>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

From: Chunfeng Yun <chunfeng.yun@mediatek.com>
Date: 2021-12-30 01:56:16

On Fri, 2021-12-24 at 08:21 +0000, Miaoqian Lin wrote:
quoted hunk
The of_device_get_match_data() function may return NULL.
Add check to prevent potential null dereference.

Signed-off-by: Miaoqian Lin <redacted>
---
 drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 28ad9403c441..67b005d5b9e3 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct
platform_device *pdev)
 		return -ENOMEM;
 
 	mipi_tx->driver_data = of_device_get_match_data(dev);
+	if (!mipi_tx->driver_data)
+		return -ENODEV;
 
 	mipi_tx->regs = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(mipi_tx->regs))
Acked-by: Chunfeng Yun <chunfeng.yun@mediatek.com>

Thanks
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Date: 2021-12-30 16:31:50

Hi, Miaoqian:

Miaoqian Lin [off-list ref] 於 2021年12月24日 週五 下午4:21寫道:
quoted hunk
The of_device_get_match_data() function may return NULL.
Add check to prevent potential null dereference.

Signed-off-by: Miaoqian Lin <redacted>
---
 drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 28ad9403c441..67b005d5b9e3 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
                return -ENOMEM;

        mipi_tx->driver_data = of_device_get_match_data(dev);
+       if (!mipi_tx->driver_data)
I'm confused. mtk_mipi_tx_probe() is called because this device node's
compatible match one in mtk_mipi_tx_match[]. So I think the return
value of of_device_get_match_data(dev) would not be NULL. If this is
true, this checking is redundant.

Regards,
Chun-Kuang.
+               return -ENODEV;

        mipi_tx->regs = devm_platform_ioremap_resource(pdev, 0);
        if (IS_ERR(mipi_tx->regs))
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Re: [PATCH] phy: mediatek: Fix missing check in mtk_mipi_tx_probe

From: Miaoqian Lin <hidden>
Date: 2022-01-06 12:16:12

Hi, Chun-Kuang:

On Fri, Dec 31, 2021 at 12:31:33AM +0800, Chun-Kuang Hu wrote:
quoted
diff --git a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
index 28ad9403c441..67b005d5b9e3 100644
--- a/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
+++ b/drivers/phy/mediatek/phy-mtk-mipi-dsi.c
@@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)
                return -ENOMEM;

        mipi_tx->driver_data = of_device_get_match_data(dev);
+       if (!mipi_tx->driver_data)
I'm confused. mtk_mipi_tx_probe() is called because this device node's
compatible match one in mtk_mipi_tx_match[]. So I think the return
value of of_device_get_match_data(dev) would not be NULL. If this is
true, this checking is redundant.
I think your are right, this checking is redundant. Thanks for your
reply.

Regards,
Miaoqian.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help