Fix of potential memory leaks at lapdm.c

This commit is contained in:
Andreas Eversberg 2013-02-05 12:01:32 +01:00 committed by Holger Hans Peter Freyther
parent 6e182087f4
commit b36ad2debe
1 changed files with 17 additions and 4 deletions

View File

@ -687,7 +687,8 @@ int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
if (oph->sap != SAP_GSM_PH) {
LOGP(DLLAPD, LOGL_ERROR, "primitive for unknown SAP %u\n",
oph->sap);
return -ENODEV;
rc = -ENODEV;
goto free;
}
switch (oph->primitive) {
@ -695,7 +696,8 @@ int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
if (oph->operation != PRIM_OP_INDICATION) {
LOGP(DLLAPD, LOGL_ERROR, "PH_DATA is not INDICATION %u\n",
oph->operation);
return -ENODEV;
rc = -ENODEV;
goto free;
}
rc = l2_ph_data_ind(oph->msg, le, pp->u.data.chan_nr,
pp->u.data.link_id);
@ -704,7 +706,8 @@ int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
if (oph->operation != PRIM_OP_INDICATION) {
LOGP(DLLAPD, LOGL_ERROR, "PH_RTS is not INDICATION %u\n",
oph->operation);
return -ENODEV;
rc = -ENODEV;
goto free;
}
rc = l2_ph_data_conf(oph->msg, le);
break;
@ -718,12 +721,22 @@ int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le)
rc = l2_ph_chan_conf(oph->msg, le, pp->u.rach_ind.fn);
break;
default:
return -EIO;
rc = -EIO;
goto free;
}
break;
default:
LOGP(DLLAPD, LOGL_ERROR, "Unknown primitive %u\n",
oph->primitive);
rc = -EINVAL;
goto free;
}
return rc;
free:
msgb_free(oph->msg);
return rc;
}