Skip to contentSkip to conversation

saa7134: fix thread shutdown handling

PATCH In review Jeff Mahoney 3 participants 3 messages Jun 21, 2007 – Jun 23, 2007 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 saa7134: fix thread shutdown handling

This patch changes the test for the thread pid from >= 0 to > 0.

When the saa8134 driver initialization fails after a certain point, it goes through the complete shutdown process for the driver. Part of shutting it down includes tearing down the thread for tv audio.

The test for tearing down the thread tests for >= 0. Since the dev structure is kzalloc'd, the test will always be true if we haven't tried to start the thread yet. We end up waiting on pid 0 to complete, which will never happen, so we lock up.

This bug was observed in Novell Bugzilla 284718, when request_irq() failed.

---

 drivers/media/video/saa7134/saa7134-tvaudio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/video/saa7134/saa7134-tvaudio.c +1 -1
@@ -1005,7 +1005,7 @@
 int saa7134_tvaudio_fini(struct saa7134_dev *dev)
 {
 	/* shutdown tvaudio thread */
-	if (dev->thread.pid >= 0) {
+	if (dev->thread.pid > 0) {
 		dev->thread.shutdown = 1;
 		wake_up_interruptible(&dev->thread.wq);
 		wait_for_completion(&dev->thread.exit);
Signature · 2 lines
Jeff Mahoney
SUSE Labs
#1 lore raw
Quoted 26 lines · On Thu, 21 Jun 2007 14:45:22 -0400 Jeff Mahoney <[email protected]> wrote:

This patch changes the test for the thread pid from >= 0 to > 0.

When the saa8134 driver initialization fails after a certain point, it goes through the complete shutdown process for the driver. Part of shutting it down includes tearing down the thread for tv audio.

The test for tearing down the thread tests for >= 0. Since the dev structure is kzalloc'd, the test will always be true if we haven't tried to start the thread yet. We end up waiting on pid 0 to complete, which will never happen, so we lock up.

This bug was observed in Novell Bugzilla 284718, when request_irq() failed.

---

 drivers/media/video/saa7134/saa7134-tvaudio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/media/video/saa7134/saa7134-tvaudio.c line 1011

Quoted 8 lines
drivers/media/video/saa7134/saa7134-tvaudio.c +1 -1
@@ -1005,7 +1005,7 @@
 int saa7134_tvaudio_fini(struct saa7134_dev *dev)
 {
 	/* shutdown tvaudio thread */
-	if (dev->thread.pid >= 0) {
+	if (dev->thread.pid > 0) {
 		dev->thread.shutdown = 1;
 		wake_up_interruptible(&dev->thread.wq);
 		wait_for_completion(&dev->thread.exit);

This is no longer applicable to the dvb devel tree, because this code has been converted to the kthread API.

However I guess we do want this in 2.6.22 and in 2.6.21.x. Mauro, if that's OK, do you want me to do the merges?

#2 lore raw

Em Sáb, 2007-06-23 às 09:54 -0700, Andrew Morton escreveu:

Quoted 38 lines
Quoted 26 lines · On Thu, 21 Jun 2007 14:45:22 -0400 Jeff Mahoney <[email protected]> wrote:

This patch changes the test for the thread pid from >= 0 to > 0.

When the saa8134 driver initialization fails after a certain point, it goes through the complete shutdown process for the driver. Part of shutting it down includes tearing down the thread for tv audio.

The test for tearing down the thread tests for >= 0. Since the dev structure is kzalloc'd, the test will always be true if we haven't tried to start the thread yet. We end up waiting on pid 0 to complete, which will never happen, so we lock up.

This bug was observed in Novell Bugzilla 284718, when request_irq() failed.

---

 drivers/media/video/saa7134/saa7134-tvaudio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/media/video/saa7134/saa7134-tvaudio.c line 1011

Quoted 8 lines
drivers/media/video/saa7134/saa7134-tvaudio.c +1 -1
@@ -1005,7 +1005,7 @@
 int saa7134_tvaudio_fini(struct saa7134_dev *dev)
 {
 	/* shutdown tvaudio thread */
-	if (dev->thread.pid >= 0) {
+	if (dev->thread.pid > 0) {
 		dev->thread.shutdown = 1;
 		wake_up_interruptible(&dev->thread.wq);
 		wait_for_completion(&dev->thread.exit);

This is no longer applicable to the dvb devel tree, because this code has been converted to the kthread API.

Quoted 2 lines

However I guess we do want this in 2.6.22 and in 2.6.21.x. Mauro, if that's OK, do you want me to do the merges?

Yes, please, Andrew. I'm OK on merging this for the -stable trees.

Quoted 1 line
Signature · 2 lines
Cheers,
Mauro