phy: mediatek: Fix missing check in mtk_mipi_tx_probe
Subsystems (4)
PATCH 1/1 phy: mediatek: Fix missing check in mtk_mipi_tx_probe
The of_device_get_match_data() function may return NULL. Add check to prevent potential null dereference.
--- drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/mediatek/phy-mtk-mipi-dsi.c +2 -0
@@ -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))
Signature · 1 line
2.17.1
Il 24/12/21 09:21, Miaoqian Lin ha scritto:
Quoted 4 lines
The
of_device_get_match_data()function may return NULL. Add check to prevent potential null dereference.Signed-off-by Miaoqian Lin <[email protected]>
Quoted 22 lines · Miaoqian Lin
The
of_device_get_match_data()function may return NULL. Add check to prevent potential null dereference.Signed-off-by Miaoqian Lin <[email protected]>--- drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++ 1 file changed, 2 insertions(+)drivers/phy/mediatek/phy-mtk-mipi-dsi.c +2
-0@@ -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 );
Quoted 1 line
if (
IS_ERR(mipi_tx->regs))
Thanks
Chun-Kuang Hu
maintainerHi, Miaoqian:
Miaoqian Lin <[email protected]> 於 2021年12月24日 週五 下午4:21寫道:
Quoted 14 lines
The
of_device_get_match_data()function may return NULL. Add check to prevent potential null dereference.Signed-off-by Miaoqian Lin <[email protected]>--- drivers/phy/mediatek/phy-mtk-mipi-dsi.c | 2 ++ 1 file changed, 2 insertions(+)drivers/phy/mediatek/phy-mtk-mipi-dsi.c +0
-0
drivers/phy/mediatek/phy-mtk-mipi-dsi.c static int mtk_mipi_tx_probe(struct platform_device *pdev) · line 149
Quoted 4 lines
drivers/phy/mediatek/phy-mtk-mipi-dsi.c +1
-0@@ -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.
Quoted 7 lines
drivers/phy/mediatek/phy-mtk-mipi-dsi.c +1
-1+return -ENODEV ; mipi_tx->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (mipi_tx->regs)) --2.17.1
Hi, Chun-Kuang:
Quoted 7 lines · Chun-Kuang Hu
Quoted 7 lines
drivers/phy/mediatek/phy-mtk-mipi-dsi.c +0
-0@@ -146,6 +146,8 @@ static int mtk_mipi_tx_probe(struct platform_device *pdev)return -ENOMEM ;
Quoted 8 lines
drivers/phy/mediatek/phy-mtk-mipi-dsi.c static int mtk_mipi_tx_probe(struct platform_device *pdev) · line 149
Quoted 2 lines
drivers/phy/mediatek/phy-mtk-mipi-dsi.c +1
-0mipi_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 ofof_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.