aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_frontend_iscsi.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2014-04-09 19:16:40 +0000
committerAlexander Motin <mav@FreeBSD.org>2014-04-09 19:16:40 +0000
commit7081bb15b0d92d7722e18efe17f7b22795e4ed9b (patch)
treec1679cad9148c14c6cf818ef747f401f5e48e130 /sys/cam/ctl/ctl_frontend_iscsi.c
parent84cb72d1c65b6940491485ddc8e0107b6aea625a (diff)
downloadsrc-7081bb15b0d92d7722e18efe17f7b22795e4ed9b.tar.gz
src-7081bb15b0d92d7722e18efe17f7b22795e4ed9b.zip
Fix three refcounter leaks and lock recursion they covered.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=264307
Diffstat (limited to 'sys/cam/ctl/ctl_frontend_iscsi.c')
-rw-r--r--sys/cam/ctl/ctl_frontend_iscsi.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/cam/ctl/ctl_frontend_iscsi.c b/sys/cam/ctl/ctl_frontend_iscsi.c
index 6f9d50b00a97..57517c3f08c2 100644
--- a/sys/cam/ctl/ctl_frontend_iscsi.c
+++ b/sys/cam/ctl/ctl_frontend_iscsi.c
@@ -1455,6 +1455,7 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
mtx_unlock(&cfiscsi_softc.lock);
snprintf(ci->error_str, sizeof(ci->error_str), "connection not found");
ci->status = CTL_ISCSI_ERROR;
+ cfiscsi_target_release(ct);
return;
}
mtx_unlock(&cfiscsi_softc.lock);
@@ -2093,15 +2094,9 @@ cfiscsi_target_hold(struct cfiscsi_target *ct)
static void
cfiscsi_target_release(struct cfiscsi_target *ct)
{
- int old;
struct cfiscsi_softc *softc;
softc = ct->ct_softc;
-
- old = ct->ct_refcount;
- if (old > 1 && atomic_cmpset_int(&ct->ct_refcount, old, old - 1))
- return;
-
mtx_lock(&softc->lock);
if (refcount_release(&ct->ct_refcount)) {
TAILQ_REMOVE(&softc->targets, ct, ct_next);
@@ -2278,6 +2273,7 @@ cfiscsi_lun_enable(void *arg, struct ctl_id target_id, int lun_id)
tmp = strtoul(lun, NULL, 10);
cfiscsi_target_set_lun(ct, tmp, lun_id);
+ cfiscsi_target_release(ct);
return (0);
}
@@ -2297,8 +2293,9 @@ cfiscsi_lun_disable(void *arg, struct ctl_id target_id, int lun_id)
continue;
if (ct->ct_luns[i] != lun_id)
continue;
+ mtx_unlock(&softc->lock);
cfiscsi_target_unset_lun(ct, i);
- break;
+ return (0);
}
}
mtx_unlock(&softc->lock);