[LU-14609] potential memory leak in osp_it_fetch() Created: 12/Apr/21 Updated: 12/Apr/21 |
|
| Status: | Open |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Andreas Dilger | Assignee: | WC Triage |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Severity: | 3 |
| Rank (Obsolete): | 9223372036854775807 |
| Description |
|
It appears there may be a memory leak in the error handling in osp_it_fetch():
OBD_ALLOC(pages, npages * sizeof(*pages));
if (pages == NULL)
RETURN(-ENOMEM);
it->ooi_pages = pages;
it->ooi_total_npages = npages;
for (i = 0; i < npages; i++) {
pages[i] = alloc_page(GFP_NOFS);
if (pages[i] == NULL)
RETURN(-ENOMEM);
}
req = ptlrpc_request_alloc(osp->opd_obd->u.cli.cl_import,
&RQF_OBD_IDX_READ);
if (req == NULL)
RETURN(-ENOMEM);
This looks like it will leak the pages array in the first case (up to 2KB), and the allocated pages themselves (up to 1MB) if the req allocation fails. I'm not 100% sure in this is an actual leak, because the pages array is saved to ooi_pages, and that is freed in osp_it_fini(), but I'm not yet convinced that is always called in the error case. This was found by code inspection while looking for large page array allocations (of which this is not currently a case). Code was added in commit v2_5_56_0-4-g77eea1985b patch http://review.whamcloud.com/8303 " |
| Comments |
| Comment by Gerrit Updater [ 12/Apr/21 ] |
|
Andreas Dilger (adilger@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/43283 |