net: sparx5: switchdev: fix possible NULL pointer dereference
[ Upstream commit 0906f3a3df07835e37077d8971aac65347f2ed57 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
409570a619
commit
b375ea083f
@ -420,6 +420,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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user