diff mbox series

net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare()

Message ID 20220303033450.2108-1-baijiaju1990@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: qlogic: check the return value of dma_alloc_coherent() in qed_vf_hw_prepare() | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 1 blamed authors not CCed: Yuval.Mintz@qlogic.com; 1 maintainers not CCed: Yuval.Mintz@qlogic.com
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Jia-Ju Bai March 3, 2022, 3:34 a.m. UTC
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>
---
 drivers/net/ethernet/qlogic/qed/qed_vf.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Jakub Kicinski March 4, 2022, 5:19 a.m. UTC | #1
On Wed,  2 Mar 2022 19:34:50 -0800 Jia-Ju Bai wrote:
> --- 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_vf2pf_request;

leaking the reply buffer
Jia-Ju Bai March 5, 2022, 8:37 a.m. UTC | #2
On 2022/3/4 13:19, Jakub Kicinski wrote:
> On Wed,  2 Mar 2022 19:34:50 -0800 Jia-Ju Bai wrote:
>> --- 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_vf2pf_request;
> leaking the reply buffer

Hi Jakub,

Thanks for pointing out this problem.
I will send a V2 patch.


Best wishes,
Jia-Ju Bai
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_vf.c b/drivers/net/ethernet/qlogic/qed/qed_vf.c
index 597cd9cd57b5..5786d7ab6310 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_vf2pf_request;
+
 	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,