From patchwork Mon Aug 19 13:41:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 2846504 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F31B99F2F4 for ; Mon, 19 Aug 2013 13:42:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A2C1B201F7 for ; Mon, 19 Aug 2013 13:42:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E3D3201ED for ; Mon, 19 Aug 2013 13:42:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750780Ab3HSNmG (ORCPT ); Mon, 19 Aug 2013 09:42:06 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:40074 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1750763Ab3HSNmF (ORCPT ); Mon, 19 Aug 2013 09:42:05 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from roid@mellanox.com) with SMTP; 19 Aug 2013 16:42:01 +0300 Received: from r-vnc02.mtr.labs.mlnx (r-vnc02.mtr.labs.mlnx [172.30.0.127]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id r7JDg0fT017030; Mon, 19 Aug 2013 16:42:00 +0300 From: Roi Dayan To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, ogerlitz@mellanox.com, Roi Dayan , Sagi Grimberg Subject: [PATCH] IB/iser: fix possible memory leak in iser_create_frwr_pool Date: Mon, 19 Aug 2013 16:41:51 +0300 Message-Id: <1376919711-23732-1-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 1.7.8.2 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP where desc is not being freed in error flows. Signed-off-by: Roi Dayan Signed-off-by: Sagi Grimberg --- drivers/infiniband/ulp/iser/iser_verbs.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index 28badac..afe9567 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c @@ -305,7 +305,7 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) if (IS_ERR(desc->data_frpl)) { ret = PTR_ERR(desc->data_frpl); iser_err("Failed to allocate ib_fast_reg_page_list err=%d\n", ret); - goto err; + goto fast_reg_page_failure; } desc->data_mr = ib_alloc_fast_reg_mr(device->pd, @@ -313,8 +313,7 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) if (IS_ERR(desc->data_mr)) { ret = PTR_ERR(desc->data_mr); iser_err("Failed to allocate ib_fast_reg_mr err=%d\n", ret); - ib_free_fast_reg_page_list(desc->data_frpl); - goto err; + goto fast_reg_mr_failure; } desc->valid = true; list_add_tail(&desc->list, &ib_conn->fastreg.frwr.pool); @@ -322,6 +321,11 @@ int iser_create_frwr_pool(struct iser_conn *ib_conn, unsigned cmds_max) } return 0; + +fast_reg_mr_failure: + ib_free_fast_reg_page_list(desc->data_frpl); +fast_reg_page_failure: + kfree(desc); err: iser_free_frwr_pool(ib_conn); return ret;