Return-Path: From: "Wu, Jiangbo" To: Luiz Augusto von Dentz CC: "Xu, Martin" , Johan Hedberg , "linux-bluetooth@vger.kernel.org" Subject: RE: [PATCH] src/device: Free bonding while failed to pair device Date: Sun, 2 Oct 2016 12:30:01 +0000 Message-ID: References: <1475249958-9934-1-git-send-email-jiangbo.wu@intel.com> In-Reply-To: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org List-ID: SGksDQoNCkl0IGNvbWVzIGZyb20gYWN0dWFsbHkgdXNlIGluIG91ciBwcm9kdWN0LiBUaGUgc2Nl bmFyaW8gaXMgdGhhdDoNCiAgICAgICAgMS4gUGFpciBhIGRldmljZSBuYW1lZCAnQScuDQogICAg ICAgICAgICBCZWZvcmUgYWdlbnQgZ2l2ZSByZXNwb25zZSBmb3IgcGFpcmluZyBkZXZpY2UgJ0En Og0KICAgICAgICAyLiBDYWxsIHBhaXIgbWV0aG9kIGFnYWluIHRvIHBhaXIgYW5vdGhlciBkZXZp Y2UgbmFtZWQgJ0InIC4NCkRldmljZSAnQicgd2lsbCBuZXZlciBiZSBwYWlyZWQgdW50aWwgdHVy biBvZmYvb24gQmx1ZXRvb3RoLiBZb3UgY2FuIHRyeSBpdCB1c2UgYmx1ZXRvb3RoY3RsLg0KDQpU aGUgcm9vdCBjYXVzZSBpcyBwYWlyIG1ldGhvZCB3aWxsIGNoZWNrIGRldmljZS0+Ym9uZGluZywg cmV0dXJuICdJbiBwcm9ncmVzcycgd2hlbiBpdCBleGlzdHMuIE5vcm1hbGx5IGRldmljZSB3aWxs IGNyZWF0ZSBib25kaW5nLiBJZiBhbm90aGVyIGRldmljZSBpcyBpbiBwYWlyaW5nIHN0YXR1cywg SXQgd2lsbCBmYWlsIHRvIGNyZWF0ZSBib25kaW5nIGluICdhZGFwdGVyX2NyZWF0ZV9ib25kaW5n JywgYmVjYXVzZSBhbm90aGVyIHBhaXJpbmcgaXMgaW4gcHJvZ3Jlc3MuIEl0IHdp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gIGFnZW50X3VucmVmKGJvbmRpbmctPmFnZW50KTsNCj4gKyAgICAgICAgICAg ICAgIGJvbmRpbmctPmFnZW50ID0gTlVMTDsNCj4gKyAgICAgICB9DQo+ICsNCj4gKyAgICAgICBp ZiAoYm9uZGluZy0+cmV0cnlfdGltZXIpDQo+ICsgICAgICAgICAgICAgICBnX3NvdXJjZV9yZW1v dmUoYm9uZGluZy0+cmV0cnlfdGltZXIpOw0KPiArDQo+ICsgICAgICAgaWYgKGJvbmRpbmctPmRl dmljZSkNCj4gKyAgICAgICAgICAgICAgIGJvbmRpbmctPmRldmljZS0+Ym9uZGluZyA9IE5VTEw7 DQo+ICsNCj4gKyAgICAgICBnX2ZyZWUoYm9uZGluZyk7DQo+ICt9DQo+ICsNCj4gIHN0YXRpYyBE QnVzTWVzc2FnZSAqcGFpcl9kZXZpY2UoREJ1c0Nvbm5lY3Rpb24gKmNvbm4sIERCdXNNZXNzYWdl ICptc2csDQo+ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB2b2lkIA0KPiAqZGF0YSkgIHsgQEAgLTIzODQsOCArMjQxMywxMCBA QCBzdGF0aWMgREJ1c01lc3NhZ2UgDQo+ICpwYWlyX2RldmljZShEQnVzQ29ubmVjdGlvbiAqY29u biwgREJ1c01lc3NhZ2UgKm1zZywNCj4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBCREFERFJfQlJFRFIsIGlvX2NhcCk7DQo+ICAgICAgICAg fQ0KPg0KPiAtICAgICAgIGlmIChlcnIgPCAwKQ0KPiArICAgICAgIGlmIChlcnIgPCAwKSB7DQo+ ICsgICAgICAgICAgICAgICBib25kaW5nX3JlcXVlc3RfZnJlZShkZXZpY2UtPmJvbmRpbmcpOw0K PiAgICAgICAgICAgICAgICAgcmV0dXJuIGJ0ZF9lcnJvcl9mYWlsZWQobXNnLCBzdHJlcnJvcigt ZX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