* [PATCH v2] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()
@ 2022-03-05 9:14 Jia-Ju Bai
2022-03-07 11:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2022-03-05 9:14 UTC (permalink / raw)
To: aelior, manishc, davem, kuba; +Cc: netdev, linux-kernel, Jia-Ju Bai
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>
---
v2:
* Fix a memory leak of p_iov->pf2vf_reply in error handling code.
Thank Jakub for good advice.
---
drivers/net/ethernet/qlogic/qed/qed_vf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 597cd9cd57b5..7b0e390c0b07 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_vf.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_vf.c
@@ -513,6 +513,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,
@@ -552,6 +555,10 @@ int qed_vf_hw_prepare(struct qed_hwfn *p_hwfn)
return rc;
+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),
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()
2022-03-05 9:14 [PATCH v2] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() Jia-Ju Bai
@ 2022-03-07 11:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-07 11:30 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: aelior, manishc, davem, kuba, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Sat, 5 Mar 2022 01:14:11 -0800 you wrote:
> 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>
>
> [...]
Here is the summary with links:
- [v2] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()
https://git.kernel.org/netdev/net/c/e0058f0fa80f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-07 11:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-05 9:14 [PATCH v2] net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() Jia-Ju Bai
2022-03-07 11:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).