public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-12  7:32 Kangjie Lu
  2019-03-12  8:28 ` Chen-Yu Tsai
  2019-03-27 13:42 ` Mukesh Ojha
  0 siblings, 2 replies; 6+ messages in thread
From: Kangjie Lu @ 2019-03-12  7:32 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Maxime Coquelin, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

In case of_device_get_match_data fails, the fix return -ENOMEM
to avoid the NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
 	int err;
 
 	data = of_device_get_match_data(&pdev->dev);
+	if (!data)
+		return -EINVAL;
 
 	err = stmmac_dvr_remove(&pdev->dev);
 	if (err < 0)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH] net: stmmac: fix a potential NULL pointer dereference
@ 2019-03-23  3:39 Kangjie Lu
  2019-03-26  0:15 ` David Miller
       [not found] ` <0f518f7a-ff1f-b8d9-8468-a1f7648ada46@codeaurora.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Kangjie Lu @ 2019-03-23  3:39 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Maxime Coquelin, netdev, linux-stm32,
	linux-arm-kernel, linux-kernel

In case of_device_get_match_data fails, the fix return -EINVAL
to avoid the NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 3256e5cbad27..344ead5949b1 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev)
 	int err;
 
 	data = of_device_get_match_data(&pdev->dev);
+	if (!data)
+		return -EINVAL;
 
 	err = stmmac_dvr_remove(&pdev->dev);
 	if (err < 0)
-- 
2.17.1


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

end of thread, other threads:[~2019-03-27 13:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-12  7:32 [PATCH] net: stmmac: fix a potential NULL pointer dereference Kangjie Lu
2019-03-12  8:28 ` Chen-Yu Tsai
2019-03-27 13:42 ` Mukesh Ojha
  -- strict thread matches above, loose matches on Subject: below --
2019-03-23  3:39 Kangjie Lu
2019-03-26  0:15 ` David Miller
     [not found] ` <0f518f7a-ff1f-b8d9-8468-a1f7648ada46@codeaurora.org>
2019-03-26 19:50   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox