Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp260249ybi; Sat, 15 Jun 2019 00:13:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3dQuZl+ymTmilTVT2rs9KJDXOl8BLQ1divPkjZTJzsIMjNojkugasLpNMzM1pxCk3ZySL X-Received: by 2002:a63:c20e:: with SMTP id b14mr28944193pgd.96.1560582781450; Sat, 15 Jun 2019 00:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560582781; cv=none; d=google.com; s=arc-20160816; b=wl5ydjBJdRtBa7pI/7tdfZDqClwDUYm8LXzKBcjB+ptSJSNWud07GRx3SRMkAG3ifa xf+h9o1PpJ5WDawTLe6YdF+x25HRBK0/Gvsz5c0gKZa6WHjObBoPxqqfJlmdlKTll8oc uRkHUjjaoUiqfVsphepLcWy4+orcvEbWeIXXEF3nm7awVRRlQcPdf//NViG/Uz7xDRLr ZJOSRoHOo8YO7w6GZcvNjqvgBuY9VmnA/6fW+rhjeUcvepdAJQVv7HRvpGxL1uHt6vt7 vcOIqjxaApj2dWoRa5rLX1+arUaDKSYOwTRwxVd2YR1zN07O28XO8xEjqrSwHL/eACLy CKoA== 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 :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=Swih4FYc82qBLXxT8o6+ulKgup/1alXQeOXBJ3dcpZQ=; b=rSZnzU9nS3k1irZUHf2KP10GKXLwFskeZnuA3yduod77D7Q1eOx01cHMDy3adQqD9i 81WCR8N4UrqeLT0875YH3kugrmojNT/oAgnPCUMblFnVsbX+m2mkXfANRTrcp/A63pzu efNp6RKjaeJq0Lz+JJv+d0h4ZQVAq1iHvGg8AzRkUKVPee3ZPBi1tTr8+CI7LXN+Vpu5 M2625PkpET+00LuNIHS+PEX69pr9uukgJrphjsVPmyFqIJFcSLE8mQZbN8Zqn7bhiB9y QK2xAfZ989roTQsJkjKjfW+3JBE9/Sh8bQVUyY5Ma0yWXHnAemkVbJ7Dnqp16xtxoKl9 alFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@Mellanox.com header.s=selector2 header.b=XqPZTecA; 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=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si4071330pls.146.2019.06.15.00.12.45; Sat, 15 Jun 2019 00:13:01 -0700 (PDT) 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=@Mellanox.com header.s=selector2 header.b=XqPZTecA; 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=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726334AbfFOHMi (ORCPT + 99 others); Sat, 15 Jun 2019 03:12:38 -0400 Received: from mail-eopbgr70089.outbound.protection.outlook.com ([40.107.7.89]:41947 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725828AbfFOHMi (ORCPT ); Sat, 15 Jun 2019 03:12:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Swih4FYc82qBLXxT8o6+ulKgup/1alXQeOXBJ3dcpZQ=; b=XqPZTecAM9oAzl5OM7/hYxsLpGkZsd3YXOGXebI651JXXwmtyJ0WL7lUkfei+IrRpTe8S/CeblkQbKmoBnpr6rhJlfe/GSJ59ltndTciYn1SPiOhl2d1Lx+PE8xkGhdA9iAl4ppO8WBMQnDKlCLTwzp368PLjOZY7NLeYQORBBQ= Received: from AM4PR05MB3137.eurprd05.prod.outlook.com (10.171.186.14) by AM4PR05MB3185.eurprd05.prod.outlook.com (10.171.188.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.12; Sat, 15 Jun 2019 07:12:27 +0000 Received: from AM4PR05MB3137.eurprd05.prod.outlook.com ([fe80::bc5a:ba8b:1a69:91b6]) by AM4PR05MB3137.eurprd05.prod.outlook.com ([fe80::bc5a:ba8b:1a69:91b6%6]) with mapi id 15.20.1987.013; Sat, 15 Jun 2019 07:12:27 +0000 From: Leon Romanovsky To: Doug Ledford CC: Colin Ian King , Gal Pressman , Dennis Dalessandro , "linux-rdma@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: RDMA: Clean destroy CQ in drivers do not return errors Thread-Topic: RDMA: Clean destroy CQ in drivers do not return errors Thread-Index: AQHVIrlo0Ha/lYZPxkOD3nwuzZMhyaabjl4AgAC/iwA= Date: Sat, 15 Jun 2019 07:12:27 +0000 Message-ID: <20190615071224.GA4694@mtr-leonro.mtl.com> References: <68d62660-902c-ca49-20fd-32e92830faa7@canonical.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM7PR03CA0028.eurprd03.prod.outlook.com (2603:10a6:20b:130::38) To AM4PR05MB3137.eurprd05.prod.outlook.com (2603:10a6:205:3::14) authentication-results: spf=none (sender IP is ) smtp.mailfrom=leonro@mellanox.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [37.142.3.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 57c18133-5702-4ada-b459-08d6f160d295 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020);SRVR:AM4PR05MB3185; x-ms-traffictypediagnostic: AM4PR05MB3185: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0069246B74 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(396003)(366004)(39860400002)(346002)(376002)(199004)(189003)(8676002)(71200400001)(71190400001)(73956011)(386003)(6506007)(52116002)(68736007)(99286004)(33656002)(229853002)(2906002)(186003)(6486002)(76176011)(102836004)(14454004)(26005)(6436002)(316002)(54906003)(478600001)(6916009)(256004)(486006)(476003)(3846002)(11346002)(6116002)(25786009)(446003)(4326008)(1076003)(66066001)(5660300002)(86362001)(53936002)(6246003)(8936002)(9686003)(64756008)(66556008)(66476007)(66446008)(66946007)(81166006)(81156014)(6512007)(7736002)(305945005);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR05MB3185;H:AM4PR05MB3137.eurprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Pcs//go+y2P3i4orFTDScVm/gN0caT2aWTz4NI6ZWShvJUAWzZGrG0+AQqDQzQBzt0Jn826LQDu8SuJCx/pH7BtQMU2h5pkAgF+KGCjNdPDF1DNbP8FqXxLUgfNTvA6/H6lCduJIhGV3s4UyVNHU9ObtOCaNq2vI/TuEe19ANwq6Dxb/6SDlPFndqP3Byv5ArBFbHo8F1YKDVn1L+fGWwTQLDPHL914RqWSA7uV4r++tB/Am61M7oGz+lSIs4GxUQhkn7LnvlE2pbnka1dY8oy8S5fFYmZjCUzfRvzLYVsptw4WlKi9en+dF5i87XyqMpJGfweatRDS8tjpI5odpRwlJEJaRiS78HPjDx0cnAWWotgCxIlJIMv5z4TNc6PyWoxf43zijIRZCxGrYsug/Vo7WBlhdCV9p/iHlIclAalg= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 57c18133-5702-4ada-b459-08d6f160d295 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jun 2019 07:12:27.8370 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: leonro@mellanox.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3185 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 14, 2019 at 03:46:50PM -0400, Doug Ledford wrote: > On Fri, 2019-06-14 at 14:59 +0100, Colin Ian King wrote: > > Hi, > > > > Static analysis with Coverity reported an issue with the following > > commit: > > > > commit a52c8e2469c30cf7ac453d624aed9c168b23d1af > > Author: Leon Romanovsky > > Date: Tue May 28 14:37:28 2019 +0300 > > > > RDMA: Clean destroy CQ in drivers do not return errors > > > > In function bnxt_re_destroy_cq() contains the following: > > > > if (!cq->umem) > > ib_umem_release(cq->umem); > > Given that the original test that was replaced was: > if (!IS_ERR_OR_NULL(cq->umem)) > > we aren't really worried about a null cq, just that umem is valid. So, > the logic is inverted on the test (or possibly we shouldn't have > replaced !IS_ERR_OR_NULL(cq->umem) at all). I took a very brief look and think that the better way will be to put this "if (null)" check inside ib_umem_release() and make unconditional call to that function in all call sites. > > But on closer inspection, the bnxt_re specific portion of this patch > appears to have another problem in that it no longer checks the result > of bnxt_qplib_destroy_cq() yet it does nothing to keep that function > from failing. It was intentional for two reasons. First, bnxt_re already had exactly same logic without any checks of returned call inside bnxt_re_create_cq(). Second, we need to release kernel memory without any relation to HW state. Maybe I should move bnxt_qplib_free_hwq() to be immediately after bnxt_qplib_rcfw_send_message() inside of bnxt_qplib_destroy_cq()? > > Leon, can you send a followup fix? Sure, I'll do it tomorrow. > > > Coverity detects this as a deference after null check on the null > > pointer cq->umem: > > > > "var_deref_model: Passing null pointer cq->umem to ib_umem_release, > > which dereferences it" > > > > Is the logic inverted on that null check? > > > > Colin > > -- > Doug Ledford > GPG KeyID: B826A3330E572FDD > Key fingerprint =3D AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 > 2FDD