Commit ba9e050e authored by Marcin Spiewak's avatar Marcin Spiewak Committed by Tomasz Zawadzki
Browse files

lib/event: verify if scheduler is not NULL



Fixed issue detected by Coverity.
If the new scheduler could not be initialized, the
spdk_scheduler_set() reverts to the old one, initializing it
again. The issue here is it was done without checking if the
old scheduler (g_scheduler) is not NULL, causing potential
NULL ptr dereference. Now it is fixed.

Change-Id: I7237e529168938e0b8a4cabb7922a69798e2393c
Signed-off-by: default avatarMarcin Spiewak <marcin.spiewak@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24053


Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 15c68d55
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -106,11 +106,15 @@ spdk_scheduler_set(const char *name)
		g_scheduler = scheduler;
	} else {
		/* Could not switch to the new scheduler, so keep the old
		 * one. We need to ->init() it again.
		 * one. We need to check if it wasn't NULL, and ->init() it again.
		 */
		if (g_scheduler) {
			SPDK_ERRLOG("Could not ->init() '%s' scheduler, reverting to '%s'\n",
				    name, g_scheduler->name);
			g_scheduler->init();
		} else {
			SPDK_ERRLOG("Could not ->init() '%s' scheduler.\n", name);
		}
	}

	return rc;