Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3069499imm; Sun, 1 Jul 2018 11:31:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLX/Ulimmw/UxtKSqiuCmnD4CMplDrjgZ56oRIhKcxRIQMj7/FR7+QqWZuBqgT1Lbms77i9 X-Received: by 2002:a17:902:e85:: with SMTP id 5-v6mr23039876plx.318.1530469916892; Sun, 01 Jul 2018 11:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530469916; cv=none; d=google.com; s=arc-20160816; b=PjUc5BjuHtmEudRZofT40yiHq8BF3fmVV/CkGzmBV8TnQs56CfLleWDsKpktvd9Isn JT9I6F4zvSABpGzsFBRXn31yS2b3rZReHsaEvCAAWXKjhUG9y1qr8iq1TGeulfUqUqgi 8TpkhD/i8x2oZWRicztsZEbqFBL0Em4soKbtNGDhLLtTWDbY+QLiymuAr/F2mlbd0dvS QXxHbBwrTXEqOh9JZOXGOYqLqINPX36Ahuloop2NER+jWWk4+IxO4BVo2WoHY8OzSo4M C5VM8HCdPAHDDv5pI+7m782n4VKFIhnpFLwRsYhvV1rI0ClCgUpSBe6s6hmL9Tq7gGA8 RVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=f1kWgo6mYdNotHS5ZBaMRA6HCzMWYKaB1cgjuxyvet0=; b=GcVm5dT8X3o1yblXw53p7fS4mIVcubK4IgRLD0g/pGt+6oSBt6lJHhYfdHJ9ZYdWNf QLOW9u2oCYBjwTGPz5LdJ+3yPzHR2ommdJ1cf4MpRWqpIjcecpv0WUdrDpjTl2QkCr9U cSPzY5KgQszuhZhEDImDAVLx5/bWTKGf7FVOdO17Cg/K+461quPyWswGOG7JOTRfMwFl tKLidJwfE6s/UtLx0LmYW32GH8+88WXZRA+/b3ZbD3M4q9d059FBhFg97xN+/RMmZ8RD 2u4jtvszWXIUmXjGFtAyCDVMAPyNoJo5nlLYKlNoTGmE8M5ObWLzJW1r0FxLni7NRuW3 8fTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h8-v6si13777582pls.69.2018.07.01.11.31.42; Sun, 01 Jul 2018 11:31:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964783AbeGAQRZ (ORCPT + 99 others); Sun, 1 Jul 2018 12:17:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:32778 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933695AbeGAQRW (ORCPT ); Sun, 1 Jul 2018 12:17:22 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0001992B; Sun, 1 Jul 2018 16:17:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joakim Tjernlund , Boris Brezillon Subject: [PATCH 4.4 055/105] mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary Date: Sun, 1 Jul 2018 18:02:05 +0200 Message-Id: <20180701153153.519042281@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153149.382300170@linuxfoundation.org> References: <20180701153149.382300170@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joakim Tjernlund commit 0cd8116f172eed018907303dbff5c112690eeb91 upstream. The "sector is in requested range" test used to determine whether sectors should be re-locked or not is done on a variable that is reset everytime we cross a chip boundary, which can lead to some blocks being re-locked while the caller expect them to be unlocked. Fix the check to make sure this cannot happen. Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2667,7 +2667,7 @@ static int __maybe_unused cfi_ppb_unlock * sectors shall be unlocked, so lets keep their locking * status at "unlocked" (locked=0) for the final re-locking. */ - if ((adr < ofs) || (adr >= (ofs + len))) { + if ((offset < ofs) || (offset >= (ofs + len))) { sect[sectors].chip = &cfi->chips[chipnum]; sect[sectors].adr = adr; sect[sectors].locked = do_ppb_xxlock(