From: Martin Krause Date: Tue, 22 Jun 2010 13:00:19 +0000 (+0200) Subject: mtd: mtdconcat: fix bug with uninitialized lock and unlock functions X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e1d0fe3cddf2306e3ac32569aa152f1909c9b46e;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Artem Bityutskiy Signed-off-by: David Woodhouse --- diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 7e075621bbf4..4567bc373780 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)