summaryrefslogtreecommitdiff
path: root/fastboot/engine.cpp
diff options
context:
space:
mode:
authorDavid Anderson <dvander@google.com>2018-09-04 14:32:54 -0700
committerDavid Anderson <dvander@google.com>2018-09-04 15:01:12 -0700
commit03de645aac4dac3b19900b3d30a29b2d10249ad6 (patch)
tree4a0e3816decf6cf0250684fc1ec6f8d588ce3cc4 /fastboot/engine.cpp
parent33dcdb808b7d60107d527c22815d586b51836836 (diff)
fastbootd: Fix transport ownership.
This change moves Transport ownership back out of FastBootDriver. Callers of set_transport must ensure that the previous transport is destroyed. In addition, deleting a transport now ensures that it is closed. Bug: 78793464 Test: fastboot, fuzzy_fastboot works Change-Id: I8f9ed2f7d5b09fd0820b2677d087a027378f26db
Diffstat (limited to 'fastboot/engine.cpp')
-rw-r--r--fastboot/engine.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/fastboot/engine.cpp b/fastboot/engine.cpp
index 6a52b12bb..d80e98601 100644
--- a/fastboot/engine.cpp
+++ b/fastboot/engine.cpp
@@ -88,7 +88,9 @@ void fb_init(fastboot::FastBootDriver& fbi) {
}
void fb_reinit(Transport* transport) {
- fb->set_transport(transport);
+ if (Transport* old_transport = fb->set_transport(transport)) {
+ delete old_transport;
+ }
}
const std::string fb_get_error() {
@@ -392,6 +394,6 @@ bool fb_reboot_to_userspace() {
}
fprintf(stderr, "OKAY\n");
- fb->set_transport(nullptr);
+ fb_reinit(nullptr);
return true;
}