diff mbox

[1/2] librdmacm: Fix resource leak in error flow

Message ID 201108151436.05171.dotanb@sw.voltaire.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dotan Barak Aug. 15, 2011, 11:36 a.m. UTC
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>

---

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Hefty, Sean Aug. 22, 2011, 4:09 p.m. UTC | #1
> Did you have a chance for reviewing those patches?

I did see and flagged them for follow up, but I have not reviewed them yet.  I should get to them sometime this week.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/cma.c b/src/cma.c
index bad1ba3..1367779 100755
--- a/src/cma.c
+++ b/src/cma.c
@@ -2122,8 +2122,11 @@  int rdma_migrate_id(struct rdma_cm_id *id, struct rdma_event_channel *channel)
 	cmd->fd = id->channel->fd;
 
 	ret = write(channel->fd, msg, size);
-	if (ret != size)
+	if (ret != size) {
+		if (sync)
+			rdma_destroy_event_channel(channel);
 		return (ret >= 0) ? ERR(ENODATA) : -1;
+	}
 
 	VALGRIND_MAKE_MEM_DEFINED(resp, sizeof *resp);