bus/vmbus: fix resource leak on error
If secondary process attempt to mmap the resource resulted in the wrong address, then it would leave behind the bad mmap. Coverity issue: 337675, 337664 Fixes: 2a28a502c607 ("bus/vmbus: map ring in secondary process") Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com>
This commit is contained in:
parent
2aa0db405f
commit
26ed007067
@ -283,10 +283,12 @@ vmbus_uio_map_secondary_subchan(const struct rte_vmbus_device *dev,
|
||||
if (mapaddr == MAP_FAILED)
|
||||
VMBUS_LOG(ERR,
|
||||
"mmap subchan %u in secondary failed", chan->relid);
|
||||
else
|
||||
else {
|
||||
VMBUS_LOG(ERR,
|
||||
"mmap subchan %u in secondary address mismatch",
|
||||
chan->relid);
|
||||
vmbus_unmap_resource(mapaddr, 2 * ring_size);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -75,9 +75,11 @@ vmbus_uio_map_secondary(struct rte_vmbus_device *dev)
|
||||
if (mapaddr == MAP_FAILED)
|
||||
VMBUS_LOG(ERR,
|
||||
"mmap resource %d in secondary failed", i);
|
||||
else
|
||||
else {
|
||||
VMBUS_LOG(ERR,
|
||||
"mmap resource %d address mismatch", i);
|
||||
vmbus_unmap_resource(mapaddr, uio_res->maps[i].size);
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user