Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3310367imu; Sun, 11 Nov 2018 12:06:33 -0800 (PST) X-Google-Smtp-Source: AJdET5ecD2H9q3xjMKRIOi+OiajJAvrZARsu+E+aAxzMYnspPA9Df0qNM26KKMeUJuuSdpavyA+l X-Received: by 2002:a17:902:7603:: with SMTP id k3-v6mr4960726pll.98.1541966793862; Sun, 11 Nov 2018 12:06:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966793; cv=none; d=google.com; s=arc-20160816; b=D53mbsWmtKu9nSTNPQB9YW1XzGJMsjci9o+q3KGWhSYmGjQzFnkP7Am0Y6qx0kLhiO bXtzZZZi7SI2iWYO/qys0QoVeJ4FNPRD8zOLsUkJbXq4QtumRpuP78lWw+MaF65hQwP7 Tn7iKtv/GJUIwab6RVVpEc6BhNsqat214gjy6vXnITkYS5BoNvh8OGkPdm3yQpYbfoiB GQUrHyNLaekelWk4PwFTNP5qVuNQ4Doijimh5UNzclXnvijchsHdOvWvcpCF+yHpGtta klRu7wljDTE0MHOjzbKMD590mSv0r5cbjvCfxei08oxlUOeW7mDxi0SJ3uA5A6EXE786 lMYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=zv5h5hUkadqkc6orMsKebP1aeTpmrbMX2Au1J/4Spcs=; b=fGmyU3z7itBDPW1E1dYKHbXfDuuBuY3OL+n1qkpM7JQoilD907+hbIu9exk4CazgJa Xm7+/FXawGiDusERJT0sm+78huvmCAjxY+/2T8pVpfnrGnMqfgUyC690h7Tzuf4iNDBD gYEQ/liJqMNyXs6jAwknKi7vkTUnllx55Ci4rECkNMMCUo6WBR9X3UTSj3DcZxqnwLoe qknqy6IRIMp8DxCtcHD9UgMk4NwSBWLw9mCVngNd93RmS6o082eFEwa0YG2D9qxmX4xd FfoT/avn7KC6aCpUfWJSsECtSTrWo54K4cAynURyUKb2X0VL8fGHhkDjdw/7dzlQUON7 eovQ== 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 e33-v6si15713681pld.314.2018.11.11.12.06.18; Sun, 11 Nov 2018 12:06:33 -0800 (PST) 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 S1731304AbeKLFzY (ORCPT + 99 others); Mon, 12 Nov 2018 00:55:24 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:51874 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726519AbeKLFzY (ORCPT ); Mon, 12 Nov 2018 00:55:24 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsz-0000oJ-Gq; Sun, 11 Nov 2018 19:59:09 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsS-0001aY-Vy; Sun, 11 Nov 2018 19:58:36 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Boris Brezillon" , "Joakim Tjernlund" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 161/366] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 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") Signed-off-by: Joakim Tjernlund Signed-off-by: Boris Brezillon Signed-off-by: Ben Hutchings --- 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 @@ -2224,8 +2224,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; @@ -2243,8 +2244,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 @@ -2282,7 +2283,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;