From 4b6627b4ca507f8ab67484f95567ff08bb5784cf Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 20 Oct 2026 16:10:09 +0300 Subject: [PATCH] scst_lib: Preserve the error pointer with ERR_CAST Coccinelle api/err_cast.cocci reports: scst/src/scst_lib.c:8710:8-15: WARNING: ERR_CAST can be used with bw blk_copy_kern_sg returns an error pointer on failure. Its caller, blk_map_kern_sg, converts that value to an integer with PTR_ERR and immediately back to a pointer with ERR_PTR. Assign ERR_CAST(bw) to rq instead. It expresses propagation of the same error pointer to the request-pointer return type without the redundant pointer-to-integer round trip. --- scst/src/scst_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 6295f1dc1..a38442c27 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8709,7 +8709,7 @@ static struct request *blk_map_kern_sg(struct request_queue *q, bw = blk_copy_kern_sg(q, sgl, nents, gfp, reading); if (IS_ERR(bw)) { - rq = ERR_PTR(PTR_ERR(bw)); + rq = ERR_CAST(bw); goto out; }