From nobody Tue Feb 10 20:14:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1501124137807193.9762656860363; Wed, 26 Jul 2017 19:55:37 -0700 (PDT) Received: from localhost ([::1]:40921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYxb-000131-Uc for importer@patchew.org; Wed, 26 Jul 2017 22:55:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54996) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYlq-0005tz-8Y for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daYlp-0008Fu-Dt for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:43:26 -0400 Received: from mail-qt0-x244.google.com ([2607:f8b0:400d:c0d::244]:38157) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1daYlp-0008F1-9A; Wed, 26 Jul 2017 22:43:25 -0400 Received: by mail-qt0-x244.google.com with SMTP id p3so8855514qtg.5; Wed, 26 Jul 2017 19:43:25 -0700 (PDT) Received: from yoga.offpageads.com ([138.117.48.223]) by smtp.gmail.com with ESMTPSA id g27sm13221147qtg.84.2017.07.26.19.43.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 19:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lnpQHmS0mkoJ2CIwvdvhNpPk+XM5i+XhB+k6Jy8lhQ4=; b=UsxBWq09L8WPgGvisyfO/F4p12G/HccJqAXz/Oahz3qrIjhtGzO7EGSGZYZd2DT3xl Xe5UR1spZtS2X24HGG/ankbHu23TBccRITD/IPgSPa7zCt/40UAGAKVP53reLpc0CNLR 6m10sTtJzp1F91Bf0LvcOlxPq7VDBrpuzYMs+t7n9qkpD6t0Nxl07AcWgX2mJ48Uhbzj LXH5fHN+pU+1NeZl81n/016KAqkIViNKaOzEcOq9rhy/GEJHFeVxsS9lDCLbCWLbMP8R VAsV2j31ldAKAXmfqpEtt0lNj0o0kbRlcXZXDs1NPCy3SrP3X8FHwE2V4/qvlYtKy+gP 0MBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=lnpQHmS0mkoJ2CIwvdvhNpPk+XM5i+XhB+k6Jy8lhQ4=; b=OQE7g+glQEtQU0V57G0W7Ss5u5mK9Gw0O5dcvQc14VIdTp+DzQ5ZP8TdMwWQswBet2 MKJ5vQp3BzFAnaxXnW8r7V2UXU0TqH53+eL/MrMKQr5cndUSR5B/g3qWdf9SyT6rGYT+ TCxnesCCQCqklOBKFZayR4aCNrMvj+fTia1O+gmf/rPH+j96X0Vfuvgrd0Gl5ZWqZ3e8 g8QsBNCa6JaUHL3gkAObwnFJWu7Dwnoj7PaRIYD8/2DV+7SLVD+SCVoCgY1/QDg+K4AJ Ba+w/zoDU7Hr0evkm0OFHQQQGTRd5k/4eZ7uUFWFW15XiXEpJWq0zrw0JYxnKfwhg7pz lGZg== X-Gm-Message-State: AIVw110I/thlWXxPn20C4cu3N1F/pA2bpR+CsmE4pRMa6ejaIf6348Pc 6YiwRtP2yB4c6w== X-Received: by 10.200.8.106 with SMTP id x39mr4304160qth.309.1501123404817; Wed, 26 Jul 2017 19:43:24 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake , Stefan Hajnoczi Date: Wed, 26 Jul 2017 23:42:21 -0300 Message-Id: <20170727024224.22900-17-f4bug@amsat.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170727024224.22900-1-f4bug@amsat.org> References: <20170727024224.22900-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::244 Subject: [Qemu-devel] [PATCH for 2.10 v2 17/20] bt-sdp: fix memory leak in sdp_service_record_build() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 hw/bt/sdp.c:753:5: warning: Potential leak of memory pointed to by 'data' qsort(record->attribute_list, record->attributes, ^~~~~ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/bt/*: get_maintainer.pl: No maintainers found hw/bt/sdp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/bt/sdp.c b/hw/bt/sdp.c index f67b3b89c0..7b2186e1f4 100644 --- a/hw/bt/sdp.c +++ b/hw/bt/sdp.c @@ -711,7 +711,7 @@ static void sdp_service_record_build(struct sdp_service= _record_s *record, struct sdp_def_service_s *def, int handle) { int len =3D 0; - uint8_t *data; + uint8_t *buf, *data; int *uuid; =20 record->uuids =3D 0; @@ -725,7 +725,8 @@ static void sdp_service_record_build(struct sdp_service= _record_s *record, g_malloc0(record->attributes * sizeof(*record->attribute_list)= ); record->uuid =3D g_malloc0(record->uuids * sizeof(*record->uuid)); - data =3D g_malloc(len); + buf =3D g_malloc(len); + data =3D buf; =20 record->attributes =3D 0; uuid =3D record->uuid; @@ -748,6 +749,7 @@ static void sdp_service_record_build(struct sdp_service= _record_s *record, record->attribute_list[record->attributes ++].len =3D len; data +=3D len; } + g_free(buf); =20 /* Sort the attribute list by the AttributeID */ qsort(record->attribute_list, record->attributes, --=20 2.13.3