[PATCH 0/5] scsi: remove dead code and redundant checks

From: shao.mingyin

Date: Thu Nov 05 2026 - 06:34:48 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, sd and st 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.

Patch 5 factors the duplicated end-of-medium test in st.c into a helper.
The similar test in write_behind_check() is intentionally left alone: it has
different remainder handling and only uses EOM to turn -EIO into -ENOSPC.

Signed-off-by: Shao Mingyin <shao.mingyin@xxxxxxxxxx>
---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c