From mboxrd@z Thu Jan 1 00:00:00 1970 From: Srinivas Kandagatla Subject: Re: [PATCH 2/4] thermal: imx: Add support for reading OCOTP through nvmem Date: Fri, 14 Jul 2017 11:54:11 +0100 Message-ID: <4ad5c6dd-8179-360f-9a90-51f13565956f@linaro.org> References: <68b476b35b0c0cbce21da0e87338323bb77e9bc4.1499347157.git.leonard.crestez@nxp.com> <20170712063629.GD3172@dragon> <3dd43cba-02f2-204c-c3a2-582827018ef8@linaro.org> <1500029388.11612.54.camel@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1500029388.11612.54.camel@nxp.com> Content-Language: en-US Sender: linux-pm-owner@vger.kernel.org To: Leonard Crestez Cc: Shawn Guo , Zhang Rui , Eduardo Valentin , Rob Herring , Mark Rutland , =?UTF-8?Q?Lothar_Wa=c3=9fmann?= , Fabio Estevam , Dong Aisheng , Bai Ping , Anson Huang , Octavian Purdila , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org List-Id: devicetree@vger.kernel.org On 14/07/17 11:49, Leonard Crestez wrote: >>>> + } >>>> + memcpy(val, buf, sizeof(*val)); >> This can overflow the memory allocated to val, we should be careful here >> not to do so. >> limit this to sizeof(u32) should be good. Also add some sanity checks to >> make sure that len is atleast 4 bytes. > I'm not sure what you mean, isn't this already done? There is an > explicit check above that the read len is exactly as expected. It's > just that the limit is written as sizeof(*val) rather than sizeof(u32). Opps, I overlooked the type.. it looks okay. thanks, srini >