From patchwork Mon May 7 16:27:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Boyer X-Patchwork-Id: 10384497 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0A5D660159 for ; Mon, 7 May 2018 16:27:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB1D328514 for ; Mon, 7 May 2018 16:27:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD42228565; Mon, 7 May 2018 16:27:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74C3B28514 for ; Mon, 7 May 2018 16:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbeEGQ1y (ORCPT ); Mon, 7 May 2018 12:27:54 -0400 Received: from esa3.dell-outbound.iphmx.com ([68.232.153.94]:6155 "EHLO esa3.dell-outbound.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752374AbeEGQ1w (ORCPT ); Mon, 7 May 2018 12:27:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dell.com; i=@dell.com; q=dns/txt; s=smtpout; t=1525710452; x=1557246452; h=from:to:cc:subject:date:message-id; bh=4AEd52v7AyBEBvD4nZ4i8NYmeOyoZCerfygSjCClAh4=; b=i9TxgSvdGwCud5ebzPcP1qJjcI9ZNcjb1fdgthWh5ZNeDKihBOtFnJf2 x8xwxdxm9qjwgresHKNN8hsjhyZbnK3gl4g/jQHtgCm7cmekgT3NnwJbF Uvskc0rBgI+FrzJUBLYf/AUttnTbCSz7kaOMIeTNnbMvqR1+/N1v9OhyR s=; X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2GPAAAyfvBamMmZ6ERcGwEBAQEDAQEBC?= =?us-ascii?q?QEBAYUfKItxjHODCJMmgXgLhGyCViE0GAECAQEBAQEBAgEBAhABAQEBAQgLCwY?= =?us-ascii?q?oL4I1IoMBUoFRhSGqNzOEWINpgkiIJYFUP4EPiEqFCAKHFZEVCIFljGgCjF8BK?= =?us-ascii?q?496AgQCBAUCFIElHIILMxojgxOCLo48U5BEAQE?= X-IPAS-Result: =?us-ascii?q?A2GPAAAyfvBamMmZ6ERcGwEBAQEDAQEBCQEBAYUfKItxjHO?= =?us-ascii?q?DCJMmgXgLhGyCViE0GAECAQEBAQEBAgEBAhABAQEBAQgLCwYoL4I1IoMBUoFRh?= =?us-ascii?q?SGqNzOEWINpgkiIJYFUP4EPiEqFCAKHFZEVCIFljGgCjF8BK496AgQCBAUCFIE?= =?us-ascii?q?lHIILMxojgxOCLo48U5BEAQE?= Received: from esa1.dell-outbound2.iphmx.com ([68.232.153.201]) by esa3.dell-outbound.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2018 11:27:31 -0500 Received: from mailuogwdur.emc.com ([128.221.224.79]) by esa1.dell-outbound2.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 May 2018 22:27:14 +0600 Received: from maildlpprd54.lss.emc.com (maildlpprd54.lss.emc.com [10.106.48.158]) by mailuogwprd52.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id w47GRlER024230 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 7 May 2018 12:27:49 -0400 X-DKIM: OpenDKIM Filter v2.4.3 mailuogwprd52.lss.emc.com w47GRlER024230 Received: from mailsyshubprd54.lss.emc.com (mailsyshubprd54.lss.emc.com [10.106.48.29]) by maildlpprd54.lss.emc.com (RSA Interceptor); Mon, 7 May 2018 12:27:25 -0400 Received: from hopcyc-boyera-1-00.cec.lab.emc.com (hopcyc-boyera-1-00.cec.lab.emc.com [10.244.196.91]) by mailsyshubprd54.lss.emc.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.0) with ESMTP id w47GRQAs004444; Mon, 7 May 2018 12:27:26 -0400 From: Andrew Boyer To: linux-rdma@vger.kernel.org Cc: Andrew Boyer Subject: [PATCH] librdmacm: Avoid crash if rdma_disconnect() is called incorrectly Date: Mon, 7 May 2018 12:27:24 -0400 Message-Id: <1525710444-17943-1-git-send-email-andrew.boyer@dell.com> X-Mailer: git-send-email 1.8.3.1 X-RSA-Classifications: public X-Sentrion-Hostname: mailuogwprd52.lss.emc.com Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the cm_id is not connected, id->verbs will be NULL. Check the pointer before dereferencing it. Signed-off-by: Andrew Boyer --- librdmacm/cma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/librdmacm/cma.c b/librdmacm/cma.c index fa37065..2b36e89 100644 --- a/librdmacm/cma.c +++ b/librdmacm/cma.c @@ -1684,6 +1684,9 @@ int rdma_notify(struct rdma_cm_id *id, enum ibv_event_type event) int ucma_shutdown(struct rdma_cm_id *id) { + if (!id->verbs || !id->verbs->device) + return ERR(EINVAL); + switch (id->verbs->device->transport_type) { case IBV_TRANSPORT_IB: return ucma_modify_qp_err(id);