Fix locking in periph drivers - don't try to unlock periph

that was already deallocated.

Reviewed by:	scottl
Approved by:	rwatson (mentor)
Sponsored by:	FreeBSD Foundation
This commit is contained in:
Edward Tomasz Napierala 2008-12-16 17:01:52 +00:00
parent fa6099fda0
commit f5bc800067
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=186186
3 changed files with 5 additions and 6 deletions

View File

@ -311,8 +311,6 @@ cam_periph_hold(struct cam_periph *periph, int priority)
struct mtx *mtx;
int error;
mtx_assert(periph->sim->mtx, MA_OWNED);
/*
* Increment the reference count on the peripheral
* while we wait for our lock attempt to succeed
@ -324,6 +322,8 @@ cam_periph_hold(struct cam_periph *periph, int priority)
return (ENXIO);
mtx = periph->sim->mtx;
mtx_assert(mtx, MA_OWNED);
if (mtx == &Giant)
mtx = NULL;

View File

@ -1595,7 +1595,7 @@ xpt_remove_periph(struct cam_periph *periph)
{
struct cam_ed *device;
mtx_assert(periph->sim->mtx, MA_OWNED);
cam_periph_lock(periph);
device = periph->path->device;
@ -1615,6 +1615,7 @@ xpt_remove_periph(struct cam_periph *periph)
mtx_lock(&xsoftc.xpt_topo_lock);
xsoftc.xpt_generation++;
mtx_unlock(&xsoftc.xpt_topo_lock);
cam_periph_unlock(periph);
}

View File

@ -772,8 +772,8 @@ daclose(struct disk *dp)
softc->flags &= ~DA_FLAG_OPEN;
cam_periph_unhold(periph);
cam_periph_release(periph);
cam_periph_unlock(periph);
cam_periph_release(periph);
return (0);
}
@ -995,10 +995,8 @@ dacleanup(struct cam_periph *periph)
xpt_print(periph->path, "can't remove sysctl context\n");
}
cam_periph_unlock(periph);
disk_destroy(softc->disk);
callout_drain(&softc->sendordered_c);
cam_periph_lock(periph);
free(softc, M_DEVBUF);
}