Skip to contentSkip to conversation

mesh: Fix potential memory leak

PATCH New Brian Gix 1 participant 1 message Jun 30, 2022 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 mesh: Fix potential memory leak

This memory leak will never happen, however since we added a new return from function that malloc'd memory, the free should still be done.

---
 mesh/mesh-config-json.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mesh/mesh-config-json.c +3 -1
index 5bb1e5ce0..7f46c8582 100644
@@ -1961,8 +1961,10 @@ bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page,
 	len = (size * 2) + 3;
 	buf = l_malloc(len);
 	ret = snprintf(buf, len, "%2.2x", page);
-	if (ret < 0)
+	if (ret < 0) {
+		l_free(buf);
 		return false;
+	}
 
 	hex2str(data, size, buf + 2, len - 2);
 
Signature · 1 line
2.36.1