Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932286AbbFILjY (ORCPT ); Tue, 9 Jun 2015 07:39:24 -0400 Received: from mga02.intel.com ([134.134.136.20]:32487 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbbFILjQ (ORCPT ); Tue, 9 Jun 2015 07:39:16 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,579,1427785200"; d="scan'208";a="707866046" Date: Tue, 9 Jun 2015 14:39:13 +0300 From: Jarkko Sakkinen To: Peter Huewe Cc: "moderated list:TPM DEVICE DRIVER" , safford@us.ibm.com, open list Subject: Re: [tpmdd-devel] [PATCH v2] tpm: introduce struct tpm_buf Message-ID: <20150609113913.GA1079@jsakkine-mobl1> References: <1433349555-30868-1-git-send-email-jarkko.sakkinen@linux.intel.com> <201506082239.33639.PeterHuewe@gmx.de> <20150609091932.GC4968@jsakkine-mobl1> <1C403FBE-76FF-425C-8627-5956838CD560@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1C403FBE-76FF-425C-8627-5956838CD560@gmx.de> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 936 Lines: 33 On Tue, Jun 09, 2015 at 12:32:57PM +0200, Peter Huewe wrote: > > > Hi > > >> > +static inline void tpm_buf_store(struct tpm_buf *buf, > >> > + unsigned int pos, > >> > + const unsigned char *data, > >> > + unsigned int len) > >> > +{ > >> > + BUG_ON((pos + len) > TPM_BUF_SIZE); > >> > + > >> > + memcpy(&buf->data[pos], data, len); > >> > +} > >> > >> Don't you have to update the ->length here? > > > >No. Store is for placing value in position, not appending to the end. > > > Then either add a length check (whether ->length is big enough) and/or > call the function "update" There is a length check in the beginning (first line of the function body). > Peter /Jarkko -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/