[RESEND PATCH v4 1/4] mtd: cfi_cmdset_0002: Add support for reading OTP
Brian Norris
computersforpeace at gmail.com
Mon Aug 11 11:54:45 PDT 2014
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?
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,
Brian
More information about the linux-mtd
mailing list