Fix for 2 possible crash scenarios one of which reported by 陳 七嘉 <volcom721@hotmail.com>

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@2405 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2010-10-14 14:27:29 +00:00
parent 19c072ec86
commit f6da0ea9c5

View File

@@ -1571,20 +1571,9 @@ int scst_add_threads(struct scst_cmd_threads *cmd_threads,
cmd_threads, "%s%d", nm, n++);
} else if (tgt_dev != NULL) {
char nm[11]; /* to limit the name's len */
int rc;
strlcpy(nm, tgt_dev->dev->virt_name, ARRAY_SIZE(nm));
thr->cmd_thread = kthread_create(scst_cmd_thread,
cmd_threads, "%s%d_%d", nm, tgt_dev_num, n++);
#ifdef RHEL_MAJOR
rc = set_cpus_allowed(thr->cmd_thread,
tgt_dev->sess->acg->acg_cpu_mask);
#else
rc = set_cpus_allowed_ptr(thr->cmd_thread,
&tgt_dev->sess->acg->acg_cpu_mask);
#endif
if (rc != 0)
PRINT_ERROR("Setting CPU affinity failed: "
"%d", rc);
} else
thr->cmd_thread = kthread_create(scst_cmd_thread,
cmd_threads, "scstd%d", n++);
@@ -1596,6 +1585,24 @@ int scst_add_threads(struct scst_cmd_threads *cmd_threads,
goto out_wait;
}
if (tgt_dev != NULL) {
int rc;
/*
* sess->acg can be NULL here, if called from
* scst_check_reassign_sess()!
*/
#ifdef RHEL_MAJOR
rc = set_cpus_allowed(thr->cmd_thread,
tgt_dev->acg_dev->acg->acg_cpu_mask);
#else
rc = set_cpus_allowed_ptr(thr->cmd_thread,
&tgt_dev->acg_dev->acg->acg_cpu_mask);
#endif
if (rc != 0)
PRINT_ERROR("Setting CPU affinity failed: "
"%d", rc);
}
list_add(&thr->thread_list_entry, &cmd_threads->threads_list);
cmd_threads->nr_threads++;