提交 04f64b57 编写于 作者: G Gerald Schaefer 提交者: Martin Schwidefsky

[S390] dcssblk: fix race in dcssblk_add_store()

Concurrently adding the same segment may lead to duplicate device_register()
calls, which will trigger an error in kobject code:
"... don't try to register things with the same name in the same directory".
This patch adds a check to avoid this.
Signed-off-by: NGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 91c36919
...@@ -384,6 +384,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char ...@@ -384,6 +384,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
* get minor, add to list * get minor, add to list
*/ */
down_write(&dcssblk_devices_sem); down_write(&dcssblk_devices_sem);
if (dcssblk_get_segment_by_name(local_buf)) {
rc = -EEXIST;
goto release_gd;
}
rc = dcssblk_assign_free_minor(dev_info); rc = dcssblk_assign_free_minor(dev_info);
if (rc) { if (rc) {
up_write(&dcssblk_devices_sem); up_write(&dcssblk_devices_sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册