Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp267850pxx; Wed, 28 Oct 2020 04:34:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTizlJby8fpj/RGhs1g7IDBbLkuqNOo/oq54vDCobcG0BO7WhyrdMo9+ZatULDv1JSahCc X-Received: by 2002:a17:906:da03:: with SMTP id fi3mr7121072ejb.321.1603884842050; Wed, 28 Oct 2020 04:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603884842; cv=none; d=google.com; s=arc-20160816; b=DrKIm/19ESOins9lYLVhYTpqulNRANjqdiC8qMgO3OciKkFAUctbchpv8ly1347GI/ KWryVYrrmhels+Idb1YuXgUEzz+hgC3e+ga+G7qCn3BHXaUx9w7qm1EHiBQQ05WxNLSR JGZdlPTQmxs3rsOAcK9z/LFbfjqb6IS8w52LRiOYBLaqXiuuQ/AVmMG7ktW9pE0ciiU+ PjwPHAXfRqcE9wqZeWuc7F/YcNe5MmRhL4xFTkMe/ILRFMAnKxXOkoiWGDSp0qbKsW8s taQ+1OuzlMSyN8xYwcefQ6xe2xKGxZHZnB9RJTDZ3X9yaHz9byD3kuHgzJTNGxCgmzY7 qWIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yRGLSiTXi545gbbml0tSYLTmBVquQsM9yNuXGiXpOlE=; b=YfhgYdtaiOz8N3kAMiDDyrsQI232w1ndWx1Cm9Jmc9LjiP9qpOMjCqby+6UTE9njcX RmWkEmk3FRr+/acj7mSFrJfI9OgdX7/kTkK5ANKQE0RUVr0znLaWfeb+Echh7OHXkTHR Qxw4geE/ZmdxCB4yr6Et3rA1bxLQDMjWzHxplIqb6IvRz2TVxQhS23Jbov4ECs5baa3t P0YdUb3Limi4BKvnoUpK2L0g2SCvSN1YLZGstzr4DwfJPaqJPbbZI9X9NZeMdMVZKJHI ueM7PsAc3c3iH7w8DjLzBfXjvpYe/8+cZdX04cns94DgXnmLzArp1/saxgn8hcFabyvB PAvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hn5x0xlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si3402013edu.343.2020.10.28.04.33.39; Wed, 28 Oct 2020 04:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hn5x0xlL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1793804AbgJ0PIW (ORCPT + 99 others); Tue, 27 Oct 2020 11:08:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:37656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1789852AbgJ0PDP (ORCPT ); Tue, 27 Oct 2020 11:03:15 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1F222071A; Tue, 27 Oct 2020 15:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810995; bh=1mpyp45N6F5kRx70Nov6eK+6CCCCm3FCVlgALSJrbgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hn5x0xlLONk1nAcYPlRB5zQZcZFl5x3sqOGhWrCerSLpJxZBR9uMXbZ7rn3Ic3/3T Hye7eDkkEo1bO7qG+RFrTEQ0JMSmAzIztbMbd/uxEX32H55yleBC3yfzh996xo5rpK OLOnFWTsb2zR8HD6ZLj/tGpjXcsy+hAAy5DFErco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.8 336/633] RDMA/mlx5: Fix potential race between destroy and CQE poll Date: Tue, 27 Oct 2020 14:51:19 +0100 Message-Id: <20201027135538.446538443@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky [ Upstream commit 4b916ed9f9e85f705213ca8d69771d3c1cd6ee5a ] The SRQ can be destroyed right before mlx5_cmd_get_srq is called. In such case the latter will return NULL instead of expected SRQ. Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Link: https://lore.kernel.org/r/20200830084010.102381-5-leon@kernel.org Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/cq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 0c18cb6a2f148..3ca379513d0e6 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -168,7 +168,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe, { enum rdma_link_layer ll = rdma_port_get_link_layer(qp->ibqp.device, 1); struct mlx5_ib_dev *dev = to_mdev(qp->ibqp.device); - struct mlx5_ib_srq *srq; + struct mlx5_ib_srq *srq = NULL; struct mlx5_ib_wq *wq; u16 wqe_ctr; u8 roce_packet_type; @@ -180,7 +180,8 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe, if (qp->ibqp.xrcd) { msrq = mlx5_cmd_get_srq(dev, be32_to_cpu(cqe->srqn)); - srq = to_mibsrq(msrq); + if (msrq) + srq = to_mibsrq(msrq); } else { srq = to_msrq(qp->ibqp.srq); } -- 2.25.1