Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3536395imu; Mon, 7 Jan 2019 05:15:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN6PWTHNjQvIyyw4ulXwph13QQpd87oB5hp4Yao4bi6wOrl63AEKDTVlze+Lj16AMw5Cq5nO X-Received: by 2002:a17:902:8484:: with SMTP id c4mr59762309plo.59.1546866948027; Mon, 07 Jan 2019 05:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546866947; cv=none; d=google.com; s=arc-20160816; b=nfDjLtnTqdf7I8eO7cmMU/LBgVAvgarUjOv2ZV6OA5DNqjD0p+SYB8sI3aE/2hwT9O LdFBjncrZ9VgyS6LHjF+iImCA64s+mB5VKhAyA0WWMHxq9pMmrrdTrztbremZkRVUsXS rVTqD8z27RYMq27tSljbfL0UoWTPcLysyuo7RoE7IEyn/kX+9Il6JkJmfoBPFBiCuzcI REMXRV3Ll2UACUGAuORVz6B6t36Et3004rdZDzgB+HN3/wjQgwpPDgqAS7PyTHaYQK/G ZsIyNozijGq/XOCHBh1ekQ5Ufgn853/KchQ95HdRZZh9MrOUOWDGgjP1gB0BhkI7/Cb8 J1oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zDgPf754ebl2rvPsMHueZxfyiMbsBFRdar7R/WirZNk=; b=lwdSikmXfHv6K1iUDY/XDd1EXXnEWvArporbU3syFBDay7HEfI7OMVvGOXOMDuvjwo wqtXsfSklMDGubcw9DrwG+As2s0VaLw+aRpNurhjxKIGBol1cKDRu/4jUvyS3taozALT FH5Rdfc6YwbQOwYiueLt0Zx62CKWSpDKj302EULzawxVyTNAfJEfDhvMLpgLET1aYO05 Of7nS5MclK41cUm3R0xsT9WDhcmHvm8ycb6x101IIoxjMjRaU/3WMlF57OCTwYcEQa6b iLFe+OXj0jj68jlrQJF2EgttInbZGZbp2jJd2M2SUXrgyIqPuZcLbi0IH1zXbXF6v1b/ yqbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CloBi320; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb2si46047663plb.298.2019.01.07.05.15.32; Mon, 07 Jan 2019 05:15:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CloBi320; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731369AbfAGNM5 (ORCPT + 99 others); Mon, 7 Jan 2019 08:12:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:51888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731339AbfAGNER (ORCPT ); Mon, 7 Jan 2019 08:04:17 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BFD821736; Mon, 7 Jan 2019 13:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866257; bh=mfNnM41Naq/mgPFbtmD7i2QBs0YV8KsU+5aqXkT9KHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CloBi3208OrFj4GcgDDcvnuCsOXykq51JdE4XJjch3YAH/f2X1nWmOBNIPSTfiJ6N wQYdOwaqP66/SgcE3Og4Rr+GyaBOjM+7Debi5IHPbDQea+5cye6lN+oU2ZZ0Gaigjx fSLauQ/RzlATsMoOOaZg6Y9ykS8C5NamPo+gkpnE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomas Winkler , Jarkko Sakkinen Subject: [PATCH 4.14 099/101] tpm: tpm_try_transmit() refactor error flow. Date: Mon, 7 Jan 2019 13:33:27 +0100 Message-Id: <20190107105338.159667198@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tomas Winkler commit 01f54664a4db0d612de0ece8e0022f21f9374e9b upstream. First, rename out_no_locality to out_locality for bailing out on both tpm_cmd_ready() and tpm_request_locality() failure. Second, ignore the return value of go_to_idle() as it may override the return value of the actual tpm operation, the go_to_idle() error will be caught on any consequent command. Last, fix the wrong 'goto out', that jumped back instead of forward. Cc: stable@vger.kernel.org Fixes: 627448e85c76 ("tpm: separate cmd_ready/go_idle from runtime_pm") Signed-off-by: Tomas Winkler Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/tpm-interface.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -479,13 +479,15 @@ static ssize_t tpm_try_transmit(struct t if (need_locality) { rc = tpm_request_locality(chip, flags); - if (rc < 0) - goto out_no_locality; + if (rc < 0) { + need_locality = false; + goto out_locality; + } } rc = tpm_cmd_ready(chip, flags); if (rc) - goto out; + goto out_locality; rc = tpm2_prepare_space(chip, space, ordinal, buf); if (rc) @@ -549,14 +551,13 @@ out_recv: dev_err(&chip->dev, "tpm2_commit_space: error %d\n", rc); out: - rc = tpm_go_idle(chip, flags); - if (rc) - goto out; + /* may fail but do not override previous error value in rc */ + tpm_go_idle(chip, flags); +out_locality: if (need_locality) tpm_relinquish_locality(chip, flags); -out_no_locality: if (chip->ops->clk_enable != NULL) chip->ops->clk_enable(chip, false);