All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Joakim Tjernlund <joakim.tjernlund@infinera.com>
Cc: "linux-mtd @ lists . infradead . org"
	<linux-mtd@lists.infradead.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 2/4] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips
Date: Wed, 20 Jun 2018 11:06:55 +0200	[thread overview]
Message-ID: <20180620110655.42ce6c1a@bbrezillon> (raw)
In-Reply-To: <20180606101330.11071-2-joakim.tjernlund@infinera.com>

On Wed,  6 Jun 2018 12:13:28 +0200
Joakim Tjernlund <joakim.tjernlund@infinera.com> wrote:

> cfi_ppb_unlock() tries to relock all sectors that was locked before

						    ^ were

> unlocking the whole chip.
> This locking used the chip start address + the FULL offset from the
> first flash chip, thereby forming an illegal address. Correct by using

							Fix/Correct that by... ?

> the chip offset(adr).
> 
> Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking")
> Cc: stable@vger.kernel.org
> Signed-off-by: Joakim Tjernlund <joakim.tjernlund@infinera.com>
> ---
> 
>  v2 - Spilt into several patches
>  
>  drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
> index 8648b1adccd5..cb85cccc48c1 100644
> --- a/drivers/mtd/chips/cfi_cmdset_0002.c
> +++ b/drivers/mtd/chips/cfi_cmdset_0002.c
> @@ -2536,7 +2536,7 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
>  
>  struct ppb_lock {
>  	struct flchip *chip;
> -	loff_t offset;
> +	unsigned long adr;
>  	int locked;
>  };
>  
> @@ -2672,7 +2672,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
>  		 */
>  		if ((adr < ofs) || (adr >= (ofs + len))) {
>  			sect[sectors].chip = &cfi->chips[chipnum];
> -			sect[sectors].offset = offset;
> +			sect[sectors].adr = adr;
>  			sect[sectors].locked = do_ppb_xxlock(
>  				map, &cfi->chips[chipnum], adr, 0,
>  				DO_XXLOCK_ONEBLOCK_GETLOCK);
> @@ -2716,7 +2716,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
>  	 */
>  	for (i = 0; i < sectors; i++) {
>  		if (sect[i].locked)
> -			do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0,
> +			do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0,
>  				      DO_XXLOCK_ONEBLOCK_LOCK);
>  	}
>  

  reply	other threads:[~2018-06-20  9:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05 14:07 [PATCH 1/2] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Joakim Tjernlund
2018-06-05 14:07 ` [PATCH 2/2] mtd: cfi_cmdset_0002: Avoid point less unlocking/locking Joakim Tjernlund
2018-06-05 15:14   ` Boris Brezillon
2018-06-05 16:57     ` Joakim Tjernlund
2018-06-06 10:15       ` Joakim Tjernlund
2018-06-19 17:23         ` Joakim Tjernlund
2018-06-05 15:02 ` [PATCH 1/2] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Boris Brezillon
2018-06-05 15:26 ` Boris Brezillon
2018-06-05 15:33   ` Joakim Tjernlund
2018-06-06 10:13   ` [PATCH v2 1/4] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() Joakim Tjernlund
2018-06-06 10:13     ` [PATCH v2 2/4] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Joakim Tjernlund
2018-06-20  9:06       ` Boris Brezillon [this message]
2018-06-06 10:13     ` [PATCH v2 3/4] mtd: cfi_cmdset_0002: Avoid point less unlocking/locking Joakim Tjernlund
2018-06-20  9:14       ` Boris Brezillon
2018-06-20 11:10         ` Joakim Tjernlund
2018-06-20 11:54           ` Boris Brezillon
2018-06-06 10:13     ` [PATCH v2 4/4] mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking Joakim Tjernlund
2018-06-20  9:25       ` Boris Brezillon
2018-06-20 11:10         ` Joakim Tjernlund
2018-06-20 12:19           ` Boris Brezillon
2018-06-20 15:07             ` Joakim Tjernlund
2018-06-20  9:03     ` [PATCH v2 1/4] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() Boris Brezillon
2018-06-20 11:10       ` Joakim Tjernlund
2018-06-22 11:35     ` Boris Brezillon

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=20180620110655.42ce6c1a@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=joakim.tjernlund@infinera.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=stable@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.