[dpdk-dev,v2,2/2] net/liquidio: fix null pointer check

Message ID 1491808736-14239-2-git-send-email-shijith.thotton@caviumnetworks.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Shijith Thotton April 10, 2017, 7:18 a.m. UTC
  Fix null pointer check in release Rx/Tx queue APIs.

Reported by Coverity scan:
1423923 Dereference before null check
1423924 Dereference before null check

Fixes: 9a30013b9884 ("net/liquidio: add API to release Rx queue")
Fixes: cf6bfcbea178 ("net/liquidio: add API to release Tx queue")

Signed-off-by: Shijith Thotton <shijith.thotton@caviumnetworks.com>
---
 drivers/net/liquidio/lio_ethdev.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
  

Patch

diff --git a/drivers/net/liquidio/lio_ethdev.c b/drivers/net/liquidio/lio_ethdev.c
index df91659..a65c749 100644
--- a/drivers/net/liquidio/lio_ethdev.c
+++ b/drivers/net/liquidio/lio_ethdev.c
@@ -1155,14 +1155,13 @@  struct rte_lio_xstats_name_off {
 lio_dev_rx_queue_release(void *rxq)
 {
 	struct lio_droq *droq = rxq;
-	struct lio_device *lio_dev = droq->lio_dev;
 	int oq_no;
 
-	/* Run time queue deletion not supported */
-	if (lio_dev->port_configured)
-		return;
+	if (droq) {
+		/* Run time queue deletion not supported */
+		if (droq->lio_dev->port_configured)
+			return;
 
-	if (droq != NULL) {
 		oq_no = droq->q_no;
 		lio_delete_droq_queue(droq->lio_dev, oq_no);
 	}
@@ -1250,14 +1249,14 @@  struct rte_lio_xstats_name_off {
 lio_dev_tx_queue_release(void *txq)
 {
 	struct lio_instr_queue *tq = txq;
-	struct lio_device *lio_dev = tq->lio_dev;
 	uint32_t fw_mapped_iq_no;
 
-	/* Run time queue deletion not supported */
-	if (lio_dev->port_configured)
-		return;
 
-	if (tq != NULL) {
+	if (tq) {
+		/* Run time queue deletion not supported */
+		if (tq->lio_dev->port_configured)
+			return;
+
 		/* Free sg_list */
 		lio_delete_sglist(tq);