UnifyFS icon indicating copy to clipboard operation
UnifyFS copied to clipboard

Possible memory leak in UNIFYCR_WRAP(lio_listio)

Open nedbass opened this issue 7 years ago • 2 comments

In client/src/unifycr-sysio.c, it looks like the error path on line 887 should call free(glb_read_reqs).

 877 int UNIFYCR_WRAP(lio_listio)(int mode, struct aiocb *const aiocb_list[],
 878                              int nitems, struct sigevent *sevp)
 879 {
 880
 881     int ret = 0, i;
 882     read_req_t *glb_read_reqs = malloc(nitems * sizeof(read_req_t));
 883
 884     for (i = 0; i < nitems; i++) {
 885         if (aiocb_list[i]->aio_lio_opcode != LIO_READ) {
 886             //does not support write operation currently
 887             return -1;
 888         }
 889         glb_read_reqs[i].fid = aiocb_list[i]->aio_fildes;
 890         glb_read_reqs[i].buf = (char *)aiocb_list[i]->aio_buf;
 891         glb_read_reqs[i].length = aiocb_list[i]->aio_nbytes;
 892         glb_read_reqs[i].offset = aiocb_list[i]->aio_offset;
 893
 894     }
 895
 896     ret = unifycr_fd_logreadlist(glb_read_reqs, nitems);
 897     free(glb_read_reqs);
 898     return ret;
 899 }

nedbass avatar Dec 23 '17 00:12 nedbass

Also, it doesn't check if the malloc(3) was successful. In fact, in many places, the return value of malloc(3) is not verified. Probably we need to open a new issue for it.

sandrain avatar Jan 04 '18 18:01 sandrain

This is fixed in head of dev. m2 does not have the fix but has other changes in the wrapper. Need to merge these.

MichaelBrim avatar Dec 17 '18 14:12 MichaelBrim