Received: by 10.223.185.116 with SMTP id b49csp8731506wrg; Fri, 2 Mar 2018 07:03:10 -0800 (PST) X-Google-Smtp-Source: AG47ELugemyjn1Lp3+Xkgl4i5pplyJ+SMS/0w7hmJeBW/OgkK11sRXS/vGG/XMTU4F9d+QENS+me X-Received: by 10.99.9.195 with SMTP id 186mr4727353pgj.152.1520002990768; Fri, 02 Mar 2018 07:03:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520002990; cv=none; d=google.com; s=arc-20160816; b=gEbQ0n+zh0n+3IZksYa+Y8KADdNGyNPyXURNFqdc+zTK3TRNs5ohiPttxSoRba7q/6 /Uhn4xXssvojvNOZhnuSfn9zbBdxkAFbpCZT+Q28QADikFWrbG+9hQXXlqvMhYu14wry 0qNY8EuNHtqis2O5ww7oaKRJ08y1Wn/XSXGK0YQkxPI50xgodA9J2q2NFwgj1yWwpYVS SoM/OSFkbn901BxQAfG9uZxME4OKrXVg0suy2xEgOETB+OI3UHhwMK1guc/RqwT7wPsa AoFkXgeXKtEB4udTD2z59eR83Trqeo49GwmoKZeZYiCecpjVr+gIAT6FEtTTu47V+ggo Zd+w== 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=qdXiG9/jlNmmsXAptrEEio4FaR0kjt+0MpscDbygZ04=; b=V/dovJE4hrh3Bua11LXL64SZv/6cNmpZrHQKpS9+xKQ975KjhFuhUHVDsoYKryR7Ei 8XxfddE+kQMIl38fuABScqyVf5Vbydc8lat+ShPGLDFjildmVbRk6ps/meRftGzNZIkp mU4bPxVzSI5enyGehuyESNgDwvU3jm4LOuyM8s3nPE3qrEyWX9mSksuHYSn0csM7S8QE eymw0vXTDtJSXxamM1dvGydDA3Qq9qgS7FKzmBklNmO3xI25kcp0+qvWvGyj2tu7VjGB pSkJaviggxKJSY39ZCVBBVtdF9DiTaoBrQrGFRcc6qTdwzfm7vu4ne9RXrtO5tCOuKWC gYqQ== 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 x12-v6si479702plr.334.2018.03.02.07.02.53; Fri, 02 Mar 2018 07:03:10 -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 S1426924AbeCBLJ2 (ORCPT + 99 others); Fri, 2 Mar 2018 06:09:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50466 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423515AbeCBIyd (ORCPT ); Fri, 2 Mar 2018 03:54:33 -0500 Received: from localhost (clnet-b04-243.ikbnet.co.at [83.175.124.243]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A531B110C; Fri, 2 Mar 2018 08:54:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nitzan Carmi , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.4 18/34] IB/mlx4: Fix mlx4_ib_alloc_mr error flow Date: Fri, 2 Mar 2018 09:51:14 +0100 Message-Id: <20180302084437.138817347@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180302084435.842679610@linuxfoundation.org> References: <20180302084435.842679610@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.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Leon Romanovsky [ Upstream commit 5a371cf87e145b86efd32007e46146e78c1eff6d ] ibmr.device is being set only after ib_alloc_mr() is successfully complete. Therefore, in case imlx4_mr_enable() returns with error, the error flow unwinder calls to mlx4_free_priv_pages(), which uses ibmr.device. Such usage causes to NULL dereference oops and to fix it, the IB device should be set in the mr struct earlier stage (e.g. prior to calling mlx4_free_priv_pages()). Fixes: 1b2cd0fc673c ("IB/mlx4: Support the new memory registration API") Signed-off-by: Nitzan Carmi Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c @@ -424,7 +424,6 @@ struct ib_mr *mlx4_ib_alloc_mr(struct ib goto err_free_mr; mr->max_pages = max_num_sg; - err = mlx4_mr_enable(dev->dev, &mr->mmr); if (err) goto err_free_pl; @@ -435,6 +434,7 @@ struct ib_mr *mlx4_ib_alloc_mr(struct ib return &mr->ibmr; err_free_pl: + mr->ibmr.device = pd->device; mlx4_free_priv_pages(mr); err_free_mr: (void) mlx4_mr_free(dev->dev, &mr->mmr);