From owner-svn-src-all@freebsd.org Thu Sep 5 23:07:58 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 06B7DD6E72; Thu, 5 Sep 2019 23:07:58 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46PbvK6GqCz4VRW; Thu, 5 Sep 2019 23:07:57 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B7631B878; Thu, 5 Sep 2019 23:07:57 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x85N7vad029209; Thu, 5 Sep 2019 23:07:57 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x85N7vZ7029208; Thu, 5 Sep 2019 23:07:57 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201909052307.x85N7vZ7029208@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Thu, 5 Sep 2019 23:07:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351907 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: imp X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 351907 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Sep 2019 23:07:58 -0000 Author: imp Date: Thu Sep 5 23:07:57 2019 New Revision: 351907 URL: https://svnweb.freebsd.org/changeset/base/351907 Log: MFC r351411: When we have errors resetting the device before we allocate the queues, don't try to tear them down in the ctrlr_destroy path. Otherwise, we dereference queue structures that are NULL and we trap. Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Sep 5 23:04:37 2019 (r351906) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Thu Sep 5 23:07:57 2019 (r351907) @@ -1211,12 +1211,14 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev if (ctrlr->cdev) destroy_dev(ctrlr->cdev); - if (!gone) - nvme_ctrlr_destroy_qpairs(ctrlr); - for (i = 0; i < ctrlr->num_io_queues; i++) - nvme_io_qpair_destroy(&ctrlr->ioq[i]); - free(ctrlr->ioq, M_NVME); - nvme_admin_qpair_destroy(&ctrlr->adminq); + if (ctrlr->is_initialized) { + if (!gone) + nvme_ctrlr_destroy_qpairs(ctrlr); + for (i = 0; i < ctrlr->num_io_queues; i++) + nvme_io_qpair_destroy(&ctrlr->ioq[i]); + free(ctrlr->ioq, M_NVME); + nvme_admin_qpair_destroy(&ctrlr->adminq); + } /* * Notify the controller of a shutdown, even though this is due to