linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]] mtdconcat: fix bug with uninitialized lock and unlock functions
@ 2010-06-22 13:00 Martin Krause
  2010-07-08  9:10 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Krause @ 2010-06-22 13:00 UTC (permalink / raw)
  To: linux-mtd

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(-)

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-07-08  9:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-22 13:00 [PATCH]] mtdconcat: fix bug with uninitialized lock and unlock functions Martin Krause
2010-07-08  9:10 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).