Skip to content

Commit 5c14931

Browse files
kengiterdavem330
authored andcommitted
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>
1 parent 4280b73 commit 5c14931

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/net/ethernet/rocker/rocker_main.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,11 @@ static int rocker_switchdev_event(struct notifier_block *unused,
28052805
memcpy(&switchdev_work->fdb_info, ptr,
28062806
sizeof(switchdev_work->fdb_info));
28072807
switchdev_work->fdb_info.addr = kzalloc(ETH_ALEN, GFP_ATOMIC);
2808+
if (unlikely(!switchdev_work->fdb_info.addr)) {
2809+
kfree(switchdev_work);
2810+
return NOTIFY_BAD;
2811+
}
2812+
28082813
ether_addr_copy((u8 *)switchdev_work->fdb_info.addr,
28092814
fdb_info->addr);
28102815
/* Take a reference on the rocker device */

0 commit comments

Comments
 (0)