]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
scsi: target: file: Use kzalloc_flex for aio_cmd
authorThinh Nguyen <Thinh.Nguyen@synopsys.com>
Sat, 14 Mar 2026 01:17:40 +0000 (01:17 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 20 Mar 2026 02:07:39 +0000 (22:07 -0400)
The target_core_file doesn't initialize the aio_cmd->iocb for the
ki_write_stream. When a write command fd_execute_rw_aio() is executed,
we may get a bogus ki_write_stream value, causing unintended write
failure status when checking iocb->ki_write_stream > max_write_streams
in the block device.

Let's just use kzalloc_flex when allocating the aio_cmd and let
ki_write_stream=0 to fix this issue.

Fixes: 732f25a2895a ("fs: add a write stream field to the kiocb")
Fixes: c27683da6406 ("block: expose write streams for block device nodes")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://patch.msgid.link/f1a2f81c62f043e31f80bb92d5f29893400c8ee2.1773450782.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_file.c

index 3ae1f7137d9d59fd98a17026585ef0596816eed1..3d593af30aa5b01df4cb806b915d2d6f3c92b510 100644 (file)
@@ -276,7 +276,7 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
        ssize_t len = 0;
        int ret = 0, i;
 
-       aio_cmd = kmalloc_flex(*aio_cmd, bvecs, sgl_nents);
+       aio_cmd = kzalloc_flex(*aio_cmd, bvecs, sgl_nents);
        if (!aio_cmd)
                return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;