]> git.ipfire.org Git - people/arne_f/kernel.git/commit
net: hns3: fix the exception when query imp info
authorJiaran Zhang <zhangjiaran@huawei.com>
Mon, 13 Sep 2021 13:08:24 +0000 (21:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:39:24 +0000 (12:39 +0200)
commit0eb2133475b443de3845cc879b80409ef4d93673
tree6e20dd6cf1d5ec24b1a7b31153ebbf166feddf1a
parentcd0015a07cf7b760d2a6ba5da7d84b7dcfa61d29
net: hns3: fix the exception when query imp info

[ Upstream commit 472430a7b066f19afa1b55867d621b2d6d323e0d ]

When the command for querying imp info is issued to the firmware,
if the firmware does not support the command, the returned value
of bd num is 0.
Add protection mechanism before alloc memory to prevent apply for
0-length memory.

Fixes: 0b198b0d80ea ("net: hns3: refactor dump m7 info of debugfs")
Signed-off-by: Jiaran Zhang <zhangjiaran@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c