diff mbox

[RESEND,v4,1/4] mtd: cfi_cmdset_0002: Add support for reading OTP

Message ID 20140811185445.GZ3711@ld-irv-0074
State Accepted
Commit 5d20bad19d25bb25d9e831dd342c7c714d872b53
Headers show

Commit Message

Brian Norris Aug. 11, 2014, 6:54 p.m. UTC
Hi Christian,

This patch is already upstream, but Coverity noticed a problem. Below:

On Mon, May 05, 2014 at 08:14:26AM +0200, Christian Riesch wrote:
> @@ -1224,6 +1238,148 @@ static int cfi_amdstd_secsi_read (struct mtd_info *mtd, loff_t from, size_t len,
>  	return ret;
>  }
>  
> +static int cfi_amdstd_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
> +			       size_t *retlen, u_char *buf,
> +			       otp_op_t action, int user_regs)
> +{
...
> +				mutex_lock(&chip->mutex);
> +				ret = get_chip(map, chip, base, FL_LOCKING);

'ret' is never checked after this.

> +

Should something like the following (untested) patch be applied?


Brian
diff mbox

Patch

diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 5a4bfe33112a..46c4643b7a07 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -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,