aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2019-03-11 02:06:06 -0500
committerDavid S. Miller <davem@davemloft.net>2019-03-11 16:17:31 -0700
commit5c149314d91876f743ee43efd75b6287ec55480e (patch)
tree060ea9e1ff52f5a153bf63f30e64be916aafde2c /drivers/net/ethernet
parentnet: qlge: fix a potential NULL pointer dereference (diff)
downloadlinux-dev-5c149314d91876f743ee43efd75b6287ec55480e.tar.xz
linux-dev-5c149314d91876f743ee43efd75b6287ec55480e.zip
net: rocker: fix a potential NULL pointer dereference
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> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/rocker/rocker_main.c5
1 files changed, 5 insertions, 0 deletions
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 */