Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3006555imm; Sun, 1 Jul 2018 10:09:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJQvzWDoAHKyy/Ivug21swz2bhup8ChQA3vV2TCDSrPmBQbdiEcHzXAxNHoRlm1PSVMjkfv X-Received: by 2002:a17:902:bb05:: with SMTP id l5-v6mr22672442pls.246.1530464972605; Sun, 01 Jul 2018 10:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464972; cv=none; d=google.com; s=arc-20160816; b=rVM+M0B5lXIaWSf+A4QWW7s2Vx+hQtb7rUfgL9wR8rmPxTSxoCEqR+FV5aMgijEyWr nLynxpVCb7gLkcwqGuBwcLYeKG2ByTNKbiDxE3VWQme52XSHJXhp3BQrM5p5zi4OKr2b juzuZEYMxZvaqMgbpCpfBlebgV3i7D6IcjC/MCA3QxaKzPpmUpheiTZvmOgLozBADPQf 80hXuf11P4ieIq1n6lFoLxijHgL+2ERNHmW9Lt1Yv7H5RbCvBpHC5fX5J2y57DXhjU3r v4I55qmnEaCPraw/9cwGMUhQtP7kA/xnVvOVMUOFwCv7vykda1TPNtca21uhPqOpF4FH FnXw== 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=AEwOsX9/t4L/LCxjewwOXvdlVz/bsTFkTyIFwIEL8BQ=; b=P0fZDb7vba7ltlQmX2xNqHv4DsIjinHeDvq1ELaiHUQLt7n4pYyKgXO8jvU5wJ2RdV 0hAt7QOgl2l9nS6pAGCUGzZdtF8N34xJpNe/PbNFK/XGj8kutovxiPzdB4WYnQH+D/Cl LnelDC5YdARn/gjAtsI1FADCpR3Ed0upWn57G9sN5Ih9nwc7A31slMo0OKjAiwqcgdcS Lml2wWpLmwQzYoMX7DqLgTar+Lf4mX5A3It3SLBK08++ouIoUM0X41DhW3ULoZ+YC591 b+MY9UBrdOQFzc9GzvlVdhg9p1Ijb/uKRdWaPYeWdc2YUMaRKx2R2Gg2poDL3vfJAtzS ZEBg== 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 f5-v6si13699021plr.56.2018.07.01.10.09.18; Sun, 01 Jul 2018 10:09:32 -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 S933988AbeGARIn (ORCPT + 99 others); Sun, 1 Jul 2018 13:08:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37388 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032051AbeGAQl3 (ORCPT ); Sun, 1 Jul 2018 12:41:29 -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 54616AA6; Sun, 1 Jul 2018 16:41:28 +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 106/220] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() Date: Sun, 1 Jul 2018 18:22:10 +0200 Message-Id: <20180701160912.814828524@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 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 @@ -2533,8 +2533,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; @@ -2552,8 +2553,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 @@ -2591,7 +2592,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;