Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8490137ybi; Thu, 6 Jun 2019 13:16:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZNWx3NtodlcZ/I7OZjY7dKkYcu+lcmJYHOiq8uaXumAZdfhUbW11SGZo9DwHq8rT8xW0R X-Received: by 2002:a17:902:8204:: with SMTP id x4mr51047759pln.226.1559852197708; Thu, 06 Jun 2019 13:16:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559852197; cv=none; d=google.com; s=arc-20160816; b=CdX3XRQ31EkrrsRtmU8f6dceQLcA3fXidDmMZfauNAoVo7Alt+5F2SXDynGaAwoJak L96UOZErEfumPEEbUWpBEotEkI5SYXVoitrLG+Tt7l1PgC0axDMKpemZR1/3JsClJ+PS +PbN1AvVNvKFnTn3beM4GX5nBDwoE56uOMhpyf3w9OtZua+0DHCtjWYwq0JATNELBZB7 o1pDoXQ9SmqG4vfmfcW+EFY1LJkYfE87hRXqqJL/2dAdlw04H/OXtkSjdyLEi/MDzRxm rICv6zBBPnl1toadv4MHm/EbAlpS/0aHm+6XEjC7/kaaz1XHObzIe39/Nx3XwVUpWhML cqHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=IsiSpOGNxH5qO0lJ2F7RYB3ZIfAPxsLo4WVPKKHQBBs=; b=CA6WEsZQiiDj0WmTe+Qf7MRL1F9YDvuaTB9nR4oVY8SRiuzqntaiBpxcP9iJyGJZtP kEgZ5L0E+P32QKVGSI+lMA2t7iQ/xXhR3shjPA7y/oe8IhCK6WCdt9G/gsS3d8/0CWh3 wy5re5DkgrifQWNtbFfTqVDi9p1Vq2VxOZfeC5SGWi6U1BvdwARB/h7kU/Ffn2XTYwE1 H0Fz0vKd8N//X5+k/5zP02oMWjmtiVobEN1X/NV33HKQC37NE7IQHxI6tcIPYq56/SNU pN3Kmsr5yHlzbijAkzRO2mEPscPK65MVQxWVlUsUI45vKSE0cKocVV99wWJxlsRbPJZA nrwg== 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 b12si2625475pfd.79.2019.06.06.13.16.03; Thu, 06 Jun 2019 13:16:37 -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 S1727493AbfFFSox (ORCPT + 99 others); Thu, 6 Jun 2019 14:44:53 -0400 Received: from mga04.intel.com ([192.55.52.120]:46098 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726906AbfFFSox (ORCPT ); Thu, 6 Jun 2019 14:44:53 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Jun 2019 11:44:52 -0700 X-ExtLoop1: 1 Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by orsmga004.jf.intel.com with ESMTP; 06 Jun 2019 11:44:52 -0700 Received: from orsmsx103.amr.corp.intel.com ([169.254.5.232]) by ORSMSX102.amr.corp.intel.com ([169.254.3.187]) with mapi id 14.03.0415.000; Thu, 6 Jun 2019 11:44:51 -0700 From: "Stotland, Inga" To: "jakub.witowski@silvair.com" , "linux-bluetooth@vger.kernel.org" CC: "Gix, Brian" Subject: Re: [PATCH BlueZ 1/1] mesh: Fix segmentation fault after adding second netkey via NET_KEY_ADD opcode Thread-Topic: [PATCH BlueZ 1/1] mesh: Fix segmentation fault after adding second netkey via NET_KEY_ADD opcode Thread-Index: AQHVHF9F+JeqyEB0iUasoT+856K6BaaPbHCA Date: Thu, 6 Jun 2019 18:44:51 +0000 Message-ID: <418aa4c3c1d5c0e0b4af385e91d4f178f5ad9747.camel@intel.com> References: <20190606115906.9262-1-jakub.witowski@silvair.com> <20190606115906.9262-2-jakub.witowski@silvair.com> In-Reply-To: <20190606115906.9262-2-jakub.witowski@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: x-originating-ip: [10.251.146.219] Content-Type: multipart/signed; micalg=sha-1; protocol="application/x-pkcs7-signature"; boundary="=-e1aEFHzs7eMB1/amSqOq" MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --=-e1aEFHzs7eMB1/amSqOq Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Jakub, On Thu, 2019-06-06 at 13:59 +0200, Jakub Witowski wrote: > Segmentation fault was caused by passing subnet pointer to the > start_network_beacon() which was NULL > --- > mesh/net.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/mesh/net.c b/mesh/net.c > index c7aff9ab4..87a861bf0 100644 > --- a/mesh/net.c > +++ b/mesh/net.c > @@ -1017,6 +1017,8 @@ int mesh_net_add_key(struct mesh_net *net, > uint16_t idx, const uint8_t *value) > return MESH_STATUS_SUCCESS; > else > return MESH_STATUS_IDX_ALREADY_STORED; > + } else { > + subnet =3D subnet_new(net, idx); > } Good catch: this is a regression. Could you please make a slighty different change that will simplify the code overall: static add_key() returns only two types of error codes: MESH_STATUS_SUCCESS & MESH_STATUS_INSUFF_RESOURCES. To simplify the code, it makes sense to change the prototype so that instead of status code it returns a pointer to the new subnet (NULL in case of failure). Then the return value is examined and in case it's NULL, MESH_STATUS_INSUFF_RESOURCES is returned in mesh_net_add_key() and "false" is returned in mesh_net_set_key() > =20 > status =3D add_key(net, idx, value); > @@ -2490,7 +2492,7 @@ static void net_rx(void *net_ptr, void > *user_data) > int8_t rssi =3D 0; > =20 > key_id =3D net_key_decrypt(net->iv_index, data->data, data->len, > - &out, > &out_size); > + &out, &out_size); Let's not change the alignment. From the bluez/doc/coding-style.txt: "The referred style for line wrapping is to indent as far as possible to the right without hitting the 80 columns limit." > =20 > if (!key_id) > return; Best regards, Inga --=-e1aEFHzs7eMB1/amSqOq Content-Type: application/x-pkcs7-signature; name="smime.p7s" Content-Disposition: attachment; filename="smime.p7s" Content-Transfer-Encoding: base64 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIKbDCCBOsw ggPToAMCAQICEDabxALowUBS+21KC0JI8fcwDQYJKoZIhvcNAQEFBQAwbzELMAkGA1UEBhMCU0Ux FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5hbCBUVFAgTmV0 d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9vdDAeFw0xMzEyMTEwMDAwMDBa Fw0yMDA1MzAxMDQ4MzhaMHkxCzAJBgNVBAYTAlVTMQswCQYDVQQIEwJDQTEUMBIGA1UEBxMLU2Fu dGEgQ2xhcmExGjAYBgNVBAoTEUludGVsIENvcnBvcmF0aW9uMSswKQYDVQQDEyJJbnRlbCBFeHRl cm5hbCBCYXNpYyBJc3N1aW5nIENBIDRCMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA yzu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