From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbdJVL3t (ORCPT ); Sun, 22 Oct 2017 07:29:49 -0400 Received: from mout.web.de ([212.227.17.11]:63482 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbdJVL3p (ORCPT ); Sun, 22 Oct 2017 07:29:45 -0400 Subject: [PATCH 1/2] xen-tpmfront: Use common error handling code in vtpm_send() From: SF Markus Elfring To: linux-integrity@vger.kernel.org, Jarkko Sakkinen , Jason Gunthorpe , =?UTF-8?Q?Peter_H=c3=bcwe?= Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <9cfcbfd0-75c3-4de5-f735-0ace23d2abcb@users.sourceforge.net> Date: Sun, 22 Oct 2017 13:29:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:hWQsQb2nVwYhQNS4IDJXuG0D/8p2kgLpyAnTh4Z4HHrj1+uKrMp naR4VqWpQ8axZwJ64UT+FUldB+Uwe/fPwu3e4b7Qs9a2lgFPjxB4+h4O/O+1aVIjmVXdDAC wF47T0qRwTNAXQ+fYGFRgsLNL66dO0geNyZyqY4UbPUMUOpjSIMxOgnOOmCkN4fE8z0OWkk /T9+tWqvWskt2XuJjdzeA== X-UI-Out-Filterresults: notjunk:1;V01:K0:0Tfi0MHyO5M=:ECTiKC2cjPQPd85YxWWAWP sFO21sxCHcQTt6rQahJRSey0m/hhDgIdTM1zWsFcTnU/UpIsHzSSZ5DjPvy5ZasVf16Cw/afP k5v8nKCGu/lHn8Xf0NPEaqlw41HuczEw1/xA05djXbz5AvEA8O6autojdhogL1/g/NCTCLHM/ EoGhDHfUGUgh4nX9lPen0ypfl140PmCBWnA+X41p3hHfVpEwxUPN8m3xlYtcwVwZYnFo/nU+x dJA1p6aryk78bdx4G0maeQmTnHiqi53x54HW4qYr26CVDtXIkDhAXJbYeBl4O7NrD8DOir9q5 EmoE/IaTMH9LFsy1NOIkxZlQUIwUyh/Z/J4GcQGcrFTawiETBnw+bnjkvOoP3mMdpNerYHdqW QDKnNWuKT9K0dy+CIOgV/0hXhWgRPf0lXNt+ia8CxyC1tDiDDCt6RpanHU+FneSXQt6McwY9j hWSytpTlPPHMiD9J0SEHqKQicXYa1QcvR+gqDleL1HHynJvOHpKaUOMdFpb/ssE98wEpllcu9 xntpOnHUGUgXiL1HOPTJPfRNhy9OMsr4TwCm1Iweg3Wndtxf+YIcFl8DEOfMF3sMzhBAmUeeq Ufmkvm/Ld2I34KwO/l8PyFGNfL1Ss2g/F39sKMUXltsgHsSYAY7mYtwXPd5FhcfyAQsiJj610 Mk7WtAy+7BUQ57Kbn7csB/hRYANlZP0LFf18099+HN76oG9YDw4qb2+9AAAN1o2aUL96QKz7N JQVtIlb0N/LtCA21xK3UHG/NeL/ncpMCDwL5c1cQZepUb7VrIoyUhDtd8rfHU6muRKirSsl8n JQjuADKp+1Ug2TEuQePjldwRp6DBsSaxNBx8fQz+7HiLVFBrdI= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 22 Oct 2017 12:56:42 +0200 Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/char/tpm/xen-tpmfront.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index 656e8af95d52..873a5631937a 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c @@ -90,10 +90,8 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) /* Wait for completion of any existing command or cancellation */ if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, chip->timeout_c, - &priv->read_queue, true) < 0) { - vtpm_cancel(chip); - return -ETIME; - } + &priv->read_queue, true) < 0) + goto cancel_vtpm; memcpy(offset + (u8 *)shr, buf, count); shr->length = count; @@ -108,11 +106,14 @@ static int vtpm_send(struct tpm_chip *chip, u8 *buf, size_t count) if (wait_for_tpm_stat(chip, VTPM_STATUS_IDLE, duration, &priv->read_queue, true) < 0) { /* got a signal or timeout, try to cancel */ - vtpm_cancel(chip); - return -ETIME; + goto cancel_vtpm; } return count; + +cancel_vtpm: + vtpm_cancel(chip); + return -ETIME; } static int vtpm_recv(struct tpm_chip *chip, u8 *buf, size_t count) -- 2.14.2