dm: virtio-i2c: fix native_adapter memory leak

If failed to create native_adapter, free allocated native_adapter memory before return.

Tracked-On: #3543
Signed-off-by: Yifan Luo <luoyifan@cmss.chinamobile.com>
This commit is contained in:
Yifan Luo 2019-08-06 15:43:07 +08:00 committed by ACRN System Integration
parent 5471473f60
commit 50e0a932a2

View File

@ -449,7 +449,7 @@ native_adapter_create(int bus, uint16_t slave_addr[], int n_slave)
fd = open(native_path, O_RDWR);
if (fd < 0) {
WPRINTF("virtio_i2c: failed to open %s\n", native_path);
return NULL;
goto fail;
}
native_adapter->fd = fd;
native_adapter->bus = bus;