drivers/scsi/sd.c:4493:2-17: WARNING: NULL check before some freeing functions is not needed.

From: kernel test robot

Date: Fri Oct 30 2026 - 18:25:48 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: abf8c33470f78e2226ee3dcdc69004660020ab47
commit: 7179e626b76eb42f2529c6f6dd6ba88ea2445372 scsi: sd: Enable sector size > PAGE_SIZE in SCSI sd driver
date: 8 months ago
config: loongarch-randconfig-r2103-20261029 (https://download.01.org/0day-ci/archive/20261030/202610302345.WFnRd62s-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.5.0

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
| Fixes: 7179e626b76e ("scsi: sd: Enable sector size > PAGE_SIZE in SCSI sd driver")
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610302345.WFnRd62s-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> drivers/scsi/sd.c:4493:2-17: WARNING: NULL check before some freeing functions is not needed.

vim +4493 drivers/scsi/sd.c

4478
4479 /**
4480 * exit_sd - exit point for this driver (when it is a module).
4481 *
4482 * Note: this function unregisters this driver from the scsi mid-level.
4483 **/
4484 static void __exit exit_sd(void)
4485 {
4486 int i;
4487
4488 SCSI_LOG_HLQUEUE(3, printk("exit_sd: exiting sd driver\n"));
4489
4490 scsi_unregister_driver(&sd_template);
4491 mempool_destroy(sd_page_pool);
4492 if (sd_large_page_pool)
> 4493 mempool_destroy(sd_large_page_pool);
4494
4495 class_unregister(&sd_disk_class);
4496
4497 for (i = 0; i < SD_MAJORS; i++)
4498 unregister_blkdev(sd_major(i), "sd");
4499 }
4500

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