[PATCH v2 0/4] scsi: remove dead code and redundant checks
From: shao.mingyin
Date: Fri Nov 06 2026 - 09:38:08 EST
This series removes checks that the surrounding code already guarantees and
one store that is overwritten a few lines later. It was found while
reading the SCSI midlayer and the UFS and sd drivers. There is no
functional change intended; every patch is independent and can be applied
on its own or as any subset.
Patch 1 removes a repeated offset check in ufshcd_read_desc_param(). The
function already rejects param_offset >= buff_len before it reaches the
is_kmalloc block, so the inner test can never be true.
Patch 2 drops the "result < SCSI_VPD_HEADER_SIZE" branch in
scsi_get_vpd_size(). scsi_vpd_inquiry() returns the page length plus the
four-byte header, and returns -EIO when the length is zero, so the value is
always at least 5.
Patch 3 removes the first of two identical nr_blocks stores in
sd_setup_atomic_cmnd(). The second store, after the boundary field, wins.
Patch 4 drops two -EOVERFLOW branches in sd_read_capacity(). Neither
read_capacity_10() nor read_capacity_16() returns that value any more.
Changes in v2:
- The st end-of-medium refactor from v1 is dropped: it is a refactor
without a functional need, and the existing EOM handling is better
left untouched.
- Patch 4: name the commit that removed the last -EOVERFLOW returns.
- Add the Reviewed-by tags received for patches 1 and 2.
- Drop the Signed-off-by from the cover.
Link: https://lore.kernel.org/all/20261105193328462jmyNd656AIL6fPlbEJ1Ki@xxxxxxxxxx/
Shao Mingyin (4):
scsi: ufs: drop the unreachable offset check
scsi: core: drop the dead VPD size check
scsi: sd: drop the dead nr_blocks store
scsi: sd: drop the dead -EOVERFLOW branches
drivers/scsi/scsi.c | 7 -------
drivers/scsi/sd.c | 5 -----
drivers/ufs/core/ufshcd.c | 11 +++--------
3 files changed, 3 insertions(+), 20 deletions(-)
---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c