diff --git a/include/pipes.h b/include/pipes.h index 740c1b282..ee8633808 100644 --- a/include/pipes.h +++ b/include/pipes.h @@ -21,7 +21,7 @@ struct pipe_data_dump { extern int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p); struct pipe_data_rst { - struct pipe_data_entry pde; + struct pipe_data_entry *pde; struct pipe_data_rst *next; }; diff --git a/pipes.c b/pipes.c index e6ca025d4..0bfe07738 100644 --- a/pipes.c +++ b/pipes.c @@ -53,21 +53,24 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash) r = xmalloc(sizeof(*r)); if (!r) break; + r->pde = xmalloc(sizeof(*r->pde)); + if (!r->pde) + break; - ret = read_img_eof(fd, &r->pde); + ret = read_img_eof(fd, r->pde); if (ret <= 0) break; - off = r->pde.off + lseek(fd, 0, SEEK_CUR); - lseek(fd, r->pde.bytes + r->pde.off, SEEK_CUR); - r->pde.off = off; + off = r->pde->off + lseek(fd, 0, SEEK_CUR); + lseek(fd, r->pde->bytes + r->pde->off, SEEK_CUR); + r->pde->off = off; - ret = r->pde.pipe_id & PIPE_DATA_HASH_MASK; + ret = r->pde->pipe_id & PIPE_DATA_HASH_MASK; r->next = hash[ret]; hash[ret] = r; pr_info("Collected pipe data for %#x (chain %u)\n", - r->pde.pipe_id, ret); + r->pde->pipe_id, ret); } close(fd); @@ -128,7 +131,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash struct pipe_data_rst *pd; for (pd = hash[id & PIPE_DATA_HASH_MASK]; pd != NULL; pd = pd->next) - if (pd->pde.pipe_id == id) + if (pd->pde->pipe_id == id) break; if (!pd) { /* no data for this pipe */ @@ -140,11 +143,11 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash if (img < 0) return -1; - pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde.bytes, pd->pde.off); - lseek(img, pd->pde.off, SEEK_SET); + pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde->bytes, pd->pde->off); + lseek(img, pd->pde->off, SEEK_SET); - while (size != pd->pde.bytes) { - ret = splice(img, NULL, pfd, NULL, pd->pde.bytes - size, 0); + while (size != pd->pde->bytes) { + ret = splice(img, NULL, pfd, NULL, pd->pde->bytes - size, 0); if (ret < 0) { pr_perror("%#x: Error splicing data", id); goto err; @@ -152,7 +155,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash if (ret == 0) { pr_err("%#x: Wanted to restore %d bytes, but got %d\n", - id, pd->pde.bytes, size); + id, pd->pde->bytes, size); ret = -1; goto err; }