From cf699a6d951d0be1407e7ec90b05663e483924de Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 6 Feb 2014 12:46:51 +0000 Subject: [PATCH] scst_local: Fix a kernel oops for kernel versions < 2.6.37 Avoid that scst_local triggers "BUG: unable to handle kernel NULL pointer dereference" on kernel versions before 2.6.37. This patch fixes a regression introduced via patch "scst_local: Avoid deadlock during module removal with kernel 3.6" (trunk r4566). Reported-by: Sebastian Herbszt git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5264 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst_local/scst_local.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scst_local/scst_local.c b/scst_local/scst_local.c index ed46a8527..310a55b26 100644 --- a/scst_local/scst_local.c +++ b/scst_local/scst_local.c @@ -960,6 +960,14 @@ static int scst_local_queuecommand_lck(struct scsi_cmnd *SCpnt, TRACE_DBG("lun %d, cmd: 0x%02X", SCpnt->device->lun, SCpnt->cmnd[0]); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) + /* + * We save a pointer to the done routine in SCpnt->scsi_done and + * we save that as tgt specific stuff below. + */ + SCpnt->scsi_done = done; +#endif + sess = to_scst_lcl_sess(scsi_get_device(SCpnt->device->host)); if (sess->unregistering) { @@ -983,12 +991,6 @@ static int scst_local_queuecommand_lck(struct scsi_cmnd *SCpnt, } tgt_specific->cmnd = SCpnt; tgt_specific->done = done; -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37) - /* - * We save a pointer to the done routine in SCpnt->scsi_done and - * we save that as tgt specific stuff below. - */ - SCpnt->scsi_done = done; #endif /*