Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3006383imm; Sun, 1 Jul 2018 10:09:20 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI8qZpv1TBGuUsVYSIFhxorD1v6K0qqU5xYrwP4ye7rXNG/w5BKzf9qUyRMGmHSYbvS/8pe X-Received: by 2002:a63:370f:: with SMTP id e15-v6mr18847705pga.192.1530464960653; Sun, 01 Jul 2018 10:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464960; cv=none; d=google.com; s=arc-20160816; b=dwgiYx/ufuJ2GYRl/CWOIFyCV4M293VIr0VK2EZSXca6v7MpL2p2vHIKb9VKiWzOyT VBVz+KXvSk6zI1n83y5Q+kVdq/5QQs9fPrw5WyJu9yZwavkdE9RZLL9BrvdCjCDdzi8U dqQ3wZsgzL1jVA3JJ0nEjMWxxmVYnQqsyCCnYJvPi1vnlRrL3A3MXDqAYWyCybbxoXgD FjOzwWSwXA82nu94X4t12gibv/wMAPqAObx4QtOkpnl5Tjx68Qh4o45spyox2OiSdt9W I5CwpfyAOxAfwgFCvs8bRWqN9/7T8fyMwfKiocdG7FQ/P1/P7C8rEf/b707kSFwEB1XZ gQrw== 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=HuECT04fjzaknaEPRrCzAM0y9A5d7pPD/Gvh+tA1Wy8=; b=LMtgM4HssDJ3n9hLIM/Quq1dtXIjxtp9t3h0CuoOe+Ux52Qg7oq+440xqHNOZ4A8iQ OFSwiGTRCl8a1fiW/hEuOvhD00dQ+qa2lqo+/9EsM3JhNs4BzSYUYNEFqaTHQLOb/9lf 2GzEQcvM/hbiG/jO9tt5hpP+Mqn+87PuMOkbZi5Rh5c954lA9bqWP26n5R3MReHT6jhk KamGdZ0ULIdK9bNYn54bMnEBK9OdVFNQKZTzHPMtdmbRyGSj5kc9LDUwJBFTJ99z4tpN axxL+t4MsTyyEqMg5768NAUoNulpTvA91j6DioendYenPtioGvJJPFoydveEBW1c5CVT ZXhg== 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 t12-v6si12046380pgp.565.2018.07.01.10.09.06; Sun, 01 Jul 2018 10:09:20 -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 S933948AbeGARIZ (ORCPT + 99 others); Sun, 1 Jul 2018 13:08:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37402 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032064AbeGAQle (ORCPT ); Sun, 1 Jul 2018 12:41:34 -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 B6DD5AA6; Sun, 1 Jul 2018 16:41:33 +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.17 108/220] mtd: cfi_cmdset_0002: Fix unlocking requests crossing a chip boudary Date: Sun, 1 Jul 2018 18:22:12 +0200 Message-Id: <20180701160912.891492771@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@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.17-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 @@ -2649,7 +2649,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(