Skip to contentSkip to conversation

target: remove dead kmap checks

PATCH Applied [email protected] 3 participants 6 messages Nov 5 – Nov 18

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover target: remove dead kmap checks

kmap() and kmap_local_page() never return NULL, so the checks after them are dead code. Remove them.

No functional change intended; both patches are independent and can be applied on their own or as a subset.

---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c

#1 lore raw

PATCH 1/2 target: iblock: drop the dead kmap() NULL check

From: Shao Mingyin <[email protected]>

kmap() never returns NULL, so the check after it is dead code.

No functional change.

---

drivers/target/target_core_iblock.c +0 -2
index ea65d39fef88..604fca959f2e 100644
@@ -461,8 +461,6 @@ iblock_execute_zero_out(struct block_device *bdev, struct se_cmd *cmd)
 	int ret;
 
 	buf = kmap(sg_page(sg)) + sg->offset;
-	if (!buf)
-		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 	/*
 	 * Fall back to block_execute_write_same() slow-path if
 	 * incoming WRITE_SAME payload does not contain zeros.
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] target: iblock: drop the dead kmap() NULL check

Quoted 20 lines · On Thu, 2026-11-05 at 19:33 +0800, [email protected] wrote:

From: Shao Mingyin <[email protected]>

kmap() never returns NULL, so the check after it is dead code.

No functional change.

---

drivers/target/target_core_iblock.c +0 -0
index ea65d39fef88..604fca959f2e 100644
@@ -461,8 +461,6 @@ iblock_execute_zero_out(struct block_device
 *bdev, struct se_cmd *cmd)
  	int ret;


  buf = kmap(sg_page(sg)) + sg->offset;

drivers/target/target_core_iblock.c +0 -2
-	if (!buf)
-		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
Quoted 3 lines

  /*
  * Fall back to block_execute_write_same() slow-path if
  * incoming WRITE_SAME payload does not contain zeros.

Looks good.

#3 lore raw

PATCH 2/2 target: core: drop the dead kmap_local_page() NULL check

In reply to [email protected]

From: Shao Mingyin <[email protected]>

kmap_local_page() never returns NULL; drop the wrapper and always zero the segment.

No functional change.

---

drivers/target/target_core_transport.c +2 -4
index 927861c30afc..9819515ce967 100644
@@ -1646,10 +1646,8 @@ static int __target_submit(struct se_cmd *cmd)
 			BUG_ON(!sgl);
 
 			buf = kmap_local_page(sg_page(sgl));
-			if (buf) {
-				memset(buf + sgl->offset, 0, sgl->length);
-				kunmap_local(buf);
-			}
+			memset(buf + sgl->offset, 0, sgl->length);
+			kunmap_local(buf);
 		}
 	}
maintainer Applied
#4 lore raw
In reply to [email protected]
Quoted 6 lines

kmap() and kmap_local_page() never return NULL, so the checks after them are dead code. Remove them.

No functional change intended; both patches are independent and can be applied on their own or as a subset.

Applied to 7.5/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
maintainer Applied
#5 lore raw
In reply to [email protected]
Quoted 9 lines · On Thu, 05 Nov 2026 19:33:46 +0800, [email protected] wrote:

kmap() and kmap_local_page() never return NULL, so the checks after them are dead code. Remove them.

No functional change intended; both patches are independent and can be applied on their own or as a subset.

---

[...]

Applied to 7.5/scsi-queue, thanks!

[1/2] target: iblock: drop the dead kmap() NULL check

      https://git.kernel.org/mkp/scsi/c/63d67440dc9f
[2/2] target: core: drop the dead kmap_local_page() NULL check
      https://git.kernel.org/mkp/scsi/c/0fc91e802801
Signature · 1 line
Martin K. Petersen