[PATCH] net: qed: Fix the use of NULL pointer
From: Jiasheng Jiang
Date: Fri Nov 05 2021 - 06:20:18 EST
If the return value of 'IS_PF(cdev)' is False, then 'p_ptt'
is NULL and the check 'if (IS_PF(cdev) && !p_ptt)' can be
passed through.
Then 'p_ptt' will be used in qed_memcpy_to().
However, 'p_ptt' will be used there, such as 'p_ptt->idx'.
Thus it might be better to fix it.
Fixes: dacd88d ("qed: IOV l2 functionality")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
drivers/net/ethernet/qlogic/qed/qed_l2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c
index dfaf10e..f5ada83 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_l2.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c
@@ -1932,7 +1932,7 @@ void qed_reset_vport_stats(struct qed_dev *cdev)
: NULL;
u32 addr = 0, len = 0;
- if (IS_PF(cdev) && !p_ptt) {
+ if (!p_ptt) {
DP_ERR(p_hwfn, "Failed to acquire ptt\n");
continue;
}
--
2.7.4