]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
librdmacm: Fix resource in rdma_migrate_id() error flow
authorDotan Barak <dotanb@dev.mellanox.co.il>
Tue, 23 Aug 2011 19:20:56 +0000 (12:20 -0700)
committerSean Hefty <sean.hefty@intel.com>
Tue, 23 Aug 2011 22:58:03 +0000 (15:58 -0700)
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>
src/cma.c

index 7efed6f0da1ab2a773c6c805ffbe833d0954cc5a..91e110e17b1c08086fe297e2e402b419e76e6cf7 100755 (executable)
--- a/src/cma.c
+++ b/src/cma.c
@@ -2063,8 +2063,11 @@ int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel)
        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);