Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1157020lqj; Mon, 3 Jun 2024 11:53:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWx87cQyo6+6NZ758YZ753m5ipZB1Na4o5ExirYvE2e8y5j0Hwjkuh/u/5UXRQs9EOsrevLNQWihRActIQNE4O0xZhVBtiAT1XQit7IHQ== X-Google-Smtp-Source: AGHT+IG8ZVIFefFudyLc6R9PVhCcD+5HV7zsTa7VcPEb0eK78Wz5/aplqP2Iz4LUIPMXvy/Sa+zk X-Received: by 2002:a05:6a20:948c:b0:1af:d017:c13e with SMTP id adf61e73a8af0-1b26f2d744dmr8379432637.41.1717440809866; Mon, 03 Jun 2024 11:53:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717440809; cv=pass; d=google.com; s=arc-20160816; b=p9B8z4+Pu/KNVY8zt+xYj5I+SBxJaCnMTZee/3Kecm9mL151R0/ocZEmCyr9v2e18o Pi6/1YplUjJoVQVJWnqu5UAhs+2ica+q7+mhxLvb7WMFov1+i9E5K/mrmIKgU6F+8zXz eU79iuNzIdxt3h9snNcz9RhE5qOzo5LfMlXH9ul7E4tW7iw9GxpFsLTVAzmN7VWSbOx+ 7NvHn4pxCzzrL61xuwFYD+cPtSMgVMtc8NxJxJWWuhAHbqU3/reDGFlcuRqvIX5jr64V cwVu3GAywY9CnL8dcXNA+N2UsFEfS3rrybieeyHXydux2MARNcgXLrkoOpIm3C7ImuTi e7cg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature; bh=9B5sTBsDV/euPRNapmwxQ9v3fRRczY8l/+j7l6rxQ+I=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=t4JCry0uP1NAqJe0wSit9cEXiarZeDlLnzfkvckjZaZHigXBR7kBhiEFLxLpSREhhC haq9LltohO3Lr3swgfvCeyZC9FYS/Zn0eo2cjSyrjyJJnMFSvgVDgV9jfEm24y1IBO5a SWOw8rFwkh6XGS3JCypOqlCNGfNSzHSsPaEk3jCFt0wP4Ilk8k3pwTaSwr33f1g58/w7 5Fm8hrhLdf2gnsamJtjR6enlFDVFRD6E9jrP21V2shntpuq+BsiRHiV6MOHPLyKE+fMm fUzsVgXQGFSlydsiFduc0NMbeHxEiEzHgZ5yhMqyr5+zGqyqpZEM2V7rWtM18O0S4mH7 ZXeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S2q4ir+o; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-5086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5086-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1c283e06esi7127071a91.145.2024.06.03.11.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-5086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=S2q4ir+o; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-5086-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-5086-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0BF6A282A83 for ; Mon, 3 Jun 2024 18:53:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FB1F139D16; Mon, 3 Jun 2024 18:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S2q4ir+o" X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-vk1-f178.google.com (mail-vk1-f178.google.com [209.85.221.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CBE813958F for ; Mon, 3 Jun 2024 18:53:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717440799; cv=none; b=p03pSeqUCoOt+ktOB+kx9cLaS/Z6bC+XqTyvQStYrkQ/F6XGdwYQTw43DsYWh+rJjGmcgqaLqSDOKD3MP7D+7bjsxmVe7oCznOx18JTqmjJ6F11PziSxTmkChrHoGXdXkoYkXkUGUzljlH9NqZLN2NOhJWqC/EWW8Ol25+RWuvc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717440799; c=relaxed/simple; bh=U3JXHJoXfxXplytEMZ36wZ4tJSsPc/8Q27PTauh6eWU=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=UkMGRyTxasukkQv/G0SumXqbVrl2a+NICowK+IoiGge0w2lAhKws3CsBnc+EKe5z3snFiK8n9z9OSYBf08kggvsLpB4KzBVNsVD7+jubpwRagulv2F9KBGp3KHUg75no5BdjNcbiWwReKMgGnVYOTpWbOZzWqYDGf++RqBHMwH4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=S2q4ir+o; arc=none smtp.client-ip=209.85.221.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-f178.google.com with SMTP id 71dfb90a1353d-4eb1b9865e4so561429e0c.1 for ; Mon, 03 Jun 2024 11:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717440796; x=1718045596; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=9B5sTBsDV/euPRNapmwxQ9v3fRRczY8l/+j7l6rxQ+I=; b=S2q4ir+ouZCfSjGpT5hFemG1+iRnPh4Tu2IvkORahp2sZQiUuZeqKfcPef/CGYp1Cy Upaf41Qa+yekdWZZS5dnodP9k+6rEzfHhoEG3/c4nMfOTQyM0Hrcv24hqmv6IhxcFhrm kzy2SoPvaOA6lA5DKjM/NSRJLWrTxq7MRVuHti9T4KRt2FMXGdxDDS6qAXVAQ+tukda2 tykO7aXGpP3NbCVkELdc0wZQeJt86DcurOJjxR9NvAASFt7Wl984vVWoxNAQYAv7vpml PmU9y2ZudaluGRCZOzqG5KZjVja80EkcmGsnBo4t4TJ+KkVY6lZv/RBLn61iqWYscYAf zCYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717440796; x=1718045596; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9B5sTBsDV/euPRNapmwxQ9v3fRRczY8l/+j7l6rxQ+I=; b=ofrSgLYuCfHRGr71jMJpwxPvN9JkFFVV6+Rgy8OUgf0ac/1tTnPVKBfxeeHlXnxIKZ zz/LMZRrW0udc+t6rBs99fgAhkA9DRN1DfRfEeNoeMFht5Aue92IOJVpg8NZYgYj8w7R Akju2TXkfIisgqyhGj7aRNG+cDRxNk4OL+4HdY7liHKNBt7h/8iv6Sr+hbcCmfeqLrZv PHrRXNAJgJ5e3Qlpbfy+R1TaZQa/+7gk1/DDcglHdihtoG6eiDAxpcWd8n/VN5Mk9gU/ J8MoYJMMMp6QVliFNui367bPIYTJWunjhPgqdG4CPbxUJndclL8NliteG+bWG0IiHrUi 4P7Q== X-Gm-Message-State: AOJu0YxypfXe+LXx522CcYnSbI3X0hgJBVUfZ8/OPu/9ZU+1P2A1ZWE1 iChDUjCNEvAwp3ybxauQkNmksSq/j1DgyZl8Ah9I6pUuORdM43rlUhbiNQ== X-Received: by 2002:a05:6122:12b7:b0:4d8:37eb:9562 with SMTP id 71dfb90a1353d-4eb02c71bd2mr9396580e0c.0.1717440795088; Mon, 03 Jun 2024 11:53:15 -0700 (PDT) Received: from lvondent-mobl4.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-4eafecbab81sm1231658e0c.0.2024.06.03.11.53.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 11:53:14 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 1/3] shared/csip: Fix memory leak Date: Mon, 3 Jun 2024 14:53:10 -0400 Message-ID: <20240603185312.162337-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Luiz Augusto von Dentz This fixes the following leak: 102 bytes in 6 blocks are definitely lost in loss record 660 of 909 at 0x484282F: malloc (vg_replace_malloc.c:446) by 0x5A078B: util_malloc (util.c:46) by 0x649162: read_sirk (csip.c:485) by 0x5C74FA: read_cb (gatt-client.c:2713) by 0x5C4137: handle_rsp (att.c:880) by 0x5C4137: can_read_data (att.c:1072) by 0x65DDA4: watch_callback (io-glib.c:157) by 0x49656AB: ??? (in /usr/lib64/libglib-2.0.so.0.8000.2) by 0x49C6707: ??? (in /usr/lib64/libglib-2.0.so.0.8000.2) by 0x496B666: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.8000.2) by 0x65FE3D: mainloop_run (mainloop-glib.c:66) by 0x6605A3: mainloop_run_with_signal (mainloop-notify.c:188) by 0x31DEFA: main (main.c:1468) --- src/shared/csip.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/shared/csip.c b/src/shared/csip.c index e13efb6ce634..87b4590d926d 100644 --- a/src/shared/csip.c +++ b/src/shared/csip.c @@ -128,6 +128,15 @@ void bt_csip_detach(struct bt_csip *csip) queue_foreach(csip_cbs, csip_detached, csip); } +static void csis_free(struct bt_csis *csis) +{ + if (!csis) + return; + + free(csis->sirk_val); + free(csis); +} + static void csip_db_free(void *data) { struct bt_csip_db *cdb = data; @@ -137,7 +146,7 @@ static void csip_db_free(void *data) gatt_db_unref(cdb->db); - free(cdb->csis); + csis_free(cdb->csis); free(cdb); } -- 2.45.1