ctdb: Fixing possible memory leak in ctdb_daemon_read_cb
authorSwen Schillig <swen@vnet.ibm.com>
Tue, 13 Mar 2018 08:06:45 +0000 (09:06 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 30 Mar 2018 22:07:18 +0000 (00:07 +0200)
In case of an error condition the further processing of the data is cancelled
and the callback returns. In such a scenario the data has to be free'd.

Signed-off-by: Swen Schillig <swen@vnet.ibm.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/server/ctdb_daemon.c

index 7665e2a29c3e9b1d5b286f527fdad3cf3ce431a9..6d2f70f99b6205861c936d013e76510109e1071c 100644 (file)
@@ -903,12 +903,12 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args)
 
        if (hdr->ctdb_magic != CTDB_MAGIC) {
                ctdb_set_error(client->ctdb, "Non CTDB packet rejected\n");
-               return;
+               goto err_out;
        }
 
        if (hdr->ctdb_version != CTDB_PROTOCOL) {
                ctdb_set_error(client->ctdb, "Bad CTDB version 0x%x rejected in daemon\n", hdr->ctdb_version);
-               return;
+               goto err_out;
        }
 
        DEBUG(DEBUG_DEBUG,(__location__ " client request %u of type %u length %u from "
@@ -917,6 +917,10 @@ static void ctdb_daemon_read_cb(uint8_t *data, size_t cnt, void *args)
 
        /* it is the responsibility of the incoming packet function to free 'data' */
        daemon_incoming_packet(client, hdr);
+       return;
+
+err_out:
+       TALLOC_FREE(data);
 }