Received: by 10.223.176.5 with SMTP id f5csp799696wra; Sat, 3 Feb 2018 10:32:56 -0800 (PST) X-Google-Smtp-Source: AH8x224SRfGBfw21EQ/lUI1ZKohz5HEcfvKKWib7xbTNPNNBa2Huji8gjU5Xw/7p4eZ+M73UyI+B X-Received: by 10.98.156.143 with SMTP id u15mr43323619pfk.170.1517682776178; Sat, 03 Feb 2018 10:32:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517682776; cv=none; d=google.com; s=arc-20160816; b=a/vy6cELJFGfbw9M7Z9Ff7cbxQ/xS9tSI4Ax1rELosKnXXG+fC+qK9JHkPq7iTKV4s s+VjqGYoriztIbHE3NhfqQ0DK19L8xcrSDAltbTnkYNHM9+VDnuWIv1gF6pkp/7h/dHM 44SBUjwZam7HH244Cc4a3CjkX5eA8V6d0UzXXzKqqrzAow6Fny6xZRg8fuwl7kjq9E4c ZdlKgwoPPdudJztoOv4+0G5D3ZtpQBiOKrUYBr3vKuLL45CquFNrAvWPhTrSUe5dJwkn z0m6khrHgeMP0tPqBHZVFEDbqWbYaVJZXVt3Bhchnqjyktc97kFsPj+LU+5NL52ggG7E N+Dg== 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=sM+xIWHnJcBT9t+lrL/s3fSCw5NgvlXYhbsUzieuLx0=; b=obnOvjGLJ5Z54n6fOSlBBqvsfW38j5TBjpy2DdT10HkdysdXs0bpPPu7LgZUVrgH/W /WAJyEXLsqbonLcMYLG7PS8V+g6lGf1UPduGWItg1KGAXNdGb4ikp6QNb8TgfhQHmkGq 1+NJJxCdaxbshIG94AE7ZYY0TchisdQ8BZvNd1QSqenYMJNOC3ASi0IztG9zuxEkGnG/ MQGaJTxiZ+CfgYYX37gdeyL0eF61cC9JKDUYpsYd0tDHp8tQeDLgTogQGG3krxAF/SWL tdcgip8IpY1ACo2aBOPjSeEeUA3heB1hEU1Za1lYgdgPkhVIrNcTk9C+0k1+j9y6q1cT gg/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=DHDaVzK9; 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 z1-v6si2039745pln.408.2018.02.03.10.32.40; Sat, 03 Feb 2018 10:32:56 -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=DHDaVzK9; 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 S1754478AbeBCSbi (ORCPT + 99 others); Sat, 3 Feb 2018 13:31:38 -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 S1753103AbeBCSEm (ORCPT ); Sat, 3 Feb 2018 13:04:42 -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=sM+xIWHnJcBT9t+lrL/s3fSCw5NgvlXYhbsUzieuLx0=; b=DHDaVzK9vPB+u38096ruupN5wy8RGY7S+CNSubqVsyAkZVVd+OHZw5zi5ogdl7q0bptRZ+jP4QyGA1WWaAXoOhQUswQCwmN9xGOFg7qrOMT4QjSds2yplTRKjwPr4lcMIBx5yLhwDpLFTjLasITNILN1mnKxCBpdifTQ8yKJDbY= 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:08 +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:08 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Leon Romanovsky , Nitzan Carmi , Jason Gunthorpe , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 073/110] IB/mlx4: Fix mlx4_ib_alloc_mr error flow Thread-Topic: [PATCH AUTOSEL for 4.14 073/110] IB/mlx4: Fix mlx4_ib_alloc_mr error flow Thread-Index: AQHTnRj8Sj/t63GiS0qWwJz4759GXg== Date: Sat, 3 Feb 2018 18:01:16 +0000 Message-ID: <20180203180015.29073-73-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:inYReKl8SMy4AMtKVfEs3B9eW1D1vOBE0qRv2hmT3JJ9mKyGWmx8JveGoHVD0SPas/0SKoW16r5tM+S608sn5BgSDMPSAovuEDog1TIGIVUTK5k7nMR4VqrLHf8KLl0SCI0p3sBJuaC/fuOTfMO8qOh6h1V6BA1ildfpmtiwQamC4AkD4S1CcO+qo4wtOMtGNcP7puxfndV7GvYLh11+kt0C+uOpnQ/I1HY6AHiPswgVwHfWddZ2uvTzSxk8XoJQ x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: be9d1d07-30ba-45b1-e8de-08d56b303dc7 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)(575784001)(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: sKXTPG/30/sCRknsMIPR9YfGcKnWRoIDwLOtEr5hh0Cbr+ZVFbMk9DWpjcCfqsvRz/74G7MuTei9MvS72MfYPg== 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: be9d1d07-30ba-45b1-e8de-08d56b303dc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:01:16.7378 (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: 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 --- drivers/infiniband/hw/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/m= r.c index e6f77f63da75..e80a7f764a74 100644 --- a/drivers/infiniband/hw/mlx4/mr.c +++ b/drivers/infiniband/hw/mlx4/mr.c @@ -406,7 +406,6 @@ struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd, goto err_free_mr; =20 mr->max_pages =3D max_num_sg; - err =3D mlx4_mr_enable(dev->dev, &mr->mmr); if (err) goto err_free_pl; @@ -417,6 +416,7 @@ struct ib_mr *mlx4_ib_alloc_mr(struct ib_pd *pd, return &mr->ibmr; =20 err_free_pl: + mr->ibmr.device =3D pd->device; mlx4_free_priv_pages(mr); err_free_mr: (void) mlx4_mr_free(dev->dev, &mr->mmr); --=20 2.11.0