Commit e2532429 authored by Miquel Raynal's avatar Miquel Raynal

mtd: rawnand: qcom: Fix address parsing within ->exec_op()

The naddrs variable is initialized but not used. Fixing this could have
been a matter of dropping the variable, but the right way to do it looks
a bit more complex: we can avoid useless writes to the q_op structure by
using it. In practice we could even have possible out-of-bound bugs with
the existing implementation. Let's fix all that by just performing the
right number of assignments in the addr{1,2}_reg fields.

Fixes: 89550beb ("mtd: rawnand: qcom: Implement exec_op()")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202307131959.PdPSC86K-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202307131730.NOYbcjBr-lkp@intel.com/Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Acked-by: default avatarManivannan Sadhasivam <mani@kernel.org>
Reviewed-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/linux-mtd/20230716144612.32132-9-miquel.raynal@bootlin.com
parent e260efea
......@@ -2616,12 +2616,13 @@ static void qcom_parse_instructions(struct nand_chip *chip,
offset = nand_subop_get_addr_start_off(subop, op_id);
naddrs = nand_subop_get_num_addr_cyc(subop, op_id);
addrs = &instr->ctx.addr.addrs[offset];
for (i = 0; i < MAX_ADDRESS_CYCLE; i++) {
if (i < 4)
q_op->addr1_reg |= (u32)addrs[i] << i * 8;
else
q_op->addr2_reg |= addrs[i];
}
for (i = 0; i < min_t(unsigned int, 4, naddrs); i++)
q_op->addr1_reg |= addrs[i] << (i * 8);
if (naddrs > 4)
q_op->addr2_reg |= addrs[4];
q_op->rdy_delay_ns = instr->delay_ns;
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment