mtd: mtdconcat: fix bug with uninitialized lock and unlock functions
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Wed Aug 4 06:59:02 EDT 2010
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=e1d0fe3cddf2306e3ac32569aa152f1909c9b46e
Commit: e1d0fe3cddf2306e3ac32569aa152f1909c9b46e
Parent: 24cc7b8a2a48a5707637e918a51ea547efe24892
Author: Martin Krause <Martin.Krause at tqs.de>
AuthorDate: Tue Jun 22 15:00:19 2010 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Aug 2 09:04:20 2010 +0100
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: Martin Krause <martin.krause at tqs.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/mtdconcat.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c
index 7e07562..4567bc3 100644
--- a/drivers/mtd/mtdconcat.c
+++ b/drivers/mtd/mtdconcat.c
@@ -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)
More information about the linux-mtd-cvs
mailing list