Skip to contentSkip to conversation

ak4117: Do not free priv until timer handler hasn't actually stopped using it

PATCH Applied Kirill Tkhai 2 participants 2 messages Feb 14, 2014 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ak4117: Do not free priv until timer handler hasn't actually stopped using it

Function del_timer() does not guarantee that timer was really deleted. If the timer handler is beeing executed at the moment, the function does nothing. So, it's possible to use already freed memory in the handler:

[ref: Documentation/DocBook/kernel-locking.tmpl]

This was found using grep and compile-tested only.

CC Jaroslav Kysela <[email protected]>
CC Takashi Iwai <[email protected]>
---
 sound/i2c/other/ak4117.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/i2c/other/ak4117.c +1 -1
index 40e33c9..88452e8 100644
@@ -62,7 +62,7 @@ static void reg_dump(struct ak4117 *ak4117)
 
 static void snd_ak4117_free(struct ak4117 *chip)
 {
-	del_timer(&chip->timer);
+	del_timer_sync(&chip->timer);
 	kfree(chip);
 }
 
Applied
#1 lore raw

At Fri, 14 Feb 2014 15:47:57 +0400,

Quoted 8 lines · Kirill Tkhai

Function del_timer() does not guarantee that timer was really deleted. If the timer handler is beeing executed at the moment, the function does nothing. So, it's possible to use already freed memory in the handler:

[ref: Documentation/DocBook/kernel-locking.tmpl]

This was found using grep and compile-tested only.

Thanks, applied.

Takashi

Quoted 24 lines
CC Jaroslav Kysela <[email protected]>
CC Takashi Iwai <[email protected]>
---
 sound/i2c/other/ak4117.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/i2c/other/ak4117.c +1 -1
index 40e33c9..88452e8 100644
@@ -62,7 +62,7 @@ static void reg_dump(struct ak4117 *ak4117)
 
 static void snd_ak4117_free(struct ak4117 *chip)
 {
-	del_timer(&chip->timer);
+	del_timer_sync(&chip->timer);
 	kfree(chip);
 }