core: fix a possible crash when removing devices
authorYun-Hao Chung <howardchung@chromium.org>
Tue, 20 Jul 2021 11:51:37 +0000 (19:51 +0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:36 +0000 (19:08 +0530)
commit136a08ce465299afcb1bbcc444ee02acf9bb3829
treefe9564d7e767efd5c0b09adbfebcea565b6058d2
parent51edaa9885588ea2036dc14795efa5228185203e
core: fix a possible crash when removing devices

In probe_service, if the service already exists in device->services, it
returns the service. This might cause dev_probe and device_probe_profile
to add a duplicate service into device->services. When removing the
device, a double-free error might occur.

This patch changes the logic of probe_service so that the same service
will not be added to a device.

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