Re: [syzbot] [mtd?] divide error in block2mtd_setup2

From: Jörn Engel

Date: Sun Aug 09 2026 - 22:11:14 EST


On Sun, Aug 09, 2026 at 05:34:28PM -0700, syzbot wrote:
>
> * 2a: f7 f6 div %esi <-- trapping instruction

Best guess would be this:

if ((long)size % erase_size) {

Someone passing an erase_size of 0 would indeed trigger an exception.
Fix would be something like this:

- if ((long)size % erase_size) {
+ if (!erase_size || (long)size % erase_size) {

I haven't touched the code is nearly two decades. If somebody else
feels like sending a patch and gathering all the glory, please be my
guest!

Jörn

--
Those who come seeking peace without a treaty are plotting.
-- Sun Tzu