Skip to content

Commit

Permalink
net: hns3: fix use-after-free bug in hclgevf_send_mbx_msg
Browse files Browse the repository at this point in the history
[ Upstream commit 27cbf64 ]

Currently, the hns3_remove function firstly uninstall client instance,
and then uninstall acceletion engine device. The netdevice is freed in
client instance uninstall process, but acceletion engine device uninstall
process still use it to trace runtime information. This causes a use after
free problem.

So fixes it by check the instance register state to avoid use after free.

Fixes: d835524 ("net: hns3: add trace event support for PF/VF mailbox")
Signed-off-by: Jie Wang <wangjie125@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>
  • Loading branch information
Jie Wang authored and gregkh committed Dec 22, 2021
1 parent 3a4f6db commit 12512bc
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c
Expand Up @@ -109,7 +109,8 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev,

memcpy(&req->msg, send_msg, sizeof(struct hclge_vf_to_pf_msg));

trace_hclge_vf_mbx_send(hdev, req);
if (test_bit(HCLGEVF_STATE_NIC_REGISTERED, &hdev->state))
trace_hclge_vf_mbx_send(hdev, req);

/* synchronous send */
if (need_resp) {
Expand Down

0 comments on commit 12512bc

Please sign in to comment.