From patchwork Wed Jul 8 04:13:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 6740301 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2C4039F38C for ; Wed, 8 Jul 2015 04:14:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61F062078C for ; Wed, 8 Jul 2015 04:14:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F3DF920788 for ; Wed, 8 Jul 2015 04:14:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750828AbbGHEOH (ORCPT ); Wed, 8 Jul 2015 00:14:07 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:37203 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750923AbbGHEOF (ORCPT ); Wed, 8 Jul 2015 00:14:05 -0400 Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NR500D7UIFFJP80@mailout3.samsung.com>; Wed, 08 Jul 2015 13:14:03 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.124]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 2A.E3.29324.B83AC955; Wed, 8 Jul 2015 13:14:03 +0900 (KST) X-AuditID: cbfee68d-f79106d00000728c-ec-559ca38b35a4 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 28.34.05312.A83AC955; Wed, 8 Jul 2015 13:14:02 +0900 (KST) Received: from localhost.localdomain ([107.108.92.210]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NR500JK2IF2Z0D0@mmp2.samsung.com>; Wed, 08 Jul 2015 13:14:02 +0900 (KST) From: Maninder Singh To: dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, ogerlitz@mellanox.com, davem@davemloft.net, roland@purestorage.com, matanb@mellanox.com, monis@mellanox.com, jackm@dev.mellanox.co.il, yishaih@mellanox.com, eranbe@mellanox.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pankaj.m@samsung.com, Maninder Singh Subject: [PATCH v2] infiniband: free only allocated items Date: Wed, 08 Jul 2015 09:43:35 +0530 Message-id: <1436328815-28072-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRmVeSWpSXmKPExsWyRsSkRrd78ZxQg/M9nBZzzrewWLw8/4HV YuHbP2wWGzdPZLRYsLSL0eLyrjlsFs8O9bJYHJ7fxmLx5qWTxYb3a9gtpt86zmhx781WJovV fywsmtdvYLGYcKmHzYHfY8vKm0we02dsYvXYOesuu8fiPS+ZPJ5NP8zkse1hL7vH+31X2Tz6 tqxi9Pi8SS6AM4rLJiU1J7MstUjfLoErY0pHRcEhjorHHYcYGxhvsXUxcnJICJhIzDq9iB3C FpO4cG89UJyLQ0hgKaPEj+dLWGGKPt+aC5WYzigxYfdysA4hgZ+MElOXxoDYbAJ6Eqt27WEB KRIR2M0ksal5O2MXIwcHs4CTxPSveiA1wgKWEmsWPmYEsVkEVCXOflnGAlLCK+AucXGrHogp IaAgMWeSDcgUCYFr7BIdp46yQJQLSHybfIgFokZWYtMBZojTJCUOrrjBMoFRcAEjwypG0dSC 5ILipPQiQ73ixNzi0rx0veT83E2MwCg5/e9Z7w7G2wesDzEKcDAq8fB6xMwJFWJNLCuuzD3E aAq0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9+UliiHfAj/pfGG8LsBgc/8ql3Jp 7jute+csGf/POPPGs+aceF27nmHKi75LO4tv3ZvzdbPIpAnCT3kn/9hYcOnImyLP1Vp5UzZG G9+95Lbu3Kdrz+508uxQOz2BN43nT2/6dSWW4oxEQy3mouJEAC1+UJzXAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.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 o If allocation of dm fails, no need to free it. o Free only allocated items. Signed-off-by: Maninder Singh Signed-off-by: Maninder Singh Signed-off-by: Doug Ledford --- drivers/infiniband/hw/mlx4/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 067a691..253498f 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -2669,17 +2669,15 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init) dm = kcalloc(ports, sizeof(*dm), GFP_ATOMIC); if (!dm) { pr_err("failed to allocate memory for tunneling qp update\n"); - goto out; + return; } for (i = 0; i < ports; i++) { dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC); if (!dm[i]) { pr_err("failed to allocate memory for tunneling qp update work struct\n"); - for (i = 0; i < dev->caps.num_ports; i++) { - if (dm[i]) - kfree(dm[i]); - } + while (--i >= 0) + kfree(dm[i]); goto out; } }