Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1934691ima; Thu, 25 Oct 2018 07:15:04 -0700 (PDT) X-Google-Smtp-Source: AJdET5fAslNpl3HLSU9w34dZIksro4IHO6v4+aabzdEVX8FUyBWNvtvmHFmAAEw1tgJa3HANfUc2 X-Received: by 2002:a63:5517:: with SMTP id j23-v6mr1624760pgb.208.1540476904783; Thu, 25 Oct 2018 07:15:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540476904; cv=none; d=google.com; s=arc-20160816; b=pCvVQ4gJYwFrgXlAOVLB2Bf72oNrGgGiEeqhj+QLhz1BjsN40t8cah38MY1p0rpXG0 BwApGpLpyS8xmUhpwZCJT9wGhwYEqKBtMSJsnGffIO3Us33cruJo1FnxPynsZHQ0EzPU OYarAfNwDbnnRlynaIqHExRLSJ/yeg9UGUumZF+2oZS/yAx5JJBlkTZH0jRaYtOtnIJv cPdIBrn2YE1syOAaQcPFb235anhEwgrGLmf+HApcm5HAERuvEzijkbMeRCkI6ZAkk5Yt +ufH6Fv6hJMn1o0dZbgnRRtgLthoTokcVxWcVALw6owDPqWLBSDD5bmcAz8rhD7JDdPA bbqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=v34SzHL2a87n6Ktc4sxJGAJxWjH2rgwEiulYKL6kU10=; b=OEBFWREXvhGiS1fuhn2CVAB6xOZ07F23JlKRafi1ld6iDr4hLpmD7l9bAUhuvVluCX I3Z8xD0QLJP/fcvg+RHoE5vo/dB51yf58Q15a4ZI7NvQnrrSIycI2Wt22PhRSPVNkP8n OeSG3HONqr8Z1gXVnhWG0pG8gCVuW7PaFJr6xGm/ixFc6acMmd0VCnLJ5zEb3Vqq574z OWPKWBVslwz14pkTrbBP7KnMfBK43JBQuAL3wgg2/39jzJhJZYvS3r9eptQyT83P3O06 q4LPBJ4SepgGU1GbJkMt98xp3FM8K2QdmF9+2YaLAhnsmIK3SQssFyvKDSXGH03JDWpW jHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vh+J51UT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18-v6si7937648plp.294.2018.10.25.07.14.43; Thu, 25 Oct 2018 07:15:04 -0700 (PDT) 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=vh+J51UT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728212AbeJYWoa (ORCPT + 99 others); Thu, 25 Oct 2018 18:44:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:53346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728157AbeJYWo3 (ORCPT ); Thu, 25 Oct 2018 18:44:29 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 804DD2054F; Thu, 25 Oct 2018 14:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476694; bh=S+cQtJiWXkeba1uEGfzSI7rh/p33OKmGOscBHVnpezA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vh+J51UTIUS5YBCUT1tGhQad1oVQk14LCd1j1GFrOLkNprpzesGP5BNmxkE0rrlYH wIMA7KUXVZ7TBoPyQi2RhVaRkszxiZYcwh5xGijAtQomA/ViPljaAroZj88iQqGox/ 0JIa9antHDp1ByM25bpDO6mU7dv9Tw/kH9ZunaQ8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Winkler, Tomas" , Jarkko Sakkinen , Sasha Levin Subject: [PATCH AUTOSEL 4.14 28/46] tpm: tpm_crb: relinquish locality on error path. Date: Thu, 25 Oct 2018 10:10:35 -0400 Message-Id: <20181025141053.213330-28-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141053.213330-1-sashal@kernel.org> References: <20181025141053.213330-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Winkler, Tomas" [ Upstream commit 1fbad3028664e114d210dc65d768947a3a553eaa ] In crb_map_io() function, __crb_request_locality() is called prior to crb_cmd_ready(), but if one of the consecutive function fails the flow bails out instead of trying to relinquish locality. This patch adds goto jump to __crb_relinquish_locality() on the error path. Fixes: 888d867df441 (tpm: cmd_ready command can be issued only after granting locality) Signed-off-by: Tomas Winkler Tested-by: Jarkko Sakkinen Reviewed-by: Jarkko Sakkinen Signed-off-by: Jarkko Sakkinen Signed-off-by: Sasha Levin --- drivers/char/tpm/tpm_crb.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index 5c7ce5aaaf6f..b4ad169836e9 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -520,8 +520,10 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, priv->regs_t = crb_map_res(dev, priv, &io_res, buf->control_address, sizeof(struct crb_regs_tail)); - if (IS_ERR(priv->regs_t)) - return PTR_ERR(priv->regs_t); + if (IS_ERR(priv->regs_t)) { + ret = PTR_ERR(priv->regs_t); + goto out_relinquish_locality; + } /* * PTT HW bug w/a: wake up the device to access @@ -529,7 +531,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, */ ret = __crb_cmd_ready(dev, priv); if (ret) - return ret; + goto out_relinquish_locality; pa_high = ioread32(&priv->regs_t->ctrl_cmd_pa_high); pa_low = ioread32(&priv->regs_t->ctrl_cmd_pa_low); @@ -574,6 +576,8 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, __crb_go_idle(dev, priv); +out_relinquish_locality: + __crb_relinquish_locality(dev, priv, 0); return ret; -- 2.17.1