Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp8710415ybn; Tue, 1 Oct 2019 11:52:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSltKp3KXdXgkY8DSqQT2kdlIQ5e//r4lEtYu8JAoRdNsvfqOTGTfktOdyBLstHhaTb/0q X-Received: by 2002:a05:6402:1501:: with SMTP id f1mr27230108edw.76.1569955952712; Tue, 01 Oct 2019 11:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569955952; cv=none; d=google.com; s=arc-20160816; b=WlcPFtos3RJgrHX55r65PxC24Obii9oCX31XYKbzmQi0coZsMbW13GdETzRn+5DwcB JS10wBa/3St+4i+qjSPjhS3nVK2WzG5VC3iTsChvt5fqWRwsFL1wj39uD75DFRHDn9zk H5Io0b3VkqriwYTFoa+0T01N9BsLzwG9VpKI5fKMFspOEG9aYAlzAo+0m/6TLGbNNDFk Nw7+XhLIB0d1WPeh4fcxJFwqeXQ+NpZvVejlmRfBipAOIKQyhkYIl4ZWSWMz1D3POcBv cQUcIYmmYzfni6ho1F+2OIs9dhp3Ow3P+3UgPSlWIPkuyH8S1FX32m+w6AdFvyQMTE/R fyDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=CD6DTYJiU/FYGQ7JMh3uPaQQ78wAFiNDOS8b3+BvARg=; b=mYKdDC5Xwxx4QyjHfiMfTHfg9izox2unXLc75S3X7tbyuH0nu1vy0IvxwCZn3KqVvG l7x9Mq5RiEieDbiSmExJyfZztrfrTqosrjMHWpZAXTped1rcFuO6eJ+Lq8FWU2VVL/ZS /r9ypQzv9fAWg51dmMc5RWsLVaxfKLrP1nB6RbEC+MLqpjW5uHaLsRZQGw3wz6+GeSx3 7vsEENBrtIjI8NZgvDu06NuY/MuOe6sWDqyj8Q+JPUvTnp2x8Ziwt3wc7htystcFz1xf pvLfSoxIfEDWBkkZBxHWTrOBaTBl8Sotf+IWaPr73m3J9GWqn434Xk6d+0DRLkN0QEox 6k3A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e46si10067175eda.401.2019.10.01.11.51.54; Tue, 01 Oct 2019 11:52:32 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725851AbfJASvO (ORCPT + 99 others); Tue, 1 Oct 2019 14:51:14 -0400 Received: from mga12.intel.com ([192.55.52.136]:58960 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbfJASvO (ORCPT ); Tue, 1 Oct 2019 14:51:14 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Oct 2019 11:51:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,571,1559545200"; d="scan'208";a="194618078" Received: from ingas-nuc1.sea.intel.com ([10.251.152.1]) by orsmga003.jf.intel.com with ESMTP; 01 Oct 2019 11:51:13 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Fix segmentation fault on Join() call Date: Tue, 1 Oct 2019 11:51:08 -0700 Message-Id: <20191001185108.5656-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Inga Stotland This fixes the following segfault: node_init_cb (node=0x0, agent=0x0) at mesh/mesh.c:359 reply = dbus_error(join_pending->msg, MESH_ERROR_FAILED, user_data=0x5555555be170) at mesh/node.c:1760 dbus=) at ell/dbus.c:216 user_data=0x5555555a6e00) at ell/dbus.c:279 user_data=0x5555555a7ef0) at ell/io.c:126 at ell/main.c:642 at mesh/main.c:205 The fault was caused by the premature deletion of preserved state. This moves setup of disconnect watch for the application calling the Join() method into the node_init_cb(), after a temporary node has been successfully created. --- mesh/mesh.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mesh/mesh.c b/mesh/mesh.c index b660a7ef2..9b2b2073b 100644 --- a/mesh/mesh.c +++ b/mesh/mesh.c @@ -377,6 +377,11 @@ static void node_init_cb(struct mesh_node *node, struct mesh_agent *agent) l_dbus_send(dbus_get_bus(), reply); join_pending->msg = NULL; + /* Setup disconnect watch */ + join_pending->disc_watch = l_dbus_add_disconnect_watch(dbus_get_bus(), + join_pending->sender, + prov_disc_cb, NULL, NULL); + return; fail: @@ -423,8 +428,6 @@ static struct l_dbus_message *join_network_call(struct l_dbus *dbus, sender = l_dbus_message_get_sender(msg); join_pending->sender = l_strdup(sender); - join_pending->disc_watch = l_dbus_add_disconnect_watch(dbus, sender, - prov_disc_cb, NULL, NULL); join_pending->msg = l_dbus_message_ref(msg); join_pending->app_path = app_path; -- 2.20.1