Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1337050

Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells()

Path csiph.com!news.freedyn.net!aioe.org!news.servidellagleba.it!bofh.it!news.nic.it!robomod
From Rasmus Villemoes <linux@rasmusvillemoes.dk>
Newsgroups linux.kernel
Subject Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells()
Date Thu, 18 Feb 2016 06:40:02 +0100
Message-ID <r3ptM-Rw-9@gated-at.bofh.it> (permalink)
References <r01eh-2kE-13@gated-at.bofh.it> <r37Qe-59r-29@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=p+Vx1xNhdO1h+khuU0n0pr6vaYV3bkUNM1+O8QmBL54=; b=Alox9a5gjIBwtASd7KHxp98hPPJZI1qI5DgEb5LgJUZ+QBDFR4jrw2monPE0/czanN PAA8jyLHb7jMI790qQShqHGnaCN4m5P1DDLzDG2QcDcN0xrJOxbLD+0RwoJRZZOZga1q 6y7TZC0+UP5irYrXBEpvO6Z/0bD0M0IaCEOfw=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version:content-type; bh=p+Vx1xNhdO1h+khuU0n0pr6vaYV3bkUNM1+O8QmBL54=; b=HW7G7pMSyqA/xw3DJtf57F/rTNTEqTMdW0l2u8bo/4PB0lddXI1tOGnNaRv4TAO/U5 sOGuj2wAvztcXuPK+eiTY3elgoeRr/bi76ickISpSkKFqMSkKbFcVFITBaDUmFSXkQ/R YfmB6TjY98olsWWHocQw4KVrENvNuHSPbQmCG+VtTZ7MTA1paCbKhZywkQCMm2bQFh4t QkHYJfel3p6xQpJUDDYmGT72yrYZFwQnbzNj3wecsBczEdi9M3oPYSTJIGWG8XTjS9My JfYKmKp16vy85KDkYvCl/5EzAQ+C0dGixWeaC+RfAod33yyUYb+yi1VmwKN9HKxAAuIu 4ClQ==
X-Gm-Message-State AG10YORCNSKHV5C02GR9fO1wrcJ3J07tDUxdpEg/RwU+0HxBiAKBADkNnvEWnnoThjJvug==
X-Received by 10.28.189.212 with SMTP id n203mr1336608wmf.50.1455773748054; Wed, 17 Feb 2016 21:35:48 -0800 (PST)
Organization D03
X-Hashcash 1:20:160218:srinivas.kandagatla@linaro.org::t43KftwdTbSwiskm:000000000000000000000000000000016bh
X-Hashcash 1:20:160218:gregkh@linuxfoundation.org::9QEBwEVcxJ/P0SY8:000000000000000000000000000000000001ebh
X-Hashcash 1:20:160218:linux-kernel@vger.kernel.org::7M6LOyCPclXMQxgJ:0000000000000000000000000000000002SaA
X-Hashcash 1:20:160218:maxime.ripard@free-electrons.com::4a+Bkjf40ql6cv2D:000000000000000000000000000004rJ9
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)
MIME-Version 1.0
Content-Type text/plain
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 28
X-Original-Cc Maxime Ripard <maxime.ripard@free-electrons.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, linux-kernel@vger.kernel.org
X-Original-Date Thu, 18 Feb 2016 06:35:46 +0100
X-Original-Message-ID <87wpq2h971.fsf@rasmusvillemoes.dk>
X-Original-References <1454965469-6141-1-git-send-email-linux@rasmusvillemoes.dk> <56C45016.2010806@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1337050

Show key headers only | View raw


On Wed, Feb 17 2016, Srinivas Kandagatla <srinivas.kandagatla@linaro.org> wrote:

>>   err:
>> -	while (--i)
>> +	while (i--)
>>   		nvmem_cell_drop(cells[i]);
> No, this will not work.
>
> 3 issues,
>
> 1> If we enter this err path from nvmem_cell_info_to_nvmem_cell()
> failures, you would be accessing already freed cells[i].
>
> 2> accessing un-allocated cells[i].
>
> 3> you would be trying to drop cells which are not in the list.
>
>
> This is what you need here to fix it correctly.
>
> while (--i >= 0)
>

Sigh. http://thread.gmane.org/gmane.linux.kernel.mm/146058/focus=2149595

TL;DR: They're equivalent.

Rasmus

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2016-02-17 11:50 +0100
  Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2016-02-18 06:40 +0100
    Re: [PATCH] nvmem: core: fix error path in nvmem_add_cells() Srinivas Kandagatla <srinivas.kandagatla@linaro.org> - 2016-02-18 10:10 +0100

csiph-web