From patchwork Mon Apr 25 20:46:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8988211 Return-Path: X-Original-To: patchwork-tpmdd-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A495A9F39D for ; Sun, 1 May 2016 06:33:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88E322028D for ; Sun, 1 May 2016 06:33:13 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8AC0120295 for ; Sun, 1 May 2016 06:33:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1awkwG-0001nI-Bj; Sun, 01 May 2016 06:33:08 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1aunP9-00069G-Tg for tpmdd-devel@lists.sourceforge.net; Mon, 25 Apr 2016 20:46:51 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.50 as permitted sender) client-ip=74.125.82.50; envelope-from=sudipm.mukherjee@gmail.com; helo=mail-wm0-f50.google.com; Received: from mail-wm0-f50.google.com ([74.125.82.50]) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1aunP9-0002Dm-1W for tpmdd-devel@lists.sourceforge.net; Mon, 25 Apr 2016 20:46:51 +0000 Received: by mail-wm0-f50.google.com with SMTP id v188so112927401wme.1 for ; Mon, 25 Apr 2016 13:46:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CuGdIszJLRam8wS8LDg23qet5Jdx2+yrqj4WfAG3/aw=; b=Egme1JOHHQoN0tW3EQb6IWlX/yLq4Tv4Ys9hSyb6tx4gEA68dI7IAIY2tPknIKsC7J TpXJ6rw06/8KwqlQL344xxQ2Bjp1A4qYjWGpwkHdXnKPNTCa2H/H35Sw4kzp6FCr4Y48 5lHpJQmGsj939EHVCOe9zmaxTOEkSZDWtfBFBXeh7E0HNW6sAsL2AW0dkwHSwuVplQAk cDiMdA5KDDL+9vQy/iCxP6EHnDXzMepY2mSW8IuBd55qEerbtV+XwqE4QUAJ6cYk/uWW uW5JcqVkz2AkFYloRdpKrMqmU8Li9W38lJSe57NcSCExs1WTS7U1bYcxiyHO5p/oljpF 9LPA== X-Gm-Message-State: AOPr4FUDS7dED4pWQcV9nfxB1CQpTwNxYInw0B20ztisJiq61b0Bz2pR2lP8bSDqsy5tEg== X-Received: by 10.28.6.140 with SMTP id 134mr14521403wmg.23.1461617204996; Mon, 25 Apr 2016 13:46:44 -0700 (PDT) Received: from localhost.localdomain (host-78-148-233-106.as13285.net. [78.148.233.106]) by smtp.gmail.com with ESMTPSA id l124sm20379647wmf.11.2016.04.25.13.46.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Apr 2016 13:46:43 -0700 (PDT) From: Sudip Mukherjee To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe Date: Mon, 25 Apr 2016 21:46:38 +0100 Message-Id: <1461617198-32351-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Score: -1.6 (-) X-Headers-End: 1aunP9-0002Dm-1W X-Mailman-Approved-At: Sun, 01 May 2016 06:33:07 +0000 Cc: tpmdd-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: [tpmdd-devel] [PATCH] tpm: use devm_add_action_or_reset X-BeenThere: tpmdd-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Tpm Device Driver maintainance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: tpmdd-devel-bounces@lists.sourceforge.net X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,HK_RANDOM_ENVFROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If devm_add_action() fails we are explicitly calling the cleanup function in the error path. Lets use the helper function devm_add_action_or_reset() and return directly as we know the cleanup has been done by the helper. Signed-off-by: Sudip Mukherjee --- drivers/char/tpm/tpm-chip.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 5bc530c..aca4505 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -212,11 +212,10 @@ struct tpm_chip *tpmm_chip_alloc(struct device *pdev, if (IS_ERR(chip)) return chip; - rc = devm_add_action(pdev, (void (*)(void *)) put_device, &chip->dev); - if (rc) { - put_device(&chip->dev); + rc = devm_add_action_or_reset(pdev, (void (*)(void *)) put_device, + &chip->dev); + if (rc) return ERR_PTR(rc); - } dev_set_drvdata(pdev, chip);