From c531f06b326c79a814ad175239505a566db058c3 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 28 Jun 2012 22:43: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. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4388 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 ea48a927e..1d0a2627b 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -3648,11 +3648,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) @@ -3660,6 +3664,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; } /*