[PATCH 4/4] mtd: remove R/O checking duplication
Artem Bityutskiy
dedekind1 at gmail.com
Mon Feb 6 04:12:20 EST 2012
On Sun, 2012-02-05 at 10:33 +0200, Shmulik Ladkani wrote:
> On Fri, 3 Feb 2012 19:01:31 +0200 Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> > diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> > index 13bd4fa..78e1df6 100644
> > --- a/drivers/mtd/mtdcore.c
> > +++ b/drivers/mtd/mtdcore.c
> > @@ -754,7 +756,7 @@ int mtd_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen,
> > const u_char *buf)
> > {
> > *retlen = 0;
> > - if (!mtd->_write)
> > + if (!mtd->_write || !(mtd->flags & MTD_WRITEABLE))
> > return -EROFS;
> > if (to < 0 || to > mtd->size || len > mtd->size - to)
> > return -EINVAL;
>
> (sorry for nit-picking)
No need to sorry, you are very welcome - I am happy when people spot
issues before patches get merged.
> Here you perform "writable" (EROFS) validation prior offset/length
> validation (EINVAL) - however in other API funtions you had it
> vice-versa.
> Really not that important, but better if handling is consistent.
I think this is rather important to first validate the input parameters
and then check for R/O. I've done this in other functions, but failed to
do in 'mtd_write()'. Fixed in l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120206/40bbe4dc/attachment.sig>
More information about the linux-mtd
mailing list