Explorar o código

Add a comment in chrdev_open()

I stared at this code for a while and almost deleted it before
understanding crept into my slow brain.  Hopefully this makes life easier
for the next person to happen on it.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Jonathan Corbet %!s(int64=17) %!d(string=hai) anos
pai
achega
a30427d92d
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      fs/char_dev.c

+ 2 - 0
fs/char_dev.c

@@ -373,6 +373,8 @@ static int chrdev_open(struct inode *inode, struct file *filp)
 			return -ENXIO;
 			return -ENXIO;
 		new = container_of(kobj, struct cdev, kobj);
 		new = container_of(kobj, struct cdev, kobj);
 		spin_lock(&cdev_lock);
 		spin_lock(&cdev_lock);
+		/* Check i_cdev again in case somebody beat us to it while
+		   we dropped the lock. */
 		p = inode->i_cdev;
 		p = inode->i_cdev;
 		if (!p) {
 		if (!p) {
 			inode->i_cdev = p = new;
 			inode->i_cdev = p = new;