* [PATCH v2] mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards
@ 2021-07-12 7:54 Andreas Persson
2021-07-15 22:50 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Andreas Persson @ 2021-07-12 7:54 UTC (permalink / raw)
To: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra; +Cc: linux-mtd
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 <andreasp56@outlook.com>
---
I posted this patch before, but I did some rookie mistakes, such as
only sending to the list and not to any maintainers. The patch format
was also broken. I hope it's better now. The actual code change is the
same.
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 3097e93787f7..a761134fd3be 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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards
2021-07-12 7:54 [PATCH v2] mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards Andreas Persson
@ 2021-07-15 22:50 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2021-07-15 22:50 UTC (permalink / raw)
To: Andreas Persson, Miquel Raynal, Richard Weinberger, Vignesh Raghavendra
Cc: linux-mtd
On Mon, 2021-07-12 at 07:54:52 UTC, Andreas Persson wrote:
> 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 <andreasp56@outlook.com>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-15 22:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 7:54 [PATCH v2] mtd: cfi_cmdset_0002: fix crash when erasing/writing AMD cards Andreas Persson
2021-07-15 22:50 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).