summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/microchip
diff options
context:
space:
mode:
authorZheng Yongjun <zhengyongjun3@huawei.com>2022-03-26 11:12:39 +0300
committerDavid S. Miller <davem@davemloft.net>2022-03-26 21:49:09 +0300
commit0906f3a3df07835e37077d8971aac65347f2ed57 (patch)
tree85f92e039959014d522db31c4a1ad70d9c79f5a3 /drivers/net/ethernet/microchip
parent7781607938c8371d4c2b243527430241c62e39c2 (diff)
downloadlinux-0906f3a3df07835e37077d8971aac65347f2ed57.tar.xz
net: sparx5: switchdev: fix possible NULL pointer dereference
As the possible failure of the allocation, devm_kzalloc() may return NULL pointer. Therefore, it should be better to check the 'db' in order to prevent the dereference of NULL pointer. Fixes: 10615907e9b51 ("net: sparx5: switchdev: adding frame DMA functionality") Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/microchip')
-rw-r--r--drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
index 2dc87584023a..1e9ff365459e 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
@@ -422,6 +422,8 @@ static int sparx5_fdma_tx_alloc(struct sparx5 *sparx5)
db_hw->dataptr = phys;
db_hw->status = 0;
db = devm_kzalloc(sparx5->dev, sizeof(*db), GFP_KERNEL);
+ if (!db)
+ return -ENOMEM;
db->cpu_addr = cpu_addr;
list_add_tail(&db->list, &tx->db_list);
}