Prevent resource leak by destroying the event channel before returning from
function in an error flow.
Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
cmd.fd = id->channel->fd;
ret = write(channel->fd, &cmd, sizeof cmd);
- if (ret != sizeof cmd)
+ if (ret != sizeof cmd) {
+ if (sync)
+ rdma_destroy_event_channel(channel);
return (ret >= 0) ? ERR(ENODATA) : -1;
+ }
VALGRIND_MAKE_MEM_DEFINED(&resp, sizeof resp);