Skip to contentSkip to conversation

tools: Fix static analysis warnings

PATCH Applied Brian Gix 2 participants 3 messages Jan 22, 2021 – Jan 26, 2021 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 tools: Fix static analysis warnings

Usage of potentially NULL pointers

---
 tools/btmgmt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/btmgmt.c +12 -0
index 383e7199e..f4eb541fa 100644
@@ -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;
Signature · 1 line
2.25.4
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=420291

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

author Applied
#2 lore raw
In reply to Brian Gix

Applied

Quoted 35 lines · Brian Gix

Usage of potentially NULL pointers

---
 tools/btmgmt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
tools/btmgmt.c +12 -0
index 383e7199e..f4eb541fa 100644
@@ -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;