Skip to contentSkip to conversation

aic94xx: sas_alloc_task

PATCH New Mike Anderson 1 participant 1 message Mar 6, 2006 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic94xx: sas_alloc_task

Check kmem_cache_alloc return prior to init of sas_task struct.

 include/scsi/sas/sas_task.h |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
include/scsi/sas/sas_task.h +8 -6
Index: linux-2.6.9-patched/include/scsi/sas/sas_task.h
===================================================================
@@ -212,12 +212,14 @@ static inline struct sas_task *sas_alloc
 	extern kmem_cache_t *sas_task_cache;
 	struct sas_task *task = kmem_cache_alloc(sas_task_cache, flags);
 
-	memset(task, 0, sizeof(*task));
-	INIT_LIST_HEAD(&task->list);
-	spin_lock_init(&task->task_state_lock);
-	task->task_state_flags = SAS_TASK_STATE_PENDING;
-	init_timer(&task->timer);
-	init_completion(&task->completion);
+	if (task) {
+		memset(task, 0, sizeof(*task));
+		INIT_LIST_HEAD(&task->list);
+		spin_lock_init(&task->task_state_lock);
+		task->task_state_flags = SAS_TASK_STATE_PENDING;
+		init_timer(&task->timer);
+		init_completion(&task->completion);
+	}
 
 	return task;
 }