Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752180AbbLMN5p (ORCPT ); Sun, 13 Dec 2015 08:57:45 -0500 Received: from mout.web.de ([212.227.15.3]:61159 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751666AbbLMN5o (ORCPT ); Sun, 13 Dec 2015 08:57:44 -0500 Subject: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection To: Andreas Dilger , Greg Kroah-Hartman , Oleg Drokin , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <566D7952.7090401@users.sourceforge.net> Date: Sun, 13 Dec 2015 14:57:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <566D7733.1030102@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:5fY7jk2Xu/QxC3sJ+TYuATYkytK9HKpYIUWk/q+DK2ho/1wDngK Bakc+OSn4/T0iB7AvVQyCLCLrk3MLiasiRnb1a8gNovN9njCLijxev96RiomC3k07au6N35 Ik3rxJY19KQ0rc+YUDSL8gJUTNJIVqMWUPseWgTZV5yb6tmznszSfCLcncB33L5FTh7vCb6 KldB3nRObSmo243gCZg0w== X-UI-Out-Filterresults: notjunk:1;V01:K0:fWAR08qWCCs=:BSA0H2M6MmCZr/303vcP0l TAw5IINUa+Hcy9QXeJWb8nbkv7wgmtK9QHEjf/y+GuIvZeav22306M3v82Aq9k3/JFPrxXh0h VW8KDrfqpFlySNlRpl5VjNuZjiITD8kcg1LZUQFV1GnCP7mT95E3nUyrj7MTpCwwRNvtGO+m8 ZMEuHdfzwcFAmVENJsbBXw2tq0J04S4i0wmllFW6UoC612Xi7jsiZD9PIsY8QdehQLXrmYE6O 4DxvONtl2kN4gYDzOG499otBroH8PwNkfMG1yj1LMhTTSR6hrTw0t6ValtAdwkYNszgMX5gy7 zr97XN72P2h25bVosAQYPISUT9ySfKpb+ghuwdw0jK+00YrXXLRr1Ijrrk+09E5AVfPEuCP6S pY5/JXQyqTirQsdY5+xFo+aOXW9s76E1dzW45jEThiKhfJpRVAPd/cFV+GEpeWBnwYnNZ29xf FnuqjXKVMMBjoMTtCZlU2bfMCy6EAz97BE52VSaWyNQ1iHmEsLAYwe2jIRe0d3YMRYitTgwrv 6IXD8Pz29JMOi6yuE9LImYGAP0Z6O0l/AYu7XNn6mVaj7BgWWmXIKhFb41VEw4x8tZXUrnXcL 8qgWbM2sV8GoqIf7n1X5vICLhBM+F60NI096CE51p3xG7VVIyhW1SiedL5ymAldM4l+F8yfpI 7gWh1iWVhiWWkU+kF/iESU3PojaWDA/ozG7Pp6LySnais/PU3vQeMkyYFAisHstuL+P2JICRa /eimlf/C9x6Qjheaedp/lYa8byPYZbL1Ak/axRPXgWHeJNpk7xVddUMV8VGOmGKNwnXfsU4wp sYIdfqG Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2365 Lines: 84 From: Markus Elfring 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/