Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp275007imu; Mon, 5 Nov 2018 00:11:46 -0800 (PST) X-Google-Smtp-Source: AJdET5cQBDSu/dPsp9Gp4hxzhRS4wm7/sdzB291ds6FuN/gDIcxGcwKq2JcnOK5wg5oTHw/cGUiP X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr20717126pfg.10.1541405506373; Mon, 05 Nov 2018 00:11:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541405506; cv=none; d=google.com; s=arc-20160816; b=mJpSfDMRbxGZ3eC14M8IK2RyOjoLLALbmAVfTs9ZufYRZ6HN6up09KOgXIXkhByP4a quwcix7b2UikWaENNdEFZm7IW1ERqBKRVmUns0GeHlyEDj/rB2TrETvN1+qZ5lxV7WHY ytu/50bvhTgi6VjanwTgF9OgXbopIDC0417Ts8tjGW/5FU0ySux+wLDeUAGVxAkz5x+q vxmfCVMEu+DKt9nrXtQp03I550Zo7W4+HaILAtBq6wpMwAAVlD41+q4aHjJQ+ouzrDWa 36U6e7LaFJZA4+zD0tCgoFzFBdvPXxf/h9I5+fUQ/Ai3GVbjk90Jye8S0xg3Y1n4VNGz NeMA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Z1S36RQXoPb8kEcWA4vQLxBOtg+cUuke3JH18kBJIo4=; b=DYSpTyQ3lj5SeaRzQXChXsYzTVEOn+UWzcSXF1sVDNWbEm6zx+prSTeMUOe6+tt6sV X+K1UEjPgnq1yFD8WIdGeC7OFKBcAfHgGoZjfJ8NHtozLpO9oWajiPgpcdLqHyKN9ER/ HVYDN83BmKCxiZ0OE2o7JGFavFqOtOEa4Y618bVeOPYn5YzNn/+NkSXetfglnOxhckmN 0NNXqDkqWSD4V87pdYu1Wxpis6S/vhq7ogHNb+PdXG7zrjhKRJaTZILz/+JdNR0Xac0C 0LJtRl6O3X2Hux14eSsTP7E+MxOQMmLO4lg9WnW+IjnNL/E3bYqvBSjVnN2068Rlkd3Y md/g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b18si531591pgj.399.2018.11.05.00.11.30; Mon, 05 Nov 2018 00:11:46 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726922AbeKER3g (ORCPT + 99 others); Mon, 5 Nov 2018 12:29:36 -0500 Received: from lhrrgout.huawei.com ([185.176.76.210]:32711 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725745AbeKER3g (ORCPT ); Mon, 5 Nov 2018 12:29:36 -0500 Received: from LHREML714-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 59B834939E4A5; Mon, 5 Nov 2018 08:11:05 +0000 (GMT) Received: from [10.204.65.142] (10.204.65.142) by smtpsuk.huawei.com (10.201.108.37) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 5 Nov 2018 08:10:59 +0000 Subject: Re: [PATCH v3 1/5] tpm: change the end marker of the active_banks array to zero To: Mimi Zohar , CC: , , , References: <20181030154711.2782-1-roberto.sassu@huawei.com> <20181030154711.2782-2-roberto.sassu@huawei.com> <1540996980.11273.67.camel@linux.ibm.com> <1541083377.4035.13.camel@linux.ibm.com> From: Roberto Sassu Message-ID: Date: Mon, 5 Nov 2018 09:10:58 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1541083377.4035.13.camel@linux.ibm.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.204.65.142] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/1/2018 3:42 PM, Mimi Zohar wrote: > On Wed, 2018-10-31 at 10:43 -0400, Mimi Zohar wrote: >> On Tue, 2018-10-30 at 16:47 +0100, Roberto Sassu wrote: >>> This patch changes the end marker of the active_banks array from >>> TPM2_ALG_ERROR to zero. >> >> The patch description is a bit off. >> >> TPM2_ALG_ERROR is defined as zero.  Since tpm_chip_alloc() calls >> kzalloc to allocate the structure, there is no need to explicitly set >> the active_banks end marker to TPM2_ALG_ERROR, nor is there a need to >> explicitly test for the end marker. >> >> This patch removes explicitly setting the end marker and changes the >> coding style. >> >>> >>> Signed-off-by: Roberto Sassu >>> --- >>> drivers/char/tpm/tpm-interface.c | 2 +- >>> drivers/char/tpm/tpm2-cmd.c | 3 --- >>> 2 files changed, 1 insertion(+), 4 deletions(-) >>> >>> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c >>> index 1a803b0cf980..f7fc4b5ee239 100644 >>> --- a/drivers/char/tpm/tpm-interface.c >>> +++ b/drivers/char/tpm/tpm-interface.c >>> @@ -1051,7 +1051,7 @@ int tpm_pcr_extend(struct tpm_chip *chip, int pcr_idx, const u8 *hash) >>> memset(digest_list, 0, sizeof(digest_list)); >>> >>> for (i = 0; i < ARRAY_SIZE(chip->active_banks) && >>> - chip->active_banks[i] != TPM2_ALG_ERROR; i++) { >>> + chip->active_banks[i]; i++) { >>> digest_list[i].alg_id = chip->active_banks[i]; >>> memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE); >>> count++; > > The fourth patch further updates this code.  Please move those changes > to this first patch.  No need to touch the same code in both places. alg_id is introduced in patch 4/5. It cannot be moved here. Roberto > for (i = 0; i < ARRAY_SIZE(chip->active_banks) && > - chip->active_banks[i]; i++) { > - digest_list[i].alg_id = chip->active_banks[i]; > + chip->active_banks[i].alg_id; i++) { > + digest_list[i].alg_id = chip->active_banks[i].alg_id; > memcpy(digest_list[i].digest, hash, TPM_DIGEST_SIZE); > count++; > } > Mimi > >>> diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c >>> index c31b490bd41d..046c9d8f3c1e 100644 >>> --- a/drivers/char/tpm/tpm2-cmd.c >>> +++ b/drivers/char/tpm/tpm2-cmd.c >>> @@ -908,9 +908,6 @@ static ssize_t tpm2_get_pcr_allocation(struct tpm_chip *chip) >>> } >>> >>> out: >>> - if (i < ARRAY_SIZE(chip->active_banks)) >>> - chip->active_banks[i] = TPM2_ALG_ERROR; >>> - >>> tpm_buf_destroy(&buf); >>> >>> return rc; >> > -- HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063 Managing Director: Bo PENG, Jian LI, Yanli SHI