Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3055945imm; Sun, 1 Jul 2018 11:12:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZU/PmRYBgk2Rj+KYH/G0lteoXBu1s7DMgrW8/0FvzdojGYaj8tPOx2DY/yPcPDJxG6zjd X-Received: by 2002:a65:62cd:: with SMTP id m13-v6mr19179894pgv.280.1530468748444; Sun, 01 Jul 2018 11:12:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530468748; cv=none; d=google.com; s=arc-20160816; b=Dg6sngSd4DmWU7wIx0IV4/KNAl1IvCL8WEBR5Ih0GliHIq/GrSRSdwRFvdT6CtiXbh ukweIZ/dPhqnVUBetUfRweO85MhFtTx/ZIwXzWNENy97ClDeTbrmF9oBn8NtJbawIXwh FNKkzCcf2N1p7Ly/LUmxCZ80uEBL/RexCt7DdrlajIAZDXbNTpMVBluRlDk2GPxzg3/f ycMQD7VvaB1qQHLIH14WXzvNz2voMUqV4rf4BSQZ/4bNG/kHOUddCBfe+FeAKlj7iTSo F+dHEBA4Vhm92Wu9kgmKF+Mci9VhrInbnTVYqPxMcLycyMJyS9xCjoHM/dEvxHTx0O2O OFHw== 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=QwWIsRDBe3BRMUobhbJ89ZQhXkY+4we6Ee9t94epM/E=; b=mYSaiIFpm6UwraQi6cM2EIdUEGG2k1MF8/xwCmJkDQv9pG0HVypGIF7/4dneoZSuBb 6e5DVl2yaFmHZFktA4WGqE+246QfZDL7Mf9THZZF1eZhVbIGv5KbJdBgdfofBHHm1DjZ SY+y2qLj5s0FG172s2h2bC3WYxN1dZUtW9UaeEzl5rD8yLEcpQ25wzcOfKWsoKWiWhwM QlVwmVsV5cUk6UlrvrJ7gGXf41eTCN9be5JaEboqSmrJMeUUWVBI/9TE9hwt+zX0ftig Rg8k8YP3DLdbvtUTypSO4WiQ9ZTG2urQ1+sqUTP2S+Tj2eqlIxdHEqqXtWsEu/ywH1xD 0dUQ== 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 x19-v6si14229999plr.15.2018.07.01.11.12.13; Sun, 01 Jul 2018 11:12:28 -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 S965637AbeGASLE (ORCPT + 99 others); Sun, 1 Jul 2018 14:11:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34160 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965557AbeGAQ1o (ORCPT ); Sun, 1 Jul 2018 12:27:44 -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 32E51AA6; Sun, 1 Jul 2018 16:27:44 +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 041/101] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() Date: Sun, 1 Jul 2018 18:21:27 +0200 Message-Id: <20180701160758.807905180@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 f93aa8c4de307069c270b2d81741961162bead6c upstream. do_ppb_xxlock() fails to add chip->start when querying for lock status (and chip_ready test), which caused false status reports. Fix that by adding adr += chip->start and adjust call sites accordingly. 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2549,8 +2549,9 @@ static int __maybe_unused do_ppb_xxlock( unsigned long timeo; int ret; + adr += chip->start; mutex_lock(&chip->mutex); - ret = get_chip(map, chip, adr + chip->start, FL_LOCKING); + ret = get_chip(map, chip, adr, FL_LOCKING); if (ret) { mutex_unlock(&chip->mutex); return ret; @@ -2568,8 +2569,8 @@ static int __maybe_unused do_ppb_xxlock( if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { chip->state = FL_LOCKING; - map_write(map, CMD(0xA0), chip->start + adr); - map_write(map, CMD(0x00), chip->start + adr); + map_write(map, CMD(0xA0), adr); + map_write(map, CMD(0x00), adr); } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) { /* * Unlocking of one specific sector is not supported, so we @@ -2607,7 +2608,7 @@ static int __maybe_unused do_ppb_xxlock( map_write(map, CMD(0x00), chip->start); chip->state = FL_READY; - put_chip(map, chip, adr + chip->start); + put_chip(map, chip, adr); mutex_unlock(&chip->mutex); return ret;