summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJia-Ju Bai <baijiaju1990@gmail.com>2022-03-05 01:14:11 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-16 12:49:00 +0100
commitdd742dd05b5449b8de13e99c7c452e02dd8fb859 (patch)
tree9793cb8e3e7f3a7ac8ce268f06abd5386fcb9f8b
parent0f4e5f285274c2de637ba769dfc51ae1d0f3034d (diff)
downloadlinux-stable-dd742dd05b5449b8de13e99c7c452e02dd8fb859.tar.gz
linux-stable-dd742dd05b5449b8de13e99c7c452e02dd8fb859.tar.bz2
linux-stable-dd742dd05b5449b8de13e99c7c452e02dd8fb859.zip
net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()
[ Upstream commit e0058f0fa80f6e09c4d363779c241c45a3c56b94 ] The function dma_alloc_coherent() in qed_vf_hw_prepare() can fail, so its return value should be checked. Fixes: 1408cc1fa48c ("qed: Introduce VFs") Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/qlogic/qed/qed_vf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 170243d3276b..d0449d5418f7 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -384,6 +384,9 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
p_iov->bulletin.size,
&p_iov->bulletin.phys,
GFP_KERNEL);
+ if (!p_iov->bulletin.p_virt)
+ goto free_pf2vf_reply;
+
DP_VERBOSE(p_hwfn, QED_MSG_IOV,
"VF's bulletin Board [%p virt 0x%llx phys 0x%08x bytes]\n",
p_iov->bulletin.p_virt,
@@ -397,6 +400,10 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
return qed_vf_pf_acquire(p_hwfn);
+free_pf2vf_reply:
+ dma_free_coherent(&p_hwfn->cdev->pdev->dev,
+ sizeof(union pfvf_tlvs),
+ p_iov->pf2vf_reply, p_iov->pf2vf_reply_phys);
free_vf2pf_request:
dma_free_coherent(&p_hwfn->cdev->pdev->dev,
sizeof(union vfpf_tlvs),