public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Richard Weinberger <richard@nod.at>,
	Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
	linux-mtd@lists.infradead.org
Cc: Peter Pan <peterpansjtu@gmail.com>
Subject: Re: [PATCH] mtd: Remove unneeded checks in part_{read,write}_oob()
Date: Sun, 7 Jan 2018 11:16:47 +0100	[thread overview]
Message-ID: <20180107111647.191e2a7b@bbrezillon> (raw)
In-Reply-To: <20180106204917.1266-1-boris.brezillon@free-electrons.com>

On Sat,  6 Jan 2018 21:49:17 +0100
Boris Brezillon <boris.brezillon@free-electrons.com> wrote:

> mtd_{read,write}_oob() are already checking parameters consistency,
> remove the checks done in part_{read,write}_oob().

Please ignore this patch. I realized I had already submitted a patch
removing redundant checks in various drivers/sub-layers [1], so I'll
just prepare a v2 of this patch integrating the mtdpart changes.

Regards,

Boris

[1]http://patchwork.ozlabs.org/patch/781354/

> 
> Suggested-by: Peter Pan <peterpansjtu@gmail.com>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  drivers/mtd/mtdpart.c | 23 -----------------------
>  1 file changed, 23 deletions(-)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index 4d1140c23ead..88f94d672e40 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -117,25 +117,6 @@ static int part_read_oob(struct mtd_info *mtd, loff_t from,
>  	struct mtd_part *part = mtd_to_part(mtd);
>  	int res;
>  
> -	if (from >= mtd->size)
> -		return -EINVAL;
> -	if (ops->datbuf && from + ops->len > mtd->size)
> -		return -EINVAL;
> -
> -	/*
> -	 * If OOB is also requested, make sure that we do not read past the end
> -	 * of this partition.
> -	 */
> -	if (ops->oobbuf) {
> -		size_t len, pages;
> -
> -		len = mtd_oobavail(mtd, ops);
> -		pages = mtd_div_by_ws(mtd->size, mtd);
> -		pages -= mtd_div_by_ws(from, mtd);
> -		if (ops->ooboffs + ops->ooblen > pages * len)
> -			return -EINVAL;
> -	}
> -
>  	res = mtd_read_oob(part->parent, from + part->offset, ops);
>  	if (unlikely(res)) {
>  		if (mtd_is_bitflip(res))
> @@ -194,10 +175,6 @@ static int part_write_oob(struct mtd_info *mtd, loff_t to,
>  {
>  	struct mtd_part *part = mtd_to_part(mtd);
>  
> -	if (to >= mtd->size)
> -		return -EINVAL;
> -	if (ops->datbuf && to + ops->len > mtd->size)
> -		return -EINVAL;
>  	return mtd_write_oob(part->parent, to + part->offset, ops);
>  }
>  

      reply	other threads:[~2018-01-07 10:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-06 20:49 [PATCH] mtd: Remove unneeded checks in part_{read,write}_oob() Boris Brezillon
2018-01-07 10:16 ` Boris Brezillon [this message]

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=20180107111647.191e2a7b@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@wedev4u.fr \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marek.vasut@gmail.com \
    --cc=peterpansjtu@gmail.com \
    --cc=richard@nod.at \
    /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