[PATCH 2/3] btmon: Fix memory leak

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andrei Emeltchenko <andrei.emeltchenko@xxxxxxxxx>

Dynamic memory stored in company allocated through function
hwdb_get_company shall be freed.
---
 monitor/packet.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/monitor/packet.c b/monitor/packet.c
index c991d04..b271cae 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -408,18 +408,20 @@ static void print_addr(const char *label, const uint8_t *addr,
 		if (!hwdb_get_company(addr, &company))
 			company = NULL;
 
-		if (company)
+		if (company) {
 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
 					" (%s)", label, addr[5], addr[4],
 							addr[3], addr[2],
 							addr[1], addr[0],
 							company);
-		else
+			free(company);
+		} else {
 			print_field("%s: %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X"
 					" (OUI %2.2X-%2.2X-%2.2X)", label,
 						addr[5], addr[4], addr[3],
 						addr[2], addr[1], addr[0],
 						addr[5], addr[4], addr[3]);
+		}
 		break;
 	case 0x01:
 		switch ((addr[5] & 0xc0) >> 6) {
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux