Skip to content

Commit 01f784f

Browse files
Thinh Nguyenmartinkpetersen
authored andcommitted
scsi: target: file: Use kzalloc_flex for aio_cmd
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: 732f25a ("fs: add a write stream field to the kiocb") Fixes: c27683d ("block: expose write streams for block device nodes") Cc: [email protected] Signed-off-by: Thinh Nguyen <[email protected]> Link: https://patch.msgid.link/f1a2f81c62f043e31f80bb92d5f29893400c8ee2.1773450782.git.Thinh.Nguyen@synopsys.com Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d71afa9 commit 01f784f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/target/target_core_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ fd_execute_rw_aio(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
276276
ssize_t len = 0;
277277
int ret = 0, i;
278278

279-
aio_cmd = kmalloc_flex(*aio_cmd, bvecs, sgl_nents);
279+
aio_cmd = kzalloc_flex(*aio_cmd, bvecs, sgl_nents);
280280
if (!aio_cmd)
281281
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
282282

0 commit comments

Comments
 (0)