From owner-svn-src-all@FreeBSD.ORG Tue Jul 8 16:56:21 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C858C392; Tue, 8 Jul 2014 16:56:21 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 B56D028C7; Tue, 8 Jul 2014 16:56:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s68GuLLm075330; Tue, 8 Jul 2014 16:56:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s68GuLcS075328; Tue, 8 Jul 2014 16:56:21 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201407081656.s68GuLcS075328@svn.freebsd.org> From: Alexander Motin Date: Tue, 8 Jul 2014 16:56:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268419 - head/sys/cam/ctl X-SVN-Group: head 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.18 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: Tue, 08 Jul 2014 16:56:21 -0000 Author: mav Date: Tue Jul 8 16:56:21 2014 New Revision: 268419 URL: http://svnweb.freebsd.org/changeset/base/268419 Log: Fix use-after-free on XPT_RESET_BUS. That command is not queued, so does not use later status update. Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c Modified: head/sys/cam/ctl/ctl_frontend_cam_sim.c ============================================================================== --- head/sys/cam/ctl/ctl_frontend_cam_sim.c Tue Jul 8 16:38:05 2014 (r268418) +++ head/sys/cam/ctl/ctl_frontend_cam_sim.c Tue Jul 8 16:56:21 2014 (r268419) @@ -460,6 +460,10 @@ cfcs_done(union ctl_io *io) union ccb *ccb; ccb = io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr; + if (ccb == NULL) { + ctl_free_io(io); + return; + } /* * At this point we should have status. If we don't, that's a bug. @@ -741,7 +745,8 @@ cfcs_action(struct cam_sim *sim, union c ctl_zero_io(io); /* Save pointers on both sides */ - io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = ccb; + if (ccb->ccb_h.func_code == XPT_RESET_DEV) + io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = ccb; ccb->ccb_h.io_ptr = io; io->io_hdr.io_type = CTL_IO_TASK;