Skip to contentSkip to conversation

1/3 Serio: claim serio early

PATCH In review Dmitry Torokhov 2 participants 2 messages Aug 23, 2003 – Aug 25, 2003 Input drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 1/3 Serio: claim serio early

Hi,

I think that serio_dev in serio_open should claim serio before calling "open" function as it has already been decided that (in case of success) this serio belongs to that serio_dev. Otherwise it might try to find an owner on its own, like i8042 module that calls serio_interrupt which in turn will do serio_rescan. From that point on 2 instances may start fighting over the same serio.

What you think about the patch below?

Dmitry

drivers/input/serio/serio.c +4 -2
diff -urN --exclude-from=/usr/src/exclude 2.6.0-test4/drivers/input/serio/serio.c linux-2.6.0-test4/drivers/input/serio/serio.c
@@ -204,9 +204,11 @@
 /* called from serio_dev->connect/disconnect methods under serio_sem */
 int serio_open(struct serio *serio, struct serio_dev *dev)
 {
-	if (serio->open(serio))
-		return -1;
 	serio->dev = dev;
+	if (serio->open(serio)) {
+		serio->dev = NULL;
+		return -1;
+	}
 	return 0;
 }
 
#1 lore raw
Quoted 10 lines · Dmitry Torokhov

Hi,

I think that serio_dev in serio_open should claim serio before calling "open" function as it has already been decided that (in case of success) this serio belongs to that serio_dev. Otherwise it might try to find an owner on its own, like i8042 module that calls serio_interrupt which in turn will do serio_rescan. From that point on 2 instances may start fighting over the same serio.

What you think about the patch below?

Agreed.

Quoted 26 lines

Dmitry

diff -urN --exclude-from=/usr/src/exclude 2.6.0-test4/drivers/input/serio/serio.c linux-2.6.0-test4/drivers/input/serio/serio.c

drivers/input/serio/serio.c +4 -3
@@ -204,9 +204,11 @@
 /* called from serio_dev->connect/disconnect methods under serio_sem */
 int serio_open(struct serio *serio, struct serio_dev *dev)
 {
-	if (serio->open(serio))
-		return -1;
 	serio->dev = dev;
+	if (serio->open(serio)) {
+		serio->dev = NULL;
+		return -1;
+	}
 	return 0;
 }
 
 
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR