Commit 7ed18ac6 authored by Jim Harris's avatar Jim Harris Committed by Konrad Sztyber
Browse files

bdev/nvme: use FOREACH_SAFE when cleaning up mdns ctxs



We need to use FOREACH_SAFE variants when traversing
a list or tailq and removing or freeing its entries.

In this case, it was just freeing them, so also remove
them while traversing the list.  This isn't strictly
necessary, but follows general practice across the
SPDK code base.

Fixes issue #2977.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I001e7fe9dc406b8981a555384839bb432ac801d1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18157


Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.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 1219d86a
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -102,13 +102,14 @@ mdns_bdev_nvme_start_discovery(void *_entry_ctx)
static void
free_mdns_discovery_entry_ctx(struct mdns_discovery_ctx *ctx)
{
	struct mdns_discovery_entry_ctx *entry_ctx = NULL;
	struct mdns_discovery_entry_ctx *entry_ctx, *tmp;

	if (!ctx) {
		return;
	}

	TAILQ_FOREACH(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq) {
	TAILQ_FOREACH_SAFE(entry_ctx, &ctx->mdns_discovery_entry_ctxs, tailq, tmp) {
		TAILQ_REMOVE(&ctx->mdns_discovery_entry_ctxs, entry_ctx, tailq);
		free(entry_ctx);
	}
}