[PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() in mgc_process_recover_log()

SF Markus Elfring elfring at users.sourceforge.net
Tue Jul 26 19:08:16 UTC 2016


From: Markus Elfring <elfring at users.sourceforge.net>
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 at users.sourceforge.net>
---
 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



More information about the devel mailing list