Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2973569imm; Sun, 1 Jul 2018 09:28:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLFKlZ/QudpNH9+FmxVOXHsc5WQ0JFmFUcOLG+ulvVwGt3t+wbOk2eaQX53ud2pKpcmLWV7 X-Received: by 2002:a63:6741:: with SMTP id b62-v6mr19128807pgc.5.1530462523351; Sun, 01 Jul 2018 09:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530462523; cv=none; d=google.com; s=arc-20160816; b=0l8IkfnA5f7BShNh58VpTl7CKvSLFu4zUMPnexiamfYSMtXdwpeSdh1SeJmDU3CBWH RWr/oV8OqqRGUvJXXt6jBzQl4V98gBOp8XRpD0v1tVQKKtgkEX5UK7kI+HfPol/VsOTq P3qoUUbAvfpnbyvlNHs+Vlqta/gmOf6TLrfkcwqhNNdud2Xn6BcTupIuTlA0GPWQWsmE 1cTaFU5lomyDtP5afTccyHtxeznVNUwXggkktV8jxGlSlaf6FwZKeNYOkVH4FJ/gqHq+ YBrKNJeIGQVoPqrOFwYTMkhutVE0T4S9/3TJ3Gmnxw4HVFN0ftm+byZDCXzibmJMI7TA fbRg== 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=KHxYEgDT/kqs5r5o4MLV6X8+G1j7MVYoBJuhngcmBHo=; b=afIWmRQpEAm0KZYpxgsF4fNquILf4STUQVew30belD/sHNGKI0zf8RpuhALVrokUxI bQtJ8GRuZ74ZYYkSoZwWQwIJZr3BR5ni/yVBoX+aSuJ+iMfKp+fFvByp1A3BMEvrhj3S EsUOPpcNTW1Lt6UW3RJ0QMFhW0fn0UE2aGUbhH2nvuaDJWlb64VcgR07b/oYUUQTs52K Ltli94I5TAGNfpXMWCsBGSuFXThUULEygRPGIMpSAsbEYyUrDPBIEDJoAF6F4s6mPiGO 1CPyST/R5RrJ1LPmHPKnn3U7t0K1cYdvKsPSn5u0yET1MPp717yPWSKpJRLAYPlljv8W Ow4w== 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 a4-v6si14060112plp.219.2018.07.01.09.28.29; Sun, 01 Jul 2018 09:28:43 -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 S965597AbeGAQ1w (ORCPT + 99 others); Sun, 1 Jul 2018 12:27:52 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34202 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965572AbeGAQ1u (ORCPT ); Sun, 1 Jul 2018 12:27:50 -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 1D42692B; Sun, 1 Jul 2018 16:27:49 +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.9 043/101] mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary Date: Sun, 1 Jul 2018 18:21:29 +0200 Message-Id: <20180701160758.884263740@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160757.138608453@linuxfoundation.org> References: <20180701160757.138608453@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.9-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 @@ -2665,7 +2665,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(