netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Check NULL ptr on lvts_data in qcom_ethqos_probe()
@ 2024-08-21 13:19 Ma Ke
  2024-08-21 17:37 ` Simon Horman
  0 siblings, 1 reply; 3+ messages in thread
From: Ma Ke @ 2024-08-21 13:19 UTC (permalink / raw)
  To: vkoul, alexandre.torgue, joabreu, davem, edumazet, kuba, pabeni,
	mcoquelin.stm32, niklas.cassel
  Cc: netdev, linux-arm-msm, linux-stm32, linux-arm-kernel,
	linux-kernel, Ma Ke, stable

of_device_get_match_data() can return NULL if of_match_device failed, and
the pointer 'data' was dereferenced without checking against NULL. Add
checking of pointer 'data' in qcom_ethqos_probe().

Cc: stable@vger.kernel.org
Fixes: a7c30e62d4b8 ("net: stmmac: Add driver for Qualcomm ethqos")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 901a3c1959fa..f18393fe58a4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -838,6 +838,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 	ethqos->mac_base = stmmac_res.addr;
 
 	data = of_device_get_match_data(dev);
+	if (!data)
+		return -ENODEV;
+
 	ethqos->por = data->por;
 	ethqos->num_por = data->num_por;
 	ethqos->rgmii_config_loopback_en = data->rgmii_config_loopback_en;
-- 
2.25.1


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

end of thread, other threads:[~2024-08-21 19:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-21 13:19 [PATCH] net: stmmac: Check NULL ptr on lvts_data in qcom_ethqos_probe() Ma Ke
2024-08-21 17:37 ` Simon Horman
2024-08-21 19:18   ` Bjorn Andersson

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).