[3/4] net/netvsc: mark chim_index as NVS_CHIM_IDX_INVALID after freeing it

Message ID 1597113194-90208-3-git-send-email-longli@linuxonhyperv.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series [1/4] net/netvsc: move rxbuf_info from per-device to per-queue |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Long Li Aug. 11, 2020, 2:33 a.m. UTC
  From: Long Li <longli@microsoft.com>

chim_index could potentially be used in other hn_txdesc when re-allocated.
Mark it as invalid to prevent stale value being used.

Signed-off-by: Long Li <longli@microsoft.com>
---
 drivers/net/netvsc/hn_rxtx.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Aug. 11, 2020, 3:32 p.m. UTC | #1
On Mon, 10 Aug 2020 19:33:13 -0700
longli@linuxonhyperv.com wrote:

> From: Long Li <longli@microsoft.com>
> 
> chim_index could potentially be used in other hn_txdesc when re-allocated.
> Mark it as invalid to prevent stale value being used.
> 
> Signed-off-by: Long Li <longli@microsoft.com>

Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  

Patch

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index c8c4ee10c..a388ff258 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -419,8 +419,10 @@  hn_nvs_send_completed(struct rte_eth_dev *dev, uint16_t queue_id,
 		++txq->stats.errors;
 	}
 
-	if (txd->chim_index != NVS_CHIM_IDX_INVALID)
+	if (txd->chim_index != NVS_CHIM_IDX_INVALID) {
 		hn_chim_free(hv, txd->chim_index);
+		txd->chim_index = NVS_CHIM_IDX_INVALID;
+	}
 
 	rte_pktmbuf_free(txd->m);
 	hn_txd_put(txq, txd);