linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: cfi_cmdset_0002.c: fix crash when erasing/writing AMD cards
@ 2021-07-04 19:31 Andreas Persson
  0 siblings, 0 replies; only message in thread
From: Andreas Persson @ 2021-07-04 19:31 UTC (permalink / raw)
  To: 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.


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;
  }


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-04 19:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 19:31 [PATCH] mtd: cfi_cmdset_0002.c: fix crash when erasing/writing AMD cards Andreas Persson

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).