Merge "Add protection against an access-after-free issue if cancel() is called after a device connection has been closed."