From 23390aca647e6e8751140565feb497ecabce6c78 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 7 Aug 2012 13:01:19 +0000 Subject: [PATCH] scst: sysfs session creation error path fix The attached patch prevents that a kernel oops is triggered if something fails when adding a session to sysfs. (Merge r4388 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@4451 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 7fbd96aca..5257dce4e 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -3696,11 +3696,15 @@ restart: sess->tgt->tgtt->sess_attrs); if (res != 0) { PRINT_ERROR("Can't add attributes for session %s", name); - goto out_free; + goto out_del; } } res = scst_create_sess_luns_link(sess); + if (res != 0) { + PRINT_ERROR("Can't add LUN links for session %s", name); + goto out_del; + } out_free: if (name != sess->initiator_name) @@ -3708,6 +3712,12 @@ out_free: TRACE_EXIT_RES(res); return res; + +out_del: + kobject_del(&sess->sess_kobj); + kobject_put(&sess->sess_kobj); + sess->sess_kobj_ready = 0; + goto out_free; } /*