[S390] dcssblk: fix race in dcssblk_add_store()
authorGerald Schaefer <gerald.schaefer@de.ibm.com>
Thu, 21 Aug 2008 17:46:40 +0000 (19:46 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Thu, 21 Aug 2008 17:46:42 +0000 (19:46 +0200)
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: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/block/dcssblk.c

index 01fcdd91b846533a920cc3076c67bf85ca3816c2..db85f1fb131e0494dfb3e7a4838b23c269d9d36b 100644 (file)
@@ -384,6 +384,10 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
         * get minor, add to list
         */
        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);
        if (rc) {
                up_write(&dcssblk_devices_sem);