Fix sg_list leak when file_read fails
@@ -497,14 +497,17 @@ closure_function(7, 1, void, file_read_complete,
{
thread_log(bound(t), "%s: status %v", __func__, s);
sysreturn rv;
+ sg_list sg = bound(sg);
if (is_ok(s)) {
file f = bound(f);
- u64 count = sg_copy_to_buf_and_release(bound(dest), bound(sg), bound(limit));
+ u64 count = sg_copy_to_buf_and_release(bound(dest), sg, bound(limit));
thread_log(bound(t), " read count %ld\n", count);
if (bound(is_file_offset)) /* vs specified offset (pread) */
f->offset += count;
rv = count;
} else {
+ sg_list_release(sg);
+ deallocate_sg_list(sg);
rv = sysreturn_from_fs_status_value(s);
}
apply(bound(completion), bound(t), rv);
