Merge "hal: Fix use-after-free in clear_devices"