From owner-svn-src-head@freebsd.org Wed Mar 15 11:16:28 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5328FD0D60F; Wed, 15 Mar 2017 11:16:28 +0000 (UTC) (envelope-from mav@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 mx1.freebsd.org (Postfix) with ESMTPS id 068831FA2; Wed, 15 Mar 2017 11:16:27 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2FBGRqf096364; Wed, 15 Mar 2017 11:16:27 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2FBGRKF096363; Wed, 15 Mar 2017 11:16:27 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201703151116.v2FBGRKF096363@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Wed, 15 Mar 2017 11:16:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315303 - head/sys/dev/isp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Mar 2017 11:16:28 -0000 Author: mav Date: Wed Mar 15 11:16:26 2017 New Revision: 315303 URL: https://svnweb.freebsd.org/changeset/base/315303 Log: Fix panic when SIM dereferenced before allocation. MFC after: 2 weeks Modified: head/sys/dev/isp/isp_freebsd.c Modified: head/sys/dev/isp/isp_freebsd.c ============================================================================== --- head/sys/dev/isp/isp_freebsd.c Wed Mar 15 10:53:40 2017 (r315302) +++ head/sys/dev/isp/isp_freebsd.c Wed Mar 15 11:16:26 2017 (r315303) @@ -362,39 +362,40 @@ isp_detach(ispsoftc_t *isp) static void isp_freeze_loopdown(ispsoftc_t *isp, int chan) { - if (IS_FC(isp)) { - struct isp_fc *fc = ISP_FC_PC(isp, chan); - if (fc->simqfrozen == 0) { - isp_prt(isp, ISP_LOGDEBUG0, - "Chan %d Freeze simq (loopdown)", chan); - fc->simqfrozen = SIMQFRZ_LOOPDOWN; - xpt_hold_boot(); - xpt_freeze_simq(fc->sim, 1); - } else { - isp_prt(isp, ISP_LOGDEBUG0, - "Chan %d Mark simq frozen (loopdown)", chan); - fc->simqfrozen |= SIMQFRZ_LOOPDOWN; - } + struct isp_fc *fc = ISP_FC_PC(isp, chan); + + if (fc->sim == NULL) + return; + if (fc->simqfrozen == 0) { + isp_prt(isp, ISP_LOGDEBUG0, + "Chan %d Freeze simq (loopdown)", chan); + fc->simqfrozen = SIMQFRZ_LOOPDOWN; + xpt_hold_boot(); + xpt_freeze_simq(fc->sim, 1); + } else { + isp_prt(isp, ISP_LOGDEBUG0, + "Chan %d Mark simq frozen (loopdown)", chan); + fc->simqfrozen |= SIMQFRZ_LOOPDOWN; } } static void isp_unfreeze_loopdown(ispsoftc_t *isp, int chan) { - if (IS_FC(isp)) { - struct isp_fc *fc = ISP_FC_PC(isp, chan); - int wasfrozen = fc->simqfrozen & SIMQFRZ_LOOPDOWN; - fc->simqfrozen &= ~SIMQFRZ_LOOPDOWN; - if (wasfrozen && fc->simqfrozen == 0) { - isp_prt(isp, ISP_LOGDEBUG0, - "Chan %d Release simq", chan); - xpt_release_simq(fc->sim, 1); - xpt_release_boot(); - } + struct isp_fc *fc = ISP_FC_PC(isp, chan); + + if (fc->sim == NULL) + return; + int wasfrozen = fc->simqfrozen & SIMQFRZ_LOOPDOWN; + fc->simqfrozen &= ~SIMQFRZ_LOOPDOWN; + if (wasfrozen && fc->simqfrozen == 0) { + isp_prt(isp, ISP_LOGDEBUG0, + "Chan %d Release simq", chan); + xpt_release_simq(fc->sim, 1); + xpt_release_boot(); } } - static int ispioctl(struct cdev *dev, u_long c, caddr_t addr, int flags, struct thread *td) {