From patchwork Wed May 12 21:35:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254797 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 F1396C433ED for ; Wed, 12 May 2021 22:40:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C710C611CC for ; Wed, 12 May 2021 22:40:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbhELWlQ (ORCPT ); Wed, 12 May 2021 18:41:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43647 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392085AbhELVgN (ORCPT ); Wed, 12 May 2021 17:36:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UYUG5IKlwMILhG+uEZ2REhn+yfaAmfuIR2TSkEbaCY0=; b=ddQQIcT0sLQQWLu91lXnSdDklL2/54kgxQs5aGccNVeNCWDDAlSF5Du5SblaRToDjhqBM5 4XFEhRHw3M7xqDlAx6IqZnqzTztPbkOMrY6FH95nKzkxv6gy1GZqc66NOn9/EY7YwBM1/w n5MoVwecm6DbQplpk7s6l62putZV2Fs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-8bQLKqjDOsGeJRFyjMWOnw-1; Wed, 12 May 2021 17:34:57 -0400 X-MC-Unique: 8bQLKqjDOsGeJRFyjMWOnw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A3A59801817 for ; Wed, 12 May 2021 21:34:56 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C3AA5D9D7 for ; Wed, 12 May 2021 21:34:56 +0000 (UTC) Date: Wed, 12 May 2021 17:35:23 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 1/6] Fix leak in mesh Message-ID: <20210512173523.622e0ade@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The dir variable needs to be closed before leaving. Signed-off-by: Steve Grubb --- mesh/rpl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesh/rpl.c b/mesh/rpl.c index ac0f6b6f2..c53c6fbfd 100644 --- a/mesh/rpl.c +++ b/mesh/rpl.c @@ -143,8 +143,10 @@ static void get_entries(const char *iv_path, struct l_queue *rpl_list) return; iv_txt = basename(iv_path); - if (sscanf(iv_txt, "%08x", &iv_index) != 1) + if (sscanf(iv_txt, "%08x", &iv_index) != 1) { + closedir(dir); return; + } memset(seq_txt, 0, sizeof(seq_txt)); From patchwork Wed May 12 21:36:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254799 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 DD4A6C433ED for ; Wed, 12 May 2021 22:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE7CD611CC for ; Wed, 12 May 2021 22:40:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237662AbhELWld (ORCPT ); Wed, 12 May 2021 18:41:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25288 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392199AbhELVgw (ORCPT ); Wed, 12 May 2021 17:36:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ECiZex0mV5Oxaxt6S04kmD8mU2S1vLa1Q2/gouDDESI=; b=jExmYDJiYjCAK5JWKk5+o+z2TuqMecET5MOd2GVYt4u3B3btdqhICmifa++p8ZoMvvCvaT voD3jFmBxjNWOOh/k63Yb7iswxMj5GDZjE/Y/mSmgogV7lNOFyp0l4q62L5yHbR2sYg4xN XYbf54Cfiune3umeEHPP/J0InAlF3tk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-nHaG0abqMEePbTVuzjrcpQ-1; Wed, 12 May 2021 17:35:41 -0400 X-MC-Unique: nHaG0abqMEePbTVuzjrcpQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE042801817 for ; Wed, 12 May 2021 21:35:40 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8739719D9F for ; Wed, 12 May 2021 21:35:40 +0000 (UTC) Date: Wed, 12 May 2021 17:36:07 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 2/6] Fix leaks in obex Message-ID: <20210512173607.31b2b63d@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In filesystem, g_file_get_contents allocates fresh memory. Use it instead of making a new copy of it. That saves having to free buf later. Destination was missed on an error path as is mld. Signed-off-by: Steve Grubb --- obexd/plugins/filesystem.c | 2 +- obexd/plugins/ftp.c | 8 ++++++-- obexd/plugins/messages-dummy.c | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 09bff8ad0..44e3cf3d2 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -415,7 +415,7 @@ static void *capability_open(const char *name, int oflag, mode_t mode, goto fail; } - object->buffer = g_string_new(buf); + object->buffer = buf; if (size) *size = object->buffer->len; diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 259bfcae2..4b04bab06 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -386,8 +386,10 @@ static int ftp_copy(struct ftp_session *ftp, const char *name, ret = verify_path(destdir); g_free(destdir); - if (ret < 0) + if (ret < 0) { + g_free(destination); return ret; + } source = g_build_filename(ftp->folder, name, NULL); @@ -424,8 +426,10 @@ static int ftp_move(struct ftp_session *ftp, const char *name, ret = verify_path(destdir); g_free(destdir); - if (ret < 0) + if (ret < 0) { + g_free(destination); return ret; + } source = g_build_filename(ftp->folder, name, NULL); diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 34199fa05..e37b52df6 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -488,6 +488,7 @@ int messages_get_messages_listing(void *session, const char *name, int err = -errno; DBG("fopen(): %d, %s", -err, strerror(-err)); g_free(path); + g_free(mld); return -EBADR; } } From patchwork Wed May 12 21:37:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254801 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 227E8C433ED for ; Wed, 12 May 2021 22:40:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE2E2611CC for ; Wed, 12 May 2021 22:40:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237920AbhELWlz (ORCPT ); Wed, 12 May 2021 18:41:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41036 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392467AbhELVhr (ORCPT ); Wed, 12 May 2021 17:37:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855399; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZjFysPE72wEn02XDNwKNZXqJiKo5jA+rqapk3/wuO3M=; b=duGiZcS1jSiE6iYGhdQzXGjGlDPHG9NVOXm63wyS/6kwPOnucsvxbJPY+0mbJa/bb0nnUV SvoLNwo+WpDi11Set8IyeG9dyST5elJ1VjKVxjWYflpznP8dB1uWw8m2lb0eQ7V8Ovmk9I AFDCyKQB5Kha7LeThGzUInpWAzN0zKo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-kBP6iXCWNvGspiPVhgejHw-1; Wed, 12 May 2021 17:36:35 -0400 X-MC-Unique: kBP6iXCWNvGspiPVhgejHw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B25A41020C37 for ; Wed, 12 May 2021 21:36:34 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E68750AC6 for ; Wed, 12 May 2021 21:36:34 +0000 (UTC) Date: Wed, 12 May 2021 17:37:01 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 3/6] Fix leaks in plugin Message-ID: <20210512173701.4bd04817@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org g_file_get_contents allocates memory. It needs to be freed on any function exit. Signed-off-by: Steve Grubb --- plugins/hostname.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/hostname.c b/plugins/hostname.c index f7ab9e8bc..1a9513adb 100644 --- a/plugins/hostname.c +++ b/plugins/hostname.c @@ -213,11 +213,10 @@ static void read_dmi_fallback(void) return; type = atoi(contents); + g_free(contents); if (type < 0 || type > 0x1D) return; - g_free(contents); - /* from systemd hostname chassis list */ switch (type) { case 0x3: From patchwork Wed May 12 21:37:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254803 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 70FC9C433B4 for ; Wed, 12 May 2021 22:41:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51193613E3 for ; Wed, 12 May 2021 22:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238978AbhELWmG (ORCPT ); Wed, 12 May 2021 18:42:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22002 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237417AbhELVij (ORCPT ); Wed, 12 May 2021 17:38:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855445; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9EmV1kN1gTkpksgYyw/F2byguyMpsEcJHlN8hTupe2E=; b=YwMiho5+mBBliBs5cntj9aJK1XzVVi9PNqvV1lqjnnzy+rZuNC725R0sNhg7Dx8a4XrRiO NW71CQZoaL4JeHKeO9r9PlkSUaFkg+O2H+LnPYXO/8T8Y9zWPdZJDcZR1mBGFZaOIDQwx3 gyVPlJYz2ovaZabgbxcmJQAuWclWa8k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-294-FYOhXDsbOQW-fAkoMUC04w-1; Wed, 12 May 2021 17:37:24 -0400 X-MC-Unique: FYOhXDsbOQW-fAkoMUC04w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75586107ACF2 for ; Wed, 12 May 2021 21:37:23 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 29D546086F for ; Wed, 12 May 2021 21:37:23 +0000 (UTC) Date: Wed, 12 May 2021 17:37:50 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 4/6] Fix leaks in profiles Message-ID: <20210512173750.63ef39a5@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org g_new0 allocates memory that must be freed Signed-off-by: Steve Grubb --- profiles/audio/avrcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index c6a342ee3..58d30b24d 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -3508,8 +3508,10 @@ static struct avrcp_player *create_ct_player(struct avrcp *session, path = device_get_path(session->dev); mp = media_player_controller_create(path, id); - if (mp == NULL) + if (mp == NULL) { + g_free(player); return NULL; + } media_player_set_callbacks(mp, &ct_cbs, player); player->user_data = mp; From patchwork Wed May 12 21:41:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254805 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 0D0F7C433ED for ; Wed, 12 May 2021 22:41:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D31B4611CC for ; Wed, 12 May 2021 22:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239174AbhELWmP (ORCPT ); Wed, 12 May 2021 18:42:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53721 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238779AbhELVl5 (ORCPT ); Wed, 12 May 2021 17:41:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GGtK1vER/182zGYhGgmWhvzrHE3DX7UFf32Re0ZgrBk=; b=Dmo0wUegUGV/LE0bDquSLRD7mSaKbkuYUFTn3/HUb6gBu6ydz77ZlOabHsgbEOtViGu5mO D/uvFMsDrFpg5v0+sh/7WnWlhWJ86u5mKPz4vrrBBo6GjfdKGYJe7mGExDc+eI35EvaNb6 p9OTigleECdaIva55wOCKIbz2bXiPyM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-482-p_j_LqWFMHyVskw6i75R7A-1; Wed, 12 May 2021 17:40:39 -0400 X-MC-Unique: p_j_LqWFMHyVskw6i75R7A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D4EEFC90 for ; Wed, 12 May 2021 21:40:38 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C6B760CC6 for ; Wed, 12 May 2021 21:40:38 +0000 (UTC) Date: Wed, 12 May 2021 17:41:05 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 5/6] Fix leaks in src Message-ID: <20210512174105.3f3f82f2@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org g_key_file_get_string allocates memory that must be freed. asprintf allocates memory that must be freed. Signed-off-by: Steve Grubb --- src/main.c | 1 + src/shared/shell.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index c32bda7d4..94141b1e4 100644 --- a/src/main.c +++ b/src/main.c @@ -795,6 +795,7 @@ static void parse_config(GKeyFile *config) parse_br_config(config); parse_le_config(config); + g_free(str); } static void init_defaults(void) diff --git a/src/shared/shell.c b/src/shared/shell.c index c0de1640d..eed300631 100644 --- a/src/shared/shell.c +++ b/src/shared/shell.c @@ -611,6 +611,7 @@ void bt_shell_prompt_input(const char *label, const char *msg, prompt->user_data = user_data; queue_push_tail(data.prompts, prompt); + free(str); return; } From patchwork Wed May 12 21:41:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Grubb X-Patchwork-Id: 12254807 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=-16.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 632E0C433B4 for ; Wed, 12 May 2021 22:41:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B31F61264 for ; Wed, 12 May 2021 22:41:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233815AbhELWmW (ORCPT ); Wed, 12 May 2021 18:42:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44621 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240090AbhELVma (ORCPT ); Wed, 12 May 2021 17:42:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TTYJ3Bnc3DeTlgL7SCfb/BMwRzq28UznCXeadugW4Mo=; b=D35ddgrwAdHFc1NIUvMdJ80xVYVHKg1tdT+sidg+fnprC3o58QwYvzUKh2PSGuHl2Rnx+B 4xRdNxzqwMOg7ZhDJ4JRpzSIv/d6AyMn79VsS801EOb5eFvwUt8e/qWUR6et9ivc8un8xH eT/fw2+gmmejVVwfdpZtQND/1HIZEnA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-0hBKDTVeN2SoeDJsl6ISpw-1; Wed, 12 May 2021 17:41:16 -0400 X-MC-Unique: 0hBKDTVeN2SoeDJsl6ISpw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42B748014D8 for ; Wed, 12 May 2021 21:41:15 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3C4160657 for ; Wed, 12 May 2021 21:41:14 +0000 (UTC) Date: Wed, 12 May 2021 17:41:42 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 6/6] Fix leaks in tools Message-ID: <20210512174142.310080bc@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org req is allocated memory that must be freed. It appears all other error paths got fail which handles this. g_new0 allocates memory to data which must be freed. g_malloc0 allocates memory to comp which must be freed. Signed-off-by: Steve Grubb --- tools/mesh-cfgclient.c | 2 +- tools/mesh-gatt/gatt.c | 1 + tools/mesh-gatt/node.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/mesh-cfgclient.c b/tools/mesh-cfgclient.c index 1eeed2a1a..49069674f 100644 --- a/tools/mesh-cfgclient.c +++ b/tools/mesh-cfgclient.c @@ -914,7 +914,7 @@ static void cmd_import_node(int argc, char *argv[]) /* Number of elements */ if (sscanf(argv[4], "%u", &req->arg3) != 1) - return; + goto fail; /* DevKey */ req->data2 = l_util_from_hexstring(argv[5], &sz); diff --git a/tools/mesh-gatt/gatt.c b/tools/mesh-gatt/gatt.c index b99234f91..c8a8123fb 100644 --- a/tools/mesh-gatt/gatt.c +++ b/tools/mesh-gatt/gatt.c @@ -525,6 +525,7 @@ bool mesh_gatt_notify(GDBusProxy *proxy, bool enable, GDBusReturnFunction cb, notify_io_destroy(); if (cb) cb(NULL, user_data); + g_free(data); return true; } else { method = "StopNotify"; diff --git a/tools/mesh-gatt/node.c b/tools/mesh-gatt/node.c index 6afda3387..356e1cd1a 100644 --- a/tools/mesh-gatt/node.c +++ b/tools/mesh-gatt/node.c @@ -396,8 +396,10 @@ bool node_parse_composition(struct mesh_node *node, uint8_t *data, uint16_t len) uint16_t vendor_id; struct mesh_element *ele; ele = g_malloc0(sizeof(struct mesh_element)); - if (!ele) + if (!ele) { + g_free(comp); return false; + } ele->index = i; ele->loc = get_le16(data); @@ -412,8 +414,10 @@ bool node_parse_composition(struct mesh_node *node, uint8_t *data, uint16_t len) mod_id = get_le16(data); /* initialize uppper 16 bits to 0xffff for SIG models */ mod_id |= 0xffff0000; - if (!node_set_model(node, ele->index, mod_id)) + if (!node_set_model(node, ele->index, mod_id)) { + g_free(comp); return false; + } data += 2; len -= 2; } @@ -421,8 +425,10 @@ bool node_parse_composition(struct mesh_node *node, uint8_t *data, uint16_t len) mod_id = get_le16(data + 2); vendor_id = get_le16(data); mod_id |= (vendor_id << 16); - if (!node_set_model(node, ele->index, mod_id)) + if (!node_set_model(node, ele->index, mod_id)) { + g_free(comp); return false; + } data += 4; len -= 4; }