From 7edf970426ada2010e8bdef32a6878fb60018da7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 17 Jan 2014 08:01:17 +0000 Subject: [PATCH] scst, procfs: Avoid that adding a device to a group triggers a kernel oops This patch fixes the following kernel oops: BUG: unable to handle kernel NULL pointer dereference at 0000000000000178 IP: [] scst_acg_add_lun+0x178/0x300 [scst] Oops: 0000 [#1] PREEMPT SMP CPU: 3 PID: 7451 Comm: scstadmin Tainted: G O 3.13.0-rc3-debug+ #1 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 RIP: 0010:[] [] scst_acg_add_lun+0x178/0x300 [scst] Call Trace: [] scst_proc_groups_devices_write+0x78f/0x890 [scst] [] proc_reg_write+0x38/0x70 [] vfs_write+0xb2/0x1f0 [] SyS_write+0x47/0xa0 [] system_call_fastpath+0x16/0x1b Code: 00 00 48 8b 4d b8 49 c7 c1 80 5a 34 a0 41 b8 ce 0d 00 00 48 8b 3d c1 15 03 00 48 c7 c2 42 ba 33 a0 48 c7 c6 31 ba 33 a0 48 8b 01 <48> 8b 80 78 01 00 00 48 89 44 24 20 8b 45 a4 89 44 24 18 48 8b RIP [] scst_acg_add_lun+0x178/0x300 [scst] RSP CR2: 0000000000000178 This regression was introduced in commit "Small logging improvement" (trunk r4838; 2013-04-12). Signed-off-by: Sebastian Herbszt git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5198 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index b20303b6b..a8f3efdde 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -3548,7 +3548,7 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, PRINT_INFO("Added device %s to group %s (LUN %lld, " "rd_only %d) to target %s", dev->virt_name, acg->acg_name, - (long long unsigned int)lun, read_only, acg->tgt->tgt_name); + lun, read_only, acg->tgt ? acg->tgt->tgt_name : "?"); if (out_acg_dev != NULL) *out_acg_dev = acg_dev; @@ -3600,7 +3600,7 @@ int scst_acg_del_lun(struct scst_acg *acg, uint64_t lun, scst_report_luns_changed(acg); PRINT_INFO("Removed LUN %lld from group %s (target %s)", - (unsigned long long)lun, acg->acg_name, acg->tgt->tgt_name); + lun, acg->acg_name, acg->tgt ? acg->tgt->tgt_name : "?"); out: TRACE_EXIT_RES(res); @@ -4390,7 +4390,7 @@ int scst_acg_add_acn(struct scst_acg *acg, const char *name) out: if (res == 0) { PRINT_INFO("Added name %s to group %s (target %s)", name, - acg->acg_name, acg->tgt->tgt_name); + acg->acg_name, acg->tgt ? acg->tgt->tgt_name : "?"); scst_check_reassign_sessions(); } @@ -4464,7 +4464,7 @@ int scst_acg_remove_name(struct scst_acg *acg, const char *name, bool reassign) if (res == 0) { PRINT_INFO("Removed name %s from group %s (target %s)", name, - acg->acg_name, acg->tgt->tgt_name); + acg->acg_name, acg->tgt ? acg->tgt->tgt_name : "?"); if (reassign) scst_check_reassign_sessions(); } else