Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Jun 2012 07:45:14 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r237469 - stable/9/sys/cam/scsi
Message-ID:  <201206230745.q5N7jEXN027332@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Jun 23 07:45:14 2012
New Revision: 237469
URL: http://svn.freebsd.org/changeset/base/237469

Log:
  MFC r237335:
  Check status of cam_periph_hold() inside cdclose().  If cd device was
  invalidated while open, cam_periph_hold() will return error and won't
  get the reference.  Following reference release will crash the system.
  
  Sponsored by:	iXsystems, Inc.

Modified:
  stable/9/sys/cam/scsi/scsi_cd.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/scsi/scsi_cd.c
==============================================================================
--- stable/9/sys/cam/scsi/scsi_cd.c	Sat Jun 23 04:47:41 2012	(r237468)
+++ stable/9/sys/cam/scsi/scsi_cd.c	Sat Jun 23 07:45:14 2012	(r237469)
@@ -1043,6 +1043,7 @@ cdclose(struct disk *dp)
 {
 	struct 	cam_periph *periph;
 	struct	cd_softc *softc;
+	int error;
 
 	periph = (struct cam_periph *)dp->d_drv1;
 	if (periph == NULL)
@@ -1051,7 +1052,11 @@ cdclose(struct disk *dp)
 	softc = (struct cd_softc *)periph->softc;
 
 	cam_periph_lock(periph);
-	cam_periph_hold(periph, PRIBIO);
+	if ((error = cam_periph_hold(periph, PRIBIO)) != 0) {
+		cam_periph_unlock(periph);
+		cam_periph_release(periph);
+		return (0);
+	}
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
 	    ("cdclose\n"));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206230745.q5N7jEXN027332>