[PATCH 2/3] mtd: move zero length verification to MTD API functions
Shmulik Ladkani
shmulik.ladkani at gmail.com
Tue Feb 7 07:35:05 EST 2012
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?
Regards
Shmulik
More information about the linux-mtd
mailing list