Received: by 10.223.176.5 with SMTP id f5csp943314wra; Sat, 3 Feb 2018 14:04:24 -0800 (PST) X-Google-Smtp-Source: AH8x225J64butCHRB/UpDNpKqCXaARPatVwmCCL6RmwvKPBhL0y0Ydq4pVe4A9cucVahet2nGMgb X-Received: by 10.101.90.10 with SMTP id y10mr35430950pgs.445.1517695464014; Sat, 03 Feb 2018 14:04:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517695463; cv=none; d=google.com; s=arc-20160816; b=Q3y/7rEzFSByFzTyXYbJqUoAjQ0GfSMUizTUO31xwOpRQIx1ABT6j/2HhmU5ndJqrJ UlMzh4ke7ZimfCv/f2yMTFoEwumvX/5qhz15jywGb0Nnspb8AldJu6GS1G1Pg9+4LycH 7UiiOr4XGdNqtSdLOG+QKv4GPicbGgEgMprTy4Ooo9boK/sl3CndjZ5KH1XNkT0nUOud G8OkEMc93W5zCHRPAJ6g8R3/AON70mj3ob/20WIYkg58po1tHlGJZ9FSDqzdbVmldfF2 PKzMKNGKmNoZIgxG/+je0qEoux02M4g5ruixNmdIJMOTAVnLOUAqXOyq+6w4bG+r+LrR stAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=eqZcgbBAdMfAicLsY2bSUko9XbpQPDhyNE1QUr916Xc=; b=z+Omcitba+rPZeAFZ4kS5hFYX8FUSbJSBuYOssUvlh8g79WEB/Y+Q15JsAdDIL8pWE 0fmLcq1JQWlBN0BTq60TTQzIc/N+hjMeHtwXI/VF9GsGoHeldo4+w0r3GyYh5I/D5nQv H2EUVz++gWRvmtzCdRE4DbM/tutJuElXty2XcALC+hGODqzdIQkKtWmtCo+lp7v40J24 nI6bl3Voftm2wHaNA6aXqD52pDE0RnhtTEWB8PCpWn1oApCj1ISN1pMgihLUp8JJryvK F65i4oFfKbE8k+gcp2COaOl2C4YYY9S4ywTld12Ev69jBGATQZMPUtRhs4jLKx+FcLUn Mjlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=fKG+Kf/T; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11-v6si78423plm.734.2018.02.03.14.04.07; Sat, 03 Feb 2018 14:04:23 -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; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=fKG+Kf/T; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754935AbeBCSmk (ORCPT + 99 others); Sat, 3 Feb 2018 13:42:40 -0500 Received: from mail-by2nam03on0097.outbound.protection.outlook.com ([104.47.42.97]:1354 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752857AbeBCSDR (ORCPT ); Sat, 3 Feb 2018 13:03:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=eqZcgbBAdMfAicLsY2bSUko9XbpQPDhyNE1QUr916Xc=; b=fKG+Kf/TGcQd1b+ZCHjX0FKiMTXWqVSvfNW7tluiyK+Q7v5yDXTIMAT7cN9Mt1dFVwhA5IsSfWOQ7x01nkhywtSFiRMDv/WjwjU+MDYhXctCdkebHZqoR58phpmK2PmUmdnTJOL2aEKrA/45BtfHoiV3OYw3tzJD1E2HrGokKl4= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1105.namprd21.prod.outlook.com (52.132.24.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.485.5; Sat, 3 Feb 2018 18:02:05 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:02:04 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Nitzan Carmi , Max Gurtovoy , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 066/110] IB/mlx5: Fix mlx5_ib_alloc_mr error flow Thread-Topic: [PATCH AUTOSEL for 4.14 066/110] IB/mlx5: Fix mlx5_ib_alloc_mr error flow Thread-Index: AQHTnRjygDbmA3Xvl0+pFk98nt7mSQ== Date: Sat, 3 Feb 2018 18:01:00 +0000 Message-ID: <20180203180015.29073-66-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1105;7:imPCi31GGLxBTLQkYr9sHd4qMWnSglak6e5QN2MlKxd5Y2iTyKySY3597zuIl12Ut/6uTDXeDoQBIGx4P9AZEXnq/EkyLtkWiXnCStuQJXu1W1rgEzXeQYd/rlMVk/q0n3rCEAL0yrjWWCB9kGSlhM286ECt7f+OJPPB9v/5tLwbv4xHWjXXroALoxZPttzABg7+Vp2+/o7WZt0j/IJlauIxZdHxkMzvTKhaiVVnBzrn+wF+0xmHASQ/ADawOdI/ x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 9c2da3c5-37f2-4548-2782-08d56b303bdf x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1105; x-ms-traffictypediagnostic: BL0PR2101MB1105: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BL0PR2101MB1105;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1105; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(396003)(39380400002)(39860400002)(346002)(376002)(199004)(189003)(6346003)(97736004)(6512007)(7736002)(26005)(305945005)(102836004)(105586002)(68736007)(5250100002)(8936002)(59450400001)(6486002)(6436002)(106356001)(6506007)(81166006)(81156014)(2501003)(2906002)(10090500001)(99286004)(66066001)(54906003)(6116002)(3846002)(36756003)(1076002)(15760500003)(8676002)(110136005)(107886003)(72206003)(2950100002)(478600001)(10290500003)(22452003)(6666003)(5660300001)(2900100001)(4326008)(25786009)(14454004)(316002)(86362001)(53936002)(3280700002)(186003)(3660700001)(76176011)(86612001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1105;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: YEkIBGca1IQ+4Z/TC7cqZppJZE06vOZqlgrnzhDoDMgMCPqRt+3c5bzCZrcFje2RVOK/PIdqt9qSKkQOkFt/8w== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c2da3c5-37f2-4548-2782-08d56b303bdf X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:01:00.1440 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nitzan Carmi [ Upstream commit 45e6ae7ef21b907dacb18da62d5787d74a31d860 ] ibmr.device is being set only after ib_alloc_mr() is (successfully) complete. Therefore, in case mlx5_core_create_mkey() return with error, the error flow calls mlx5_free_priv_descs() which uses ibmr.device (which doesn't exist yet), causing a NULL dereference oops. To fix this, the IB device should be set in the mr struct earlier stage (e.g. prior to calling mlx5_core_create_mkey()). Fixes: 8a187ee52b04 ("IB/mlx5: Support the new memory registration API") Signed-off-by: Max Gurtovoy Signed-off-by: Nitzan Carmi Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/mlx5/mr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/m= r.c index 37bbc543847a..231b043e2806 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1637,6 +1637,7 @@ struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd, MLX5_SET(mkc, mkc, access_mode, mr->access_mode); MLX5_SET(mkc, mkc, umr_en, 1); =20 + mr->ibmr.device =3D pd->device; err =3D mlx5_core_create_mkey(dev->mdev, &mr->mmkey, in, inlen); if (err) goto err_destroy_psv; --=20 2.11.0