mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-21 06:36:27 +00:00
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:
@@ -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
@@ -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 =
|
||||
|
||||
Reference in New Issue
Block a user