[PATCH BlueZ] tools: Fix static analysis warnings

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

 



Usage of potentially NULL pointers
---
 tools/btmgmt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index 383e7199e..f4eb541fa 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -4912,6 +4912,12 @@ static void cmd_advmon_add_pattern(int argc, char **argv)
 
 	cp_len = sizeof(*cp) + argc * sizeof(struct mgmt_adv_pattern);
 	cp = malloc0(cp_len);
+	if (!cp) {
+		error("Failed to alloc patterns.");
+		success = false;
+		goto done;
+	}
+
 	cp->pattern_count = argc;
 
 	for (i = 0; i < argc; i++) {
@@ -4987,6 +4993,12 @@ static void cmd_advmon_add_pattern_rssi(int argc, char **argv)
 
 	cp_len = sizeof(*cp) + argc * sizeof(struct mgmt_adv_pattern);
 	cp = malloc0(cp_len);
+	if (!cp) {
+		error("Failed to alloc patterns.");
+		success = false;
+		goto done;
+	}
+
 	cp->pattern_count = argc;
 	cp->rssi.high_threshold = rssi_high;
 	cp->rssi.low_threshold = rssi_low;
-- 
2.25.4




[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