Bring in some CAM bug fixes from FreeBSD.
authorMatthew Dillon <dillon@dragonflybsd.org>
Tue, 15 Mar 2005 20:42:14 +0000 (20:42 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Tue, 15 Mar 2005 20:42:14 +0000 (20:42 +0000)
Submitted-by: Xin LI <delphij@frontfree.net>
Obtained-from: FreeBSD

sys/bus/cam/cam_periph.c
sys/bus/cam/cam_xpt.c
sys/bus/cam/scsi/scsi_all.c
sys/bus/cam/scsi/scsi_target.c

index 6d801b7..39474df 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/cam_periph.c,v 1.24.2.3 2003/01/25 19:04:40 dillon Exp $
- * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.8 2004/03/12 03:23:13 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.9 2005/03/15 20:42:12 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -399,6 +399,12 @@ camperiphfree(struct cam_periph *periph)
                if (strcmp((*p_drv)->driver_name, periph->periph_name) == 0)
                        break;
        }
+
+       if (*p_drv == NULL) {
+               printf("camperiphfree: attempt to free "
+                       "non-existant periph: %s\n", periph->periph_name);
+               return;
+       }
        
        if (periph->periph_dtor != NULL)
                periph->periph_dtor(periph);
index 7b86d6e..5b6b3c3 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/cam_xpt.c,v 1.80.2.18 2002/12/09 17:31:55 gibbs Exp $
- * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.22 2005/03/05 18:29:24 swildner Exp $
+ * $DragonFly: src/sys/bus/cam/cam_xpt.c,v 1.23 2005/03/15 20:42:12 dillon Exp $
  */
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -2333,7 +2333,7 @@ xptplistperiphfunc(struct cam_periph *periph, void *arg)
                                        break;
                        }
 
-                       if (pdrv == NULL) {
+                       if (*pdrv == NULL) {
                                cdm->status = CAM_DEV_MATCH_ERROR;
                                return(0);
                        }
index 0d7e98b..4e7e41f 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_all.c,v 1.14.2.11 2003/10/30 15:06:35 thomas Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_all.c,v 1.4 2003/12/29 06:42:10 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_all.c,v 1.5 2005/03/15 20:42:14 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -1689,7 +1689,7 @@ scsi_sense_print(struct ccb_scsiio *csio)
                         * XXX KDM this is stupid, but casting the
                         * structure doesn't work...
                         */
-                       bcopy(&csio->sense_data, sense, 
+                       bcopy(&csio->sense_data, &sense, 
                              sizeof(struct scsi_sense_data *));
                }
        } else {
@@ -1874,7 +1874,7 @@ scsi_sense_string(struct cam_device *device, struct ccb_scsiio *csio,
                         * XXX KDM this is stupid, but casting the
                         * structure doesn't work...
                         */
-                       bcopy(&csio->sense_data, sense, 
+                       bcopy(&csio->sense_data, &sense, 
                              sizeof(struct scsi_sense_data *));
                }
        } else {
index 5401383..eee4d1b 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_target.c,v 1.22.2.7 2003/02/18 22:07:10 njl Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_target.c,v 1.9 2004/05/19 22:52:38 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_target.c,v 1.10 2005/03/15 20:42:14 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -532,7 +532,6 @@ targwrite(dev_t dev, struct uio *uio, int ioflag)
                  ("write - uio_resid %d\n", uio->uio_resid));
        while (uio->uio_resid >= sizeof(user_ccb) && error == 0) {
                union ccb *ccb;
-               int error;
 
                error = uiomove((caddr_t)&user_ccb, sizeof(user_ccb), uio);
                if (error != 0) {