linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: ocelot_board: fix a NULL pointer dereference
@ 2019-03-11  6:36 Kangjie Lu
  2019-03-11 10:26 ` Alexandre Belloni
  0 siblings, 1 reply; 5+ messages in thread
From: Kangjie Lu @ 2019-03-11  6:36 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Alexandre Belloni, Microchip Linux Driver Support,
	David S. Miller, netdev, linux-kernel

In case devm_kcalloc fails, the fix returns -ENOMEM to avoid
NULL pointer dereference.

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

diff --git a/drivers/net/ethernet/mscc/ocelot_board.c b/drivers/net/ethernet/mscc/ocelot_board.c
index e7f90101d2e0..af68abf1632a 100644
--- a/drivers/net/ethernet/mscc/ocelot_board.c
+++ b/drivers/net/ethernet/mscc/ocelot_board.c
@@ -256,6 +256,8 @@ static int mscc_ocelot_probe(struct platform_device *pdev)
 
 	ocelot->ports = devm_kcalloc(&pdev->dev, ocelot->num_phys_ports,
 				     sizeof(struct ocelot_port *), GFP_KERNEL);
+	if (!ocelot->ports)
+		return -ENOMEM;
 
 	INIT_LIST_HEAD(&ocelot->multicast);
 	ocelot_init(ocelot);
-- 
2.17.1


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

end of thread, other threads:[~2019-03-23  3:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  6:36 [PATCH] net: ocelot_board: fix a NULL pointer dereference Kangjie Lu
2019-03-11 10:26 ` Alexandre Belloni
2019-03-11 14:14   ` Eric Dumazet
2019-03-11 17:39     ` David Miller
2019-03-23  3:33     ` Kangjie Lu

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