Avoid that the code for dumping the PR state triggers a race condition

Callers of scst_pr_dump_prs() must hold dev_pr_mutex.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5508 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2014-05-08 02:28:49 +00:00
parent 410b27ccdc
commit b7f80e0566
2 changed files with 16 additions and 3 deletions
+6 -1
View File
@@ -397,7 +397,12 @@ int scst_proc_log_entry_write(struct file *file, const char __user *buf,
list_for_each_entry(dev, &scst_dev_list, dev_list_entry) {
if (strcmp(dev->virt_name, p) == 0) {
scst_pr_dump_prs(dev, true);
if (mutex_lock_interruptible(&dev->dev_pr_mutex) == 0) {
scst_pr_dump_prs(dev, true);
mutex_unlock(&dev->dev_pr_mutex);
} else {
res = -EINTR;
}
goto out_up;
}
}
+10 -2
View File
@@ -2762,15 +2762,23 @@ static ssize_t scst_dev_sysfs_dump_prs(struct kobject *kobj,
struct kobj_attribute *attr, const char *buf, size_t count)
{
struct scst_device *dev;
int res;
TRACE_ENTRY();
dev = container_of(kobj, struct scst_device, dev_kobj);
res = mutex_lock_interruptible(&dev->dev_pr_mutex);
if (res != 0)
goto out;
scst_pr_dump_prs(dev, true);
mutex_unlock(&dev->dev_pr_mutex);
TRACE_EXIT_RES(count);
return count;
res = count;
out:
TRACE_EXIT_RES(res);
return res;
}
static struct kobj_attribute dev_dump_prs_attr =