From 13c7a98d337dfe9e53be5d02f721dc5291240efd Mon Sep 17 00:00:00 2001 From: GangCao Date: Fri, 23 Sep 2022 06:32:48 -0400 Subject: [PATCH] thread: add assert for io_channel_iter allocation failure For example, in the calling from spdk_bdev_get_current_qd(), if spdk_for_each_channel() failed to allocate struct spdk_io_channel_iter, it will just return and the ctx allocated in spdk_bdev_get_current_qd() is not released. Instead to change the public API of spdk_for_each_channel() to return the failed status to let the caller properly handle the NOMEM case and release the allocation, it just adds the assert here. Change-Id: I6a95207dd390586bdae4e86e5d550cdac709e10a Signed-off-by: GangCao Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14657 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Konrad Sztyber Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/thread/thread.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/thread/thread.c b/lib/thread/thread.c index 6bdb0acda..94c695623 100644 --- a/lib/thread/thread.c +++ b/lib/thread/thread.c @@ -2381,6 +2381,7 @@ spdk_for_each_channel(void *io_device, spdk_channel_msg fn, void *ctx, i = calloc(1, sizeof(*i)); if (!i) { SPDK_ERRLOG("Unable to allocate iterator\n"); + assert(false); return; }