Commit 112a8b68 authored by paul luse's avatar paul luse Committed by Jim Harris
Browse files

bdev/compress: fix issue with freeing mbufs in compress error path



mbufs are freed with a single call to the first mbuf in the chain
unless we hit an error before we chain them. So free them correctly
when chained and loop through the array one at a time and free them
that way if not.

Signed-off-by: default avatarpaul luse <paul.e.luse@intel.com>
Change-Id: I80ebb86bc2147b42db89d24f8e985cacf7d4bceb
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455019


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent bc1495b0
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -511,17 +511,20 @@ _compress_operation(struct spdk_reduce_backing_dev *backing_dev, struct iovec *s
	/* We always expect 1 got queued, if 0 then we need to queue it up. */
	if (rc == 1) {
		return 0;
	} else {
		/* we free mbufs differently depending on whether they were chained or not */
		rte_pktmbuf_free(comp_op->m_src);
		rte_pktmbuf_free(comp_op->m_dst);
		goto error_enqueue;
	}

	/* Error cleanup paths. */
	for (i = 0; i < dst_iovcnt; i++) {
		rte_pktmbuf_free((struct rte_mbuf *)&dst_mbufs[i]);
	}
error_get_dst:
	for (i = 0; i < src_iovcnt; i++) {
		rte_pktmbuf_free((struct rte_mbuf *)&src_mbufs[i]);
	}
error_get_src:
error_enqueue:
	rte_comp_op_free(comp_op);
error_get_op:
	op_to_queue = calloc(1, sizeof(struct vbdev_comp_op));