1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-19 15:33:56 +00:00

Fix a use-after-free when "zpool import" fails

clear vd->vdev_tsd in vdev_geom_close_locked instead of vdev_geom_detach.
In the latter function, it would fail to happen in certain circumstances
where cp->private was unset.  Ideally, the latter should never happen, but
it can happen when vdev open fails, or where spares are involved.

MFC after:	4 weeks
X-MFC-With:	298786
Sponsored by:	Spectra Logic Corp
This commit is contained in:
Alan Somers 2016-04-29 21:29:37 +00:00
parent 053359b7f4
commit c9a807447d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298814

View File

@ -276,10 +276,6 @@ vdev_geom_detach(struct g_consumer *cp, boolean_t open_for_read)
cp->provider && cp->provider->name ? cp->provider->name : "NULL");
vd = cp->private;
if (vd != NULL) {
vd->vdev_tsd = NULL;
vd->vdev_delayed_close = B_FALSE;
}
cp->private = NULL;
gp = cp->geom;
@ -311,6 +307,8 @@ vdev_geom_close_locked(vdev_t *vd)
g_topology_assert();
cp = vd->vdev_tsd;
vd->vdev_tsd = NULL;
vd->vdev_delayed_close = B_FALSE;
if (cp == NULL)
return;