diff mbox series

[1/4] mtd: rawnand: add missing error handling in subop helpers

Message ID 20180714133003.25187-1-miquel.raynal@bootlin.com
State Changes Requested
Headers show
Series [1/4] mtd: rawnand: add missing error handling in subop helpers | expand

Commit Message

Miquel Raynal July 14, 2018, 1:30 p.m. UTC
A report from Colin Ian King pointed a CoverityScan issue where error
values on these helpers where not checked in the drivers. These
helpers could error out only in case of a software bug in driver code,
not because of a runtime/hardware error but in any cases it is safer
to handle these errors properly.

Before fixing the drivers, let's add some consistency and fix these
helpers error handling.

Fixes: 8878b126df76 ("mtd: nand: add ->exec_op() implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
---
 drivers/mtd/nand/raw/nand_base.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index 10c4f9919850..51f68203aa63 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -2720,6 +2720,8 @@  int nand_subop_get_num_addr_cyc(const struct nand_subop *subop,
 		return -EINVAL;
 
 	start_off = nand_subop_get_addr_start_off(subop, instr_idx);
+	if (start_off < 0)
+		return start_off;
 
 	if (instr_idx == subop->ninstrs - 1 &&
 	    subop->last_instr_end_off)
@@ -2774,6 +2776,8 @@  int nand_subop_get_data_len(const struct nand_subop *subop,
 		return -EINVAL;
 
 	start_off = nand_subop_get_data_start_off(subop, instr_idx);
+	if (start_off < 0)
+		return start_off;
 
 	if (instr_idx == subop->ninstrs - 1 &&
 	    subop->last_instr_end_off)