[3.13.y.z extended stable] Patch "Target/sbc: Initialize COMPARE_AND_WRITE write_sg scatterlist" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Thu May 1 19:17:53 UTC 2014

This is a note to let you know that I have just added a patch titled

    Target/sbc: Initialize COMPARE_AND_WRITE write_sg scatterlist

to the linux-3.13.y-queue branch of the 3.13.y.z extended stable tree 
which can be found at:


This patch is scheduled to be released in version

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.13.y.z tree, see



>From 9f66dd6cf460dad813317c5a41cc10b1b87e94e5 Mon Sep 17 00:00:00 2001
From: Martin Svec <martin.svec at zoner.cz>
Date: Tue, 1 Apr 2014 16:03:02 +0200
Subject: Target/sbc: Initialize COMPARE_AND_WRITE write_sg scatterlist

commit a1e1774c6dfa3a524dd8df51ca95185fe5ef3247 upstream.

When compiled with CONFIG_DEBUG_SG set, uninitialized SGL leads
to BUG() in compare_and_write_callback().

Signed-off-by: Martin Svec <martin.svec at zoner.cz>
Signed-off-by: Nicholas Bellinger <nab at linux-iscsi.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
 drivers/target/target_core_sbc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 52ae54e..baa8bf4 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -419,13 +419,14 @@ static sense_reason_t compare_and_write_callback(struct se_cmd *cmd)
 		goto out;

-	write_sg = kzalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
+	write_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
 	if (!write_sg) {
 		pr_err("Unable to allocate compare_and_write sg\n");
 		goto out;
+	sg_init_table(write_sg, cmd->t_data_nents);
 	 * Setup verify and write data payloads from total NumberLBAs.

More information about the kernel-team mailing list