From 2c93d5baf9a83f2485a22b87be42d4789b04b8a1 Mon Sep 17 00:00:00 2001 From: Rasesh Mody Date: Tue, 7 Nov 2017 00:34:25 -0800 Subject: [PATCH] net/qede: fix null pointer dereferences Fix null pointer dereferences in qede_vxlan_enable() and qede_conf_udp_dst_port() Coverity issue: 195010, 195012, 198439 Fixes: e0947ed912f7 ("net/qede: add support for VXLAN UDP port config over VF") Fixes: 739a5b2f2b49 ("net/qede/base: use passed ptt handler") Signed-off-by: Rasesh Mody --- drivers/net/qede/qede_ethdev.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index 7a589a2d13..883214515d 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -631,7 +631,13 @@ qede_vxlan_enable(struct rte_eth_dev *eth_dev, uint8_t clss, for_each_hwfn(edev, i) { p_hwfn = &edev->hwfns[i]; - p_ptt = IS_PF(edev) ? ecore_ptt_acquire(p_hwfn) : NULL; + if (IS_PF(edev)) { + p_ptt = ecore_ptt_acquire(p_hwfn); + if (!p_ptt) + return -EAGAIN; + } else { + p_ptt = NULL; + } rc = ecore_sp_pf_update_tunn_cfg(p_hwfn, p_ptt, &tunn, ECORE_SPQ_MODE_CB, NULL); if (rc != ECORE_SUCCESS) { @@ -2258,7 +2264,13 @@ qede_conf_udp_dst_port(struct rte_eth_dev *eth_dev, tunn.vxlan_port.port = udp_port; for_each_hwfn(edev, i) { p_hwfn = &edev->hwfns[i]; - p_ptt = IS_PF(edev) ? ecore_ptt_acquire(p_hwfn) : NULL; + if (IS_PF(edev)) { + p_ptt = ecore_ptt_acquire(p_hwfn); + if (!p_ptt) + return -EAGAIN; + } else { + p_ptt = NULL; + } rc = ecore_sp_pf_update_tunn_cfg(p_hwfn, p_ptt, &tunn, ECORE_SPQ_MODE_CB, NULL); if (rc != ECORE_SUCCESS) { -- 2.20.1