[PATCH]] mtdconcat: fix bug with uninitialized lock and unlock functions
Martin Krause
Martin.Krause at tqs.de
Tue Jun 22 09:00:19 EDT 2010
Test if a lock or unlock function is present (pointer not NULL) before
calling it, to prevent a kernel dump.
Signed-off-by: Martin Krause <martin.krause at tqs.de>
---
drivers/mtd/mtdconcat.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index db6de74..0a7ee03 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -541,10 +541,13 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;
- err = subdev->lock(subdev, ofs, size);
+ if (subdev->lock) {
+ err = subdev->lock(subdev, ofs, size);
- if (err)
- break;
+ if (err)
+ break;
+ } else
+ err = -EOPNOTSUPP;
len -= size;
if (len == 0)
@@ -579,10 +582,13 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
else
size = len;
- err = subdev->unlock(subdev, ofs, size);
+ if (subdev->unlock) {
+ err = subdev->unlock(subdev, ofs, size);
- if (err)
- break;
+ if (err)
+ break;
+ } else
+ err = -EOPNOTSUPP;
len -= size;
if (len == 0)
--
1.6.6.1
More information about the linux-mtd
mailing list