netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: rocker: fix a potential NULL pointer dereference
@ 2019-03-11  7:06 Kangjie Lu
  2019-03-11 23:18 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2019-03-11  7:06 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, Jiri Pirko, David S. Miller, netdev, linux-kernel

In case kzalloc fails, the fix releases resources and returns
NOTIFY_BAD to avoid NULL pointer dereference.

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

diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index c883aa89b7ca..a71c900ca04f 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2805,6 +2805,11 @@ static int rocker_switchdev_event(struct notifier_block *unused,
 		memcpy(&switchdev_work->fdb_info, ptr,
 		       sizeof(switchdev_work->fdb_info));
 		switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);
+		if (unlikely(!switchdev_work->fdb_info.addr)) {
+			kfree(switchdev_work);
+			return NOTIFY_BAD;
+		}
+
 		ether_addr_copy((u8 *)switchdev_work->fdb_info.addr,
 				fdb_info->addr);
 		/* Take a reference on the rocker device */
-- 
2.17.1


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

* Re: [PATCH] net: rocker: fix a potential NULL pointer dereference
  2019-03-11  7:06 [PATCH] net: rocker: fix a potential NULL pointer dereference Kangjie Lu
@ 2019-03-11 23:18 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-03-11 23:18 UTC (permalink / raw)
  To: kjlu; +Cc: pakki001, jiri, netdev, linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Mon, 11 Mar 2019 02:06:06 -0500

> In case kzalloc fails, the fix releases resources and returns
> NOTIFY_BAD to avoid NULL pointer dereference.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>

Applied.

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  7:06 [PATCH] net: rocker: fix a potential NULL pointer dereference Kangjie Lu
2019-03-11 23:18 ` David Miller

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