From 404b21b5f056578efc050e60cbc15af578d974b4 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 10 Oct 2013 04:02:46 +0000 Subject: [PATCH] iscsi-scst, scst_local: Avoid that session reassignment triggers a crash This patch fixes the following crash triggered by session reassignment when using a target driver that defines a report_aen callback in its target template (iscsi-scst and scst_local): BUG: unable to handle kernel NULL pointer dereference at 00000000000000c0 IP: [] scst_alloc_aen+0xbf/0x220 [scst] RIP: 0010:[] [] scst_alloc_aen+0xbf/0x220 [scst] Call Trace: [] scst_gen_aen_or_ua+0xff/0x2d0 [scst] [] scst_tg_change_tgt_dev_state+0x61/0xd0 [scst] [] scst_tg_init_tgt_dev+0x5b/0xa0 [scst] [] scst_alloc_add_tgt_dev+0x686/0x750 [scst] [] scst_check_reassign_sess+0x367/0x660 [scst] [] scst_check_reassign_sessions+0x88/0x140 [scst] [] scst_acg_add_acn+0x1ba/0x2b0 [scst] [] scst_process_acg_ini_mgmt_store+0x43f/0x570 [scst] [] scst_acg_ini_mgmt_store_work_fn+0x1e/0x20 [scst] [] scst_process_sysfs_works+0xbf/0x190 [scst] [] sysfs_work_thread_fn+0x110/0x2a0 [scst] [] kthread+0xd6/0xe0 [] ret_from_fork+0x7c/0xb0 Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5053 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 45c9d48ef..df3b9558a 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -2486,7 +2486,7 @@ static void scst_check_reassign_sess(struct scst_session *sess) acg->acg_name); old_acg = sess->acg; - sess->acg = NULL; /* to catch implicit dependencies earlier */ + sess->acg = acg; retry_add: add_failed = false; @@ -2559,8 +2559,6 @@ next: goto retry_add; } - sess->acg = acg; - TRACE_DBG("Moving sess %p from acg %s to acg %s", sess, old_acg->acg_name, acg->acg_name); list_move_tail(&sess->acg_sess_list_entry, &acg->acg_sess_list);