From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Tue, 26 Jul 2016 17:12:51 +0200 Release memory directly after a page allocation failed at the beginning. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index d716bb2..b064bd3 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1346,7 +1346,7 @@ static int mgc_process_recover_log(struct obd_device *obd, pages[i] = alloc_page(GFP_KERNEL); if (!pages[i]) { rc = -ENOMEM; - goto out; + goto free_pages; } } @@ -1461,14 +1461,13 @@ out: if (rc == 0 && !eof) goto again; - if (pages) { - for (i = 0; i < nrpages; i++) { - if (!pages[i]) - break; - __free_page(pages[i]); - } - kfree(pages); +free_pages: + for (i = 0; i < nrpages; i++) { + if (!pages[i]) + break; + __free_page(pages[i]); } + kfree(pages); return rc; } -- 2.9.2 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel