net: hns3: add validity check for message data length
Add validity check for message data length in function hclge_send_mbx_msg(), avoid unexpected overflow. Fixes: dde1a86e93ca ("net: hns3: Add mailbox support to PF driver") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
48009e9972
commit
7d413735cb
@ -94,6 +94,13 @@ static int hclge_send_mbx_msg(struct hclge_vport *vport, u8 *msg, u16 msg_len,
|
||||
enum hclge_comm_cmd_status status;
|
||||
struct hclge_desc desc;
|
||||
|
||||
if (msg_len > HCLGE_MBX_MAX_MSG_SIZE) {
|
||||
dev_err(&hdev->pdev->dev,
|
||||
"msg data length(=%u) exceeds maximum(=%u)\n",
|
||||
msg_len, HCLGE_MBX_MAX_MSG_SIZE);
|
||||
return -EMSGSIZE;
|
||||
}
|
||||
|
||||
resp_pf_to_vf = (struct hclge_mbx_pf_to_vf_cmd *)desc.data;
|
||||
|
||||
hclge_cmd_setup_basic_desc(&desc, HCLGEVF_OPC_MBX_PF_TO_VF, false);
|
||||
|
Loading…
x
Reference in New Issue
Block a user