From patchwork Mon Mar 1 16:14:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 389101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0ACDC433E0 for ; Mon, 1 Mar 2021 20:36:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A936F601FC for ; Mon, 1 Mar 2021 20:36:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238585AbhCAUgU (ORCPT ); Mon, 1 Mar 2021 15:36:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:48310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240281AbhCAU0z (ORCPT ); Mon, 1 Mar 2021 15:26:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1978D65413; Mon, 1 Mar 2021 18:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614622016; bh=CMmtLrMKBUjulMGzE1Q8tpVlLB8zO+8Bmaac/0MrXZo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHsZ5gUtMToehNFGDkwSgqi6bey5fTf/iqFmgj5olz3PK+C+mJWG7nmqTzFsHOARt dDUhowoJsc7D6c4qap2xJHgVHBT98xfzVwIW1j89l2xgL68F+gyYWrxGPuDMxq6jcR PB2cq9VmhTz5tH7VArXFC82RgGq6uo4yBp2gSvc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takahiro Kuwano , Tudor Ambarus Subject: [PATCH 5.11 696/775] mtd: spi-nor: core: Add erase size check for erase command initialization Date: Mon, 1 Mar 2021 17:14:24 +0100 Message-Id: <20210301161235.774780738@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161201.679371205@linuxfoundation.org> References: <20210301161201.679371205@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Takahiro Kuwano commit 58fa22f68fcaff20ce4d08a6adffa64f65ccd37d upstream. Even if erase type is same as previous region, erase size can be different if the previous region is overlaid region. Since 'region->size' is assigned to 'cmd->size' for overlaid region, comparing 'erase->size' and 'cmd->size' can detect previous overlaid region. Fixes: 5390a8df769e ("mtd: spi-nor: add support to non-uniform SFDP SPI NOR flash memories") Cc: stable@vger.kernel.org Signed-off-by: Takahiro Kuwano [ta: Add Fixes tag and Cc to stable] Signed-off-by: Tudor Ambarus Link: https://lore.kernel.org/r/13d47e8d8991b8a7fd8cc7b9e2a5319c56df35cc.1601612872.git.Takahiro.Kuwano@infineon.com Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/spi-nor/core.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1516,6 +1516,7 @@ static int spi_nor_init_erase_cmd_list(s goto destroy_erase_cmd_list; if (prev_erase != erase || + erase->size != cmd->size || region->offset & SNOR_OVERLAID_REGION) { cmd = spi_nor_init_erase_cmd(region, erase); if (IS_ERR(cmd)) {