Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3076592imm; Sun, 1 Jul 2018 11:42:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd2aLK1qBnOEeEvW7MmPSK9+TX6sYg0E3zQg22HuLp18qnUjUCBsKPqchy5X/UzTLMAjdhP X-Received: by 2002:a62:170c:: with SMTP id 12-v6mr22482939pfx.139.1530470574836; Sun, 01 Jul 2018 11:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530470574; cv=none; d=google.com; s=arc-20160816; b=g0sysGTbo0DGhsf/uNZ6Ln+PqLfxSaS2+9Y7K2q9SmY9CDZ4wbIyxr5OKtw3oUgEL7 kne9TCWVzHnsbbMuhG4O8WvAdRQxlD5n1vurYZjnLfTWeLgYqspPyaDCZvdRC3A/e7G9 fKTJMONcce5cCdLT3/EaofCiJPPF89b4sev5H/BQOE1gN8Cpdcrt1T7H9pG1UTEJG8tB LI8hCgsYylHOd3yoyomHMF7JgQSu2uityXtQjl4ANuSAA4a6nq8KPSiciVYMmLlpKVEK +7AKDWzWtZYLs18+oY6Gn4JdWkrSvdBP4E3VqOQPyGlCaHN+7Nk/EfUyUb8fR8N0jKDs atrA== 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=psuHBfXFum7xx04/Wf+WmZ28zsmErHngIGodse1GJCI=; b=GziFortj/Iv7dkN/zbcYPBx/eTZs6tp+jxtiK/U4UJA5i9hy3BCJRrxRm+Ti6nXtbd BQlPYxwePys4dqgkT58N63b/UrPp4DyCXK88mks7/QHxAW2sntAeHEkgXPQfTVLJbDOf 5M14ETORMIisvwecHmahnd/2uJLT8YTtA3Dp03QHDu7AUsIkeJCd7d+enfTbPhZOcO+c TxW8Hf1bSoYMWz4uDnh6IGC9qi/D15JUtuKEahU1gO9hwtlMtjB9/rKNqsgtpg70F1wy g92jgI7hZdvAQVcdTAOgI+U0nFb6XB2jdiVW6dym3KgWQ7T3fcmQ0FEH2Fjy5ao+IH74 6NyA== 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 x3-v6si15630266pfj.289.2018.07.01.11.42.40; Sun, 01 Jul 2018 11:42:54 -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 S1753212AbeGASl6 (ORCPT + 99 others); Sun, 1 Jul 2018 14:41:58 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60206 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932644AbeGAQNq (ORCPT ); Sun, 1 Jul 2018 12:13:46 -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 1E39F4A3; Sun, 1 Jul 2018 16:13:45 +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 3.18 66/85] mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary Date: Sun, 1 Jul 2018 18:02:24 +0200 Message-Id: <20180701153125.012309502@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701153122.365061142@linuxfoundation.org> References: <20180701153122.365061142@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 3.18-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(