[10/15] net/bnxt: avoid null pointer dereference

Message ID 20190712060622.76975-11-ajit.khaparde@broadcom.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series bnxt patch series |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ajit Khaparde July 12, 2019, 6:06 a.m. UTC
  From: Lance Richardson <lance.richardson@broadcom.com>

Avoid null pointer dereference when allocating an insolated
completion ring by basing nq ring allocation on whether an
nq ring was requested instead of whether the device supports
nq rings.

Fixes: f8168ca0e690 ("net/bnxt: support thor controller")
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ring.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ring.c b/drivers/net/bnxt/bnxt_ring.c
index 9e6074ae3..98853ea7a 100644
--- a/drivers/net/bnxt/bnxt_ring.c
+++ b/drivers/net/bnxt/bnxt_ring.c
@@ -280,7 +280,7 @@  int bnxt_alloc_rings(struct bnxt *bp, uint16_t qidx,
 	}
 	cp_ring_info->hw_stats_ctx_id = HWRM_NA_SIGNATURE;
 
-	if (BNXT_HAS_NQ(bp)) {
+	if (nq_ring_info) {
 		struct bnxt_ring *nq_ring = nq_ring_info->cp_ring_struct;
 
 		nq_ring->bd = (char *)mz->addr + nq_ring_start;