nvme: fix double free of g_hotplug_probe_ctx

Add a check and only free g_hotplug_probe_ctx once.

This is to fix below issue:
https://github.com/spdk/spdk/issues/1849

Change-Id: I7387495890830badd06a7341d9ac4d149ca1c9f4
Signed-off-by: GangCao <gang.cao@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7002
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Xiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
GangCao 2021-03-23 15:25:08 -04:00 committed by Tomasz Zawadzki
parent 0968ee2fcf
commit 09a1028e0f

View File

@ -1812,6 +1812,11 @@ remove_cb(void *cb_ctx, struct spdk_nvme_ctrlr *ctrlr)
static int
bdev_nvme_hotplug_probe(void *arg)
{
if (g_hotplug_probe_ctx == NULL) {
spdk_poller_unregister(&g_hotplug_probe_poller);
return SPDK_POLLER_IDLE;
}
if (spdk_nvme_probe_poll_async(g_hotplug_probe_ctx) != -EAGAIN) {
g_hotplug_probe_ctx = NULL;
spdk_poller_unregister(&g_hotplug_probe_poller);
@ -2276,6 +2281,7 @@ bdev_nvme_library_fini(void)
spdk_poller_unregister(&g_hotplug_poller);
free(g_hotplug_probe_ctx);
g_hotplug_probe_ctx = NULL;
TAILQ_FOREACH_SAFE(entry, &g_skipped_nvme_ctrlrs, tailq, entry_tmp) {
TAILQ_REMOVE(&g_skipped_nvme_ctrlrs, entry, tailq);