Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ubi: Fix error for write access

When opening a device with write access, ubiblock_open returns an error
code. Currently, this error code is -EPERM, but this is not the right
value.

The open function for other block devices returns -EROFS when opening
read-only devices with FMODE_WRITE set. When used with dm-verity, the
veritysetup userspace tool is expecting EROFS, and refuses to use the
ubiblock device.

Use -EROFS for ubiblock as well. As a result, veritysetup accepts the
ubiblock device as valid.

Cc: stable@vger.kernel.org
Fixes: 9d54c8a33eec (UBI: R/O block driver on top of UBI volumes)
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

authored by

Romain Izard and committed by
Richard Weinberger
78a8dfba 29b7a6fa

+1 -1
+1 -1
drivers/mtd/ubi/block.c
··· 244 244 * in any case. 245 245 */ 246 246 if (mode & FMODE_WRITE) { 247 - ret = -EPERM; 247 + ret = -EROFS; 248 248 goto out_unlock; 249 249 } 250 250