Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1389603pxb; Fri, 22 Jan 2021 14:45:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJqu0ZWPcpD8VQksPqxuZxynqh/mGMMcz9HZ9N2qrMC4kT2RsWHjpvwvNquFAumVqg4W23 X-Received: by 2002:a05:6402:158:: with SMTP id s24mr5110808edu.19.1611355503175; Fri, 22 Jan 2021 14:45:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611355503; cv=none; d=google.com; s=arc-20160816; b=f/2YLEBeKPGkZjeKO4XIb9rWRPMDWjg7BAEiLxHvBZNmv1veO02/FCX8xIFeBlBPFh riz6NZkxUpmyzwEuj6UBKaSt8a4u22sXIrAUBIy4Ycd2IPS82K06mZM+oJ/uTmXKSkvf 4ISvU4d/ON8hCGOfdYw3CXt5itoy/n0jl15at9LKJ0UhtsK3PpvJp6h9lxM2evDDAj9L ohYfKW36U/5iSFTgg28xbPzvhHaEc6juBoDMy2xEN74hjWAZbklh89v52ljVfwjx19d7 HT1UKcP/QnyGJI0Ape+02bXnpmjGr6H8yhi/n8y0tGXYQpMBJDxESrN5cUKiqfgcXxqk t5WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=sZEDgo3F8qErzP7uM88IT9CMiJi1owSqBmtQg6Rthrk=; b=oXqSdTOQscKtP37BxhN2I4mlz3n4BMpYghpuoeQf4rwwWxCl4N/kZa1x1J7yvIyLWa Z4aIT9o8FuFdrkw6bPiFXi2kN8xB9HcF4jtfz0MZZIczvM8SYFY/gx5zYWTjRioAxUSA 3RUGDnH9wh09QyQVNWs/wGJTTHWqZXW5DHPOiZhATGTA73CJv+6rzMxaEYO6Mhso8GtD dfznliGldaJaIPvuWmDFq02UrlIxhRkXhZEYLFtcWzJw/e2C59jofEOyUTqZQJUpMAUw XX0oZPq8+m87y/osjKwN1GN3ehemDK67/36FUdn6rIV5cJIvHHERyM6+3l+ALKKp4u1A Wa0Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si4118479edz.486.2021.01.22.14.44.39; Fri, 22 Jan 2021 14:45:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728469AbhAVWm4 (ORCPT + 99 others); Fri, 22 Jan 2021 17:42:56 -0500 Received: from mga05.intel.com ([192.55.52.43]:45066 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729364AbhAVToB (ORCPT ); Fri, 22 Jan 2021 14:44:01 -0500 IronPort-SDR: kZ8HcsdBQz2QBmRgRg96l/1w7N9kPaz9LI33ojUq44rpHvlNyBmHq5CZMxyu92NnEOEanqgAI4 MAOy7JaTfw5Q== X-IronPort-AV: E=McAfee;i="6000,8403,9872"; a="264317667" X-IronPort-AV: E=Sophos;i="5.79,367,1602572400"; d="scan'208";a="264317667" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 11:43:18 -0800 IronPort-SDR: vXkG5+/XC0hdqF9LaETo8OYbq/BEo/k04+UdHDKuvQGQ4yWO213uBD0sXn1Vbwy6QLiMNOUvIW 2X4E1SFnvLbg== X-IronPort-AV: E=Sophos;i="5.79,367,1602572400"; d="scan'208";a="428148625" Received: from bgi1-mobl2.amr.corp.intel.com ([10.209.2.104]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2021 11:43:18 -0800 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: luiz.dentz@gmail.com, Brian Gix Subject: [PATCH BlueZ] tools: Fix static analysis warnings Date: Fri, 22 Jan 2021 11:42:58 -0800 Message-Id: <20210122194258.538970-1-brian.gix@intel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org 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