aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-02-22 20:16:13 +0100
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-02-22 20:23:12 +0100
commit3c201a920e4b2d53e7105e761d50bec2d57b53d0 (patch)
treead6e5454a5ff7a50fec972f28285753f4ad38a1d
parent637cb958d33bf0b6ad70c2411631d685bffcfdbe (diff)
libdvbv5: don't leak memory at dvb-dev-remote
If something goes wrong, ensure that the allocated msg and ringbuf will be freed. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r--lib/libdvbv5/dvb-dev-remote.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libdvbv5/dvb-dev-remote.c b/lib/libdvbv5/dvb-dev-remote.c
index e4ea3a82..07ab35a6 100644
--- a/lib/libdvbv5/dvb-dev-remote.c
+++ b/lib/libdvbv5/dvb-dev-remote.c
@@ -251,6 +251,7 @@ static struct queued_msg *send_fmt(struct dvb_device_priv *dvb, int fd,
dvb_logdbg("buffer to short for int32_t");
stack_dump(parms);
pthread_mutex_unlock(&priv->lock_io);
+ free(msg);
return NULL;
}
memcpy(p, &i32, 4);
@@ -263,6 +264,7 @@ static struct queued_msg *send_fmt(struct dvb_device_priv *dvb, int fd,
p - buf, len, sizeof(buf));
stack_dump(parms);
pthread_mutex_unlock(&priv->lock_io);
+ free(msg);
return NULL;
}
i32 = htobe32(len);
@@ -279,6 +281,7 @@ static struct queued_msg *send_fmt(struct dvb_device_priv *dvb, int fd,
if (ret < 0) {
pthread_mutex_unlock(&priv->lock_io);
+ free(msg);
return NULL;
}
@@ -1041,8 +1044,10 @@ static struct dvb_open_descriptor *dvb_remote_open(struct dvb_device_priv *dvb,
open_dev = &ringbuf->open_dev;
msg = send_fmt(dvb, priv->fd, "dev_open", "%s%i", sysname, flags);
- if (!msg)
+ if (!msg) {
+ free(ringbuf);
return NULL;
+ }
ret = pthread_cond_wait(&msg->cond, &msg->lock);
if (ret < 0) {
@@ -1077,6 +1082,7 @@ error:
pthread_mutex_unlock(&msg->lock);
free_msg(dvb, msg);
+ free(ringbuf);
return NULL;
}

Privacy Policy