From patchwork Mon Aug 15 11:36:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dotan Barak X-Patchwork-Id: 1067112 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7FBaKAl012092 for ; Mon, 15 Aug 2011 11:36:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752137Ab1HOLgL (ORCPT ); Mon, 15 Aug 2011 07:36:11 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:64822 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751951Ab1HOLgK (ORCPT ); Mon, 15 Aug 2011 07:36:10 -0400 Received: by wyg24 with SMTP id 24so3425815wyg.19 for ; Mon, 15 Aug 2011 04:36:09 -0700 (PDT) Received: by 10.216.69.147 with SMTP id n19mr3248868wed.84.1313408169347; Mon, 15 Aug 2011 04:36:09 -0700 (PDT) Received: from vnc11.lab.mtl.com ([82.166.227.17]) by mx.google.com with ESMTPS id x14sm3583917weq.24.2011.08.15.04.36.06 (version=SSLv3 cipher=OTHER); Mon, 15 Aug 2011 04:36:08 -0700 (PDT) From: Dotan Barak To: Sean Hefty Subject: [PATCH 1/2] librdmacm: Fix resource leak in error flow Date: Mon, 15 Aug 2011 14:36:04 +0300 User-Agent: KMail/1.9.4 Cc: linux-rdma@vger.kernel.org MIME-Version: 1.0 Content-Disposition: inline Message-Id: <201108151436.05171.dotanb@sw.voltaire.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 15 Aug 2011 11:36:21 +0000 (UTC) Prevent resource leak by destroying the event channel before returning from function in an error flow. Signed-off-by: Dotan Barak --- -- 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 --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);