Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1154402ybi; Wed, 3 Jul 2019 10:24:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDvYWrzWuwf2WI6x0Q6PcB9N7BsShkvCPhk6sakJwSKMlX4W98znX5gWqXFF9mQpVzSx9O X-Received: by 2002:a17:902:76c6:: with SMTP id j6mr43675629plt.263.1562174689777; Wed, 03 Jul 2019 10:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562174689; cv=none; d=google.com; s=arc-20160816; b=A/Wu+xbVZAPPRN5019+hCVa/ICgBscPiHsJdVApw9C3yOsr+HZKVRpzVjAhdRdsJQu 2ZvSJW5n3IOmJ0BPtUhbhfdoemEfazg6zZsZHugLtA2YQb55PAdgskJowYuWWjysdGZ+ RCtj2THV1fnlw4x+xxK97gw4IHInazmRAd6gSaOvUWVl0ogcO1BqhdkO3r0fGXgUZElf c9J0hfag95zBPmhck7vMDxU1ktEjXYUgXpkc141ZwIboVenK2EOboZHRlLkMuyg9mi9L pYCOhB8oPgEKMgQ1pws0OhmBb4IKzxjhDM2foNxz/9HJWp65lDbEr3ih98PIA6sQZCxo NyOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=q+OFyINI6SSDUW9DCpyWL7PsqLgYetLCVbikOwTw0Dc=; b=XVYuq7SSAVIjkxGcFFJOWgJdrCRF7/PIWH+Xop2k/18ym8TinPmfEQM6u/ZsOXwfQE moegYHT8bhdY/sGftw+cMPE9X2YvFGcVmlHqamPTPGytAb6wJxnSKOBVguwUfCS0PjNF M3eVX1VuU/e7E1ruMuyLk0ronrZAh+RWkghq9vliSfrR74G4H5Pa12N0k93+ggz6WUIa wOwXs7LUaqYaL5Ip+w9TaE7q4kn7yza0H2fcNREDlPsz+SNHdkGdH1Rgkk3O//RnvWP0 LY0gr+WCOnKHMp0M8HmF3uxcmbDY0cF9EAckHlXcAMqhmOoJPRFSjPAjQLNHRsRIy0+V dWiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=fjFpry6F; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g18si2862884pgk.477.2019.07.03.10.24.22; Wed, 03 Jul 2019 10:24:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=fjFpry6F; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726621AbfGCRYU (ORCPT + 99 others); Wed, 3 Jul 2019 13:24:20 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40570 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726430AbfGCRYU (ORCPT ); Wed, 3 Jul 2019 13:24:20 -0400 Received: by mail-lj1-f195.google.com with SMTP id a21so3321684ljh.7 for ; Wed, 03 Jul 2019 10:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=q+OFyINI6SSDUW9DCpyWL7PsqLgYetLCVbikOwTw0Dc=; b=fjFpry6FI+CkhYquUYO2Cu6fOP2gUOIA1rfC6W+Onx9crNozh419rFSJfgB3NF5pXw jUJto3V83os2hj9RZp10FaxkKTPWLptIUrDaoiJ8hruWX36D7L8UaUiL/D4E9/pEJQyu wBQLcetRoXlhXqO/LbvPx6kebPT9apwVJn+c70yZDHDxW7cNppUDIXC3zGHOdqs3za03 v7y8ZYntexKs18mvWDWAagKRkhJuti03BO2wrhMXaPqMwBf2ElXXBJ80cVkxz7cpF9zK 8bxklv+FuegqjnGldTDtnfIP+nqmdBFQilqpGrOUk73k6JA6VA+6HWN0N0xf5xlZR1tH FbOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=q+OFyINI6SSDUW9DCpyWL7PsqLgYetLCVbikOwTw0Dc=; b=ZB8QqOeDZsL0zTgJcBMMW/JV9i+ph4p+9tARneN1iho6CpVaqtgkUxv1aUvXzzn4/3 B8U/hLKE3CaRzcEgS30oDLLVZxR9kwEGSOcSHK1WT4KGA5oVVUa2tSUM0Bat//1hRKKh Yk6uEmjsibezn0Aqak0WXpWoq1qp/V0MmEOGqvWm/hZk+zEYEz8wVB9bGm2wVrf8Tajj wLW3TrQRu1Gf9EDIjg42goBvdkoRpOrAGKxz17J7L0GfKjhFDsUEuFVvCvrFn3c9bXqc 2E3qZWhCijjuzUUCA87/BxY0kWjzC99Huaxj4BI7X+NHNfdstLizhFolSrW3RbmNEj0S AyQA== X-Gm-Message-State: APjAAAXcRE5hMr9bhCS9BXVLcWSOMwKQBu7EeLyNmZN0LVGe+rFwC6Dh luqZFdgQ34LxAjoSk3PI1CeGkrAGOJg= X-Received: by 2002:a2e:5c6:: with SMTP id 189mr22371305ljf.22.1562174658530; Wed, 03 Jul 2019 10:24:18 -0700 (PDT) Received: from kynes (apn-77-112-37-101.dynamic.gprs.plus.pl. [77.112.37.101]) by smtp.gmail.com with ESMTPSA id c1sm482402lfh.13.2019.07.03.10.24.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jul 2019 10:24:17 -0700 (PDT) Date: Wed, 3 Jul 2019 19:24:16 +0200 From: =?utf-8?Q?Micha=C5=82?= Lowas-Rzechonek To: Brian Gix Cc: linux-bluetooth@vger.kernel.org, inga.stotland@intel.com Subject: Re: [PATCH BlueZ] mesh: Fix memory leak on dbus message creation Message-ID: <20190703172416.thky44wklorfz7zz@kynes> Mail-Followup-To: Brian Gix , linux-bluetooth@vger.kernel.org, inga.stotland@intel.com References: <20190703163403.15814-1-brian.gix@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190703163403.15814-1-brian.gix@intel.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi, On 07/03, Brian Gix wrote: > --- > mesh/model.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mesh/model.c b/mesh/model.c > index 7401dcecb..a2b3e5c18 100644 > --- a/mesh/model.c > +++ b/mesh/model.c > @@ -729,10 +729,13 @@ static void send_msg_rcvd(struct mesh_node *node, uint8_t ele_idx, bool is_sub, > if (!l_dbus_message_builder_finalize(builder)) > goto error; > > + l_dbus_message_builder_destroy(builder); > l_dbus_send(dbus, msg); > + return; > > error: > l_dbus_message_builder_destroy(builder); > + l_dbus_message_unref(msg); > } > > bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0, Since in ELL's dbus API it's legal to unref a NULL message, I'd rather write this as: l_dbus_send(dbus, msg); msg = NULL; error: l_dbus_message_builder_destroy(builder); l_dbus_message_unref(msg); or (version for purists): l_dbus_send(dbus, msg); msg = NULL; error: l_dbus_message_builder_destroy(builder); if (msg) l_dbus_message_unref(msg); mostly to emphasize that l_dbus_send has "move" semantics. -- Michał Lowas-Rzechonek Silvair http://silvair.com Jasnogórska 44, 31-358 Krakow, POLAND