]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ubi: Refuse attaching if mtd's erasesize is 0
authorZhihao Cheng <chengzhihao1@huawei.com>
Sun, 23 Apr 2023 11:10:41 +0000 (19:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Oct 2023 19:43:41 +0000 (21:43 +0200)
commitef7a4c97a85ab1bff7abc98f885678bd33bb4881
treec316f3a8748b6e517ae19fab37c8d724b6a50401
parent2e0618fa9cddac3b552b3b6e6b1cd0773ac9c271
ubi: Refuse attaching if mtd's erasesize is 0

[ Upstream commit 017c73a34a661a861712f7cc1393a123e5b2208c ]

There exists mtd devices with zero erasesize, which will trigger a
divide-by-zero exception while attaching ubi device.
Fix it by refusing attaching if mtd's erasesize is 0.

Fixes: 801c135ce73d ("UBI: Unsorted Block Images")
Reported-by: Yu Hao <yhao016@ucr.edu>
Link: https://lore.kernel.org/lkml/977347543.226888.1682011999468.JavaMail.zimbra@nod.at/T/
Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/ubi/build.c