vtophys: fix uninitialized variable read on mem unregister

spdk_mem_map_translate() inside the vtophys unregister
callback could potentially read unitialized variable.

This isn't critical since vtophys mem map doesn't yet
implement the callback for checking mem contiguity and
the spdk_mem_map_translate() was exiting early - before
the unitialized variable was actually processed. It was
still technically dereferenced though, which is a bug.

Change-Id: I2af52e6f41bee35528c3d771aafd9c768c9d2fc7
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/438445
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2018-12-28 11:18:17 +01:00 committed by Jim Harris
parent ec5972cb0d
commit 668c8c57be

View File

@ -400,7 +400,7 @@ spdk_vtophys_notify(void *cb_ctx, struct spdk_mem_map *map,
* we need to unmap the range from the IOMMU * we need to unmap the range from the IOMMU
*/ */
if (g_vfio.enabled) { if (g_vfio.enabled) {
uint64_t buffer_len; uint64_t buffer_len = VALUE_2MB;
paddr = spdk_mem_map_translate(map, (uint64_t)vaddr, &buffer_len); paddr = spdk_mem_map_translate(map, (uint64_t)vaddr, &buffer_len);
if (buffer_len != VALUE_2MB) { if (buffer_len != VALUE_2MB) {
return -EINVAL; return -EINVAL;