Skip to content

Commit

Permalink
mtd: mtdconcat: fix bug with uninitialized lock and unlock functions
Browse files Browse the repository at this point in the history
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@tqs.de>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Martin Krause authored and David Woodhouse committed Aug 2, 2010
1 parent 24cc7b8 commit e1d0fe3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/mtd/mtdconcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e1d0fe3

Please sign in to comment.