thread: fix double unlock in spdk_io_device_register

Since there is a pthread_mutex_unlock() in normal condition, another
pthread_mutex_unlock() in the "tmp != NULL" branch should be removed,
otherwise will cause a double unlock.

Fixes issue #2378.

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11642 (master)

(cherry picked from commit 8be59045ea)
Change-Id: I6c80a9527dd60e0b7c1d3c54b6da371b31118f02
Signed-off-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12470
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Weiguo Li 2022-02-17 01:50:47 +08:00 committed by Keith Lucas
parent 50719da890
commit 8282628ec1

View File

@ -1988,7 +1988,6 @@ spdk_io_device_register(void *io_device, spdk_io_channel_create_cb create_cb,
if (tmp != NULL) {
SPDK_ERRLOG("io_device %p already registered (old:%s new:%s)\n",
io_device, tmp->name, dev->name);
pthread_mutex_unlock(&g_devlist_mutex);
free(dev);
}