programs: plug file descriptor leak

This leaked a file descriptor if bpf_prog_get_info_by_fd failed.
reviewable/pr712/r17
Tamir Duberstein 1 year ago
parent b1404e9a73
commit 7bb9b7f5a5
No known key found for this signature in database

@ -954,10 +954,11 @@ impl ProgramInfo {
io_error, io_error,
})? as RawFd; })? as RawFd;
let info = bpf_prog_get_info_by_fd(fd)?; let info = bpf_prog_get_info_by_fd(fd);
unsafe { unsafe {
libc::close(fd); libc::close(fd);
} }
let info = info?;
Ok(ProgramInfo(info)) Ok(ProgramInfo(info))
} }
} }

Loading…
Cancel
Save