Skip to contentSkip to conversation

mtd: cfi_cmdset_0002: check return code for get_chip()

PATCH In review Brian Norris 2 participants 4 messages Aug 14, 2014 – Aug 19, 2014 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: cfi_cmdset_0002: check return code for get_chip()

Untested

Coverity CID 1230633

Cc Christian Riesch <[email protected]>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +4 -0
index 6da141af9cba..c50d8cf0f60d 100644
@@ -1434,6 +1434,10 @@ static int cfi_amdstd_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
 
 				mutex_lock(&chip->mutex);
 				ret = get_chip(map, chip, base, FL_LOCKING);
+				if (ret) {
+					mutex_unlock(&chip->mutex);
+					return ret;
+				}
 
 				/* Enter lock register command */
 				cfi_send_gen_cmd(0xAA, cfi->addr_unlock1,
Signature · 1 line
1.7.9.5
Tested-by on v1 1/1
#1 lore raw

Hi Brian,
Thanks for catching this!

Quoted 9 lines · Brian Norris

Untested

Coverity CID 1230633

Cc Christian Riesch <[email protected]>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |    4 ++++
 1 file changed, 4 insertions(+)

Regards,
Christian

Quoted 23 lines
drivers/mtd/chips/cfi_cmdset_0002.c +4 -1
index 6da141af9cba..c50d8cf0f60d 100644
@@ -1434,6 +1434,10 @@ static int cfi_amdstd_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
 
                                mutex_lock(&chip->mutex);
                                ret = get_chip(map, chip, base, FL_LOCKING);
+                               if (ret) {
+                                       mutex_unlock(&chip->mutex);
+                                       return ret;
+                               }
 
                                /* Enter lock register command */
                                cfi_send_gen_cmd(0xAA, cfi->addr_unlock1,
--

1.7.9.5

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

#2 lore raw
Quoted 2 lines · Christian Riesch

Hi Brian,
Thanks for catching this!

Don't thank me, thank Coverity (TM)! (And Dave Jones, I guess, since he maintains the project instance.)

Quoted 6 lines
Quoted 4 lines · Brian Norris

Untested

Coverity CID 1230633

Quoted 7 lines
Quoted 5 lines
Cc Christian Riesch <[email protected]>
---
 drivers/mtd/chips/cfi_cmdset_0002.c |    4 ++++
 1 file changed, 4 insertions(+)

Thanks! Queued to linux-mtd.git/master. It'll probably go in 3.16, as it's a fix for a new feature.

Brian

[1] http://codemonkey.org.uk/2014/08/05/linux-316-coverity-stats/

#3 lore raw
Quoted 2 lines · Brian Norris

Thanks! Queued to linux-mtd.git/master. It'll probably go in 3.16, as it's a fix for a new feature.

Just noticed my typo: this is of course for 3.17, not 3.16 :)

Brian