From patchwork Sun Jun 12 14:05:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 9171509 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 419E96044F for ; Sun, 12 Jun 2016 14:05:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2742D25D99 for ; Sun, 12 Jun 2016 14:05:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09B7227D07; Sun, 12 Jun 2016 14:05:55 +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=-6.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 6326A25D99 for ; Sun, 12 Jun 2016 14:05:54 +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 1bC61N-0000NP-Q4; Sun, 12 Jun 2016 14:05:49 +0000 Received: from sog-mx-3.v43.ch3.sourceforge.com ([172.29.43.193] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1bC61L-0000ND-M9 for tpmdd-devel@lists.sourceforge.net; Sun, 12 Jun 2016 14:05:47 +0000 Received-SPF: pass (sog-mx-3.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.65 as permitted sender) client-ip=74.125.82.65; envelope-from=sudipm.mukherjee@gmail.com; helo=mail-wm0-f65.google.com; Received: from mail-wm0-f65.google.com ([74.125.82.65]) by sog-mx-3.v43.ch3.sourceforge.com with esmtps (TLSv1:AES128-SHA:128) (Exim 4.76) id 1bC61K-000078-Mt for tpmdd-devel@lists.sourceforge.net; Sun, 12 Jun 2016 14:05:47 +0000 Received: by mail-wm0-f65.google.com with SMTP id k184so9009434wme.2 for ; Sun, 12 Jun 2016 07:05:46 -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=sWPVt2J0qaeekZfe+yBqgEXx90MuNocttoX/ggN8zCs=; b=l9BTMXETrMG4aCNu/dpnFTkEVRT+9Q3FZ+pFs+ehLDDZyJRYe4sgH/kE/O9XlfimVW JpAqCiFaGagVSa7/TcscJhlWQPXrUbqdAkfJvsaQTXx9J2A4EMjLrNzoh9pI0a5o8M0K oLF2UMvjYUr5Ay1pv9OnfIl2fr43MGvnG+T7WG09hCQA/U6uJ8qDRwnxIlILRIv6H2m3 eqWnbwirWX0D5TjlQJVb1l6xAUxOTTHVon2f74AUysTwtHtcITlglrTmZ77Sjw/JJyb3 DO8+a78Z8KCNX5PCfayUKcz25JOuVyYQrH2Pb9IFEbdJjQs8QugRlFFYVnxKsXsuCxTn CrLw== X-Gm-Message-State: ALyK8tJyOFOTjGt/X32WzJE4uItN9hj4hKRL8AEMveYgCklDhZmGxwXeCX55aypDn9Z56Q== X-Received: by 10.194.72.103 with SMTP id c7mr10098377wjv.141.1465740340427; Sun, 12 Jun 2016 07:05:40 -0700 (PDT) Received: from sudip-laptop.lan (234.98.208.46.dyn.plus.net. [46.208.98.234]) by smtp.gmail.com with ESMTPSA id y6sm9209998wmy.8.2016.06.12.07.05.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 12 Jun 2016 07:05:39 -0700 (PDT) From: Sudip Mukherjee To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe Date: Sun, 12 Jun 2016 15:05:29 +0100 Message-Id: <1465740329-4699-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 X-Headers-End: 1bC61K-000078-Mt 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-Virus-Scanned: ClamAV using ClamSMTP If devm_add_action() fails we are explicitly calling put_device() to free the resources allocated. Lets use the helper devm_add_action_or_reset() and return directly in case of error, as we know that the cleanup function has been already called by the helper if there was any error. Signed-off-by: Sudip Mukherjee Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm-chip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c index 1965dc7..5a2f043 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -213,11 +213,11 @@ 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);