svn commit: r213776 - stable/8/sys/cam/scsi
Jaakko Heinonen
jh at FreeBSD.org
Wed Oct 13 14:02:45 UTC 2010
Author: jh
Date: Wed Oct 13 14:02:45 2010
New Revision: 213776
URL: http://svn.freebsd.org/changeset/base/213776
Log:
MFC r200036 by scottl:
Fix several cases where the periph lock was held over malloc.
PR: kern/130735
Modified:
stable/8/sys/cam/scsi/scsi_cd.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/cam/scsi/scsi_cd.c
==============================================================================
--- stable/8/sys/cam/scsi/scsi_cd.c Wed Oct 13 13:22:11 2010 (r213775)
+++ stable/8/sys/cam/scsi/scsi_cd.c Wed Oct 13 14:02:45 2010 (r213776)
@@ -2671,12 +2671,10 @@ cdioctl(struct disk *dp, u_long cmd, voi
authinfo = (struct dvd_authinfo *)addr;
- cam_periph_lock(periph);
if (cmd == DVDIOCREPORTKEY)
error = cdreportkey(periph, authinfo);
else
error = cdsendkey(periph, authinfo);
- cam_periph_unlock(periph);
break;
}
case DVDIOCREADSTRUCTURE: {
@@ -2684,9 +2682,7 @@ cdioctl(struct disk *dp, u_long cmd, voi
dvdstruct = (struct dvd_struct *)addr;
- cam_periph_lock(periph);
error = cdreaddvdstructure(periph, dvdstruct);
- cam_periph_unlock(periph);
break;
}
@@ -3732,8 +3728,6 @@ cdreportkey(struct cam_periph *periph, s
databuf = NULL;
lba = 0;
- ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
-
switch (authinfo->format) {
case DVD_REPORT_AGID:
length = sizeof(struct scsi_report_key_data_agid);
@@ -3759,9 +3753,7 @@ cdreportkey(struct cam_periph *periph, s
length = 0;
break;
default:
- error = EINVAL;
- goto bailout;
- break; /* NOTREACHED */
+ return (EINVAL);
}
if (length != 0) {
@@ -3769,6 +3761,8 @@ cdreportkey(struct cam_periph *periph, s
} else
databuf = NULL;
+ cam_periph_lock(periph);
+ ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
scsi_report_key(&ccb->csio,
/* retries */ cd_retry_count,
@@ -3869,12 +3863,14 @@ cdreportkey(struct cam_periph *periph, s
goto bailout;
break; /* NOTREACHED */
}
+
bailout:
+ xpt_release_ccb(ccb);
+ cam_periph_unlock(periph);
+
if (databuf != NULL)
free(databuf, M_DEVBUF);
- xpt_release_ccb(ccb);
-
return(error);
}
@@ -3889,8 +3885,6 @@ cdsendkey(struct cam_periph *periph, str
error = 0;
databuf = NULL;
- ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
-
switch(authinfo->format) {
case DVD_SEND_CHALLENGE: {
struct scsi_report_key_data_challenge *challenge_data;
@@ -3942,11 +3936,12 @@ cdsendkey(struct cam_periph *periph, str
break;
}
default:
- error = EINVAL;
- goto bailout;
- break; /* NOTREACHED */
+ return (EINVAL);
}
+ cam_periph_lock(periph);
+ ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
+
scsi_send_key(&ccb->csio,
/* retries */ cd_retry_count,
/* cbfcnp */ cddone,
@@ -3961,13 +3956,12 @@ cdsendkey(struct cam_periph *periph, str
error = cdrunccb(ccb, cderror, /*cam_flags*/CAM_RETRY_SELTO,
/*sense_flags*/SF_RETRY_UA);
-bailout:
+ xpt_release_ccb(ccb);
+ cam_periph_unlock(periph);
if (databuf != NULL)
free(databuf, M_DEVBUF);
- xpt_release_ccb(ccb);
-
return(error);
}
@@ -3985,8 +3979,6 @@ cdreaddvdstructure(struct cam_periph *pe
/* The address is reserved for many of the formats */
address = 0;
- ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
-
switch(dvdstruct->format) {
case DVD_STRUCT_PHYSICAL:
length = sizeof(struct scsi_read_dvd_struct_data_physical);
@@ -4004,13 +3996,7 @@ cdreaddvdstructure(struct cam_periph *pe
length = sizeof(struct scsi_read_dvd_struct_data_manufacturer);
break;
case DVD_STRUCT_CMI:
- error = ENODEV;
- goto bailout;
-#ifdef notyet
- length = sizeof(struct scsi_read_dvd_struct_data_copy_manage);
- address = dvdstruct->address;
-#endif
- break; /* NOTREACHED */
+ return (ENODEV);
case DVD_STRUCT_PROTDISCID:
length = sizeof(struct scsi_read_dvd_struct_data_prot_discid);
break;
@@ -4027,21 +4013,9 @@ cdreaddvdstructure(struct cam_periph *pe
length = sizeof(struct scsi_read_dvd_struct_data_spare_area);
break;
case DVD_STRUCT_RMD_LAST:
- error = ENODEV;
- goto bailout;
-#ifdef notyet
- length = sizeof(struct scsi_read_dvd_struct_data_rmd_borderout);
- address = dvdstruct->address;
-#endif
- break; /* NOTREACHED */
+ return (ENODEV);
case DVD_STRUCT_RMD_RMA:
- error = ENODEV;
- goto bailout;
-#ifdef notyet
- length = sizeof(struct scsi_read_dvd_struct_data_rmd);
- address = dvdstruct->address;
-#endif
- break; /* NOTREACHED */
+ return (ENODEV);
case DVD_STRUCT_PRERECORDED:
length = sizeof(struct scsi_read_dvd_struct_data_leadin);
break;
@@ -4049,13 +4023,7 @@ cdreaddvdstructure(struct cam_periph *pe
length = sizeof(struct scsi_read_dvd_struct_data_disc_id);
break;
case DVD_STRUCT_DCB:
- error = ENODEV;
- goto bailout;
-#ifdef notyet
- length = sizeof(struct scsi_read_dvd_struct_data_dcb);
- address = dvdstruct->address;
-#endif
- break; /* NOTREACHED */
+ return (ENODEV);
case DVD_STRUCT_LIST:
/*
* This is the maximum allocation length for the READ DVD
@@ -4067,9 +4035,7 @@ cdreaddvdstructure(struct cam_periph *pe
length = 65535;
break;
default:
- error = EINVAL;
- goto bailout;
- break; /* NOTREACHED */
+ return (EINVAL);
}
if (length != 0) {
@@ -4077,6 +4043,9 @@ cdreaddvdstructure(struct cam_periph *pe
} else
databuf = NULL;
+ cam_periph_lock(periph);
+ ccb = cdgetccb(periph, CAM_PRIORITY_NORMAL);
+
scsi_read_dvd_structure(&ccb->csio,
/* retries */ cd_retry_count,
/* cbfcnp */ cddone,
@@ -4164,13 +4133,14 @@ cdreaddvdstructure(struct cam_periph *pe
min(sizeof(dvdstruct->data), dvdstruct->length));
break;
}
+
bailout:
+ xpt_release_ccb(ccb);
+ cam_periph_unlock(periph);
if (databuf != NULL)
free(databuf, M_DEVBUF);
- xpt_release_ccb(ccb);
-
return(error);
}
More information about the svn-src-stable-8
mailing list