From patchwork Mon Jul 4 04:32:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sajjan, Vikas C" X-Patchwork-Id: 9211617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53D2060467 for ; Mon, 4 Jul 2016 04:38:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 337BB28638 for ; Mon, 4 Jul 2016 04:38:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 162B3286B5; Mon, 4 Jul 2016 04:38:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1920628638 for ; Mon, 4 Jul 2016 04:38:37 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 18E951A1E00; Sun, 3 Jul 2016 21:39:16 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E51C81A1E00 for ; Sun, 3 Jul 2016 21:39:14 -0700 (PDT) Received: from dctxvm241.in.rdlabs.hpecorp.net (dctxvm241.in.rdlabs.hpecorp.net [15.146.152.172]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id D23044A; Mon, 4 Jul 2016 04:38:32 +0000 (UTC) From: Vikas C Sajjan To: dan.j.williams@intel.com Subject: [PATCH] nfit: use devm_add_action_or_reset() Date: Mon, 4 Jul 2016 10:02:51 +0530 Message-Id: <1467606771-21704-1-git-send-email-vikas.cha.sajjan@hpe.com> X-Mailer: git-send-email 1.9.1 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-acpi@vger.kernel.org, Vikas C Sajjan , linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP If devm_add_action() fails, we are explicitly calling the cleanup to free the resources allocated. Lets use the helper devm_add_action_or_reset() and return directly in case of error, since the cleanup function has been already called by the helper if there was any error. Signed-off-by: Vikas C Sajjan Reviewed-by: Johannes Thumshirn Reviewed-by: Lee, Chun-Yi --- drivers/acpi/nfit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c index c2ad967..44ebe1e 100644 --- a/drivers/acpi/nfit.c +++ b/drivers/acpi/nfit.c @@ -1920,11 +1920,11 @@ static int acpi_nfit_insert_resource(struct acpi_nfit_desc *acpi_desc, if (ret) return ret; - ret = devm_add_action(acpi_desc->dev, acpi_nfit_remove_resource, res); - if (ret) { - remove_resource(res); + ret = devm_add_action_or_reset(acpi_desc->dev, + acpi_nfit_remove_resource, + res); + if (ret) return ret; - } return 0; }