Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2904999pxb; Tue, 24 Aug 2021 10:16:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynssiwR5Jpni3Rb/2/MeoR6faeDyARQvSEQtMbhdMVnEzueVJhlk/KFZTpmkwxZHgmdir4 X-Received: by 2002:a17:906:1d59:: with SMTP id o25mr14096907ejh.431.1629825405768; Tue, 24 Aug 2021 10:16:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825405; cv=none; d=google.com; s=arc-20160816; b=P2rdtzvkvbuA28q/hZqLHb9VUa2ziVIwcxCMFtnyBnOCIQTEYOX4Z2DJ9pHVP3hm9i 61PI3io8q7hgvxh8GiYYFPMc8rwk5ocBBdaCL/O3DesgdIVNd+mhDLkXedeY3w/uxx8B CAUotaBhnqJnoyB4/Qyp5Z7f6tRILmGeP4cPFbuxfnmXp3wouRw0kcv1PTnbjOeK2wkB pJHBydONNZLOepVnTf6e7ued+NMRqS0H4fEyamweeFTvkF2BOeWF2G08RNi/iWQjga+V lUzdFyKUC2+0NSvG1kI4O9vlvMMoMSpoCV2mvB/qYNa/yRs7/li08DakvKFupOs86wms 7sSw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Y12coVemCNugorZFft0CD6rQw5Q5jQ4JEOb0r/mzOaM=; b=Ezjl8EOnSIuRUqx8Bua3xnalG3r4/UjoZAhLhOTGOIob/WytzTNFGyYpOZDwWIOtr+ XFKu/eupQblkeBaKf4GKLmkldiz/QYqm8zRZeAeAJo8ev1c34ITHLicnJx+cNIpam9hY 5gxiOSn7gvH+KA6o9imdzAo5tqXW3XXlKKFNXoaamJxHxNTHoHAyGFMxeYxjoR4qZ+sy QTHgD33Y34jGKpodbfy5ZYdjjz7dzKQl6Z+7kw90dU0SpUQNQTf5zqwConOEuzLgmayk 5LJcUSiwIgO7bN8tGbDlaU0tGSgYlkWx7HqWtpDgS1YMMFbLAz3uwzsTo5cPzUPq6wks 90Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=odUh86ac; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lv19si3079826ejb.445.2021.08.24.10.16.20; Tue, 24 Aug 2021 10:16:45 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=odUh86ac; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239923AbhHXRPm (ORCPT + 99 others); Tue, 24 Aug 2021 13:15:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:52052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239610AbhHXRMD (ORCPT ); Tue, 24 Aug 2021 13:12:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E2C9E61A59; Tue, 24 Aug 2021 17:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824476; bh=s70CONoP/RTBH5frNaDhB5bwpfMHzrr+9j+ErpNFcM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=odUh86acSHJZ47yFto0hYV2LOug9gYr53HVBiUP2psySu0wt00BH2UCIrD6nRaCKP iXfxgwPCaOBfNxL6DGFaoz64TfrT1+eO7s53qMBL8sEXr4k/DYsQClowsbD4k7rQNB RjMgEORbraO4PaCtbLGY94emHm6CSKlQJzQ+y8hJGI9eb6Ejzs3TtDtddWJqjEDfS8 /Qkg5itNlO8MPwIbtqRtVqi0F+7+bp7fQ5slWExUPN2NS7/ajYqSscwQQy+ep6JSCG 4GlxbtOc0ktMJfgl6n4HgVeMgfo7am80x9PKUfnBPIlDCc6ykuVygQv3NeLuRJukCL HsRTxXR+SZiag== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andreas Persson , Miquel Raynal , Greg Kroah-Hartman Subject: [PATCH 5.4 08/61] mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards Date: Tue, 24 Aug 2021 13:00:13 -0400 Message-Id: <20210824170106.710221-9-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824170106.710221-1-sashal@kernel.org> References: <20210824170106.710221-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.143-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.4.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.4.143-rc1 X-KernelTest-Deadline: 2021-08-26T17:01+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Persson commit 2394e628738933aa014093d93093030f6232946d upstream. Erasing an AMD linear flash card (AM29F016D) crashes after the first sector has been erased. Likewise, writing to it crashes after two bytes have been written. The reason is a missing check for a null pointer - the cmdset_priv field is not set for this type of card. Fixes: 4844ef80305d ("mtd: cfi_cmdset_0002: Add support for polling status register") Signed-off-by: Andreas Persson Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/DB6P189MB05830B3530B8087476C5CFE4C1159@DB6P189MB0583.EURP189.PROD.OUTLOOK.COM Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index c8b9ab40a102..9c98ddef0097 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -119,7 +119,7 @@ static int cfi_use_status_reg(struct cfi_private *cfi) struct cfi_pri_amdstd *extp = cfi->cmdset_priv; u8 poll_mask = CFI_POLL_STATUS_REG | CFI_POLL_DQ; - return extp->MinorVersion >= '5' && + return extp && extp->MinorVersion >= '5' && (extp->SoftwareFeatures & poll_mask) == CFI_POLL_STATUS_REG; } -- 2.30.2