All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero
@ 2026-08-21  4:45 kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-08-21  4:45 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "linux-review patch is more than 7 days old, verify it wasn't already superseded"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01@kylinos.cn>
References: <48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01@kylinos.cn>
TO: Pei Xiao <xiaopei01@kylinos.cn>
TO: joern@lazybastard.org
TO: miquel.raynal@bootlin.com
TO: richard@nod.at
TO: vigneshr@ti.com
TO: linux-mtd@lists.infradead.org
TO: linux-kernel@vger.kernel.org
CC: Pei Xiao <xiaopei01@kylinos.cn>
CC: syzbot+b320a4d5f65a61dbbf89@syzkaller.appspotmail.com
CC: "Jörn Engel" <joern@barelysecure.org>
CC: stable@vger.kernel.org

Hi Pei,

kernel test robot noticed the following build errors:

[auto build test ERROR on mtd/mtd/next]
[also build test ERROR on mtd/mtd/fixes linus/master v7.2 next-20260819]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pei-Xiao/mtd-block2mtd-Fix-divide-error-when-erase_size-is-zero/20260812-095242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
patch link:    https://lore.kernel.org/r/48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01%40kylinos.cn
patch subject: [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero
:::::: branch date: 22 hours ago
:::::: commit date: 22 hours ago
config: sh-randconfig-002-20260821 (https://download.01.org/0day-ci/archive/20260821/202608211251.8RIgwpgB-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 13.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260821/202608211251.8RIgwpgB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202608211251.8RIgwpgB-lkp@intel.com/

All errors (new ones prefixed by >>):

   sh4-linux-ld: drivers/mtd/devices/block2mtd.o: in function `block2mtd_free_device':
>> drivers/mtd/devices/block2mtd.c:215:(.text+0x670): undefined reference to `__moddi3'


vim +215 drivers/mtd/devices/block2mtd.c

^1da177e4c3f41 Linus Torvalds    2005-04-16  201  
^1da177e4c3f41 Linus Torvalds    2005-04-16  202  
^1da177e4c3f41 Linus Torvalds    2005-04-16  203  static void block2mtd_free_device(struct block2mtd_dev *dev)
^1da177e4c3f41 Linus Torvalds    2005-04-16  204  {
^1da177e4c3f41 Linus Torvalds    2005-04-16  205  	if (!dev)
^1da177e4c3f41 Linus Torvalds    2005-04-16  206  		return;
^1da177e4c3f41 Linus Torvalds    2005-04-16  207  
^1da177e4c3f41 Linus Torvalds    2005-04-16  208  	kfree(dev->mtd.name);
^1da177e4c3f41 Linus Torvalds    2005-04-16  209  
f9d8c3c4236ef2 Christian Brauner 2024-01-23  210  	if (dev->bdev_file) {
f9d8c3c4236ef2 Christian Brauner 2024-01-23  211  		invalidate_mapping_pages(dev->bdev_file->f_mapping, 0, -1);
22650a99821dda Christian Brauner 2024-03-26  212  		bdev_fput(dev->bdev_file);
^1da177e4c3f41 Linus Torvalds    2005-04-16  213  	}
^1da177e4c3f41 Linus Torvalds    2005-04-16  214  
^1da177e4c3f41 Linus Torvalds    2005-04-16 @215  	kfree(dev);
^1da177e4c3f41 Linus Torvalds    2005-04-16  216  }
^1da177e4c3f41 Linus Torvalds    2005-04-16  217  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero
@ 2026-08-21  4:03 kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2026-08-21  4:03 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "linux-review patch is more than 7 days old, verify it wasn't already superseded"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01@kylinos.cn>
References: <48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01@kylinos.cn>
TO: Pei Xiao <xiaopei01@kylinos.cn>
TO: joern@lazybastard.org
TO: miquel.raynal@bootlin.com
TO: richard@nod.at
TO: vigneshr@ti.com
TO: linux-mtd@lists.infradead.org
TO: linux-kernel@vger.kernel.org
CC: Pei Xiao <xiaopei01@kylinos.cn>
CC: syzbot+b320a4d5f65a61dbbf89@syzkaller.appspotmail.com
CC: "Jörn Engel" <joern@barelysecure.org>
CC: stable@vger.kernel.org

Hi Pei,

kernel test robot noticed the following build errors:

[auto build test ERROR on mtd/mtd/next]
[also build test ERROR on mtd/mtd/fixes linus/master v7.2 next-20260819]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pei-Xiao/mtd-block2mtd-Fix-divide-error-when-erase_size-is-zero/20260812-095242
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next
patch link:    https://lore.kernel.org/r/48230456575d27aa83ce8640de8fc07cc62e8efb.1786499433.git.xiaopei01%40kylinos.cn
patch subject: [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero
:::::: branch date: 22 hours ago
:::::: commit date: 22 hours ago
config: xtensa-randconfig-001-20260821 (https://download.01.org/0day-ci/archive/20260821/202608211145.dy7HkzsP-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260821/202608211145.dy7HkzsP-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202608211145.dy7HkzsP-lkp@intel.com/

All errors (new ones prefixed by >>):

   `.exit.text' referenced in section `__jump_table' of fs/fuse/inode.o: defined in discarded section `.exit.text' of fs/fuse/inode.o
   `.exit.text' referenced in section `__jump_table' of fs/fuse/inode.o: defined in discarded section `.exit.text' of fs/fuse/inode.o
   `.exit.text' referenced in section `__jump_table' of drivers/target/target_core_configfs.o: defined in discarded section `.exit.text' of drivers/target/target_core_configfs.o
   `.exit.text' referenced in section `__jump_table' of drivers/target/target_core_configfs.o: defined in discarded section `.exit.text' of drivers/target/target_core_configfs.o
   xtensa-linux-ld: drivers/mtd/devices/block2mtd.o: in function `block2mtd_sync':
>> block2mtd.c:(.text+0xb8): undefined reference to `__moddi3'
   xtensa-linux-ld: drivers/mtd/devices/block2mtd.o: in function `block2mtd_setup2':
   block2mtd.c:(.text+0x466): undefined reference to `__moddi3'

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero
@ 2026-08-12  1:52 ` Pei Xiao
  0 siblings, 0 replies; 8+ messages in thread
From: Pei Xiao @ 2026-08-12  1:52 UTC (permalink / raw)
  To: joern, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: Pei Xiao, syzbot+b320a4d5f65a61dbbf89, Jörn Engel, stable

The erase size is parsed from the "block2mtd" module parameter and can
be set to zero. add_device() then evaluates

        if (size % erase_size)

with a zero divisor, which triggers a divide error:

        divide error: 0000 [#1] PREEMPT SMP PTI
        RIP: 0010:add_device drivers/mtd/devices/block2mtd.c:296 [inline]
        RIP: 0010:block2mtd_setup2+0x592/0xda0 drivers/mtd/devices/block2mtd.c:459
        Call Trace:
         block2mtd_setup+0x27/0xe0 drivers/mtd/devices/block2mtd.c:476
         param_attr_store+0x214/0x310 kernel/params.c:589
         module_attr_store+0x65/0x90 kernel/params.c:904
         kernfs_fop_write_iter+0x3a4/0x540 fs/kernfs/file.c:345
         ...

Reject a zero erase size before performing the modulo operation so the
existing "erasesize must be a divisor of device size" error path
reports the invalid argument and frees the device.

While at it, drop the unnecessary (long) cast from the size operand of
the modulo.

Fixes: ea6d833a3fdd ("mtd: block2mtd: check device size")
Reported-by: syzbot+b320a4d5f65a61dbbf89@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/lkml/6a7b58ba.ac361c09.22ff0a.0045.GAE@google.com/
Suggested-by: Jörn Engel <joern@barelysecure.org>
Cc: stable@vger.kernel.org
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
changlogs in v2:
1.Add Suggested-by tag
2.remove unnecessary (long) cast from the size
---
 drivers/mtd/devices/block2mtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 03e80b2c4f5a..3e2367dfff88 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -293,7 +293,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
 	}
 
 	size = bdev_nr_bytes(bdev);
-	if ((long)size % erase_size) {
+	if (!erase_size || size % erase_size) {
 		pr_err("erasesize must be a divisor of device size\n");
 		goto err_free_block2mtd;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-08-21  4:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  4:45 [PATCH v2] mtd: block2mtd: Fix divide error when erase_size is zero kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2026-08-21  4:03 kernel test robot
2026-08-12  1:52 Pei Xiao
2026-08-12  1:52 ` Pei Xiao
2026-08-12 12:34 ` Miquel Raynal
2026-08-12 12:34   ` Miquel Raynal
2026-08-13  2:30   ` Pei Xiao
2026-08-13  2:30     ` Pei Xiao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.