提交 cb56caac 编写于 作者: V Vignesh Raghavendra 提交者: Jagan Teki

mtd: spi-nor-core: Fix static checker warnings

Static checker warns 'ret' variable may be used uninitialized in
spi_nor_erase() and spi_nor_write() in case of zero length requests.
Fix these warnings by checking for zero length requests and returning
early.
Reported-by: NDan Murphy <dmurphy@ti.com>
Signed-off-by: NVignesh Raghavendra <vigneshr@ti.com>
上级 864d6643
......@@ -546,6 +546,9 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
dev_dbg(nor->dev, "at 0x%llx, len %lld\n", (long long)instr->addr,
(long long)instr->len);
if (!instr->len)
return 0;
div_u64_rem(instr->len, mtd->erasesize, &rem);
if (rem)
return -EINVAL;
......@@ -1226,6 +1229,9 @@ static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
if (!len)
return 0;
for (i = 0; i < len; ) {
ssize_t written;
loff_t addr = to + i;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册