From patchwork Sat Apr 30 16:58:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 8988221 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 B2FFD9FC6A for ; Sun, 1 May 2016 06:33:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E7F9A20295 for ; Sun, 1 May 2016 06:33:14 +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 8DD8A202AE 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-0001nN-Cg; Sun, 01 May 2016 06:33:08 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1awYDj-0006AE-4B for tpmdd-devel@lists.sourceforge.net; Sat, 30 Apr 2016 16:58:19 +0000 Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of gmail.com designates 74.125.82.45 as permitted sender) client-ip=74.125.82.45; envelope-from=sudipm.mukherjee@gmail.com; helo=mail-wm0-f45.google.com; Received: from mail-wm0-f45.google.com ([74.125.82.45]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:RC4-SHA:128) (Exim 4.76) id 1awYDi-00031C-3z for tpmdd-devel@lists.sourceforge.net; Sat, 30 Apr 2016 16:58:19 +0000 Received: by mail-wm0-f45.google.com with SMTP id g17so81326789wme.1 for ; Sat, 30 Apr 2016 09:58:18 -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=5Z6FxIWt0GDAGyRk/QOciBhP8QKWO8J4/GKlRNTYarw=; b=X8fjS4ss3j+PcKYecVX7gcOMzqMayZ08L4nDsmsOt/UgWmba0E8BTWS2hLtdVWBmjn kSdopwHav0hOUxlzWtBiUGULWiE+mSnjavzdYGpfxT4jBLNEzwH7L5tfmRK3CvLJVM8b u481gs+WMVTsFQA1ZqJ94vFSMnjCB+RtJHSUFJF3GGHu1+nbNedVuaWCfw6iEzydnptB EOat+0Y//T9+HZkKf/Rn1qakpXB7ibwymva7Yl76WcHlmc3F75wQ2xOZSdpnhoCvjDYD wL83rahudh1zoCDRvUfwc1lq1AToM3PHtbakXoVCRtgAbDllLmOnnOatJJy8tdvrwUMU RJMA== X-Gm-Message-State: AOPr4FUQ8vam9eVvm7g4PGWo+PUh02M+kwln75/In+CGgxEphE+L9AgfP1SCto6G3gySAw== X-Received: by 10.194.16.8 with SMTP id b8mr27833686wjd.51.1462035491992; Sat, 30 Apr 2016 09:58:11 -0700 (PDT) Received: from localhost.localdomain (cpc12-nmal17-2-0-cust370.croy.cable.virginm.net. [77.96.123.115]) by smtp.gmail.com with ESMTPSA id s6sm20683405wjy.31.2016.04.30.09.58.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 30 Apr 2016 09:58:11 -0700 (PDT) From: Sudip Mukherjee To: Peter Huewe , Marcel Selhorst , Jarkko Sakkinen , Jason Gunthorpe Date: Sat, 30 Apr 2016 17:58:06 +0100 Message-Id: <1462035486-26463-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 X-Spam-Score: -1.6 (-) X-Headers-End: 1awYDi-00031C-3z 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 v2] 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 From: Sudip Mukherjee 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. Reviewed-by: Jason Gunthorpe Signed-off-by: Sudip Mukherjee --- v2: rebased against the current charmisc-testing branch. 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 274dd01..4c2deea 100644 --- a/drivers/char/tpm/tpm-chip.c +++ b/drivers/char/tpm/tpm-chip.c @@ -137,11 +137,10 @@ struct tpm_chip *tpmm_chip_alloc(struct device *dev, chip->cdev.owner = chip->pdev->driver->owner; chip->cdev.kobj.parent = &chip->dev.kobj; - rc = devm_add_action(dev, (void (*)(void *)) put_device, &chip->dev); - if (rc) { - put_device(&chip->dev); + rc = devm_add_action_or_reset(dev, (void (*)(void *)) put_device, + &chip->dev); + if (rc) return ERR_PTR(rc); - } return chip; }