From: Andreas Mohr <andi@lisas.de>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: "Andreas Mohr" <andi@lisas.de>,
"Ulf Hansson" <ulf.hansson@linaro.org>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Russell King" <rmk+kernel@arm.linux.org.uk>,
"Shawn Lin" <shawn.lin@rock-chips.com>,
"Douglas Anderson" <dianders@chromium.org>,
"Heiko Stübner" <heiko@sntech.de>,
"David Jander" <david@protonic.nl>,
"Hans de Goede" <hdegoede@redhat.com>,
linux-mmc <linux-mmc@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"Mark Brown" <broonie@kernel.org>,
"Linus Walleij" <linus.walleij@linaro.org>
Subject: Re: [PATCH v4 2/3] mmc: core: Factor out the alignment of erase size
Date: Tue, 6 Sep 2016 09:19:18 +0200 [thread overview]
Message-ID: <20160906071918.GA27539@rhlx01.hs-esslingen.de> (raw)
In-Reply-To: <CAMz4kuJzqyAEam3RNJga5EERMh6TgXWFoY-uZ8pbm1OZW7uy8g@mail.gmail.com>
On Tue, Sep 06, 2016 at 02:26:06PM +0800, Baolin Wang wrote:
> On 6 September 2016 at 12:34, Andreas Mohr <andi@lisas.de> wrote:
> >> - to = from + nr;
> >> -
> >> - if (to <= from)
> >> - return -EINVAL;
> >
> > Hmm, this is swallowing -EINVAL behaviour
> > i.e., now possibly violating protocol?
>
> I didn't see what situation will make variable 'to' is less than
> 'from' since I think variable 'nr' is always larger than 0, right? If
> so, we should remove this useless checking. Thanks.
Hmm, indeed, since all participating variables are unsigned,
the existing calculation should never hit this.
However, one could argue that this is an additional safeguard
against implementation source getting modified in a way
that will suddenly result in this pathologic case becoming true
(where a -EINVAL bailout surely will then pinpoint things
much more visibly for some users,
as opposed to potential data corruption or some such).
I have seen another change
> - if (nr == 0)
> - return 0;
where it gets moved out of common path
and into MMC_ERASE_ARG-specific branch
(likely because the subsequent common-path conditional of
nr > rem
is deemed sufficient).
This seems to be again a change
where a simple yet crucial
device geometry calculation post-condition
(either to > from, or nr > 0)
is then not verified specifically/separately.
Ultimately, I am not sure whether or not
these (post-)conditions should be verified
in their most basic, simple form,
as an extra/separate verification step.
HTH,
Andreas
next prev parent reply other threads:[~2016-09-06 7:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 2:55 [PATCH v4 1/3] mmc: core: Remove some redundant validations in mmc_erase() function Baolin Wang
2016-09-06 2:55 ` [PATCH v4 2/3] mmc: core: Factor out the alignment of erase size Baolin Wang
2016-09-06 4:34 ` Andreas Mohr
2016-09-06 6:26 ` Baolin Wang
2016-09-06 7:19 ` Andreas Mohr [this message]
2016-09-06 8:25 ` Baolin Wang
2016-09-06 7:52 ` Adrian Hunter
2016-09-06 8:27 ` Baolin Wang
2016-09-06 2:55 ` [PATCH v4 3/3] mmc: core: Optimize the mmc erase size alignment Baolin Wang
2016-09-06 12:17 ` [PATCH v4 1/3] mmc: core: Remove some redundant validations in mmc_erase() function Ulf Hansson
2016-09-06 12:35 ` Baolin Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160906071918.GA27539@rhlx01.hs-esslingen.de \
--to=andi@lisas.de \
--cc=adrian.hunter@intel.com \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=david@protonic.nl \
--cc=dianders@chromium.org \
--cc=hdegoede@redhat.com \
--cc=heiko@sntech.de \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=shawn.lin@rock-chips.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®