Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp5600610ima; Tue, 5 Feb 2019 14:49:40 -0800 (PST) X-Google-Smtp-Source: AHgI3IY/7WmtpHWnbhb5FnbjFfSuYzmltfjK7P0AU6e1+U8vLF10rtLey8jL7RKWvV8qFp4DphDv X-Received: by 2002:a63:5252:: with SMTP id s18mr6709535pgl.326.1549406980065; Tue, 05 Feb 2019 14:49:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549406980; cv=none; d=google.com; s=arc-20160816; b=QiuKCT9Vw7+iZwtUHfPIATY9VEV/+a1jnUPabbWXsHFsx3n39Q03KCjD3J4q5zvBMC 6VwQbmSGKVKN5Lljxag+x2iMRoOjqOjYeoGVAHFew93EitDygYs6ipBdxKb61ViGR2wu EmGOIa/Fhhf1VnQBbUJeR+Iz2BYHmAam7jWRl/MYDcgZyK9aE/p+puBMW1inV1T6ssNe ISP0iml9NydIvJW/whKYvm6+3hxUuXADsGQQCClQWQ386rtWGhr/7ORAkJW+v4uj8VGv ZQE/BRE23K8YYi9BEQYVmEnWUs9sQQ+fkM+VchKBKr+7+icXSbns5IXqaVL90kgY7sHy Vmpg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=IPCbITwXDoR7xCAXqWujNJ9WCEUedcksoeg0HcBPsKI=; b=ZVrFxEJ/t2RL0/+QS4uChuIsjdDumKuSYascAY2DEdO56N2MDJ1URb+XVta/WP5cVE MCIlpyPBGeGE7QU4g5aMB1VkdJ6ROHzF8nH5xJYdX1DwFqwvfAocZvA5DkbPDNSCacna ruAuHwWqvJJmQlhSxE/CR9njULmhIW6gISPcii1QgsnzIHlOuwvC3BpYkERtOb+KN7cy BDPtTZ9bv3iEgKjLkDY/GiBRGlGITvE9Do55Veo4qP/7vosqEngmbiDFiZHuRUDFs2yZ dQ10A9HAcFMc3zBQaOoURoPRFPmQqeLNqZfpvKdJIpJr/+JhQqdLU6o5TLirI8DKi1PX aELg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cw15si4600860plb.377.2019.02.05.14.49.24; Tue, 05 Feb 2019 14:49:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730787AbfBEWsT (ORCPT + 99 others); Tue, 5 Feb 2019 17:48:19 -0500 Received: from mga09.intel.com ([134.134.136.24]:3158 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729902AbfBEWsQ (ORCPT ); Tue, 5 Feb 2019 17:48:16 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Feb 2019 14:48:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,337,1544515200"; d="scan'208";a="113982169" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.171]) by orsmga006.jf.intel.com with ESMTP; 05 Feb 2019 14:48:11 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Tomas Winkler , Tadeusz Struk , Stefan Berger , Nayna Jain , Jarkko Sakkinen Subject: [PATCH v11 06/16] tpm: access command header through struct in tpm_try_transmit() Date: Wed, 6 Feb 2019 00:47:13 +0200 Message-Id: <20190205224723.19671-7-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190205224723.19671-1-jarkko.sakkinen@linux.intel.com> References: <20190205224723.19671-1-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of accessing fields of the command header through offsets to the raw buffer, it is a better idea to use the header struct pointer that is already used elsewhere in the function. Signed-off-by: Jarkko Sakkinen Reviewed-by: Stefan Berger Tested-by: Stefan Berger Reviewed-by: Jerry Snitselaar Reviewed-by: James Bottomley --- drivers/char/tpm/tpm-interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c index b5b6a7c3f995..c28ffef92f1a 100644 --- a/drivers/char/tpm/tpm-interface.c +++ b/drivers/char/tpm/tpm-interface.c @@ -187,8 +187,8 @@ static ssize_t tpm_try_transmit(struct tpm_chip *chip, struct tpm_space *space, if (bufsiz > TPM_BUFSIZE) bufsiz = TPM_BUFSIZE; - count = be32_to_cpu(*((__be32 *) (buf + 2))); - ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); + count = be32_to_cpu(header->length); + ordinal = be32_to_cpu(header->ordinal); if (count == 0) return -ENODATA; if (count > bufsiz) { -- 2.19.1