diff mbox series

qed/qed_sriov: avoid null-ptr-deref

Message ID 20241025093135.1053121-1-chenridong@huaweicloud.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series qed/qed_sriov: avoid null-ptr-deref | expand

Commit Message

Chen Ridong Oct. 25, 2024, 9:31 a.m. UTC
From: Chen Ridong <chenridong@huawei.com>

The qed_iov_get_public_vf_info may return NULL, which may lead to
null-ptr-deref. To avoid possible null-ptr-deref, check vf_info
before accessing its member.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 drivers/net/ethernet/qlogic/qed/qed_sriov.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Alexander Lobakin Oct. 25, 2024, 3:28 p.m. UTC | #1
From: Chen Ridong <chenridong@huaweicloud.com>
Date: Fri, 25 Oct 2024 09:31:35 +0000

> [PATCH] qed/qed_sriov: avoid null-ptr-deref

Use the correct tree prefix, [PATCH net] in your case.

> From: Chen Ridong <chenridong@huawei.com>

Why do you commit from @huawei.com, but send from @huaweicloud.com?

> 
> The qed_iov_get_public_vf_info may return NULL, which may lead to
> null-ptr-deref. To avoid possible null-ptr-deref, check vf_info

Do you have a repro for this or it's purely hypothetical?

> before accessing its member.
> 

Here you should have a "Fixes:" tag if you believe this is a fix.

> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>  drivers/net/ethernet/qlogic/qed/qed_sriov.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> index fa167b1aa019..30da9865496d 100644
> --- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> +++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
> @@ -2997,6 +2997,8 @@ static int qed_iov_pre_update_vport(struct qed_hwfn *hwfn,
>  		return 0;
>  
>  	vf_info = qed_iov_get_public_vf_info(hwfn, vfid, true);
> +	if (!vf_info)
> +		return 0;

0 or error code?

>  
>  	if (flags->update_rx_mode_config) {
>  		vf_info->rx_accept_mode = flags->rx_accept_filter;

Thanks,
Olek
diff mbox series

Patch

diff --git a/drivers/net/ethernet/qlogic/qed/qed_sriov.c b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
index fa167b1aa019..30da9865496d 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sriov.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_sriov.c
@@ -2997,6 +2997,8 @@  static int qed_iov_pre_update_vport(struct qed_hwfn *hwfn,
 		return 0;
 
 	vf_info = qed_iov_get_public_vf_info(hwfn, vfid, true);
+	if (!vf_info)
+		return 0;
 
 	if (flags->update_rx_mode_config) {
 		vf_info->rx_accept_mode = flags->rx_accept_filter;
@@ -5145,6 +5147,9 @@  static void qed_iov_handle_trust_change(struct qed_hwfn *hwfn)
 		 * needed.
 		 */
 		vf_info = qed_iov_get_public_vf_info(hwfn, i, true);
+		if (!vf_info)
+			continue;
+
 		if (vf_info->is_trusted_configured ==
 		    vf_info->is_trusted_request)
 			continue;