From b947eb9e7aa7585ddb968bc6e9d5fd47b7b29402 Mon Sep 17 00:00:00 2001 From: Brian Gix Date: Fri, 22 Jan 2021 11:40:14 -0800 Subject: [PATCH] tools: Fix static analysis warnings Usage of potentially NULL pointers Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- tools/btmgmt.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/btmgmt.c b/tools/btmgmt.c index 3d1a604..51a5143 100755 --- a/tools/btmgmt.c +++ b/tools/btmgmt.c @@ -4913,6 +4913,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++) { @@ -4988,6 +4994,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.7.4