From patchwork Fri Aug 28 08:53:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehmet Fide X-Patchwork-Id: 2293957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hWXHc1DXxz1xvq for ; Fri, 28 Aug 2026 18:54:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XZGx3hs8HYaUsRiNJHISv7y4rEZeKV01KuRORS8ZPtM=; b=JjF2/XdQtcaIWF pO2yPa/8whmLJwJ/rYCjDHsARuyzrMHNnnDA/iiJHEMKq8oFQc50CauoNECelqh2CPtlHQk+bQzO9 qbzVxzc41/m75+G5lXkQlCXaMlgb1oM5Wf4mYLI4xH2nj0lcrXGAArhbBaQ6dnsutW+GdW3ngqgnB jpZLEO/YzBthwLL6rbBukZRDt3/fQZ2kNXP2/Z+IFr8Hjv1bAGIXl1sNsoYrRBDHaMlau8sX125HD EvNY/pPeJpZ+2Bv5ACtokZnSvF/O+ufQ0MshSTNdgUevWKXvi3C8lHygkp3lknSej/0D19Dl1c9k+ LyGAMlSD0e/jtsG6vLgw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wzsLN-00000005MvW-20sT; Fri, 28 Aug 2026 08:53:49 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wzsLI-00000005Mt7-3hgn for linux-mtd@lists.infradead.org; Fri, 28 Aug 2026 08:53:46 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-482e2904915so513084f8f.0 for ; Fri, 28 Aug 2026 01:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787907223; x=1788512023; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lhmXMGSEBsCnlvTzh8T6ufA5k4c6HxTFoY+6zbiHuaU=; b=FUQpkJrVWpJOVX4FymFLtBsn3E3UYyzFyuBdWl7McPucX87Bp7Ihghp3slMLJ/Qdjs HmZIyf4zbzO9k5lBHYVC4BbPKdigrAvMHvWJatvnK9cOPgPfR0w8SXsNBvdpsDjz6qlj U531p2pIj2xxQ5DezsLU0A5gWmlgWpzdprAD5bT+ioCa2g/HYifY2irpOdfXnf9mF3y0 fXaEUG/pDDO5RSf66HvoYb0tNA1t5rp+sqMj6sXF9h0A76WZ43FqpmbQdF3YjjHGvINM lTKBbriD20SxsPbrZegUcLzL6kjAm+TaMvZS+AP3qEnu/Jxpp29hKuZgw8oCawaasw3X Tfig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787907223; x=1788512023; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lhmXMGSEBsCnlvTzh8T6ufA5k4c6HxTFoY+6zbiHuaU=; b=jRSF4HgdfVz94hzGTZEtMd3U1AERAcfx14PQXltOWd/uv823wnYz6F1UGHBJPAKWTh vGy8H4ag4yu6ycMLDbuhofD834dlAWJGypvIlocFWdWoK6vCJPonFfnacmRqBk3qqlub TH5ms6eRMpjr0pQmc5VUloJrCUtm8OaFLSEIDvzBKDOrE0aSY92toh39F0N2XP/oL9UG Xt8smNvoH68GoalkxMoNXUJe/+HKVPj3IguE300+5lvoWP08ad7EP9Bjlyi/X2X0YylV 7p7KvN1J97uuuk0VJ61RO/lGXUw6kOrXLyHyJPPOyXn5mQzdI1i9ptZ8PL15WRmfscFB 3ooA== X-Forwarded-Encrypted: i=1; AHgh+RrkvYP3MIFSb87CAvObgQlRuqJaj5gcMZ33R+xtqRJfkDe2h1san4AZOeG6lK5OvFeeClujXa8N+yw=@lists.infradead.org X-Gm-Message-State: AFuF++msQwOWyfWH2TO8xst+jrBJfvzawSPGPnC5Dt8xxmDkXJNKWEAr xWqHw4bHNB9xQ3BGQ22q3q6bJHAvJkgRR1bOZDKHHxUCV0nZZ22zniP/ X-Gm-Gg: AR+sD10KnnMrdVeVFmlZAuD5SoPNevrtr5yxFRRAg4ZiP4412XMeqfpVjsJ31WDopYQ aDcBxGn/BL4Uhv0AsBLKGGasGLtHaEvaW/u4cyGt6UpItUBxaYxAxBKdPokLYCPE1tTf1NnmEBD Vj+VXlghR6eBDM93/6eLJ9UHjIhyUm3Sxxu5FNb55XJDN9KQ+2LWOZlKQcJXi8j/UT8wJtTctpY 22Lj8m1KP1NrFArPwHeLxHGe9lJwMxKcbxqpRe6C0Fp+hyxhkNp2E8EMVMy+Ch6uNoYcVFqMNC/ dTXt0CL5DQ7YauMiWolhC2qWTsk2M/KD4ruUmshiK5/OrntMTIGCXt4MgxeGoM/DhX5rsfxL1Qm Bdqt+tmCD9ct2r4Kh3A+PxxsqOs6gFqbxBVCn7ZEXXU52u4bdT3mxDwfvnVJ1JGW0dcOkf5yDWZ GBOOA667tmRJeJdp2kdMr4N+FMO79uQ6e3BRKdrJiIv85WW3mHsT+/kKaG5UHl1HO1Xg== X-Received: by 2002:a05:600c:c0cf:b0:499:726b:7375 with SMTP id 5b1f17b1804b1-49b91c51e62mr67153615e9.14.1787907222695; Fri, 28 Aug 2026 01:53:42 -0700 (PDT) Received: from deb05.proceq.com ([213.160.61.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49b926874fdsm43155175e9.4.2026.08.28.01.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 01:53:42 -0700 (PDT) From: Mehmet Fide To: Miquel Raynal Cc: Stefan Agner , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , Bill Pringlemeir , Brian Norris , Alexey Klimov , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] mtd: rawnand: vf610_nfc: write the OOB bytes on page writes Date: Fri, 28 Aug 2026 10:53:39 +0200 Message-ID: <20260828085340.3916239-2-mehmet.fide@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260828085340.3916239-1-mehmet.fide@gmail.com> References: <20260828085340.3916239-1-mehmet.fide@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260828_015344_937954_AB3BC6BB X-CRM114-Status: GOOD ( 13.44 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Mehmet Fide The ECC page write transfers writesize plus the spare area from the controller SRAM, but only the data half of the SRAM buffer is filled: the conversion to ->exec_op() dropped the vf610_nfc_write_buf( [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:42d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [mehmet.fide(at)gmail.com] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Mehmet Fide The ECC page write transfers writesize plus the spare area from the controller SRAM, but only the data half of the SRAM buffer is filled: the conversion to ->exec_op() dropped the vf610_nfc_write_buf() call that used to copy chip->oob_poi, so whatever the previous transfer left in the spare region of the buffer is programmed into the OOB of every written page. User OOB data is silently lost and the free OOB bytes of a freshly written page read back as leftovers of an earlier page. Copy the spare bytes into the SRAM buffer before starting the program operation. The copy is unconditional: the NAND core fills chip->oob_poi with 0xff when the caller writes no OOB, and the ECC engine overwrites the parity region on its way to the flash, so this also stops the stale-buffer leak into the free bytes. Fixes: 1cbe30b0ddc7 ("mtd: rawnand: vf610_nfc: make use of ->exec_op()") Cc: stable@vger.kernel.org Signed-off-by: Mehmet Fide --- drivers/mtd/nand/raw/vf610_nfc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index ffcf66f96c7f..f831780d6fff 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -633,6 +633,9 @@ static int vf610_nfc_write_page(struct nand_chip *chip, const uint8_t *buf, */ vf610_nfc_wr_to_sram(nfc->regs + NFC_MAIN_AREA(0), buf, mtd->writesize, false); + /* Fill the spare area too; oob_poi is 0xff when the caller writes no OOB */ + vf610_nfc_wr_to_sram(nfc->regs + NFC_MAIN_AREA(0) + mtd->writesize, + chip->oob_poi, vf610_nfc_spare_size(mtd), false); code |= COMMAND_RB_HANDSHAKE; cmd2 |= code << CMD_CODE_SHIFT; From patchwork Fri Aug 28 08:53:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mehmet Fide X-Patchwork-Id: 2293956 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=aikINvRN; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=BsG05O/N; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hWXHg0W40z1y12 for ; Fri, 28 Aug 2026 18:54:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=b90BPPNonsTG76AiXBwbWszisidbzqYjIZLbDL9IAos=; b=aikINvRN6/l236 kn5lFCcTM9zFkw4fslrGKeu0egJEqJqyon1WTTfP+ur1qoeNzMAetZOjzxMB1/XsHjobdT0RmXScC 3SgXazNlqFprIRvwwkdWCWHeMbps6W4QRd7eH1Gfkef+1kWEHz8T9rLjI97iieKFJfJRQvRu0VHVm 4k91tipb39kqCQpTqV+A9/p3tYpJVkkkPKIwvTReSjefy++pipVJOA5NWzFvz/Hhs/n/IPehO3j2M 0mO3egSevyhBNJtRBhXtwcYOyy8wudPbs+N2V7uV6ddFue/jonPO0UcgHuwhdja3U8+3A6p3ZeytC dhD4VeZaLMOC53+6pwPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wzsLN-00000005Mvh-2TzO; Fri, 28 Aug 2026 08:53:49 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wzsLJ-00000005MtR-1sDB for linux-mtd@lists.infradead.org; Fri, 28 Aug 2026 08:53:46 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-499ac87c92bso6184465e9.1 for ; Fri, 28 Aug 2026 01:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787907224; x=1788512024; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vtwEXzyI/WEatI7C9Ufc77ZLEa/MCSb7xNe3YfRc2+E=; b=BsG05O/NGLfKNw1Io7TP68S2Jku2dIF1CvZ2VMs3bttJDcvFkKDLMogvf2UeEy6Ldn 2VnQA96+gz1dX06T8lEb+mBYyBxP6ScVqwetDqNnqIoxho+/lIInD6QW++zvIADYv3tc BXG7hodwlWnzLxy59Wn5nGixgYhxz0SusnqP9XTS899ClI2xI17A2b3YjlCxqKQnFJQg FH2r8b4mHzbGCV4h6+S3iaAywiWGqAguuaDe6CI3CSQcf/n14meSl+IT7lk/ip9psKkQ L+SRtqfj+8lut4mfAoxdqecMXxzpTUYhhER8JU5Vh6wlEWRrFbv/kgFhujS3P8q/9lQN 90UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787907224; x=1788512024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vtwEXzyI/WEatI7C9Ufc77ZLEa/MCSb7xNe3YfRc2+E=; b=lzTIJ2CgwYQsqREla5glxxyJBWMZQGg/sQiInqaWUNeSll4DZNVUb9m22m5yLq682e ZKz4f1Zc5sAr3g7XZvmnKZeSTDB3upgs5J6QmV3WS+TluOnIG8xUMoRD8QtnstYageCo trboKjPOOeCWp7iSQI84+1XM++h2VkFu07ChRXLvsMY074uWIUfk66qU2/0Dj3RkQLwH 5/Sg/Aj/oGE7UAzFOTePQLGtYVLozWI2CDC3gFly7OOn0/ZEb5qcPzHEFW+pvcUFdEls G/IbtoDHuoIgj0gdwtPsiw5o7mm6uhhKaLylodGzZbS7892WFFhFx+UeaB4Zngz+OKzz wkCA== X-Forwarded-Encrypted: i=1; AHgh+RrjUeybMVO5bh0lzrYi5lhVpDM2IQ937cyHgvwkedRj2IpordYZX/gV5ERB79FWNJTqm6DSHo1Vb3k=@lists.infradead.org X-Gm-Message-State: AFuF++k32h1leJUvCjULsF/DdjOnWJ3tEcMG7qSlR3I/+DyM7I9HujjA FphkFn6uQYWgczD+y6Isfr7ByUo30smeruaOSopakAMTEen1CGO3n1Bl X-Gm-Gg: AR+sD11xFGnP3Tvg2oUnIBCZpW9KcyqwKU8zvdoF25aepFFl3kDfBHsqL9HaWa9+A+y JrYAKJqhzY668JjRAlEwLTXHSqsaP6Z6tNc+fvUeVLXoEqQsiyN5tbAarfUJC95fb7KKk0Apm5V zdTGpDAZeag3qW2Cn+6Lx/PRHKvaVDeTve2P1oKyqG4ZjjsQkG93gsZbgMXnUZrH28iT+fSmawT 7MW4j0nuUbpwt/OH+5Yk574OyHRrSSJ4mKpQtsfmmNhNyZ1/d9Y50Cu/2FukgntbK8dGVN7lSZy wH/l2eXDJW5+6OfWjESoXz+lEPBUg96FNmrpYvagnukKKAZ6zJo6S8xtzgrHXcB9NhMMGNqqfVF Y+cbJp/k3NuvaEMcOw/Kkq4f7Qj3uSbSVn8qaApCtMk/N5JYKlcdeKfsLetVK6dX8SjTIqK0AmE o47f1EvcxmGwOIZKzcYYgMZSFhBhZH3FeP9HB9ti7x73Ytgvac4ssqj4kjv856s2++O7ByeFreM nLG X-Received: by 2002:a05:600c:4704:b0:493:cefc:d113 with SMTP id 5b1f17b1804b1-49b91c2d8femr69750805e9.5.1787907223642; Fri, 28 Aug 2026 01:53:43 -0700 (PDT) Received: from deb05.proceq.com ([213.160.61.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49b926874fdsm43155175e9.4.2026.08.28.01.53.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 01:53:43 -0700 (PDT) From: Mehmet Fide To: Miquel Raynal Cc: Stefan Agner , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , Bill Pringlemeir , Brian Norris , Alexey Klimov , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] mtd: rawnand: vf610_nfc: rearm the completion before starting a command Date: Fri, 28 Aug 2026 10:53:40 +0200 Message-ID: <20260828085340.3916239-3-mehmet.fide@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260828085340.3916239-1-mehmet.fide@gmail.com> References: <20260828085340.3916239-1-mehmet.fide@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260828_015345_503388_64DC9FD5 X-CRM114-Status: GOOD ( 13.39 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Mehmet Fide When a command times out, its interrupt may still arrive later and complete cmd_done. The next command then sees the completion already done and vf610_nfc_done() returns before the controller has fini [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:334 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [mehmet.fide(at)gmail.com] -0.0 DMARC_PASS DMARC pass policy X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Mehmet Fide When a command times out, its interrupt may still arrive later and complete cmd_done. The next command then sees the completion already done and vf610_nfc_done() returns before the controller has finished, so the caller reads the SRAM buffer of an unfinished transfer. Reinitialize the completion before starting the command, so the wait can only be satisfied by the interrupt of the command it belongs to. Fixes: 456930d80a2d ("mtd: nand: vf610_nfc: Freescale NFC for VF610, MPC5125 and others") Cc: stable@vger.kernel.org Signed-off-by: Mehmet Fide --- drivers/mtd/nand/raw/vf610_nfc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/mtd/nand/raw/vf610_nfc.c b/drivers/mtd/nand/raw/vf610_nfc.c index f831780d6fff..f88c7b45bcbc 100644 --- a/drivers/mtd/nand/raw/vf610_nfc.c +++ b/drivers/mtd/nand/raw/vf610_nfc.c @@ -291,6 +291,9 @@ static void vf610_nfc_done(struct vf610_nfc *nfc) { unsigned long timeout = msecs_to_jiffies(100); + /* A late interrupt of a timed-out command may have completed this already */ + reinit_completion(&nfc->cmd_done); + /* * Barrier is needed after this write. This write need * to be done before reading the next register the first