Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9f067b4 authored by Yifan Hong's avatar Yifan Hong
Browse files

fastboot driver: Fix fd ownership.

load_sparse_files assumes that the client maintains
the lifetime of the input fd is longer than
the output sparse_file handle.

Bug: 183409401
Bug: 183223098
Test: flash super image
Change-Id: I295b912c665577b5767a133f3148e58a22733998
parent 12744bd2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -911,8 +911,9 @@ static bool load_buf_fd(unique_fd fd, struct fastboot_buffer* buf) {

    lseek(fd, 0, SEEK_SET);
    int64_t limit = get_sparse_limit(sz);
    buf->fd = std::move(fd);
    if (limit) {
        sparse_file** s = load_sparse_files(fd, limit);
        sparse_file** s = load_sparse_files(buf->fd.get(), limit);
        if (s == nullptr) {
            return false;
        }
@@ -921,7 +922,6 @@ static bool load_buf_fd(unique_fd fd, struct fastboot_buffer* buf) {
    } else {
        buf->type = FB_BUFFER_FD;
        buf->data = nullptr;
        buf->fd = std::move(fd);
        buf->sz = sz;
    }