memleak: gsmtap_sendmsg(): don't return 0 when no data was written
If less than the msgb size was written by write(), we want to return -EIO.
Hence do not return zero when write() wrote zero bytes, return -EIO in that
case as well.
Previously, if write() returned zero, gsmtap_sendmsg() would return zero
*without* freeing the msg, hence neither would the (ideal) caller. So this
fixes a corner-case memleak.
Change-Id: I099ae1c663c018da5db884f7e9d52c45af3ed817
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 8c044b1..962782b 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -282,7 +282,7 @@
int rc;
rc = write(gsmtap_inst_fd(gti), msg->data, msg->len);
- if (rc <= 0) {
+ if (rc < 0) {
return rc;
} else if (rc >= msg->len) {
msgb_free(msg);