From afa076b5377cff7e1b4096965849e7939c399af1 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 21 Oct 2013 12:35:48 +0200 Subject: [PATCH] lib: Make scsi_free_scsi_task() accept a NULL task pointer Several cleanup paths can be simplified if it is allowed to pass a NULL pointer to scsi_free_scsi_task(). Hence modify this function such that it returns immediately if passed a NULL task pointer. Signed-off-by: Bart Van Assche --- lib/scsi-lowlevel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/scsi-lowlevel.c b/lib/scsi-lowlevel.c index 37ba28b..4c05427 100644 --- a/lib/scsi-lowlevel.c +++ b/lib/scsi-lowlevel.c @@ -66,6 +66,9 @@ scsi_free_scsi_task(struct scsi_task *task) { struct scsi_allocated_memory *mem; + if (!task) + return; + while ((mem = task->mem)) { SLIST_REMOVE(&task->mem, mem); free(mem);