net: ethernet: mtk_eth_soc: add check for allocation failure
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 21 Apr 2022 15:49:02 +0000 (18:49 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 25 Apr 2022 10:26:30 +0000 (11:26 +0100)
Check if the kzalloc() failed.

Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mediatek/mtk_wed.c

index 5530f7991d1d3ba8962b42282b81ea1dd8c5aa06..8f0cd3196aacffedf6f59957fdd131e7ddb6e305 100644 (file)
@@ -827,6 +827,8 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
                goto unlock;
 
        hw = kzalloc(sizeof(*hw), GFP_KERNEL);
+       if (!hw)
+               goto unlock;
        hw->node = np;
        hw->regs = regs;
        hw->eth = eth;