From patchwork Sat May 30 06:10:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland Dreier X-Patchwork-Id: 6512351 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20AA0C0020 for ; Sat, 30 May 2015 06:17:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57658207E6 for ; Sat, 30 May 2015 06:17:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7721C207E1 for ; Sat, 30 May 2015 06:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752516AbbE3GRk (ORCPT ); Sat, 30 May 2015 02:17:40 -0400 Received: from na3sys010aog110.obsmtp.com ([74.125.245.88]:33993 "EHLO mail-ig0-f179.google.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751225AbbE3GRk (ORCPT ); Sat, 30 May 2015 02:17:40 -0400 Received: from mail-ig0-f179.google.com ([209.85.213.179]) (using TLSv1) by na3sys010aob110.postini.com ([74.125.244.12]) with SMTP ID DSNKVWlWA9WcfOPEeaSsWcqe/zEr34ZyQQ+N@postini.com; Fri, 29 May 2015 23:17:40 PDT Received: by igbyr2 with SMTP id yr2so29468391igb.0 for ; Fri, 29 May 2015 23:17:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google; h=sender:from:to:cc:subject:date:message-id; bh=m/mpOSSlTsrrhtG22LErpmc2JutU+b/IEcGTf5hmios=; b=POzxfvfF6jcgiEQgs+BlRQu64HeWRuFUZ6aEW4gIPXikh2kCRGRAhKM96TSyjdqQnP FJMI36XmdEJO9RgLZ5biLNzyU18X/rOVC/sRsaQZ2xpSViql3hXPQkps0tN62aoBnGJa huj1LnsMJw3TP62X4ZTuyoNEi+pBL7ukdpo04= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=m/mpOSSlTsrrhtG22LErpmc2JutU+b/IEcGTf5hmios=; b=gvkI796iIyyhBYoH8JBR2ydkH0imjB+3zGGjdYHqDPwkdKDPuHtN29+PG4rgOGRVaP EMqI4PDK2z8/AbxFfmTskCyk07c5nBjrDCTiJ9uftyocc0lmhQD93RRFv1kkouu7FqnS AztLcHUizvYo2BP7whiZOv/RKMaE/GzmPJmuTVoY1NPQCL4DkNRExYXxn1b0inIAqus9 asWO3NTZWHYJlQ9ZEn7EJ8tXZXDVv26PsipY4cqbE2cAm1UqF/448NV1c7T3F1RQ7p1y aXf78uTEt4nhNLkmpBpbkweTVRhg8dyP1xpnArQy/FCr/U+qKtzAV2KGc1oghtpi/PAu ZVWw== X-Received: by 10.50.27.6 with SMTP id p6mr1311583igg.46.1432966238086; Fri, 29 May 2015 23:10:38 -0700 (PDT) X-Gm-Message-State: ALoCoQmkLef1brFCv3+aKPEOiv8GK/sX+TUqiyTVlV+pOQHcBHcJLqVO3UfIt4qu3QA2CaphlqKaFofWYsc8nUWqX60FWNRSUIIKnrspcbn6Fq2ameDKEOdRxxVou0YXwLjSuod92sZjYFJBuVnlZBTcNsHafCZt4A== X-Received: by 10.50.27.6 with SMTP id p6mr1311574igg.46.1432966237974; Fri, 29 May 2015 23:10:37 -0700 (PDT) Received: from roland-t440p.purestorage.com (50-206-43-50-static.hfc.comcastbusiness.net. [50.206.43.50]) by mx.google.com with ESMTPSA id f10sm3165212igt.7.2015.05.29.23.10.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 May 2015 23:10:36 -0700 (PDT) From: Roland Dreier To: Doug Ledford Cc: Selvin Xavier , Devesh Sharma , Mitesh Ahuja , linux-rdma@vger.kernel.org Subject: [PATCH 1/3] RDMA/ocrdma: Fix memory leak in _ocrdma_alloc_pd() Date: Fri, 29 May 2015 23:10:31 -0700 Message-Id: <1432966231-12125-1-git-send-email-roland@kernel.org> X-Mailer: git-send-email 2.1.4 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_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 From: Roland Dreier If ocrdma_get_pd_num() fails, then we need to free the pd struct we allocated. This was detected by Coverity (CID 1271245). Signed-off-by: Roland Dreier Acked-By: Devesh Sharma --- drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 9dcb66077d6c..fcb86749efc9 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c @@ -375,7 +375,12 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev, if (dev->pd_mgr->pd_prealloc_valid) { status = ocrdma_get_pd_num(dev, pd); - return (status == 0) ? pd : ERR_PTR(status); + if (status == 0) { + return pd; + } else { + kfree(pd); + return ERR_PTR(status); + } } retry: