From patchwork Wed May 10 10:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 9719663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BC50060236 for ; Wed, 10 May 2017 10:46:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B224B2857C for ; Wed, 10 May 2017 10:46:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6F812858D; Wed, 10 May 2017 10:46:22 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 5CB7E2857C for ; Wed, 10 May 2017 10:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752605AbdEJKqV (ORCPT ); Wed, 10 May 2017 06:46:21 -0400 Received: from mail-qt0-f170.google.com ([209.85.216.170]:33440 "EHLO mail-qt0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbdEJKqV (ORCPT ); Wed, 10 May 2017 06:46:21 -0400 Received: by mail-qt0-f170.google.com with SMTP id t26so23926274qtg.0 for ; Wed, 10 May 2017 03:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tZWgnz2OmuldJVsdvLR3v75vVnNl5Z1Wyclf83qN+Ko=; b=OtD2bkqnWy2ULY7zqtho6Fl3DznyPQ68XRrNxvogxHln+QkADrhtxMeDzz2cXolKnw T9UUqzAWsmOz6Ng9e3fa2rSLlRdrEcW5ygRP3LqPt/IkMwalyt2i23M52NI615u4S9IK exmu66DaczkmjU2wgLrGgsAoAArUG3xclcHX4= 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:in-reply-to :references; bh=tZWgnz2OmuldJVsdvLR3v75vVnNl5Z1Wyclf83qN+Ko=; b=MYbVVnW2KV+uqHksw8/VAu2W4QULkTNAnMuIULW1IGf27VpONM+FbeyEneNSUG5UkG HM3dDMjg6LjNeNqed95Z85Fl5qOaJ3pGj2oaDIAkuUl1h1imYh3SZZPYott/OtJ1QaaZ WurldnwwqIwJX9yM19U5/WwGIZFRtW9Id8l8FZLwY4jsJqcp2eNHlYtJmAzamnQHu7Bs MPLqI5rgVfq/xpXmZLP+ZuHXyNiZnzJbeblKMRvDsjxj9ihvlWzCuJMu0XZtI/veVB1f KsuYgUjjBRcloNN5eOUKQ4KKP+SeHs/Jv8nKv3AqZqUcvNXgHitUvsit+9KhAkyi/8sz RNXw== X-Gm-Message-State: AODbwcB5yZgoB0Xssptw8lNhzKx2c6GBpJpnxc67tfVb1hCXpWOlECO1 e9yjCOiYdLqZTQUl X-Received: by 10.237.63.69 with SMTP id q5mr5027840qtf.232.1494413180129; Wed, 10 May 2017 03:46:20 -0700 (PDT) Received: from dhcp-10-192-206-197.iig.avagotech.net ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id k10sm1868531qke.3.2017.05.10.03.46.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 May 2017 03:46:19 -0700 (PDT) From: Selvin Xavier To: dledford@redhat.com, linux-rdma@vger.kernel.org Cc: Selvin Xavier , Kalesh AP Subject: [PATCH for-next 09/14] RDMA/bnxt_re: Do not free the ctx_tbl entry if delete GID fails Date: Wed, 10 May 2017 03:45:34 -0700 Message-Id: <1494413139-11883-10-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1494413139-11883-1-git-send-email-selvin.xavier@broadcom.com> References: <1494413139-11883-1-git-send-email-selvin.xavier@broadcom.com> 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 Do not free context table entry if delete GID fails. Stack may call back the add_gid for the same context again which could result in panic Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 61703f3..525f4b0 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -375,15 +375,17 @@ int bnxt_re_del_gid(struct ib_device *ibdev, u8 port_num, return -EINVAL; ctx->refcnt--; if (!ctx->refcnt) { - rc = bnxt_qplib_del_sgid - (sgid_tbl, - &sgid_tbl->tbl[ctx->idx], true); - if (rc) + rc = bnxt_qplib_del_sgid(sgid_tbl, + &sgid_tbl->tbl[ctx->idx], + true); + if (rc) { dev_err(rdev_to_dev(rdev), "Failed to remove GID: %#x", rc); - ctx_tbl = sgid_tbl->ctx; - ctx_tbl[ctx->idx] = NULL; - kfree(ctx); + } else { + ctx_tbl = sgid_tbl->ctx; + ctx_tbl[ctx->idx] = NULL; + kfree(ctx); + } } } else { return -EINVAL;