From: Andy Grover <agrover@xxxxxxxxxx> If the function fails to allocate mem for task_sg_bidi, it would return with an error, and the task_sg would be allocated but only partially initialized. This patch frees the task_sg in that scenario. Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> Signed-off-by: Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/target_core_transport.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index bae584d..edf24b4 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -4499,6 +4499,8 @@ next: task->task_sg_bidi = kzalloc(task_sg_num_padded * sizeof(struct scatterlist), GFP_KERNEL); if (!(task->task_sg_bidi)) { + kfree(task->task_sg); + task->task_sg = NULL; printk(KERN_ERR "Unable to allocate memory for" " task->task_sg_bidi\n"); return -ENOMEM; -- 1.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html