Commit 76d023fd authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Daniel Verkamp
Browse files

iscsi: pthread_mutex_lock is called before pthread_mutex_init



iSCSI's global mutex is used in spdk_iscsi_portal_grp_create()
before it is initialized by pthread_mutex_init().

A mutex filled with zero bytes has been accepted by now but
this should be fixed.

Change-Id: I2e197bec8da2f781c8c4f6e2a2caf9924b0a4369
Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/402497


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent fd5ee08e
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -794,6 +794,12 @@ spdk_iscsi_app_read_parameters(void)
	 */
	g_spdk_iscsi.MaxConnections = g_spdk_iscsi.MaxSessions;

	rc = pthread_mutex_init(&g_spdk_iscsi.mutex, NULL);
	if (rc != 0) {
		SPDK_ERRLOG("mutex_init() failed\n");
		return -1;
	}

	spdk_iscsi_log_globals();

	/* portal groups */
@@ -810,12 +816,6 @@ spdk_iscsi_app_read_parameters(void)
		return -1;
	}

	rc = pthread_mutex_init(&g_spdk_iscsi.mutex, NULL);
	if (rc != 0) {
		SPDK_ERRLOG("mutex_init() failed\n");
		return -1;
	}

	return 0;
}