Skip to content

Commit a1e1774

Browse files
MartySvecNicholas Bellinger
authored and
Nicholas Bellinger
committed
Target/sbc: Initialize COMPARE_AND_WRITE write_sg scatterlist
When compiled with CONFIG_DEBUG_SG set, uninitialized SGL leads to BUG() in compare_and_write_callback(). Signed-off-by: Martin Svec <[email protected]> Cc: <[email protected]> #3.12+ Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 9d2e59f commit a1e1774

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/target/target_core_sbc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,14 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd)
425425
goto out;
426426
}
427427

428-
write_sg = kzalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
428+
write_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
429429
GFP_KERNEL);
430430
if (!write_sg) {
431431
pr_err("Unable to allocate compare_and_write sg\n");
432432
ret = TCM_OUT_OF_RESOURCES;
433433
goto out;
434434
}
435+
sg_init_table(write_sg, cmd->t_data_nents);
435436
/*
436437
* Setup verify and write data payloads from total NumberLBAs.
437438
*/

0 commit comments

Comments
 (0)