mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] net: renesas: fix a potential NULL pointer dereference
@ 2019-03-11  7:01 Kangjie Lu
  2019-03-11  7:43 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Kangjie Lu @ 2019-03-11  7:01 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Vladimir Barinov, Chris Brandt, netdev,
	linux-renesas-soc, linux-kernel

In case of_get_phy_mode fails, the fix returns NULL to avoid
the NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/renesas/sh_eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 339b2eae2100..b119587ec673 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
 		return NULL;
 
 	pdata->phy_interface = of_get_phy_mode(np);
+	if (unlikely(!pdata->phy_interface))
+		return NULL;
 
 	mac_addr = of_get_mac_address(np);
 	if (mac_addr)
-- 
2.17.1


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

end of thread, other threads:[~2019-03-11 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  7:01 [PATCH] net: renesas: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11  7:43 ` Geert Uytterhoeven
2019-03-11 10:43   ` Sergei Shtylyov

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

all inboxes | Powered by JetHome®