net: sparx5: switchdev: fix possible NULL pointer dereference
authorZheng Yongjun <zhengyongjun3@huawei.com>
Sat, 26 Mar 2022 08:12:39 +0000 (08:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:53 +0000 (14:23 +0200)
commitb375ea083fa649092cd016ac1f89a2d1fd8f8e8b
tree07e6a32bb10965bbd4cb37258f9365dd1a4a48f7
parent409570a619c1cda2e0fde6018a256b9e3d3ba0ee
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>
drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c