From patchwork Mon Apr 22 14:00:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10911087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 185BA1575 for ; Mon, 22 Apr 2019 14:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BA35284F9 for ; Mon, 22 Apr 2019 14:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A04128707; Mon, 22 Apr 2019 14:00:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 352E2285A3 for ; Mon, 22 Apr 2019 14:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfDVOAs (ORCPT ); Mon, 22 Apr 2019 10:00:48 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:35433 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbfDVOAs (ORCPT ); Mon, 22 Apr 2019 10:00:48 -0400 Received: by mail-wm1-f65.google.com with SMTP id y197so14606451wmd.0 for ; Mon, 22 Apr 2019 07:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rlFBM8vaibrfjmiOFNp8jcVpx8xMZAUXkoDzlGDEGI4=; b=Cg0sXlWMAi8FoDZkvdEw3k8ytqRD6G3cNqa8BG46Ve481gbITncSYIQdz/l67JsT5Z mYh7xB8IfZpX/aG00ZfEtJrMJtIwxDFMIujExkRAyAbbCpVlErVqhZogO/YWeDM9KS0G 895fefSra5ROcteJejJCvLL+G6QUrVI58AWXL+30EOQJUH2OxOlDvyamV6fAjVF/MGXV 1eqw7mW/GYq85Z6J74o7Nn/4JckdTiobq3xDl8BQZsUrrw2bFm/PRdo45jdRG9dDsrL4 p0sPNTQo8pblRHFcqSGQdhKh0+rJcAgr3b1WxCgcpE4xOLMk2qUzlg1/BoTSpQWMkKnV HE6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rlFBM8vaibrfjmiOFNp8jcVpx8xMZAUXkoDzlGDEGI4=; b=l/BGyPSzCzKzR/fhVb/nSc6cO+aPaUqfGZziJiyupY/ZhlcSxv5QDKQVO2kc8GsUY6 FPkI9moMB03LctT2nFkVrOp4wY2s7WlNXFokw2kiz9Yleck4M3pRrQnpXcZ3H1oSaDnR Mkmqc3EDoC+m9avXBD3Y57UmNfDatrn2GD3OHc42dvDQbvzaBfafl7YPrfmt9nyUDk5g 1f958XXIUfXn+SwuttPc9yBfJRvrPJASnRP6rowlX4S1ubQFJBMAPw7H+1KAfR+jFok8 zOL93TOD6vLhopuYDejHPsvxdOnSwR02ZAD6MY/Y16uhZjJTfbxsoXm7mO84JJeASbWx sx9g== X-Gm-Message-State: APjAAAVq9jg8CboRTArI3iD4/+fizAG2/noWAIuhxOikc1reAsvC8Fk6 XWQozqVz1UEua3sl1mW3LSIBHArw X-Google-Smtp-Source: APXvYqyUZxGW50ud0vkRfMntSRItyHPAxc+418PEC4Yv9a1EXPSwlLKHahHKqxLuaaZPEODk++mwXg== X-Received: by 2002:a1c:9942:: with SMTP id b63mr12864243wme.116.1555941646555; Mon, 22 Apr 2019 07:00:46 -0700 (PDT) Received: from kheib-workstation.redhat.com (bzq-109-65-99-200.red.bezeqint.net. [109.65.99.200]) by smtp.gmail.com with ESMTPSA id o1sm18217963wmh.47.2019.04.22.07.00.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Apr 2019 07:00:45 -0700 (PDT) From: Kamal Heib To: linux-rdma@vger.kernel.org Cc: Michal Kalderon , Ariel Elior , Jason Gunthorpe , Kamal Heib Subject: [PATCH for-rc] RDMA/qder: Fix memory leak of iwcm pointer Date: Mon, 22 Apr 2019 17:00:19 +0300 Message-Id: <20190422140019.13102-1-kamalheib1@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to release the iwcm pointer that is allocated in qedr_iw_register_device() but never released. Fixes: e6a38c54faf3 ("RDMA/qedr: Add support for registering an iWARP device") Signed-off-by: Kamal Heib --- drivers/infiniband/hw/qedr/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index 996d9ecd93e0..567f55178379 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c @@ -293,7 +293,13 @@ static int qedr_register_device(struct qedr_dev *dev) ib_set_device_ops(&dev->ibdev, &qedr_dev_ops); dev->ibdev.driver_id = RDMA_DRIVER_QEDR; - return ib_register_device(&dev->ibdev, "qedr%d"); + rc = ib_register_device(&dev->ibdev, "qedr%d"); + if (rc) { + if (IS_IWARP(dev)) + kfree(dev->ibdev.iwcm); + } + + return rc; } /* This function allocates fast-path status block memory */ @@ -937,6 +943,8 @@ static void qedr_remove(struct qedr_dev *dev) * of the registered clients. */ ib_unregister_device(&dev->ibdev); + if (IS_IWARP(dev)) + kfree(dev->ibdev.iwcm); qedr_stop_hw(dev); qedr_sync_free_irqs(dev);