Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3493102imu; Sun, 11 Nov 2018 16:20:35 -0800 (PST) X-Google-Smtp-Source: AJdET5dEG5kNTwxbO3Q1qX4YjMQevUS0EdFRzFz0TIkWU2kljMHnj8Dzw/UcHw+5bhyN7iDD0pH5 X-Received: by 2002:a17:902:8306:: with SMTP id bd6-v6mr17966877plb.321.1541982035230; Sun, 11 Nov 2018 16:20:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541982035; cv=none; d=google.com; s=arc-20160816; b=08IVac0c508xi61vKs8hkI/8vp4BwbDbJeahMfGjld5CObCDcxL8d0GVKsg3FOhGXH OwMY6KQ2iYupK+kiCJb76M9kYZivJ68Io7bhzxoKXxGqSblujsG5mcTbKh+rOb62kXck Ig/pk1f+DVK0YzbGVQr11oqK4dqjdWUaERTYUfvh/7iVE7+KXxPqybsFnZufLkYrRKCY FIed/MULtNJ65lBOVA6n0bNrAQyks2z+cFYKOmKc2YgqRByVhLAhH9LxJyxBs5M2iTkI Hv/yE9nWKDHBnamCWzHOBwvlcbv7ceej9hwMi7fO1FErnN1T0I06c78rTKQVM1odhnmI 75Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5DMU1stctBbLuycVQsRwAFyBos0Dpx55GJ+z8XH+z54=; b=S+cqXCigkPCaIeI8n9UdGkwpIHEt5EdKOtyXYbT/iSqhcZW+dceA8p96oWRXOtsQ2s wGTuLYw0jAsdqhXuuYBSltmpN2PEuYMYzIbzVBMNHiHVWS8uTfBzTldMBAy9ZUkHjeDh 5Mg/mCV6FTvGLGiXVt2RCL2gHL27qZ9VLsm9N5kXSMGbvNqry+qeYGbYFold0LTZbEYr j2ae9qcLWz6qqZeoieiSdq6jUF9W5wuo+4uV+ThDaMZvP0w4nWmZhhIy7hdN4iZ2Kjcb 6qx27inXHv+vRbdSq3aqrGwK6RnOjG1124bzxOAjoQJX1/Zg0tdUf18paJQidyJHmHvk z2MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NXQom0Kq; 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 l8si13894046pgr.345.2018.11.11.16.20.20; Sun, 11 Nov 2018 16:20:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=NXQom0Kq; 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 S1730345AbeKLKJM (ORCPT + 99 others); Mon, 12 Nov 2018 05:09:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:58446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729918AbeKLIQ6 (ORCPT ); Mon, 12 Nov 2018 03:16:58 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 277CB214F1; Sun, 11 Nov 2018 22:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975223; bh=9swfgSmAHjZZyr+P/Ut6mXdgQdBN/ToIzj/STWHgm7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NXQom0KqglSKNx6CRNN66LYKmWx9t0BzEXpDC37YdQe6eoFovFSo4ZpR4uKJoKq89 7JshJv0j4G9jvatExt1jbXQYCy/h3CV1mvbja8hxx41UHT0CrfWP42oR5y9WvLUsrL SFFmmfxRUrwaoyWQh5ay59/L2ymPBYmsUMsvQnU8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ahmad Fatoum , Boris Brezillon Subject: [PATCH 4.19 008/361] mtd: spi-nor: fsl-quadspi: Dont let -EINVAL on the bus Date: Sun, 11 Nov 2018 14:15:55 -0800 Message-Id: <20181111221621.132095362@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ahmad Fatoum commit 000412276370a9bcfec73b3752ceefd9a927f1db upstream. fsl_qspi_get_seqid() may return -EINVAL, but fsl_qspi_init_ahb_read() doesn't check for error codes with the result that -EINVAL could find itself signalled over the bus. In conjunction with the LS1046A SoC's A-009283 errata ("Illegal accesses to SPI flash memory can result in a system hang") this illegal access to SPI flash memory results in a system hang if userspace attempts reading later on. Avoid this by always checking fsl_qspi_get_seqid()'s return value and bail out otherwise. Fixes: e46ecda764dc ("mtd: spi-nor: Add Freescale QuadSPI driver") Cc: stable@vger.kernel.org Signed-off-by: Ahmad Fatoum Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/spi-nor/fsl-quadspi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/drivers/mtd/spi-nor/fsl-quadspi.c +++ b/drivers/mtd/spi-nor/fsl-quadspi.c @@ -544,6 +544,9 @@ fsl_qspi_runcmd(struct fsl_qspi *q, u8 c /* trigger the LUT now */ seqid = fsl_qspi_get_seqid(q, cmd); + if (seqid < 0) + return seqid; + qspi_writel(q, (seqid << QUADSPI_IPCR_SEQID_SHIFT) | len, base + QUADSPI_IPCR); @@ -672,7 +675,7 @@ static void fsl_qspi_set_map_addr(struct * causes the controller to clear the buffer, and use the sequence pointed * by the QUADSPI_BFGENCR[SEQID] to initiate a read from the flash. */ -static void fsl_qspi_init_ahb_read(struct fsl_qspi *q) +static int fsl_qspi_init_ahb_read(struct fsl_qspi *q) { void __iomem *base = q->iobase; int seqid; @@ -697,8 +700,13 @@ static void fsl_qspi_init_ahb_read(struc /* Set the default lut sequence for AHB Read. */ seqid = fsl_qspi_get_seqid(q, q->nor[0].read_opcode); + if (seqid < 0) + return seqid; + qspi_writel(q, seqid << QUADSPI_BFGENCR_SEQID_SHIFT, q->iobase + QUADSPI_BFGENCR); + + return 0; } /* This function was used to prepare and enable QSPI clock */ @@ -806,9 +814,7 @@ static int fsl_qspi_nor_setup_last(struc fsl_qspi_init_lut(q); /* Init for AHB read */ - fsl_qspi_init_ahb_read(q); - - return 0; + return fsl_qspi_init_ahb_read(q); } static const struct of_device_id fsl_qspi_dt_ids[] = {