adapter: Fix possible crash when stopping discovery
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 8 Jun 2020 21:55:57 +0000 (14:55 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:49 +0000 (14:30 +0530)
commit4d5cd91803a8427760c844f041bf65b09d81a219
tree174a8bbba6a76fa0731547392f9ef2a1a24f8898
parent32b6cf45c99319e165d4895976bf90c45e9fa1c1
adapter: Fix possible crash when stopping discovery

If the client disconnect/crash while MGMT_OP_STOP_DISCOVERY was pending
it would possibly cause a crash as the client pointer is passed to
mgmt_send and accessed in the callback after being freed.

To fix this the adapter itself is now passed to the callback so the
client is not accessed directly, instead the code now checks if
discovery_list has not been cleared in the meantime and only then
proceed to access the client pointer which is how
MGMT_OP_START_DISCOVERY is handled.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/adapter.c