bdev/error: make sure error_disk is not NULL

If the user specifies the name of a bdev that is not an error injection
bdev, bdev_inject_error would cause a NULL pointer dereference.

Change-Id: Ibcc7daee5a75ac37c3567ebc048662e0165c2860
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/365526
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Cunyin Chang <cunyin.chang@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Daniel Verkamp 2017-06-14 17:43:28 -07:00
parent 5091cadcd0
commit 9f770dae7e

View File

@ -80,6 +80,12 @@ spdk_vbdev_inject_error(char *name, uint32_t io_type_mask, uint32_t error_num)
}
}
if (error_disk == NULL) {
SPDK_ERRLOG("Could not find ErrorInjection bdev %s\n", name);
pthread_mutex_unlock(&g_vbdev_error_mutex);
return -1;
}
error_disk->io_type_mask = io_type_mask;
error_disk->error_num = error_num;
pthread_mutex_unlock(&g_vbdev_error_mutex);