From: SF Markus Elfring <elfring@users.sourceforge.net>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
Date: Sun, 13 Dec 2015 14:57:38 +0100 [thread overview]
Message-ID: <566D7952.7090401@users.sourceforge.net> (raw)
In-Reply-To: <566D7733.1030102@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 12:21:17 +0100
A few checks would be performed by the mgc_process_recover_log() function
even if it is known already that the passed variable "pages" contained
a null pointer.
* Let us return directly if a call of the kcalloc() function failed.
* Move assignments for the variables "eof" and "req" behind
this memory allocation.
* Delete a sanity check then.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/staging/lustre/lustre/mgc/mgc_request.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index da130f4..f3b4c30 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1285,14 +1285,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
static int mgc_process_recover_log(struct obd_device *obd,
struct config_llog_data *cld)
{
- struct ptlrpc_request *req = NULL;
+ struct ptlrpc_request *req;
struct config_llog_instance *cfg = &cld->cld_cfg;
struct mgs_config_body *body;
struct mgs_config_res *res;
struct ptlrpc_bulk_desc *desc;
struct page **pages;
int nrpages;
- bool eof = true;
+ bool eof;
bool mne_swab;
int i;
int ealen;
@@ -1309,10 +1309,11 @@ static int mgc_process_recover_log(struct obd_device *obd,
nrpages = CONFIG_READ_NRPAGES_INIT;
pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
- if (pages == NULL) {
- rc = -ENOMEM;
- goto out;
- }
+ if (!pages)
+ return -ENOMEM;
+
+ req = NULL;
+ eof = true;
for (i = 0; i < nrpages; i++) {
pages[i] = alloc_page(GFP_KERNEL);
@@ -1432,14 +1433,12 @@ out:
if (rc == 0 && !eof)
goto again;
- if (pages) {
- for (i = 0; i < nrpages; i++) {
- if (pages[i] == NULL)
- break;
- __free_page(pages[i]);
- }
- kfree(pages);
+ for (i = 0; i < nrpages; i++) {
+ if (pages[i] == NULL)
+ break;
+ __free_page(pages[i]);
}
+ kfree(pages);
return rc;
}
--
2.6.3
next prev parent reply other threads:[~2015-12-13 13:57 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-13 13:48 ` [lustre-devel] [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
2015-12-13 13:52 ` [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
2015-12-15 14:27 ` Joe Perches
2015-12-15 14:41 ` Dan Carpenter
2015-12-15 15:02 ` Joe Perches
2015-12-15 17:48 ` Dan Carpenter
2015-12-15 18:10 ` Joe Perches
2015-12-15 18:26 ` [lustre-devel] " SF Markus Elfring
2015-12-15 18:34 ` Joe Perches
2015-12-15 18:49 ` SF Markus Elfring
2015-12-15 18:55 ` Joe Perches
2015-12-15 18:02 ` SF Markus Elfring
2015-12-15 18:22 ` Joe Perches
2015-12-13 13:54 ` [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
2015-12-14 6:53 ` Dan Carpenter
2015-12-14 9:08 ` SF Markus Elfring
2015-12-14 9:31 ` Dan Carpenter
2015-12-14 10:03 ` [lustre-devel] " SF Markus Elfring
2015-12-13 13:55 ` [lustre-devel] [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring
2015-12-13 13:56 ` [lustre-devel] [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
2015-12-13 13:57 ` SF Markus Elfring [this message]
2015-12-14 11:00 ` [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection Dan Carpenter
2015-12-14 12:04 ` SF Markus Elfring
2015-12-14 12:38 ` Dan Carpenter
2015-12-14 12:45 ` [lustre-devel] " SF Markus Elfring
2015-12-14 13:57 ` Dan Carpenter
2015-12-14 17:43 ` SF Markus Elfring
2015-12-15 11:42 ` Dan Carpenter
2015-12-15 15:00 ` SF Markus Elfring
2015-12-13 13:58 ` [lustre-devel] [PATCH 6/7] staging: lustre: A few checks less " SF Markus Elfring
2015-12-13 14:00 ` [lustre-devel] [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring
[not found] ` <56784D83.7080108@users.sourceforge.net>
[not found] ` <56784F0C.6040007@users.sourceforge.net>
[not found] ` <20151221234857.GA27079@kroah.com>
2016-07-26 18:54 ` [lustre-devel] [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
2016-07-26 18:56 ` [lustre-devel] [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
2016-07-26 19:00 ` [lustre-devel] [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put" SF Markus Elfring
2016-07-26 19:02 ` [lustre-devel] [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
2016-07-26 19:08 ` Oleg Drokin
2016-07-26 19:56 ` [lustre-devel] " SF Markus Elfring
2016-07-26 21:49 ` Oleg Drokin
2016-07-28 5:53 ` SF Markus Elfring
2016-07-29 15:28 ` Oleg Drokin
2016-07-30 6:24 ` SF Markus Elfring
2016-07-26 19:04 ` [lustre-devel] [PATCH 04/12] staging: lustre: Split a condition check in class_register_type() SF Markus Elfring
2016-07-26 19:05 ` [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
2016-07-26 19:11 ` Oleg Drokin
2016-07-26 19:16 ` Oleg Drokin
2016-07-26 20:11 ` [lustre-devel] " SF Markus Elfring
2016-07-26 19:07 ` [lustre-devel] [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log() SF Markus Elfring
2016-07-26 19:08 ` [lustre-devel] [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() " SF Markus Elfring
2016-07-26 19:09 ` [lustre-devel] [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() " SF Markus Elfring
2016-07-26 19:10 ` [lustre-devel] [PATCH 09/12] staging: lustre: Delete a check for the variable "req" " SF Markus Elfring
2016-07-26 19:12 ` [lustre-devel] [PATCH 10/12] staging: lustre: Rename jump labels " SF Markus Elfring
2016-07-26 19:13 ` [lustre-devel] [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" " SF Markus Elfring
2016-07-26 19:14 ` [lustre-devel] [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-08-21 9:45 ` [lustre-devel] [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=566D7952.7090401@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=lustre-devel@lists.lustre.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).