From 17cb105213a7a0c075973965cb78df6c99489d22 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 7 Dec 2010 16:59:19 +0000 Subject: [PATCH] Made sure that srpt_release() doesn't oops if srpt_add_one() fails after having registered the target and before the srpt_post_recv() loop started. Reported-by: Frank Zago . git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2963 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 1ea4fa4a5..ee599fad6 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -3510,6 +3510,10 @@ static void srpt_add_one(struct ib_device *device) if (!sdev) goto err; + sdev->device = device; + INIT_LIST_HEAD(&sdev->rch_list); + spin_lock_init(&sdev->spinlock); + sdev->scst_tgt = scst_register_target(&srpt_template, NULL); if (!sdev->scst_tgt) { PRINT_ERROR("SCST registration failed for %s.", @@ -3519,8 +3523,6 @@ static void srpt_add_one(struct ib_device *device) scst_tgt_set_tgt_priv(sdev->scst_tgt, sdev); - sdev->device = device; - sdev->dev.class = &srpt_class; #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) sdev->dev.dev = device->dma_device; @@ -3602,9 +3604,6 @@ static void srpt_add_one(struct ib_device *device) if (!sdev->ioctx_ring) goto err_event; - INIT_LIST_HEAD(&sdev->rch_list); - spin_lock_init(&sdev->spinlock); - for (i = 0; i < sdev->srq_size; ++i) srpt_post_recv(sdev, sdev->ioctx_ring[i]);