[PATCH 2/3] mtd: move zero length verification to MTD API functions
Artem Bityutskiy
dedekind1 at gmail.com
Wed Feb 8 07:42:53 EST 2012
On Tue, 2012-02-07 at 14:35 +0200, Shmulik Ladkani wrote:
> On Mon, 6 Feb 2012 14:03:08 +0200 Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> > @@ -712,6 +717,8 @@ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
> > return -EOPNOTSUPP;
> > if (from < 0 || from > mtd->size || len > mtd->size - from)
> > return -EINVAL;
> > + if (!len)
> > + return 0;
> > return mtd->_point(mtd, from, len, retlen, virt, phys);
> > }
>
> Previously, '_point' implementors usually assigned *virt (e.g. for NOR -
> to the relevant ioremapped address), regardless 'len' value.
> Meaning, *virt was set, even in the 'len == 0' case.
> New 'mtd_point()' does not set *virt in this case.
>
> (Luckily, seems there are no calls to 'mtd_point' with zero 'len'...)
>
> I guess it is safe to assume the *virt assignment in the '!len' case was
> wrong?
If length is zero then 'virt' is anyway useless. But we should set it to
NULL in 'mtd_point()' to make sure that if someone accesses it he gets
an oops. I'll amend the patch and update the commit message
correspondingly, thanks a lot for review.
--
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/20120208/89f6057f/attachment.sig>
More information about the linux-mtd
mailing list