Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1d0fe3c authored by Martin Krause's avatar Martin Krause Committed by David Woodhouse
Browse files

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: default avatarMartin Krause <martin.krause@tqs.de>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 24cc7b8a
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -540,10 +540,12 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
		else
			size = len;

		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;

		if (subdev->unlock) {
			err = subdev->unlock(subdev, ofs, size);

			if (err)
				break;
		} else
			err = -EOPNOTSUPP;

		len -= size;
		if (len == 0)