2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 13:58:34 +00:00

dump: increase fcntl call failure judgment

The pipe_size type is unsigned int, when the fcntl call fails and
return -1, it will cause a negative rollover problem.

Signed-off-by: zhoujie <zhoujie133@huawei.com>
This commit is contained in:
hdzhoujie
2023-04-18 21:03:53 +08:00
committed by Andrei Vagin
parent 1c0f8787b2
commit fa6af25e75

View File

@@ -99,6 +99,7 @@ static struct page_pipe_buf *ppb_alloc(struct page_pipe *pp, unsigned int ppb_fl
{
struct page_pipe_buf *prev = pp_prev_ppb(pp, ppb_flags);
struct page_pipe_buf *ppb;
int ppb_size = 0;
ppb = xmalloc(sizeof(*ppb));
if (!ppb)
@@ -120,7 +121,13 @@ static struct page_pipe_buf *ppb_alloc(struct page_pipe *pp, unsigned int ppb_fl
cnt_add(CNT_PAGE_PIPES, 1);
ppb->pipe_off = 0;
ppb->pipe_size = fcntl(ppb->p[0], F_GETPIPE_SZ, 0) / PAGE_SIZE;
ppb_size = fcntl(ppb->p[0], F_GETPIPE_SZ, 0);
if (ppb_size < 0) {
xfree(ppb);
pr_perror("Can't get pipe size");
return NULL;
}
ppb->pipe_size = ppb_size / PAGE_SIZE;
pp->nr_pipes++;
}