Re: [syzbot] [mtd?] divide error in block2mtd_setup2
From: Pei Xiao
Date: Mon Aug 10 2026 - 23:03:14 EST
在 2026/8/10 20:40, Miquel Raynal 写道:
> Hi Pei,
>
>>> 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!
>> Thank you for your contribution. I have sent this patch, but I forgot to
>> add the Suggested-by: tag
>
> You are invited to send a v2 with the said tag :)
Thank you for your reply. I am waiting for a reply on whether the cast
on 'long' needs to be removed. Once that is confirmed, I would be happy
to do it. Thank you.
Pei.
>
> Thanks,
> Miquèl