提交 e1d0fe3c 编写于 作者: M Martin Krause 提交者: David Woodhouse

mtd: mtdconcat: fix bug with uninitialized lock and unlock functions

Test if a lock or unlock function is present (pointer not NULL) before
calling it, to prevent a kernel dump.

Artem: removed extra blank lines
Signed-off-by: NMartin Krause <martin.krause@tqs.de>
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 24cc7b8a
......@@ -540,10 +540,12 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;
err = subdev->lock(subdev, ofs, size);
if (err)
break;
if (subdev->lock) {
err = subdev->lock(subdev, ofs, size);
if (err)
break;
} else
err = -EOPNOTSUPP;
len -= size;
if (len == 0)
......@@ -578,10 +580,12 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;
err = subdev->unlock(subdev, ofs, size);
if (err)
break;
if (subdev->unlock) {
err = subdev->unlock(subdev, ofs, size);
if (err)
break;
} else
err = -EOPNOTSUPP;
len -= size;
if (len == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册