From patchwork Tue Oct 18 09:11:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 616035 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2502665pvb; Tue, 18 Oct 2022 02:12:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jnnwnRj4GU4qsjY1U2k6lpWrsQLr615dxa1RKNZIugMVz0dpHKrbJSXEotYeFLoT+7cus X-Received: by 2002:a63:24d:0:b0:452:87c1:9781 with SMTP id 74-20020a63024d000000b0045287c19781mr1846964pgc.512.1666084341520; Tue, 18 Oct 2022 02:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666084341; cv=none; d=google.com; s=arc-20160816; b=Lz0iPFqy4YcTGb5F5UMFtohkptE0TxLpRO1DEEVE59Zz37o4m/46bL/54NvFblAU42 2BK2ZOOCPASDbOemfgIM/X3vB9/wN90UjKqq33jT5eS4BDF/OH9fnvfQEucovWV+9CCR QtOrQNaRQqMtxwTMWwN/QZttWJBVFwzjtUOvx73ZH98z72KqlO+GTdYlmYMmGcMrC5MO rqYFPIbP+fAkH6u7bdIaVwzHUm1ks4hM6j+hLRF2Rq6HjXxmogqrXbzXdjz19zMf4RsT bPy4dSCXYaLvwfvZ61H2SpQxYReORz5e9+xTFeZU6uygOHauTtI++lLHRfavsf2JxDdX aHiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=/mM1TdSI2PLPj2LoDMOC/pphqvNBNRqk0rnqu6dl80M=; b=SIEz0IHXYILlnPu8qxKmuxCVT04ZTyfvfM9SwtG9QfIFsdYp8Df0UKe9LWrE3wz0/T pxWq9AYywMSrU3bQTt4gqo4tINuUWU/GycRoC0Y0IwHTCd9GsNy7gPWeK7gAEmm3YpLf LNo7WFPM57Mg9gHhq0A6eVjugh1dVuiiomvQxo3UbOHRmejV/5jfTzo7PVCHZZE75Qe0 +L2MzolEfbbYaIrftmSX1dqWz6QfdfSMglb+yL1In6KWJ7XyaZ2yS4mHEUt6DPtap7DA 25dqXdMNir4ZhXmF47Zhx3U0SD/l1TEbEq6av0gj7WEYbyQk3E94bWiRar1rABH5Ew8p w30w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=AGhvM5Zc; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="cQ8VS/TM"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:3::133]) by mx.google.com with ESMTPS id t14-20020a63954e000000b0046ae2a8ea9csi15045262pgn.733.2022.10.18.02.12.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 02:12:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) client-ip=2607:7c80:54:3::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=AGhvM5Zc; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="cQ8VS/TM"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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: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:In-Reply-To:References: List-Owner; bh=/mM1TdSI2PLPj2LoDMOC/pphqvNBNRqk0rnqu6dl80M=; b=AGhvM5ZcfKN6t+ FZ9/dd5Ycj8HuHCyol/rQ/Pvw7UuTirwnIb6wvALrg827lbYLS9oIF8cZoS4cjV/kvofidBYqA+/x 48SP1Jvuo+haNl1OjdctkKUmU4P5q+3xO3n8gYBGpZD2Zm70iwX92aC+hWRAfR4LPKNqavZpJqy6p wDIOlGySPwobpqkhJuuTB9lajYBW2fPdo22iXIRFJrxI7dxaSeo71wCsLJ7FOo+ABc/oOSviKqYA1 zW/4RB1zhotrTC0PP/XNbicpOU+WGjzBQslj0bJpOaXB0ZkpD5rojuB2iziaXXZDWSraJjJfpSx0P mbSzXqhctNtQkyWSRZAA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1okidR-004lUQ-HG; Tue, 18 Oct 2022 09:11:41 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1okidO-004lQa-1H for linux-mtd@lists.infradead.org; Tue, 18 Oct 2022 09:11:39 +0000 Received: by mail-lf1-x129.google.com with SMTP id b2so21507485lfp.6 for ; Tue, 18 Oct 2022 02:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Hs5kolKpC/C8pusTeJANmsAcelkkPgG9+Ckh4D5mS3U=; b=cQ8VS/TMzJ1bSVnAog0nYXSe/HvTh2YhN3SDM1Scm7eOWSVxvVpxkFkmlo251b4uZe o58JpQozt15w1GWyyRhgQla9SHsqzbF34bVct1r16gTPQZVBLH6Y4aFn44JeP0hvqb2z sZtTzv7AMV0Ovc9PX8NqqnQEdVHtHsVJupNkFBGQ76niK/RwG4FigCN0yQ6SZJEcz8x/ KGuxDhdMZN17yLgrw6XACbIesW5gBphTFZksraIq0pl+DLpUW0ub69Bu29YU8x3/HAnp GO1yyNPPyNZoEIfEYjWJYGwYlT+5Nz8d8VMDCBe1mIbjMVpQkRMXyGPZhwxKZT8UHxUF 3IVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Hs5kolKpC/C8pusTeJANmsAcelkkPgG9+Ckh4D5mS3U=; b=jeESIm9pclGwdn4v3MIpXrlkmfRpn9IWsSfHrmJNKMNCmDy9752tx7DY+cKizm///6 TBiUittMd9iPfmkxR9hcd8YTdivS2CBhf9cnegg6WWZTyAedo5BufidzVfnROARA48P/ 2Sri9pPjKMyYUqb7WJFG8Q+EVoEz0L3UkwzRW8NPyxBqT1OoQLowPxkTMJv86Ur9IiKu mmAV/FrBO7mGWEJJpIIUw8l7MwBCMWXI0Evc2OCDwHp58+iRPZaptXvF5OmYX9O8UX8L SGarl0yIzW8ZW4NKF4ooN1rvarzlCK5d1XaYEOpxGDjx1OHamrYGKlJjRt+nXoTP3a/p 8VFQ== X-Gm-Message-State: ACrzQf3kpKJ36Y/Fk1rHh6JyT5w+x4BnGUPer+CReL9ngCQiCEQd7Y3Z +UMYc3as3rNzIhlWXQ2c0Rz9Ww== X-Received: by 2002:a19:ac04:0:b0:49a:7253:4a68 with SMTP id g4-20020a19ac04000000b0049a72534a68mr700876lfc.322.1666084293321; Tue, 18 Oct 2022 02:11:33 -0700 (PDT) Received: from fedora.. ([85.235.10.72]) by smtp.gmail.com with ESMTPSA id k15-20020ac24f0f000000b00498fc3d4d15sm1772701lfr.190.2022.10.18.02.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 02:11:32 -0700 (PDT) From: Linus Walleij To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, Linus Walleij , stable@vger.kernel.org, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Florian Fainelli Subject: [PATCH v2] mtd: parsers: bcm47xxpart: Fix halfblock reads Date: Tue, 18 Oct 2022 11:11:29 +0200 Message-Id: <20221018091129.280026-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221018_021138_127121_42AE833A X-CRM114-Status: GOOD ( 16.29 ) X-Spam-Score: -0.2 (/) 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: There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get th [...] Content analysis details: (-0.2 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:129 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 Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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+patch=linaro.org@lists.infradead.org There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get these parse errors as we reach the end of the flash: spi-nor spi0.0: mx25l1606e (2048 Kbytes) mtd_read error while parsing (offset: 0x200000): -22 mtd_read error while parsing (offset: 0x201000): -22 (...) Fix the code to do what I think was intended. Cc: stable@vger.kernel.org Fixes: f0501e81fbaa ("mtd: bcm47xxpart: alternative MAGIC for board_data partition") Cc: Rafał Miłecki Cc: Florian Fainelli Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Add some fixes and stable tags. --- drivers/mtd/parsers/bcm47xxpart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/parsers/bcm47xxpart.c b/drivers/mtd/parsers/bcm47xxpart.c index 50fcf4c2174b..13daf9bffd08 100644 --- a/drivers/mtd/parsers/bcm47xxpart.c +++ b/drivers/mtd/parsers/bcm47xxpart.c @@ -233,11 +233,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, } /* Read middle of the block */ - err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read, + err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read, (uint8_t *)buf); if (err && !mtd_is_bitflip(err)) { pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", - offset + 0x8000, err); + offset + (blocksize / 2), err); continue; }