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:
@@ -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++;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user