net: dsa: qca8k: Add check for skb_copy
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Mon, 10 Jul 2023 01:39:07 +0000 (09:39 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Jul 2023 07:21:53 +0000 (08:21 +0100)
Add check for the return value of skb_copy in order to avoid NULL pointer
dereference.

Fixes: 2cd548566384 ("net: dsa: qca8k: add support for phy read/write with mgmt Ethernet")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/qca/qca8k-8xxx.c

index f7d7cfb2fd86517e9dbd7d9c5124472795e400ea..09b80644c11bd679557ee626f0c78eb5f24297ed 100644 (file)
@@ -588,6 +588,9 @@ qca8k_phy_eth_busy_wait(struct qca8k_mgmt_eth_data *mgmt_eth_data,
        bool ack;
        int ret;
 
+       if (!skb)
+               return -ENOMEM;
+
        reinit_completion(&mgmt_eth_data->rw_done);
 
        /* Increment seq_num and set it in the copy pkt */