[S390] ccwgroup: add locking around drvdata access

Several processes may concurrently try to create a group device
from the same ccw_device(s). Add locking arround the drvdata
access to prevent race conditions.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by Sebastian Ott and committed by Martin Schwidefsky c560d105 a65a3e82

+7
+7
drivers/s390/cio/ccwgroup.c
··· 123 123 124 124 for (i = 0; i < gdev->count; i++) { 125 125 if (gdev->cdev[i]) { 126 + spin_lock_irq(gdev->cdev[i]->ccwlock); 126 127 if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev) 127 128 dev_set_drvdata(&gdev->cdev[i]->dev, NULL); 129 + spin_unlock_irq(gdev->cdev[i]->ccwlock); 128 130 put_device(&gdev->cdev[i]->dev); 129 131 } 130 132 } ··· 264 262 goto error; 265 263 } 266 264 /* Don't allow a device to belong to more than one group. */ 265 + spin_lock_irq(gdev->cdev[i]->ccwlock); 267 266 if (dev_get_drvdata(&gdev->cdev[i]->dev)) { 267 + spin_unlock_irq(gdev->cdev[i]->ccwlock); 268 268 rc = -EINVAL; 269 269 goto error; 270 270 } 271 271 dev_set_drvdata(&gdev->cdev[i]->dev, gdev); 272 + spin_unlock_irq(gdev->cdev[i]->ccwlock); 272 273 } 273 274 /* Check for sufficient number of bus ids. */ 274 275 if (i < num_devices && !curr_buf) { ··· 308 303 error: 309 304 for (i = 0; i < num_devices; i++) 310 305 if (gdev->cdev[i]) { 306 + spin_lock_irq(gdev->cdev[i]->ccwlock); 311 307 if (dev_get_drvdata(&gdev->cdev[i]->dev) == gdev) 312 308 dev_set_drvdata(&gdev->cdev[i]->dev, NULL); 309 + spin_unlock_irq(gdev->cdev[i]->ccwlock); 313 310 put_device(&gdev->cdev[i]->dev); 314 311 gdev->cdev[i] = NULL; 315 312 }