kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: mixer_oss: Remove some incorrect kfree_const() usages
@ 2024-09-26 18:17 Christophe JAILLET
  2024-09-30  8:12 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2024-09-26 18:17 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Takashi Iwai,
	linux-sound

"assigned" and "assigned->name" are allocated in snd_mixer_oss_proc_write()
using kmalloc() and kstrdup(), so there is no point in using kfree_const()
to free these resources.

Switch to the more standard kfree() to free these resources.

This could avoid a memory leak.

Fixes: 454f5ec1d2b7 ("ALSA: mixer: oss: Constify snd_mixer_oss_assign_table definition")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.

For the records, this patch is a clean-up effort related to discussions at:
  - https://lore.kernel.org/all/ZvHurCYlCoi1ZTCX@skv.local/
  - https://lore.kernel.org/all/20240924050937.697118-1-senozhatsky@chromium.org/
---
 sound/core/oss/mixer_oss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 33bf9a220ada..89b317c728b4 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -901,8 +901,8 @@ static void snd_mixer_oss_slot_free(struct snd_mixer_oss_slot *chn)
 	struct slot *p = chn->private_data;
 	if (p) {
 		if (p->allocated && p->assigned) {
-			kfree_const(p->assigned->name);
-			kfree_const(p->assigned);
+			kfree(p->assigned->name);
+			kfree(p->assigned);
 		}
 		kfree(p);
 	}
-- 
2.46.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: mixer_oss: Remove some incorrect kfree_const() usages
  2024-09-26 18:17 [PATCH] ALSA: mixer_oss: Remove some incorrect kfree_const() usages Christophe JAILLET
@ 2024-09-30  8:12 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2024-09-30  8:12 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Jaroslav Kysela, Takashi Iwai, linux-kernel, kernel-janitors,
	Takashi Iwai, linux-sound

On Thu, 26 Sep 2024 20:17:36 +0200,
Christophe JAILLET wrote:
> 
> "assigned" and "assigned->name" are allocated in snd_mixer_oss_proc_write()
> using kmalloc() and kstrdup(), so there is no point in using kfree_const()
> to free these resources.
> 
> Switch to the more standard kfree() to free these resources.
> 
> This could avoid a memory leak.
> 
> Fixes: 454f5ec1d2b7 ("ALSA: mixer: oss: Constify snd_mixer_oss_assign_table definition")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied now.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-30  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 18:17 [PATCH] ALSA: mixer_oss: Remove some incorrect kfree_const() usages Christophe JAILLET
2024-09-30  8:12 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).