Received: by 10.223.185.116 with SMTP id b49csp819834wrg; Sat, 10 Feb 2018 21:07:49 -0800 (PST) X-Google-Smtp-Source: AH8x225fprliosU9iuVeh2Yi6/RynLyvCtRtX8GnvRh/0fBwNcK7wLC6B/0guaLBs6YHBuUOQD55 X-Received: by 10.101.83.195 with SMTP id z3mr6443087pgr.133.1518325669422; Sat, 10 Feb 2018 21:07:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518325669; cv=none; d=google.com; s=arc-20160816; b=GOYbiAFoxj3Z0vlU70DNb8C2vjKVcswlj3KbgiLW588iqavR3z8BYdzAnP88UOeB3z GXmT00drvyWAy7FhHzoLBn7W8mjMQh3Wa8RtROIOA00sdNXHn1MAtXADSIHNtv/d9V6h uVpkjNtrs/o4UFze95jtxXP/MCT3Th7PsCrKREc8Usb11S8H35MJYbhjqEi2A4jd3Dwk 3dkERLBUZCYcAvBA2sKmiamDhOKrSClHngrvdhKaG59G+xQ1Ca+RgxnHzfQLyn1L+QBJ 8IP+Sz0h12/BscGR8FQFKxwBBuTnXQuJMHtklQnAwKDv27p+w94MB68nsrKsAErGhC8y B0MA== 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 :arc-authentication-results; bh=y606sNS29rhpbq9PO3DqtEwfYsNZWGFu4tvZ4pIHdIQ=; b=oT8/qVK9W+/0/H5uASh5x6mSx6G563VJTrlXrkKmSp2PipaNUqyJk0/qms2cYMGbm+ bQmTIsP4Wz4Tp9BEYRX53QvLVh/Yt1fPkoOLmZTySUr/eGRDCE/PIcAMqFtmJ1HavW8u 1yqqhUTHi9I1zIAS0HhfQOi19Ed5aKmVdOdnPBJEgRAn9mRIM6dACMqkGZBF/UEFf4CM kRvlcep0vcatu6txMp/gB+kKTbfaCCXjJ2vcIevBKbcLzxYQD9oX+qriCRnl5pML+weW woJ5r52CmwVgfV0an1CWeeCzniG1DPu55DfVvqLcyVlTjEKQ2BXsRh2V3kUk+3WmB8eZ zbvg== 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 x10-v6si2807286plm.261.2018.02.10.21.07.35; Sat, 10 Feb 2018 21:07:49 -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 S1753913AbeBKFFs (ORCPT + 99 others); Sun, 11 Feb 2018 00:05:48 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41500 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752676AbeBKEdn (ORCPT ); Sat, 10 Feb 2018 23:33:43 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekjKe-0002hQ-Tj; Sun, 11 Feb 2018 04:33:41 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKX-0004TH-Jv; Sun, 11 Feb 2018 04:33:33 +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" , "Brent Taylor" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 23/79] mtd: nand: Fix writing mtdoops to nand flash. In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Brent Taylor commit 30863e38ebeb500a31cecee8096fb5002677dd9b upstream. When mtdoops calls mtd_panic_write(), it eventually calls panic_nand_write() in nand_base.c. In order to properly wait for the nand chip to be ready in panic_nand_wait(), the chip must first be selected. When using the atmel nand flash controller, a panic would occur due to a NULL pointer exception. Fixes: 2af7c6539931 ("mtd: Add panic_write for NAND flashes") Signed-off-by: Brent Taylor Signed-off-by: Boris Brezillon [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- drivers/mtd/nand/nand_base.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -2290,6 +2290,7 @@ static int panic_nand_write(struct mtd_i size_t *retlen, const uint8_t *buf) { struct nand_chip *chip = mtd->priv; + int chipnr = (int)(to >> chip->chip_shift); struct mtd_oob_ops ops; int ret; @@ -2299,12 +2300,14 @@ static int panic_nand_write(struct mtd_i if (!len) return 0; - /* Wait for the device to get ready */ - panic_nand_wait(mtd, chip, 400); - /* Grab the device */ panic_nand_get_device(chip, mtd, FL_WRITING); + chip->select_chip(mtd, chipnr); + + /* Wait for the device to get ready */ + panic_nand_wait(mtd, chip, 400); + ops.len = len; ops.datbuf = (uint8_t *)buf; ops.oobbuf = NULL;