* [PATCH] ufs: core: Remove an unnecessary NULL pointer check
@ 2025-11-11 18:47 Bart Van Assche
2025-11-13 1:58 ` Martin K. Petersen
2025-11-20 4:15 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Bart Van Assche @ 2025-11-11 18:47 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, James E.J. Bottomley, Avri Altman,
Bean Huo, Guixin Liu, Ziqi Chen, Arthur Simchaev
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.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/ufs/core/ufs_bsg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/ufs/core/ufs_bsg.c b/drivers/ufs/core/ufs_bsg.c
index 252186124669..58b506eac6dc 100644
--- a/drivers/ufs/core/ufs_bsg.c
+++ b/drivers/ufs/core/ufs_bsg.c
@@ -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);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ufs: core: Remove an unnecessary NULL pointer check
2025-11-11 18:47 [PATCH] ufs: core: Remove an unnecessary NULL pointer check Bart Van Assche
@ 2025-11-13 1:58 ` Martin K. Petersen
2025-11-20 4:15 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-11-13 1:58 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, linux-scsi, James E.J. Bottomley,
Avri Altman, Bean Huo, Guixin Liu, Ziqi Chen, Arthur Simchaev
Bart,
> 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!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ufs: core: Remove an unnecessary NULL pointer check
2025-11-11 18:47 [PATCH] ufs: core: Remove an unnecessary NULL pointer check Bart Van Assche
2025-11-13 1:58 ` Martin K. Petersen
@ 2025-11-20 4:15 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2025-11-20 4:15 UTC (permalink / raw)
To: Bart Van Assche
Cc: Martin K . Petersen, linux-scsi, James E.J. Bottomley,
Avri Altman, Bean Huo, Guixin Liu, Ziqi Chen, Arthur Simchaev
On Tue, 11 Nov 2025 10:47:59 -0800, Bart Van Assche wrote:
> 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
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-20 4:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-11 18:47 [PATCH] ufs: core: Remove an unnecessary NULL pointer check Bart Van Assche
2025-11-13 1:58 ` Martin K. Petersen
2025-11-20 4:15 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox