From patchwork Fri Nov 20 20:07:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922067 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7290C2D0E4 for ; Fri, 20 Nov 2020 20:07:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66CAE2240A for ; Fri, 20 Nov 2020 20:07:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OlHsQ+Er" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730136AbgKTUHa (ORCPT ); Fri, 20 Nov 2020 15:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgKTUH3 (ORCPT ); Fri, 20 Nov 2020 15:07:29 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9990C0613CF for ; Fri, 20 Nov 2020 12:07:29 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id v21so4160646plo.12 for ; Fri, 20 Nov 2020 12:07:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; bh=+Kn0LlPza5fInle5gl6ExVZWBDlTbtXt7CPfXJUezIA=; b=OlHsQ+Erf4H4Jvw7P53dhXPpLYiJDl0oO0TTpEJRePXsSfaPjru/urGR9TTiNiK5+H 6xq1M4Smo7vz34dDnoInhi5INjWOfSI6P7PVkJ2yHqNwxd3xWcqkBNqSXGLGY0iyIEBI R7WjQft3SPmCKOhTT8KhH8uf34uYidJ6f8e0IX3EhIO/hX/sbkk9I2UgRhjMKMgX240u 02/cYqZbV4iJIGDsOa6z5se0kJK+YdbkEjqg2/Q+GCzlQWtHShwshMXCxeakx1C/6rqH 6sUo/6H6IawRuJvGH1gKYjsY4vI3ZH3tqTv0U5q6dRW/TYKehA9Z5xycMk6jWb8zL0mA 7Mtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :mime-version:content-transfer-encoding; bh=+Kn0LlPza5fInle5gl6ExVZWBDlTbtXt7CPfXJUezIA=; b=p7S9DfVwaZ6i8n61ylJD/5Cy9DVMn3dWeLMke1XN8rPuB8DAySikYJVwvjdG2Icn3U QPUhWEUm013DisQLsTFKKwd27B0SBF3T4Kd8/bwxgb/lDY7q2JaLP7Y02rF0Ov8OSz46 4mC4k3iLGM0k49eGJ4lBElEeIyQXcc/D8eKAMw55RwQCaL41uvSVOdMnzG7S9meN91BN OLByzF+5VBOMbWqkQNQ7fu8c2dpsrY3i3nn2YAv4BR6YZXGw/C1VRNFJCas9VIBdvYZe qm4WPxAvfizbzH2x3kXBu55FJLbK/HuQ/BDNPbJOczpy1T3mBc8tw2+qgbXjC5ZBi96J hLJA== X-Gm-Message-State: AOAM533bIxZ7UOgSODRXQf5pObXMrvoX2ZJC2YDfoteQVVXpqCMg6LbE ufqIuAu1xC0ruSnSOi1ZgUrA/U25/bWd/Q== X-Google-Smtp-Source: ABdhPJzhrKst+43P5Unf2TBiYUq+pHwIgicYP+craXNrLMN/x/EUgYBc6tYni2DgTe9xyU6dhbKIYA== X-Received: by 2002:a17:902:b7c6:b029:d8:e447:f7ef with SMTP id v6-20020a170902b7c6b02900d8e447f7efmr14525329plz.1.1605902848926; Fri, 20 Nov 2020 12:07:28 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:28 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 1/6] monitor: Fix potential memory leak Date: Fri, 20 Nov 2020 12:07:07 -0800 Message-Id: <20201120200712.491219-1-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If the mainloop_add_fd() returns with failure, the destroy callback is never called so any reosurces need to be released never freed/closed. This potential leakage is checked with valgrind after failing the mainloop_add_fd() function manually. ==258684== 1,500 bytes in 1 blocks are definitely lost in loss record 3 of 3 ==258684== at 0x483BB1A: calloc (vg_replace_malloc.c:760) ==258684== by 0x123F1A: open_channel (control.c:1058) ==258684== by 0x125B09: control_tracing (control.c:1540) ==258684== by 0x122764: main (main.c:255) ==258684== ==258684== LEAK SUMMARY: ==258684== definitely lost: 1,500 bytes in 1 blocks ==258684== indirectly lost: 0 bytes in 0 blocks ==258684== possibly lost: 0 bytes in 0 blocks ==258684== still reachable: 48 bytes in 2 blocks ==258684== suppressed: 0 bytes in 0 blocks This patch frees/closes the resources if the function returns with failure. --- monitor/control.c | 20 +++++++++++++++++--- monitor/hcidump.c | 14 +++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/monitor/control.c b/monitor/control.c index 962da4980..d1ba97d37 100644 --- a/monitor/control.c +++ b/monitor/control.c @@ -1071,7 +1071,12 @@ static int open_channel(uint16_t channel) if (filter_index != HCI_DEV_NONE) attach_index_filter(data->fd, filter_index); - mainloop_add_fd(data->fd, EPOLLIN, data_callback, data, free_data); + if (mainloop_add_fd(data->fd, EPOLLIN, data_callback, + data, free_data) < 0) { + close(data->fd); + free(data); + return -1; + }; return 0; } @@ -1148,7 +1153,11 @@ static void server_accept_callback(int fd, uint32_t events, void *user_data) data->channel = HCI_CHANNEL_MONITOR; data->fd = nfd; - mainloop_add_fd(data->fd, EPOLLIN, client_callback, data, free_data); + if (mainloop_add_fd(data->fd, EPOLLIN, client_callback, + data, free_data) < 0) { + close(data->fd); + free(data); + } } static int server_fd = -1; @@ -1399,7 +1408,12 @@ int control_tty(const char *path, unsigned int speed) data->channel = HCI_CHANNEL_MONITOR; data->fd = fd; - mainloop_add_fd(data->fd, EPOLLIN, tty_callback, data, free_data); + if (mainloop_add_fd(data->fd, EPOLLIN, tty_callback, + data, free_data) < 0) { + close(data->fd); + free(data); + return -1; + } return 0; } diff --git a/monitor/hcidump.c b/monitor/hcidump.c index 690b9b913..fac9c8a08 100644 --- a/monitor/hcidump.c +++ b/monitor/hcidump.c @@ -184,7 +184,11 @@ static void open_device(uint16_t index) return; } - mainloop_add_fd(data->fd, EPOLLIN, device_callback, data, free_data); + if (mainloop_add_fd(data->fd, EPOLLIN, device_callback, + data, free_data) < 0) { + close(data->fd); + free(data); + } } static void device_info(int fd, uint16_t index, uint8_t *type, uint8_t *bus, @@ -393,8 +397,12 @@ int hcidump_tracing(void) return -1; } - mainloop_add_fd(data->fd, EPOLLIN, stack_internal_callback, - data, free_data); + if (mainloop_add_fd(data->fd, EPOLLIN, stack_internal_callback, + data, free_data) < 0) { + close(data->fd); + free(data); + return -1; + } return 0; } From patchwork Fri Nov 20 20:07:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922069 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D7BCC63777 for ; Fri, 20 Nov 2020 20:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A4B92240A for ; Fri, 20 Nov 2020 20:07:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jeqEqAmV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730221AbgKTUHa (ORCPT ); Fri, 20 Nov 2020 15:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgKTUHa (ORCPT ); Fri, 20 Nov 2020 15:07:30 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 579BDC0613CF for ; Fri, 20 Nov 2020 12:07:30 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id q34so8209739pgb.11 for ; Fri, 20 Nov 2020 12:07:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=5K2z/gPk9a04YuZK6k3j8tBO+dwk4PTXBCcUW0nAKAk=; b=jeqEqAmVbTjKTNLS37nRG2RZipo9BOsBMGDdpMds5zOfz2mRo7cL8z4cVL4+sTKeN7 w8u8FG1imQyEdpgKGLR/46lK0PEk8JfVxfVUI+YmzgmFV/FhCqT3R4MR2Zk43qdO9nL8 IIdHFo6srl+ZkqoqVZjCU/3fLVLXU2utYumAz3Vp19BPu7MqBtSCKmU6Zjx6/Ifncbbu 7YIO19PkViq2vrQn2y8Fjdt3ZZ5WzLAzoa6yz0VNBlgDdN90tzGM4Xj+oI+ECBQ4poyy OqeS+mBh+rmAcAtVehn5oqGjPw2r3WpVrD+cv7eU+04KGrqJp6jrobC74tpDAHWFdvZl x/Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=5K2z/gPk9a04YuZK6k3j8tBO+dwk4PTXBCcUW0nAKAk=; b=r/u/d6mOSvpBWCaZrpSpvlk1UBeFR7zIhK0ob23BHUUi7EVoqsyB0Sfjy0G4YgPvg0 YG9tgm0y2hnS+5vxJXEY92/q85f2iFY+Lk1++M7MZO972H0eAWPKuAYzJ+9twITRlqKi 81saF6NelcyxfqheC29qQB91aNGJ/nOC5K59yoD9I/488Ul2Bq/M310hxKshRRVBUUjg 8ZWhVcbEhXwyhciFjjkraPOqcql0eYsneLpNcXnUzqwmH9xIyVelxsUdWhyUeCAUsaBs 9kQdx+GqimVYNcOp+Deal8H2vQMRdfYjZFepql68c67FUC4S2DA2AYEwQCGfgfCMekW7 ARsg== X-Gm-Message-State: AOAM532iM2TyOovyo5n1/DlKyezO5D1BZIfELmGsPgtl9NcoeKOG+gZs 1FQIwPwjYTvn2Zdiiv3KePQseXY/udCRzQ== X-Google-Smtp-Source: ABdhPJyd1AipFHnGe///Gy3kFPpbFVKf4+d7XhwT86pHKqMcK8BgfXreLs0+5WHeSy/1Z30/zL5d/A== X-Received: by 2002:a17:90a:a81:: with SMTP id 1mr11682011pjw.165.1605902849703; Fri, 20 Nov 2020 12:07:29 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:29 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 2/6] monitor: Fix the unchecked return value Date: Fri, 20 Nov 2020 12:07:08 -0800 Message-Id: <20201120200712.491219-2-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com> References: <20201120200712.491219-1-tedd.an@intel.com> Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch fixes the unchecked return value. --- monitor/a2dp.c | 30 ++++++++++++++++++++---------- monitor/l2cap.c | 3 +++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/monitor/a2dp.c b/monitor/a2dp.c index ac2e1a228..f6e99ab26 100644 --- a/monitor/a2dp.c +++ b/monitor/a2dp.c @@ -364,7 +364,8 @@ static bool codec_mpeg12_cap(uint8_t losc, struct l2cap_frame *frame) if (losc != 4) return false; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; layer = (cap >> 8) & 0xe0; crc = cap & 0x1000; @@ -372,7 +373,8 @@ static bool codec_mpeg12_cap(uint8_t losc, struct l2cap_frame *frame) mpf = cap & 0x0040; freq = cap & 0x003f; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; vbr = cap & 0x8000; bitrate = cap & 0x7fff; @@ -414,7 +416,8 @@ static bool codec_mpeg12_cfg(uint8_t losc, struct l2cap_frame *frame) if (losc != 4) return false; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; layer = (cap >> 8) & 0xe0; crc = cap & 0x1000; @@ -422,7 +425,8 @@ static bool codec_mpeg12_cfg(uint8_t losc, struct l2cap_frame *frame) mpf = cap & 0x0040; freq = cap & 0x003f; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; vbr = cap & 0x8000; bitrate = cap & 0x7fff; @@ -466,19 +470,22 @@ static bool codec_aac_cap(uint8_t losc, struct l2cap_frame *frame) if (losc != 6) return false; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; type = cap >> 8; freq = cap << 8; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; freq |= (cap >> 8) & 0xf0; chan = (cap >> 8) & 0x0c; bitrate = (cap << 16) & 0x7f0000; vbr = cap & 0x0080; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; bitrate |= cap; @@ -509,19 +516,22 @@ static bool codec_aac_cfg(uint8_t losc, struct l2cap_frame *frame) if (losc != 6) return false; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; type = cap >> 8; freq = cap << 8; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; freq |= (cap >> 8) & 0xf0; chan = (cap >> 8) & 0x0c; bitrate = (cap << 16) & 0x7f0000; vbr = cap & 0x0080; - l2cap_frame_get_be16(frame, &cap); + if (!l2cap_frame_get_be16(frame, &cap)) + return false; bitrate |= cap; diff --git a/monitor/l2cap.c b/monitor/l2cap.c index ca1997a0c..f16f82532 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -3243,6 +3243,9 @@ void l2cap_frame(uint16_t index, bool in, uint16_t handle, uint16_t cid, case L2CAP_MODE_LE_FLOWCTL: case L2CAP_MODE_ECRED: chan = get_chan(&frame); + if (!chan) + return; + if (!chan->sdu) { if (!l2cap_frame_get_le16(&frame, &chan->sdu)) return; From patchwork Fri Nov 20 20:07:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922071 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A436C56202 for ; Fri, 20 Nov 2020 20:07:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0692C2240A for ; Fri, 20 Nov 2020 20:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q2hIClu+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730342AbgKTUHb (ORCPT ); Fri, 20 Nov 2020 15:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728762AbgKTUHb (ORCPT ); Fri, 20 Nov 2020 15:07:31 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65B39C0613CF for ; Fri, 20 Nov 2020 12:07:31 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id g7so8928875pfc.2 for ; Fri, 20 Nov 2020 12:07:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=uz5Je2GO4Y4lUeU8Nm3qiNFyYWK2y4YsXzOtpUfdpFg=; b=Q2hIClu+OqOvox7gD5M1jE0DKSJSYKiMcGkB7/b8L3vEF3quGc+YY8Aj7hfEFgB6c6 AGp5YlcnAWJhzdYpvxd0erXiAQS9vbACB6G1HGEGgdAO5FSn+zuAcrCO43ZsNbdZjUM7 4Wlvf+NF0+g1VvxR9hAQ7nx2BmNAJJ9HhaZlUIKj5PWaLLzFrB+w2Has/gFceaI1vYgW 6C8rhiKXvmUmjOVPokgylY2qys6UnwSQEwACyi7hTFKGcBtfdBR6lxpg5IOtc3hUNYft pk/IV8FDHowA8W9b0aZN6IBR0Dm15p+5Sk3ZTKzDE+m0RNxs/vN3qbG94p3jdTgDATOk 6SkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=uz5Je2GO4Y4lUeU8Nm3qiNFyYWK2y4YsXzOtpUfdpFg=; b=k/A4818a+aqirt0oaQSyX44SorMJKtByZPqtmwvp9rH8MyRg0v7+TuJD1jdglGoQ0P vPVfkDfope3zXP8CAgPQvsaGH/c/bhgXQqwtwSHuAJMSpHCIzkqyPg5LxnHWMl6wWloX ISwWIbY3h3SlPTLeCAznzA8sW/lVLENM/+Aak3qWbeiDntpItODkiW7F4dX0x/1ts1sd DfJ8Qm25zM3bCUlkS3qRvWXYtq7RcDF2yrbLqtwWlTJ7D5RwAzvo/77+OUDUSFXowtDO e2hJSGPAJwuNZ4Ckm+w750Td9j4ED/tFGsYlNKN4Z7yo3erk4o39Q9QymW3XegkcJo0F FaXA== X-Gm-Message-State: AOAM533HASroFKkHC72p5/ZeYW4ILE+peecHUnZ++O11DsKJH4QHU2PF 2n2bI97eqo//kBzT6UcxACKJ8zHCA3E7rw== X-Google-Smtp-Source: ABdhPJwRX5ukqWMhML/QTisBNgKvVYnJiDXbb4F0YOV1tAwVfPHgdVy2l48jeX1R6JJSNUFSFVwwbQ== X-Received: by 2002:a05:6a00:2305:b029:197:a56b:899f with SMTP id h5-20020a056a002305b0290197a56b899fmr10483799pfh.52.1605902850813; Fri, 20 Nov 2020 12:07:30 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:30 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 3/6] btio: Fix the unchecked return value Date: Fri, 20 Nov 2020 12:07:09 -0800 Message-Id: <20201120200712.491219-3-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com> References: <20201120200712.491219-1-tedd.an@intel.com> Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch fixes the unchecked return value. --- btio/btio.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index c18b6a012..8230212b4 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1701,8 +1701,11 @@ GIOChannel *bt_io_connect(BtIOConnect connect, gpointer user_data, /* Use DEFER_SETUP when connecting using Ext-Flowctl */ if (opts.mode == BT_IO_MODE_EXT_FLOWCTL && opts.defer) { - setsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, &opts.defer, - sizeof(opts.defer)); + if (setsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, + &opts.defer, sizeof(opts.defer)) < 0) { + ERROR_FAILED(gerr, "setsockopt(BT_DEFER_SETUP)", errno); + return NULL; + } } switch (opts.type) { @@ -1761,8 +1764,11 @@ GIOChannel *bt_io_listen(BtIOConnect connect, BtIOConfirm confirm, sock = g_io_channel_unix_get_fd(io); if (confirm) - setsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, &opts.defer, - sizeof(opts.defer)); + if (setsockopt(sock, SOL_BLUETOOTH, BT_DEFER_SETUP, + &opts.defer, sizeof(opts.defer)) < 0) { + ERROR_FAILED(err, "setsockopt(BT_DEFER_SETUP)", errno); + return NULL; + } if (listen(sock, 5) < 0) { ERROR_FAILED(err, "listen", errno); From patchwork Fri Nov 20 20:07:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922073 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56820C2D0E4 for ; Fri, 20 Nov 2020 20:07:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9E272240A for ; Fri, 20 Nov 2020 20:07:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TM3P67qj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730361AbgKTUHc (ORCPT ); Fri, 20 Nov 2020 15:07:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730347AbgKTUHc (ORCPT ); Fri, 20 Nov 2020 15:07:32 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A86C0613CF for ; Fri, 20 Nov 2020 12:07:32 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id 131so8911305pfb.9 for ; Fri, 20 Nov 2020 12:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=e2hnhdDfJx56jcdkepK95+QfBU/VLT0jLXe4tjVzKSI=; b=TM3P67qjTgQmZtA5leof3ZRMHSv5yvmr1p1PpaJGq+fsSnrqY64BUi8Z2j75XzXY0W xt57ksYXmeYwDyhtwQ0TYF0hb0M4oLfMoUT0GKOYouKEvlgDVOpdCnM9Z3B+kTtZ51YB 8BrwC91ZsFKp4xZfAyeWGc9r6/rkgHfr2y4SFK5lBS1+aG3x0259CJzzcfSGtUPYKOmK uwjF41TqvyeJVP+jYe1qCzEGRAv5cMxhTYem2PF4XDbNxuV7QxnPW9uvQOSJ3XbVUfxf ccd5UrXW1kbFJYFo0KvIeQ8uZB1Tvz6RkL1dOqiBuTSa43i0COK/ktigrqgIKVxRVr3c gG4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=e2hnhdDfJx56jcdkepK95+QfBU/VLT0jLXe4tjVzKSI=; b=R1bZaewjFHNkZf8BKRhvo3/1+7FTq/GMpAV41E0gVvLHwZNN01s+9f4I9hPD2qe5B0 A951p8y9qtF19wrD6MoDJpBtU7t8QlrOdCUCmuE18KfNnGEt2j0lDCdKkIcVSP7V6MPT 7FJNjGbxzhAWRz7DNvEE1RY5EIiz39ohDYF8Ctuz7sCD4kdwkA5tAzsUOhhgBJSts0CL 13PUBlO5qwCoHFJ+25od2Y91Bl/1D/jxk4/KykFDW9EUM5ZSXsaoJrAslv1xqOwPUgPr ckwiVc4tg5jlVrXssneGNpa7YNP88EQy8qXFq6XmpJd4nyRQv78FAs4roDHADgM4V6tf y9Ew== X-Gm-Message-State: AOAM5306RgilmZ6x2pFjlH+/JzZdt+cVyn6+P56joUrnS4LPHW1eSA9s 0y2SZapmKwGcL7UQfFvcuprQdf2ZEM72XA== X-Google-Smtp-Source: ABdhPJyB8fhw555bQzFJBCcuEbE3DhHkY6rIgk1574JKglmQAip6msYHUd/5sHBvF+dhb4TQdhj5Ag== X-Received: by 2002:a17:90b:e86:: with SMTP id fv6mr12614856pjb.196.1605902851724; Fri, 20 Nov 2020 12:07:31 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:31 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 4/6] emulator: Fix the unchecked return value Date: Fri, 20 Nov 2020 12:07:10 -0800 Message-Id: <20201120200712.491219-4-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com> References: <20201120200712.491219-1-tedd.an@intel.com> Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch fixes the unchecked return value. --- emulator/phy.c | 10 ++++++++-- emulator/server.c | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/emulator/phy.c b/emulator/phy.c index 4517ad107..2ae6ad3a2 100644 --- a/emulator/phy.c +++ b/emulator/phy.c @@ -115,7 +115,10 @@ static int create_rx_socket(void) if (fd < 0) return -1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { + close(fd); + return -1; + } memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; @@ -138,7 +141,10 @@ static int create_tx_socket(void) if (fd < 0) return -1; - setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)); + if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt)) < 0) { + close(fd); + return -1; + } return fd; } diff --git a/emulator/server.c b/emulator/server.c index 3b07a7156..ceb417a40 100644 --- a/emulator/server.c +++ b/emulator/server.c @@ -322,7 +322,11 @@ static int open_tcp(void) return -1; } - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) { + perror("Failed to set socket option"); + close(fd); + return -1; + } memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; From patchwork Fri Nov 20 20:07:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922075 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DF28C63798 for ; Fri, 20 Nov 2020 20:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C14DF2240A for ; Fri, 20 Nov 2020 20:07:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c4vEMPXr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730371AbgKTUHd (ORCPT ); Fri, 20 Nov 2020 15:07:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730347AbgKTUHd (ORCPT ); Fri, 20 Nov 2020 15:07:33 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D562C0613CF for ; Fri, 20 Nov 2020 12:07:33 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id v21so8249759pgi.2 for ; Fri, 20 Nov 2020 12:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=Aka74bqXFA68BXE1RxfdOvwFymuRf+8vsT8BRQTSE04=; b=c4vEMPXruEODb/uG1I85f36UsCyaJjm8Udins9Kyqus1saGrOOTfPeTmHDhAv39ptN U9Sn/56c9qn9c8es5YyipGB2v6yiGOGzVMG4gJVbzt3Maig9631h9wTNngGWgMxdFcYN 4mmkylVgu1RQuttXTeE2tBhltL9D9U1ubB7fEoiIwa2lXX/qA4UrFZiFDHmEcgWq1KzX vsOCNnCpT5S9g/J6xK+Jh0h8OEZ4IF8iSjRPDNGVABzlcwI/X9dEDr6j2wLOAg2xlzDe JnmyHTZke/qM+e6y77BAcV8svCTHT/1OJ1hxR41ZD1XzhMVUpoJFGeyvJUptk/UkwrL1 D5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=Aka74bqXFA68BXE1RxfdOvwFymuRf+8vsT8BRQTSE04=; b=S3z1yNQYqPr0HwRgxDDE4Li/dYFF+dc598/7nQQEzYgzy5U0HhUdCyqNgtNgX+9LYA j2gLF00pNu6AyOfHSiZDSxYKbx4SzVwNEvDCAdkIr4adp32gzFHXHzHYL5QqLpo2rpMu 2d3I8EaAMDqBX05hV4YRva1IQIZKrnLD9VmyhaL4SeAp4jZzvb5OTGi7e/WouratWhfj CL0lFmFu6fO7wvqVxKJZ4y8S3NIbQ38W9Xw+kbbRhSFbTmxxOineVODpI7nocOMNQ7qI GnJl/DuQr1BwjU0GiEygGTEuO1snOmnV/5NAxF1jsgsuPuNHi0YrB93KE715eXw1q9eP BV+A== X-Gm-Message-State: AOAM530rkugv1YFa9ssPl49RuHkF5i/EVVzuA7/DdBCsszvQQE/TZce3 98LK2krLXvNBJ2kqBzlYiCY/zvgKMrw8eQ== X-Google-Smtp-Source: ABdhPJwT4GfoDlEAmZ/QJo7kxN6TT5e4LMCK2u+e1vsmCKU5psQrYvYfWoAOtPRzdeHaDOZBwpIT3g== X-Received: by 2002:a05:6a00:4d:b029:197:7198:fc37 with SMTP id i13-20020a056a00004db02901977198fc37mr14623894pfk.7.1605902852564; Fri, 20 Nov 2020 12:07:32 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:32 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 5/6] profile/bnep: Fix the unchecked return value Date: Fri, 20 Nov 2020 12:07:11 -0800 Message-Id: <20201120200712.491219-5-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com> References: <20201120200712.491219-1-tedd.an@intel.com> Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch fixes the unchecked return value. --- profiles/network/bnep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/profiles/network/bnep.c b/profiles/network/bnep.c index 4dde55786..7e777e29c 100644 --- a/profiles/network/bnep.c +++ b/profiles/network/bnep.c @@ -255,7 +255,11 @@ static gboolean bnep_setup_cb(GIOChannel *chan, GIOCondition cond, memset(&timeo, 0, sizeof(timeo)); timeo.tv_sec = 0; - setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo)); + if (setsockopt(sk, SOL_SOCKET, SO_RCVTIMEO, &timeo, + sizeof(timeo)) < 0) { + error("bnep: Set setsockopt failed: %s", strerror(errno)); + goto failed; + }; sk = g_io_channel_unix_get_fd(session->io); if (bnep_connadd(sk, session->src, session->iface) < 0) From patchwork Fri Nov 20 20:07:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tedd Ho-Jeong An X-Patchwork-Id: 11922077 X-Patchwork-Delegate: luiz.dentz@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E356FC2D0E4 for ; Fri, 20 Nov 2020 20:07:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 862792240A for ; Fri, 20 Nov 2020 20:07:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GSKim4ZY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730378AbgKTUHe (ORCPT ); Fri, 20 Nov 2020 15:07:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730347AbgKTUHe (ORCPT ); Fri, 20 Nov 2020 15:07:34 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C1AC0613CF for ; Fri, 20 Nov 2020 12:07:33 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id a18so8924182pfl.3 for ; Fri, 20 Nov 2020 12:07:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=6JoIhqlLd/kjIceAs6w1qAKl0eooc9HwRrMzM7J/ARA=; b=GSKim4ZYPFIA6Ya+XrHocDcHmOUCq0GCOUx5VDJHaYrQwwxfwiZPHjD/2VsbPw4Vzw B+8M0WYpdhDTGhqDF7gWJ2ApR0WVLdlKUHLhonHAPokGiK3krUk0z+aixFhsVc/K6Fc9 5j4l8usCKHcxB1qkorYlHZ/iXY/71JaOex9snb76wV/7viyFfoMEr9qzrbEpMTXOXLy6 68zK7GCSRAV7esno49l5ytDAfB64/r2RUfMDM1h787wAwOMv6gGb0ZsKzV/PRCwwyNeR yakEzltODzKPIG4cqyzs9y6P5zPn49Umnhn2SOK+lXQ2YaY3RXvfvE9aTOhCgDkM3txi k1jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=6JoIhqlLd/kjIceAs6w1qAKl0eooc9HwRrMzM7J/ARA=; b=ljtg13Lys36fF8Zb0lDBZUaObUY4PoReI2ogru8+NLNooTFatSoFhIGZtvuAJRRQyR OUx0BbQ55+FMIkTsNbJXJbyIqnUwBkjSkxcmO+7+S4gyGyUJTCLfma6f9GxNxkz1y529 CR8cn2rAFg9s0+jR+OhoPjGIHSgG1zBp75IF14U+14HgTX7iudI/0bEsE/Pr4Hu4uZJ7 sJySuYMuCUheOzhrTcCv47na2fWx4RrPfRvoAXc+bqvBsK76mzo4xh4/9yTkJYAT7JsA D0qrUXgmuTPdTWPvwMmU73gKnLdL82W5CWsZV3GrSlc434D7zYC8Wgub0Lle6jALTZPB AEdg== X-Gm-Message-State: AOAM530J01IxW0Jh29cFMMOSXP5PWruBAYBgJU9uM/1D41Y8QsE5bchY SmBvny0C9rGEtVn4ZS0ZEX09PWHgeOwjeg== X-Google-Smtp-Source: ABdhPJxTSOA3T38uZGX4ksep33Z5NeszoZyivS1HAUpbJB42nFWgNdsnxiKth23sNJ9xwL4ybzDtng== X-Received: by 2002:a63:1514:: with SMTP id v20mr19142627pgl.203.1605902853352; Fri, 20 Nov 2020 12:07:33 -0800 (PST) Received: from han1-mobl3.jf.net (c-73-164-224-32.hsd1.or.comcast.net. [73.164.224.32]) by smtp.gmail.com with ESMTPSA id t5sm3979267pgt.15.2020.11.20.12.07.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 12:07:32 -0800 (PST) From: Tedd Ho-Jeong An X-Google-Original-From: Tedd Ho-Jeong An To: linux-bluetooth@vger.kernel.org Cc: tedd.an@intel.com Subject: [PATCH 6/6] lib: Fix the unchecked return value Date: Fri, 20 Nov 2020 12:07:12 -0800 Message-Id: <20201120200712.491219-6-tedd.an@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201120200712.491219-1-tedd.an@intel.com> References: <20201120200712.491219-1-tedd.an@intel.com> Reply-To: tedd.an@intel.com MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch fixes the unchecked return value. --- lib/hci.c | 6 ++++-- lib/sdp.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/hci.c b/lib/hci.c index 4bd33f241..53af0a114 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -1246,12 +1246,14 @@ int hci_send_req(int dd, struct hci_request *r, int to) failed: err = errno; - setsockopt(dd, SOL_HCI, HCI_FILTER, &of, sizeof(of)); + if (setsockopt(dd, SOL_HCI, HCI_FILTER, &of, sizeof(of)) < 0) + err = errno; errno = err; return -1; done: - setsockopt(dd, SOL_HCI, HCI_FILTER, &of, sizeof(of)); + if (setsockopt(dd, SOL_HCI, HCI_FILTER, &of, sizeof(of)) < 0) + return -1; return 0; } diff --git a/lib/sdp.c b/lib/sdp.c index ebaed3e40..844ae0d25 100644 --- a/lib/sdp.c +++ b/lib/sdp.c @@ -4705,7 +4705,8 @@ static int sdp_connect_l2cap(const bdaddr_t *src, if (flags & SDP_WAIT_ON_CLOSE) { struct linger l = { .l_onoff = 1, .l_linger = 1 }; - setsockopt(sk, SOL_SOCKET, SO_LINGER, &l, sizeof(l)); + if (setsockopt(sk, SOL_SOCKET, SO_LINGER, &l, sizeof(l)) < 0) + return -1; } if ((flags & SDP_LARGE_MTU) &&