dahdi: Add msgb_free() to prevent memeory leaks

Change-Id: I862dfa80dc195639552f99ec0734ec94290a7bb5
This commit is contained in:
Andreas Eversberg 2023-08-01 09:34:36 +02:00
parent 7e5ab270b4
commit 23bac40d75
1 changed files with 6 additions and 0 deletions

View File

@ -179,10 +179,12 @@ static int handle_ts1_read(struct osmo_fd *bfd)
handle_dahdi_exception(e1i_ts);
else if (ret < 0) {
LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "%s read failed %d (%s)\n", __func__, ret, strerror(errno));
msgb_free(msg);
return ret;
}
if (ret <= 3) {
LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "%s read failed %d (%s)\n", __func__, ret, strerror(errno));
msgb_free(msg);
return ret;
}
msgb_put(msg, ret - 2);
@ -316,10 +318,12 @@ static int handle_hdlc_read(struct osmo_fd *bfd)
handle_dahdi_exception(e1i_ts);
else if (ret < 0) {
LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "%s read failed %d (%s)\n", __func__, ret, strerror(errno));
msgb_free(msg);
return ret;
}
if (ret <= 3) {
LOGPITS(e1i_ts, DLMI, LOGL_ERROR, "%s read failed %d (%s)\n", __func__, ret, strerror(errno));
msgb_free(msg);
return ret;
}
msgb_put(msg, ret - 2);
@ -377,6 +381,7 @@ static int handle_tsX_read(struct osmo_fd *bfd)
ret = read(bfd->fd, msg->data, D_TSX_ALLOC_SIZE);
if (ret < 0 || ret != D_TSX_ALLOC_SIZE) {
LOGPITS(e1i_ts, DLINP, LOGL_DEBUG, "read error %d %s\n", ret, strerror(errno));
msgb_free(msg);
return ret;
}
@ -446,6 +451,7 @@ static int handle_ts_raw_read(struct osmo_fd *bfd)
ret = read(bfd->fd, msg->data, D_TSX_ALLOC_SIZE);
if (ret < 0 || ret != D_TSX_ALLOC_SIZE) {
LOGPITS(e1i_ts, DLINP, LOGL_DEBUG, "read error %d %s\n", ret, strerror(errno));
msgb_free(msg);
return ret;
}