Skip to contentSkip to conversation

emu10k1: correctly handling failed thread creation

PATCH Superseded Insu Yun 2 participants 2 messages Jan 28, 2016 – Jan 29, 2016 Sound

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 emu10k1: correctly handling failed thread creation

Since kthread_create can be failed, it needs to check whether error occurred and return error code.

---
 sound/pci/emu10k1/emu10k1_main.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/pci/emu10k1/emu10k1_main.c +6 -0
index 28e2f8b..b9eac15 100644
@@ -1141,6 +1141,12 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 		emu->emu1010.firmware_thread =
 			kthread_create(emu1010_firmware_thread, emu,
 				       "emu1010_firmware");
+		if (IS_ERR(emu->emu1010.firmware_thread)) {
+			dev_info(emu->card->dev,
+					"emu1010: Creating thread failed\n");
+			return PTR_ERR(emu->emu1010.firmware_thread);
+		}
+
 		wake_up_process(emu->emu1010.firmware_thread);
 	}
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 14 lines · Insu Yun

Since kthread_create can be failed, it needs to check whether error occurred and return error code.

---
 sound/pci/emu10k1/emu10k1_main.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/pci/emu10k1/emu10k1_main.c +0 -0
index 28e2f8b..b9eac15 100644

sound/pci/emu10k1/emu10k1_main.c static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu) · line 1147

Quoted 7 lines
sound/pci/emu10k1/emu10k1_main.c +4 -0
@@ -1141,6 +1141,12 @@ static int snd_emu10k1_emu1010_init(struct snd_emu10k1 *emu)
 		emu->emu1010.firmware_thread =
 			kthread_create(emu1010_firmware_thread, emu,
 				       "emu1010_firmware");
+		if (IS_ERR(emu->emu1010.firmware_thread)) {
+			dev_info(emu->card->dev,
+					"emu1010: Creating thread failed\n");
+			return PTR_ERR(emu->emu1010.firmware_thread);

It needs to NULL-clear emu->emu1010.firmware_thread after this, since kthread_stop() is called for non-NULL case in the destructor. Could you fix it and resubmit?

thanks,

Takashi

Quoted 9 lines
sound/pci/emu10k1/emu10k1_main.c +2 -0
+		}
+
 		wake_up_process(emu->emu1010.firmware_thread);
 	}
 
Signature · 1 line
1.9.1