Received: by 10.223.185.116 with SMTP id b49csp1017672wrg; Wed, 21 Feb 2018 10:38:27 -0800 (PST) X-Google-Smtp-Source: AH8x224hoa6ojdCZp0AjvPc2TNu8E8aWXA6SdNc97BTtXsBIkq+QlIdGsrtsne1SJJ+G6JiuZt/K X-Received: by 2002:a17:902:22f:: with SMTP id 44-v6mr3938807plc.418.1519238306898; Wed, 21 Feb 2018 10:38:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519238306; cv=none; d=google.com; s=arc-20160816; b=N6A+s4xTnvmLbhDsYpHvFN8pmq6qf05vv1x1TkL2PBZ5LvxAA1ciYxASvo9LZ+qvQy ZMd6lgagZiDh7eSGRkWORYUhft3RPQYinj6iSkYJaoqz9aZVyvcQcxkczK5yv6QuXzrf /5TKQnubK3fT/AxfVhMLX3P0DjAlBneRA2VZI+77v1ZHFB5DiwaJ8MSjnk6qOwsF09SG m3K2gWsAQQ48YCnZyaILKpZDniNjogh8uDsiiAfYleaifDESzjOCKPjwbDXy7XPJU9Sx awRBVavg55z20t7pXqqNNR/cp4FLqqDg40hEeup2rgU2xaduVZi+HvpNkx0oH7mzi3Ut Ol3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=j+47s1km7n8F2boy2fe8THKWmKU2sFQkPQnDdX4tDug=; b=mF2NqX2fs0rdX2eNIrmNE96CS5a9rUS09+domxycwBMZ8CdvrBRc2EWIZsdIjD8hFx hX33htN8WUOre2PS2V+dJDOSJaE5U5G/mICmjFeAYBSjjYVwmx7mOMnNaY3MMC8tWZM2 yDwFLTkkpBx8uIafxfPob+sdUm715xjDmn2az1C2S6bdto/Tjt0fcD8AP2JbHv5t3C3b 5IDIofG+/vJHVdBosyLyDIUhkNXKiEroz2zCRTZ54830ipqW7kiZPkDJyeN/06OeAb30 c/CsJQgdfeVsVObXQIVCeljetmYVyb+zS0zpuAs+NYJyOGiMQdiqdtRkIBmo2byE4ZaV oscw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si3766839pgq.309.2018.02.21.10.38.09; Wed, 21 Feb 2018 10:38:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965585AbeBUNL5 (ORCPT + 99 others); Wed, 21 Feb 2018 08:11:57 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45476 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753717AbeBUNLw (ORCPT ); Wed, 21 Feb 2018 08:11:52 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EC133E7F; Wed, 21 Feb 2018 13:11:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kalderon , Chuck Lever , Anna Schumaker Subject: [PATCH 4.15 130/163] xprtrdma: Fix BUG after a device removal Date: Wed, 21 Feb 2018 13:49:19 +0100 Message-Id: <20180221124537.316025776@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124529.931834518@linuxfoundation.org> References: <20180221124529.931834518@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever commit e89e8d8fcdc6751e86ccad794b052fe67e6ad619 upstream. Michal Kalderon reports a BUG that occurs just after device removal: [ 169.112490] rpcrdma: removing device qedr0 for 192.168.110.146:20049 [ 169.143909] BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 [ 169.181837] IP: rpcrdma_dma_unmap_regbuf+0xa/0x60 [rpcrdma] The RPC/RDMA client transport attempts to allocate some resources on demand. Registered buffers are one such resource. These are allocated (or re-allocated) by xprt_rdma_allocate to hold RPC Call and Reply messages. A hardware resource is associated with each of these buffers, as they can be used for a Send or Receive Work Request. If a device is removed from under an NFS/RDMA mount, the transport layer is responsible for releasing all hardware resources before the device can be finally unplugged. A BUG results when the NFS mount hasn't yet seen much activity: the transport tries to release resources that haven't yet been allocated. rpcrdma_free_regbuf() already checks for this case, so just move that check to cover the DEVICE_REMOVAL case as well. Reported-by: Michal Kalderon Fixes: bebd031866ca ("xprtrdma: Support unplugging an HCA ...") Signed-off-by: Chuck Lever Tested-by: Michal Kalderon Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/xprtrdma/verbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -1476,6 +1476,9 @@ __rpcrdma_dma_map_regbuf(struct rpcrdma_ static void rpcrdma_dma_unmap_regbuf(struct rpcrdma_regbuf *rb) { + if (!rb) + return; + if (!rpcrdma_regbuf_is_mapped(rb)) return; @@ -1491,9 +1494,6 @@ rpcrdma_dma_unmap_regbuf(struct rpcrdma_ void rpcrdma_free_regbuf(struct rpcrdma_regbuf *rb) { - if (!rb) - return; - rpcrdma_dma_unmap_regbuf(rb); kfree(rb); }