Skip to content

Commit 0906f3a

Browse files
Zheng Yongjundavem330
authored andcommitted
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: 1061590 ("net: sparx5: switchdev: adding frame DMA functionality") Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7781607 commit 0906f3a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ static int sparx5_fdma_tx_alloc(struct sparx5 *sparx5)
422422
db_hw->dataptr = phys;
423423
db_hw->status = 0;
424424
db = devm_kzalloc(sparx5->dev, sizeof(*db), GFP_KERNEL);
425+
if (!db)
426+
return -ENOMEM;
425427
db->cpu_addr = cpu_addr;
426428
list_add_tail(&db->list, &tx->db_list);
427429
}

0 commit comments

Comments
 (0)