Commit e8b53c0d authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Konrad Sztyber
Browse files

lib/idxd: simplify early failure in _dsa_alloc_batches



ops_pool list is already initialized in spdk_idxd_get_channel(),
called before _dsa_alloc_batches(). There is no need to
initialize it again, especially not in error path of allocating batches.

Meanwhile chan->desc_base and chan->base_ops are allocated and properly
freed in the spdk_idxd_get_channel(), even if batch allocation fails.

With no need for any of the above, just return early with ENOMEM.

Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I6a72c7437183086b19508c85f184741a8d329dbe
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22855


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Community-CI: Mellanox Build Bot
parent 9d513abf
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -162,7 +162,7 @@ _dsa_alloc_batches(struct spdk_idxd_io_channel *chan, int num_descriptors)
	chan->batch_base = calloc(num_batches, sizeof(struct idxd_batch));
	if (chan->batch_base == NULL) {
		SPDK_ERRLOG("Failed to allocate batch pool\n");
		goto error_desc;
		return -ENOMEM;
	}
	batch = chan->batch_base;
	for (i = 0 ; i < num_batches ; i++) {
@@ -211,12 +211,6 @@ error_user:
		spdk_free(batch->user_desc);
		batch->user_desc = NULL;
	}
	spdk_free(chan->ops_base);
	chan->ops_base = NULL;
error_desc:
	STAILQ_INIT(&chan->ops_pool);
	spdk_free(chan->desc_base);
	chan->desc_base = NULL;
	return rc;
}