From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751274AbdAaUzy (ORCPT ); Tue, 31 Jan 2017 15:55:54 -0500 Received: from mga07.intel.com ([134.134.136.100]:39124 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751144AbdAaUzc (ORCPT ); Tue, 31 Jan 2017 15:55:32 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,316,1477983600"; d="scan'208";a="1101320105" Date: Tue, 31 Jan 2017 22:52:09 +0200 From: Jarkko Sakkinen To: James Bottomley Cc: tpmdd-devel@lists.sourceforge.net, open list , linux-security-module@vger.kernel.org Subject: Re: [tpmdd-devel] [PATCH] tpm: fix a sparse error in tpm-interface.c Message-ID: <20170131205209.5552qjqaxjsrycxe@intel.com> References: <20170131180742.28460-1-jarkko.sakkinen@linux.intel.com> <1485889841.3199.57.camel@HansenPartnership.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1485889841.3199.57.camel@HansenPartnership.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 31, 2017 at 11:10:41AM -0800, James Bottomley wrote: > On Tue, 2017-01-31 at 20:07 +0200, Jarkko Sakkinen wrote: > > drivers/char/tpm//tpm-interface.c:492:42: warning: bad assignment ( > > -=) > > to restricted __be32 > > > > Fixes: 0883743825e3 ("TPM: sysfs functions consolidation") > > Signed-off-by: Jarkko Sakkinen > > --- > > drivers/char/tpm/tpm-interface.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm > > -interface.c > > index 423938e..746bc54 100644 > > --- a/drivers/char/tpm/tpm-interface.c > > +++ b/drivers/char/tpm/tpm-interface.c > > @@ -489,7 +489,7 @@ ssize_t tpm_getcap(struct tpm_chip *chip, u32 > > subcap_id, cap_t *cap, > > tpm_cmd.params.getcap_in.cap = > > cpu_to_be32(subcap_id); > > /*subcap field not necessary */ > > tpm_cmd.params.getcap_in.subcap_size = > > cpu_to_be32(0); > > - tpm_cmd.header.in.length -= > > cpu_to_be32(sizeof(__be32)); > > + tpm_cmd.header.in.length = cpu_to_be32(18); > > using bare numbers here without comment isn't really best practice. > What about setting header.in.length in both legs of the if() to either > > tpm_cmd.header.in.length = cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in)) > > or > > /* setting subcap_size to zero allows us to elimnate the subcap field */ > tpm_cmd.header.in.length = cpu_to_be32(HEADER_SIZE + sizeof(struct tpm_getcap_params_in) - sizeof(tpm_cmd.params.getcap_in.subcap)) Yeah, also the commit message should be updated rather than referring to the static checking tool. I'll update the commit along the lines you proposed... /Jarkko