Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3890527pxb; Tue, 2 Mar 2021 00:52:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzo7Ur50aRL6LPBmRGJsib3Pa3vCNdwO1gxesLdieXGm1JXmixczbvSFlZDPw/HGqWZ1CKz X-Received: by 2002:a17:906:4e99:: with SMTP id v25mr19821385eju.532.1614675166882; Tue, 02 Mar 2021 00:52:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614675166; cv=none; d=google.com; s=arc-20160816; b=pIfhzFdfHWpo5Qow3xq8z3U7foUDoOKgFGuJs+4BmmvE+uj0ijcVOJmaAe3B5+LX/C wdTnTJ3KLDkvUCyPoxuc8UllIymnpzY2HbQCUvPYq0SAeHID8FwzectRgklWIchKYcpX UMv5XLR8CNHKpKyzeaj0wbEmWB1snhzcXPAKFwc05qrKpydsKVgkPe4Gem3og5B0x09V rBlyQOwLR8c70+3K8H1lKYfWupFd00jh99OaAucM4UpI4UJAfGkD9+UiRRcEkPnSM6Z5 QKXquSgRDdibGcAsI/P0rd6/DU27ObLxkZ+6sf6t3Un5JUeHvOylNwrS/fNTf+Q3PhRP enzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Nm0pF/OD8q/LGlzWRjJP6FZeAESdEgAKEpSgxPuiiBY=; b=nq+EyS13EJnlzK5ZPIBpsv/b6rtVHX+ca4X/hCvz3TQ02eXr2642yEX56k8Zn/7pcG eJMqxWU4sppfQ7oEg2YsFh+yoJm2P/bb61gCn4bebnAH0qGxQKWsXh8x4SNnfgBQnHyx aOqLKmEEUR41ZuBXSwnrlCyxT4h68i5fOYMUK3CeYJxTgMOtGx/hj2jlSaesvZBM72r7 JK0neEL0Wq+VaY0FJGEpmq2e3qKdpTonuL5ipegF+SA0wd0TXZKL3GS+3JmC8ADCyY3E wP49AqA9RM3aphTRwdcfiAwV2lqzcQN0qM+rB7XfpaVdCuvFMY411u+0DI+vuAfskTSI NZJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G9zTFPOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d3si3457618eds.83.2021.03.02.00.52.23; Tue, 02 Mar 2021 00:52:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=G9zTFPOC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378669AbhCBBHd (ORCPT + 99 others); Mon, 1 Mar 2021 20:07:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:37268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239515AbhCATEO (ORCPT ); Mon, 1 Mar 2021 14:04:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19AF164FA7; Mon, 1 Mar 2021 17:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619900; bh=sSlT3c14wnGE1MMEKnrwI48vDPotCsFFTsXPuVfWcvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G9zTFPOCk81La9Emqz1f/+mZod45wP2HegRcQvBi1FzcSFQIW4iqB6CnJymu+Zhk7 XZkSG5h/R5a8FSBnckEZuPiryIL8XmtV6Zw44EBBTn8vIiZT+h+rghHRkBZ7zHLHVC oAYntAUDMGC7f8LP1PqV804upH4EXRQTdhwI1AVo= 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.10 591/663] mtd: spi-nor: core: Add erase size check for erase command initialization Date: Mon, 1 Mar 2021 17:13:59 +0100 Message-Id: <20210301161211.106523425@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -1364,6 +1364,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)) {