From 8f1382d1f241cac7aad7bec5aa42d3a93a1c145f Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Thu, 28 Oct 2010 04:14:28 +0000 Subject: [PATCH] sys/dev/xen/blkback/blkback.c: In xbb_detach() only perform cleanup of our taskqueue and device statistics structures if they have been initialized. This avoids a panic when xbb_detach() is called on a partially initialized device instance, due to an early failure in attach. Sponsored by: Spectra Logic Corporation --- sys/dev/xen/blkback/blkback.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/dev/xen/blkback/blkback.c b/sys/dev/xen/blkback/blkback.c index 72087f5994ce..458149d5f06f 100644 --- a/sys/dev/xen/blkback/blkback.c +++ b/sys/dev/xen/blkback/blkback.c @@ -2827,8 +2827,11 @@ xbb_detach(device_t dev) DPRINTF("\n"); - taskqueue_free(xbb->io_taskqueue); - devstat_remove_entry(xbb->xbb_stats); + if (xbb->io_taskqueue != NULL) + taskqueue_free(xbb->io_taskqueue); + + if (xbb->xbb_stats != NULL) + devstat_remove_entry(xbb->xbb_stats); xbb_close_backend(xbb); xbb_free_communication_mem(xbb);