From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751505AbcKFRLb (ORCPT ); Sun, 6 Nov 2016 12:11:31 -0500 Received: from smtp01.smtpout.orange.fr ([80.12.242.123]:50004 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbcKFRL3 (ORCPT ); Sun, 6 Nov 2016 12:11:29 -0500 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 06 Nov 2016 18:11:26 +0100 X-ME-IP: 92.140.232.152 From: Christophe JAILLET To: oleg.drokin@intel.com, andreas.dilger@intel.com, jsimmons@infradead.org, gregkh@linuxfoundation.org, emoly.liu@intel.com Cc: lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/2] staging: lustre: obdclass: Add handling of error returned by lustre_cfg_new Date: Sun, 6 Nov 2016 18:11:23 +0100 Message-Id: <20161106171123.24929-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.9.3 X-Antivirus: avast! (VPS 161106-0, 06/11/2016), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'lustre_cfg_new()' can return ERR_PTR(-ENOMEM). Handle these errors and propagate the error code to the callers. Error handling has been rearranged in 'lustre_process_log()' with the addition of a label in order to free some resources. Signed-off-by: Christophe JAILLET --- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index 59fbc29aae94..5473615cd338 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -89,11 +89,14 @@ int lustre_process_log(struct super_block *sb, char *logname, lustre_cfg_bufs_set(bufs, 2, cfg, sizeof(*cfg)); lustre_cfg_bufs_set(bufs, 3, &sb, sizeof(sb)); lcfg = lustre_cfg_new(LCFG_LOG_START, bufs); + if (IS_ERR(lcfg)) { + rc = PTR_ERR(lcfg); + goto out_free; + } + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); - kfree(bufs); - if (rc == -EINVAL) LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n", mgc->obd_name, logname, rc); @@ -104,6 +107,9 @@ int lustre_process_log(struct super_block *sb, char *logname, rc); /* class_obd_list(); */ + +out_free: + kfree(bufs); return rc; } EXPORT_SYMBOL(lustre_process_log); @@ -127,6 +133,9 @@ int lustre_end_log(struct super_block *sb, char *logname, if (cfg) lustre_cfg_bufs_set(&bufs, 2, cfg, sizeof(*cfg)); lcfg = lustre_cfg_new(LCFG_LOG_END, &bufs); + if (IS_ERR(lcfg)) + return PTR_ERR(lcfg); + rc = obd_process_config(mgc, sizeof(*lcfg), lcfg); lustre_cfg_free(lcfg); return rc; @@ -159,6 +168,9 @@ static int do_lcfg(char *cfgname, lnet_nid_t nid, int cmd, lustre_cfg_bufs_set_string(&bufs, 4, s4); lcfg = lustre_cfg_new(cmd, &bufs); + if (IS_ERR(lcfg)) + return PTR_ERR(lcfg); + lcfg->lcfg_nid = nid; rc = class_process_config(lcfg); lustre_cfg_free(lcfg); -- 2.9.3