[Midnightbsd-cvs] src [8246] trunk/sys/cam: protect xpt_getattr callls
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Sep 17 17:33:33 EDT 2016
Revision: 8246
http://svnweb.midnightbsd.org/src/?rev=8246
Author: laffer1
Date: 2016-09-17 17:33:33 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
protect xpt_getattr callls
Modified Paths:
--------------
trunk/sys/cam/ata/ata_da.c
trunk/sys/cam/cam_xpt.c
trunk/sys/cam/scsi/scsi_da.c
trunk/sys/cam/scsi/scsi_pass.c
Modified: trunk/sys/cam/ata/ata_da.c
===================================================================
--- trunk/sys/cam/ata/ata_da.c 2016-09-17 21:33:14 UTC (rev 8245)
+++ trunk/sys/cam/ata/ata_da.c 2016-09-17 21:33:33 UTC (rev 8246)
@@ -1170,17 +1170,17 @@
static int
adagetattr(struct bio *bp)
{
- int ret = -1;
+ int ret;
struct cam_periph *periph;
- if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
- return ENXIO;
periph = (struct cam_periph *)bp->bio_disk->d_drv1;
- if (periph->path == NULL)
- return ENXIO;
+ if (periph == NULL)
+ return (ENXIO);
+ cam_periph_lock(periph);
ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute,
periph->path);
+ cam_periph_unlock(periph);
if (ret == 0)
bp->bio_completed = bp->bio_length;
return ret;
Modified: trunk/sys/cam/cam_xpt.c
===================================================================
--- trunk/sys/cam/cam_xpt.c 2016-09-17 21:33:14 UTC (rev 8245)
+++ trunk/sys/cam/cam_xpt.c 2016-09-17 21:33:33 UTC (rev 8246)
@@ -1111,6 +1111,8 @@
int ret = -1;
struct ccb_dev_advinfo cdai;
+ mtx_assert(path->bus->sim->mtx, MA_OWNED);
+
memset(&cdai, 0, sizeof(cdai));
xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL);
cdai.ccb_h.func_code = XPT_DEV_ADVINFO;
Modified: trunk/sys/cam/scsi/scsi_da.c
===================================================================
--- trunk/sys/cam/scsi/scsi_da.c 2016-09-17 21:33:14 UTC (rev 8245)
+++ trunk/sys/cam/scsi/scsi_da.c 2016-09-17 21:33:33 UTC (rev 8246)
@@ -1213,17 +1213,17 @@
static int
dagetattr(struct bio *bp)
{
- int ret = -1;
+ int ret;
struct cam_periph *periph;
- if (bp->bio_disk == NULL || bp->bio_disk->d_drv1 == NULL)
- return ENXIO;
periph = (struct cam_periph *)bp->bio_disk->d_drv1;
- if (periph->path == NULL)
- return ENXIO;
+ if (periph == NULL)
+ return (ENXIO);
+ cam_periph_lock(periph);
ret = xpt_getattr(bp->bio_data, bp->bio_length, bp->bio_attribute,
periph->path);
+ cam_periph_unlock(periph);
if (ret == 0)
bp->bio_completed = bp->bio_length;
return ret;
Modified: trunk/sys/cam/scsi/scsi_pass.c
===================================================================
--- trunk/sys/cam/scsi/scsi_pass.c 2016-09-17 21:33:14 UTC (rev 8245)
+++ trunk/sys/cam/scsi/scsi_pass.c 2016-09-17 21:33:33 UTC (rev 8246)
@@ -212,27 +212,26 @@
*/
periph = context;
softc = periph->softc;
+ physpath = malloc(MAXPATHLEN, M_DEVBUF, M_WAITOK);
cam_periph_lock(periph);
if (periph->flags & CAM_PERIPH_INVALID) {
cam_periph_unlock(periph);
- return;
+ goto out;
}
- cam_periph_unlock(periph);
- physpath = malloc(MAXPATHLEN, M_DEVBUF, M_WAITOK);
if (xpt_getattr(physpath, MAXPATHLEN,
"GEOM::physpath", periph->path) == 0
&& strlen(physpath) != 0) {
+ cam_periph_unlock(periph);
make_dev_physpath_alias(MAKEDEV_WAITOK, &softc->alias_dev,
softc->dev, softc->alias_dev, physpath);
+ cam_periph_lock(periph);
}
- free(physpath, M_DEVBUF);
/*
* Now that we've made our alias, we no longer have to have a
* reference to the device.
*/
- cam_periph_lock(periph);
if ((softc->flags & PASS_FLAG_INITIAL_PHYSPATH) == 0) {
softc->flags |= PASS_FLAG_INITIAL_PHYSPATH;
cam_periph_unlock(periph);
@@ -240,6 +239,9 @@
}
else
cam_periph_unlock(periph);
+
+out:
+ free(physpath, M_DEVBUF);
}
static void
More information about the Midnightbsd-cvs
mailing list