From patchwork Thu May 11 07:26:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13237585 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35F35C7EE24 for ; Thu, 11 May 2023 07:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237240AbjEKHiY (ORCPT ); Thu, 11 May 2023 03:38:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237235AbjEKHiW (ORCPT ); Thu, 11 May 2023 03:38:22 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF30DE6D for ; Thu, 11 May 2023 00:38:21 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6434e263962so6164353b3a.2 for ; Thu, 11 May 2023 00:38:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1683790701; x=1686382701; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=VTCDfev+9SuBMicj6EM46vREt354/ZHKaNT10vy5v6M=; b=Qxp/ku6hmZqKL4VYzjomulvLpoGVS54zsA5OrTbLIe6SMfORiUd+EgYOzeBlo+EH8d L0X3XVczQtmGSoFpirTQIT3LJca0A/d96g0YTxuEl/01G3wSTFh9eiIfK3Mg1YHzgZg6 oOjrIEQ9ANIE1mMu8+7KEqmETeRsQ4eXmBGEw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683790701; x=1686382701; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VTCDfev+9SuBMicj6EM46vREt354/ZHKaNT10vy5v6M=; b=iwDel6X1tqc6I5zeD4SRWYs7MT5ycY58NxqHh/57anzOhuD5NQuhjQ43l7OWaakwuZ 5MQtWtXUaPNGZ8iZzOHtJjf0/7xOzN/B5cQLvTTuR1Mpm3qL4OqH0LGgltx+/HgvbpC4 PfZOwk+RiPy7PGYWynQpPemkrPYVZLZjc5BWXTqy8kGm7wO1vSLl+TJKytU+L/D9s5S6 nz2pcjzBhci6u/dSouIdaYYMFWUQJQMJOG3QOyp2dkg8bDNXbQzghKrmw2342C6ylhYq 1FdvHnvjavceTt1LjVeD7dpnCghoL5mZNgV6PDsz0fKTI5IcRmns5NQGybuWyND8bPw6 N89g== X-Gm-Message-State: AC+VfDzWykovnuab6RCQ8533UCHQQ67Gs3bGmetf0nh67maIUOcRSeVS au4uV1l5oT/3O29p/ArvNEP5Lw== X-Google-Smtp-Source: ACHHUZ4z5mX0X9y//sW43e809998gLfxb0WY4WKkmtcVuWS9IAYEYaGyirSeec29Xbbcd+1T9zeY2w== X-Received: by 2002:a05:6a00:17a5:b0:63b:1708:10aa with SMTP id s37-20020a056a0017a500b0063b170810aamr30575027pfg.34.1683790701127; Thu, 11 May 2023 00:38:21 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id n14-20020a65488e000000b00502f4c62fd3sm4174332pgs.33.2023.05.11.00.38.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2023 00:38:20 -0700 (PDT) From: Selvin Xavier To: jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, Kalesh AP , Selvin Xavier Subject: [PATCH for-rc 01/10] RDMA/bnxt_re: Fix a possible memory leak Date: Thu, 11 May 2023 00:26:16 -0700 Message-Id: <1683789985-22917-2-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1683789985-22917-1-git-send-email-selvin.xavier@broadcom.com> References: <1683789985-22917-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org From: Kalesh AP Inside bnxt_qplib_create_cq(), when the check for NULL DPI fails, driver returns directly without freeing the memory allocated inside bnxt_qplib_alloc_init_hwq() routine. Fixed this by moving the check for NULL DPI before invoking bnxt_qplib_alloc_init_hwq(). Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver") Reviewed-by: Kashyap Desai Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index f139d4c..8974f62 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -2056,6 +2056,12 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq) u32 pg_sz_lvl; int rc; + if (!cq->dpi) { + dev_err(&rcfw->pdev->dev, + "FP: CREATE_CQ failed due to NULL DPI\n"); + return -EINVAL; + } + hwq_attr.res = res; hwq_attr.depth = cq->max_wqe; hwq_attr.stride = sizeof(struct cq_base); @@ -2069,11 +2075,6 @@ int bnxt_qplib_create_cq(struct bnxt_qplib_res *res, struct bnxt_qplib_cq *cq) CMDQ_BASE_OPCODE_CREATE_CQ, sizeof(req)); - if (!cq->dpi) { - dev_err(&rcfw->pdev->dev, - "FP: CREATE_CQ failed due to NULL DPI\n"); - return -EINVAL; - } req.dpi = cpu_to_le32(cq->dpi->dpi); req.cq_handle = cpu_to_le64(cq->cq_handle); req.cq_size = cpu_to_le32(cq->hwq.max_elements);