diff mbox

] mtdconcat: fix bug with uninitialized lock and unlock functions

Message ID 47F3F98010FF784EBEE6526EAAB078D10635E728@tq-mailsrv.tq-net.de
State New, archived
Headers show

Commit Message

Martin Krause June 22, 2010, 1 p.m. UTC
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@tqs.de>
---
 drivers/mtd/mtdconcat.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

Comments

Artem Bityutskiy July 8, 2010, 9:10 a.m. UTC | #1
On Tue, 2010-06-22 at 15:00 +0200, Martin Krause wrote:
> 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@tqs.de>
> ---
>  drivers/mtd/mtdconcat.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)

Pushed to l2-mtd-2.6.git, thanks!
diff mbox

Patch

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)