gsm_04_11: Release SMS transaction only after starting next one.

This ensures that we don't re-use the same transaction ID.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index d4572ca..c3a49f3 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -752,14 +752,16 @@
 	sms_free(sms);
 	trans->sms.sms = NULL;
 
-	/* free the transaction here */
-	trans_free(trans);
-
 	/* check for more messages for this subscriber */
 	sms = db_sms_get_unsent_for_subscr(msg->lchan->subscr);
 	if (sms)
 		gsm411_send_sms_lchan(msg->lchan, sms);
-	else
+
+	/* free the transaction here */
+	trans_free(trans);
+
+	/* release channel if done */
+	if (!sms)
 		rsl_release_request(msg->lchan, trans->sms.link_id);
 
 	return 0;