Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754314AbbHJItW (ORCPT ); Mon, 10 Aug 2015 04:49:22 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:34639 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753548AbbHJItV (ORCPT ); Mon, 10 Aug 2015 04:49:21 -0400 Message-ID: <55C8658F.4000201@linaro.org> Date: Mon, 10 Aug 2015 09:49:19 +0100 From: Srinivas Kandagatla User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Shunqian Zheng , maxime.ripard@free-electrons.com, heiko@sntech.de, linux-kernel@vger.kernel.org, caesar.wang@rock-chips.com CC: dianders@chromium.org, linux-rockchip@lists.infradead.org, xjq@rock-chips.com Subject: Re: [PATCH 1/3] nvmem: fix the out-of-range leak in read/write() References: <1439176963-8969-1-git-send-email-zhengsq@rock-chips.com> <1439176963-8969-2-git-send-email-zhengsq@rock-chips.com> In-Reply-To: <1439176963-8969-2-git-send-email-zhengsq@rock-chips.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1308 Lines: 46 On 10/08/15 04:22, Shunqian Zheng wrote: > From: ZhengShunQian > > The position to read/write must be less than max > register size. > > Signed-off-by: ZhengShunQian > --- > drivers/nvmem/core.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index d3c6676..f4af8e5 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -67,7 +67,7 @@ static ssize_t bin_attr_nvmem_read(struct file *filp, struct kobject *kobj, > int rc; > > /* Stop the user from reading */ > - if (pos > nvmem->size) > + if (pos >= nvmem->size) > return 0; > > if (pos + count > nvmem->size) > @@ -92,7 +92,7 @@ static ssize_t bin_attr_nvmem_write(struct file *filp, struct kobject *kobj, > int rc; > > /* Stop the user from writing */ > - if (pos > nvmem->size) > + if (pos >= nvmem->size) > return 0; > > if (pos + count > nvmem->size) > This looks good, Acked-by: Srinivas Kandagatla -- 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/