rspro_dec_msg: Simplify msgb ownership handling
Initially it seemed like a good idea that rspro_dec_msg() takes care
of freeing the input msgb when generating a new decoded output
structure. However, in reality this made the implementation of
every caller more complicated, as it had to treat messages going into
rspro_dec_msg() differently than messages going elsewhere.
Adding to that, not every caller got it right, and the comments were
disagreeing about what happens to msgb ownership in erroneous cases.
Change-Id: I55d5d61922053fd94e2b5a8cdf0d799b29feec98
diff --git a/src/rspro_client_fsm.c b/src/rspro_client_fsm.c
index d487f32..45cd08e 100644
--- a/src/rspro_client_fsm.c
+++ b/src/rspro_client_fsm.c
@@ -133,7 +133,6 @@
default:
break;
}
- msgb_free(msg);
break;
case IPAC_PROTO_OSMO:
if (!he || msgb_l2len(msg) < sizeof(*he))
@@ -146,7 +145,7 @@
* and unsuccessful cases */
pdu = rspro_dec_msg(msg);
if (!pdu)
- goto invalid;
+ break;
rc = srvc->handle_rx(srvc, pdu);
ASN_STRUCT_FREE(asn_DEF_RsproPDU, pdu);
break;
@@ -157,6 +156,8 @@
default:
goto invalid;
}
+
+ msgb_free(msg);
return rc;
invalid: