Skip to contentSkip to conversation

ufs: core: Remove an unnecessary NULL pointer check

PATCH Applied Bart Van Assche 2 participants 3 messages Nov 11, 2025 – Nov 20, 2025

Subsystems (2)
lore
Share & tools
lore

Bart Van Assche

author reviewer
#0 lore raw

PATCH 1/1 ufs: core: Remove an unnecessary NULL pointer check

The !payload check tests the address of a member of a data structure. We know that the start address of this data structure (job) is not NULL since the 'job' pointer has already been dereferenced. Hence, the !payload check is superfluous. Remove this test. This was reported by the CodeSonar static analyzer.

---
 drivers/ufs/core/ufs_bsg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ufs/core/ufs_bsg.c +1 -1
index 252186124669..58b506eac6dc 100644
@@ -105,7 +105,7 @@ static int ufs_bsg_exec_advanced_rpmb_req(struct ufs_hba *hba, struct bsg_job *j
 
 	if (dir != DMA_NONE) {
 		payload = &job->request_payload;
-		if (!payload || !payload->payload_len || !payload->sg_cnt)
+		if (!payload->payload_len || !payload->sg_cnt)
 			return -EINVAL;
 
 		sg_cnt = dma_map_sg(hba->host->dma_dev, payload->sg_list, payload->sg_cnt, dir);
#1 lore raw

Bart,

Quoted 5 lines

The !payload check tests the address of a member of a data structure. We know that the start address of this data structure (job) is not NULL since the 'job' pointer has already been dereferenced. Hence, the !payload check is superfluous. Remove this test. This was reported by the CodeSonar static analyzer.

Applied to 6.19/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen
#2 lore raw
In reply to Bart Van Assche
Quoted 8 lines · Bart Van Assche

The !payload check tests the address of a member of a data structure. We know that the start address of this data structure (job) is not NULL since the 'job' pointer has already been dereferenced. Hence, the !payload check is superfluous. Remove this test. This was reported by the CodeSonar static analyzer.

[...]

Applied to 6.19/scsi-queue, thanks!

[1/1] ufs: core: Remove an unnecessary NULL pointer check

      https://git.kernel.org/mkp/scsi/c/18987143d4b1
Signature · 1 line
Martin K. Petersen