[PATCH] tgtd: fix internal error of __inaccount_bind()

Ryusuke Konishi <[email protected]>
Newsgroups org.kernel.vger.stgt
Message-ID <[email protected]>
When trying to bind 32 accounts to the same target, tgtadm outputs
"unknown error" and exits returing status code 22 (EINVAL).

This is because __inaccount_bind() function of tgtd does not increment
target->account.nr_inaccount when it doubles maximum number of
accounts for the target, and therefore it tries to allocate an aid
slot on target->account.in_aids[] array even though no free aid slot
is available there.

This fixes the bug.

Reported-by: Satoshi Yoshida <[email protected]>
Signed-off-by: Ryusuke Konishi <[email protected]>
---
 usr/target.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/target.c b/usr/target.c
index f4c5b4e..b6f324c 100644
--- a/usr/target.c
+++ b/usr/target.c
@@ -1581,7 +1581,6 @@ static tgtadm_err __inaccount_bind(struct target *target, int aid)
 		}
 
 		target->account.in_aids[i] = aid;
-		target->account.nr_inaccount++;
 	} else {
 		int new_max = target->account.max_inaccount << 1;
 		int *buf;
@@ -1597,6 +1596,7 @@ static tgtadm_err __inaccount_bind(struct target *target, int aid)
 		target->account.in_aids[target->account.max_inaccount] = aid;
 		target->account.max_inaccount = new_max;
 	}
+	target->account.nr_inaccount++;
 
 	return TGTADM_SUCCESS;
 }
-- 
1.7.9.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.