Skip to contentSkip to conversation

7/7 replace snd_kmalloc_strdup by kstrdup

PATCH In review [email protected] 2 participants 15 messages Feb 1, 2005 – Feb 2, 2005 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 7/7 replace snd_kmalloc_strdup by kstrdup

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

--
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing. Edmund Burke (1729 - 1797)

include/sound/core.h +0 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h
@@ -310,7 +310,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 
sound/core/info.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;
sound/core/info_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c
@@ -27,6 +27,7 @@
 #include <sound/info.h>
 #include <sound/version.h>
 #include <linux/utsname.h>
+#include <linux/string.h>
 
 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
 
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;
sound/core/memory.c +0 -23
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/memory.c linux-2.6.11-rc2-bk9/sound/core/memory.c
@@ -221,29 +221,6 @@ int __exit snd_memory_info_done(void)
 #endif /* CONFIG_SND_DEBUG_MEMORY */
 
 /**
- * snd_kmalloc_strdup - copy the string
- * @string: the original string
- * @flags: allocation conditions, GFP_XXX
- *
- * Allocates a memory chunk via kmalloc() and copies the string to it.
- *
- * Returns the pointer, or NULL if no enoguh memory.
- */
-char *snd_kmalloc_strdup(const char *string, int flags)
-{
-	size_t len;
-	char *ptr;
-
-	if (!string)
-		return NULL;
-	len = strlen(string) + 1;
-	ptr = _snd_kmalloc(len, flags);
-	if (ptr)
-		memcpy(ptr, string, len);
-	return ptr;
-}
-
-/**
  * copy_to_user_fromio - copy data from mmio-space to user-space
  * @dst: the destination pointer on user-space
  * @src: the source pointer on mmio
sound/core/oss/mixer_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;
sound/core/oss/pcm_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}
sound/core/sound.c +0 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */
sound/core/timer.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;
sound/isa/gus/gus_mem.c +4 -3
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG
sound/synth/emux/emux.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c
@@ -25,6 +25,7 @@
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
+#include <linux/string.h>
 #include "emux_voice.h"
 
 MODULE_AUTHOR("Takashi Iwai");
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;
#1 lore raw

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 7 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Takashi

Quoted 210 lines

--
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
[2 patch7 <text/x-diff (base64)>]
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h

include/sound/core.h +0 -1
@@ -310,7 +310,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c

sound/core/info.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c

sound/core/info_oss.c +2 -1
@@ -27,6 +27,7 @@
 #include <sound/info.h>
 #include <sound/version.h>
 #include <linux/utsname.h>
+#include <linux/string.h>
 
 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
 
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/memory.c linux-2.6.11-rc2-bk9/sound/core/memory.c

sound/core/memory.c +0 -23
@@ -221,29 +221,6 @@ int __exit snd_memory_info_done(void)
 #endif /* CONFIG_SND_DEBUG_MEMORY */
 
 /**
- * snd_kmalloc_strdup - copy the string
- * @string: the original string
- * @flags: allocation conditions, GFP_XXX
- *
- * Allocates a memory chunk via kmalloc() and copies the string to it.
- *
- * Returns the pointer, or NULL if no enoguh memory.
- */
-char *snd_kmalloc_strdup(const char *string, int flags)
-{
-	size_t len;
-	char *ptr;
-
-	if (!string)
-		return NULL;
-	len = strlen(string) + 1;
-	ptr = _snd_kmalloc(len, flags);
-	if (ptr)
-		memcpy(ptr, string, len);
-	return ptr;
-}
-
-/**
  * copy_to_user_fromio - copy data from mmio-space to user-space
  * @dst: the destination pointer on user-space
  * @src: the source pointer on mmio

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c

sound/core/oss/mixer_oss.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c

sound/core/oss/pcm_oss.c +2 -1
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c

sound/core/timer.c +2 -1
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c

sound/isa/gus/gus_mem.c +4 -3
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c

sound/synth/emux/emux.c +1 -0
@@ -25,6 +25,7 @@
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
+#include <linux/string.h>
 #include "emux_voice.h"
 
 MODULE_AUTHOR("Takashi Iwai");

sound/synth/emux/emux.c int snd_emux_register(snd_emux_t *emu, s · line 83

Quoted 8 lines
sound/synth/emux/emux.c +1 -1
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl

#2 lore raw
In reply to [email protected]

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 7 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Takashi

Quoted 218 lines

--
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
[2 patch7 <text/x-diff (base64)>]
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h

include/sound/core.h +0 -1
@@ -310,7 +310,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c

sound/core/info.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c

sound/core/info_oss.c +2 -1
@@ -27,6 +27,7 @@
 #include <sound/info.h>
 #include <sound/version.h>
 #include <linux/utsname.h>
+#include <linux/string.h>
 
 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
 
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/memory.c linux-2.6.11-rc2-bk9/sound/core/memory.c

sound/core/memory.c +0 -23
@@ -221,29 +221,6 @@ int __exit snd_memory_info_done(void)
 #endif /* CONFIG_SND_DEBUG_MEMORY */
 
 /**
- * snd_kmalloc_strdup - copy the string
- * @string: the original string
- * @flags: allocation conditions, GFP_XXX
- *
- * Allocates a memory chunk via kmalloc() and copies the string to it.
- *
- * Returns the pointer, or NULL if no enoguh memory.
- */
-char *snd_kmalloc_strdup(const char *string, int flags)
-{
-	size_t len;
-	char *ptr;
-
-	if (!string)
-		return NULL;
-	len = strlen(string) + 1;
-	ptr = _snd_kmalloc(len, flags);
-	if (ptr)
-		memcpy(ptr, string, len);
-	return ptr;
-}
-
-/**
  * copy_to_user_fromio - copy data from mmio-space to user-space
  * @dst: the destination pointer on user-space
  * @src: the source pointer on mmio

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c

sound/core/oss/mixer_oss.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c

sound/core/oss/pcm_oss.c +2 -1
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c

sound/core/timer.c +2 -1
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c

sound/isa/gus/gus_mem.c +4 -3
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c

sound/synth/emux/emux.c +2 -1
@@ -25,6 +25,7 @@
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
+#include <linux/string.h>
 #include "emux_voice.h"
 
 MODULE_AUTHOR("Takashi Iwai");
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;
#3 lore raw
Quoted 5 lines · Takashi Iwai

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 2 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 7 lines
Quoted 4 lines

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Humm.. compiles ok here.

I just rebuilt a vanilla 2.6.11-rc2-bk9 tree, applied the patches, selected CONFIG_SND_DEBUG and CONFIG_SND_DEBUG_MEMORY, and it compiled just fine.

I had already tested the patches with an allyesconfig, but tested it anyway just to be sure.

Are you sure you also applied the first patch in the series that creates the kstrdup library function? If you are, can you send me your .config so that I can test it here?

Signature · 4 lines
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
#4 lore raw

At Tue, 01 Feb 2005 12:27:44 +0000,

Quoted 21 lines · Paulo Marques
Quoted 5 lines · Takashi Iwai

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 2 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 7 lines
Quoted 4 lines

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Humm.. compiles ok here.

I just rebuilt a vanilla 2.6.11-rc2-bk9 tree, applied the patches, selected CONFIG_SND_DEBUG and CONFIG_SND_DEBUG_MEMORY, and it compiled just fine.

Quoted 6 lines

I had already tested the patches with an allyesconfig, but tested it anyway just to be sure.

Are you sure you also applied the first patch in the series that creates the kstrdup library function? If you are, can you send me your .config so that I can test it here?

The compile should be fine but it may result in memory corruption since kmalloc/kfree become wrappers when CONFIG_SND_DEBUG_MEMORY is set. See include/sound/core.h.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl

#5 lore raw
In reply to Paulo Marques

At Tue, 01 Feb 2005 12:27:44 +0000,

Quoted 21 lines · Paulo Marques
Quoted 5 lines · Takashi Iwai

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 2 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

Quoted 7 lines
Quoted 4 lines

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Humm.. compiles ok here.

I just rebuilt a vanilla 2.6.11-rc2-bk9 tree, applied the patches, selected CONFIG_SND_DEBUG and CONFIG_SND_DEBUG_MEMORY, and it compiled just fine.

Quoted 6 lines

I had already tested the patches with an allyesconfig, but tested it anyway just to be sure.

Are you sure you also applied the first patch in the series that creates the kstrdup library function? If you are, can you send me your .config so that I can test it here?

The compile should be fine but it may result in memory corruption since kmalloc/kfree become wrappers when CONFIG_SND_DEBUG_MEMORY is set. See include/sound/core.h.

Takashi

#6 lore raw
Quoted 4 lines · Takashi Iwai

[...]
The compile should be fine but it may result in memory corruption since kmalloc/kfree become wrappers when CONFIG_SND_DEBUG_MEMORY is set. See include/sound/core.h.

Ok, I see what you mean. I'm sorry I've missed this, but you must admit that code like this:

Quoted 2 lines

#define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) #define kfree(obj) snd_hidden_kfree(obj)

in sound/core.h make the code really hard to read :P

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Signature · 4 lines
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
#7 lore raw

At Tue, 01 Feb 2005 13:07:25 +0000,

Quoted 5 lines · Paulo Marques

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

Quoted 8 lines

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

This sounds good. We can do just like normal kmalloc:

#ifdef CONFIG_SND_DEBUG_MEMORY
...
#define kstrdup(s) my_kstrdup_wrapper(s)
#endif

Quoted 2 lines

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Heh, it's up to you ;) Using kstrdup() in normal cases would be better, of course.

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl

#8 lore raw
In reply to Paulo Marques

At Tue, 01 Feb 2005 13:07:25 +0000,

Quoted 5 lines · Paulo Marques

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

Quoted 8 lines

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

This sounds good. We can do just like normal kmalloc:

#ifdef CONFIG_SND_DEBUG_MEMORY
...
#define kstrdup(s) my_kstrdup_wrapper(s)
#endif

Quoted 2 lines

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Heh, it's up to you ;) Using kstrdup() in normal cases would be better, of course.

Takashi

#9 lore raw
Quoted 18 lines · Takashi Iwai

At Tue, 01 Feb 2005 13:07:25 +0000,

Quoted 5 lines · Paulo Marques

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

This sounds good. We can do just like normal kmalloc:

#ifdef CONFIG_SND_DEBUG_MEMORY
...
#define kstrdup(s) my_kstrdup_wrapper(s)
#endif

Quoted 5 lines
Quoted 1 line

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Heh, it's up to you ;) Using kstrdup() in normal cases would be better, of course.

Ok, how about this patch, then?

This was just compile-tested (with and without CONFIG_SND_DEBUG_MEMORY), but it seems correct...

Signature · 4 lines
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
include/sound/core.h +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h
@@ -291,6 +291,7 @@ void *snd_hidden_kcalloc(size_t n, size_
 void snd_hidden_kfree(const void *obj);
 void *snd_hidden_vmalloc(unsigned long size);
 void snd_hidden_vfree(void *obj);
+char *snd_hidden_kstrdup(const char *s, int flags);
 #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
 #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
 #define kfree(obj) snd_hidden_kfree(obj)
@@ -300,6 +301,7 @@ void snd_hidden_vfree(void *obj);
 #define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
 #define kfree_nocheck(obj) snd_wrapper_kfree(obj)
 #define vfree_nocheck(obj) snd_wrapper_vfree(obj)
+#define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
 #else
 #define snd_memory_init() /*NOP*/
 #define snd_memory_done() /*NOP*/
@@ -310,7 +312,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 
sound/core/info.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;
sound/core/info_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c
@@ -22,6 +22,7 @@
 #include <sound/driver.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;
sound/core/memory.c +14 -27

56 lines not on this page · raw message

sound/core/oss/mixer_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;
sound/core/oss/pcm_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}
sound/core/sound.c +0 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */
sound/core/timer.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;
sound/isa/gus/gus_mem.c +4 -3
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG
sound/synth/emux/emux.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c
@@ -22,6 +22,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;
#10 lore raw

At Tue, 01 Feb 2005 15:39:25 +0000,

Quoted 28 lines · Paulo Marques

[1 <text/plain; us-ascii (7bit)>]

Quoted 25 lines · Takashi Iwai

At Tue, 01 Feb 2005 13:07:25 +0000,

Quoted 4 lines · Paulo Marques

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

Quoted 8 lines

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

This sounds good. We can do just like normal kmalloc:

#ifdef CONFIG_SND_DEBUG_MEMORY
...
#define kstrdup(s) my_kstrdup_wrapper(s)
#endif

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Heh, it's up to you ;) Using kstrdup() in normal cases would be better, of course.

Ok, how about this patch, then?

Thanks, that looks almost fine except:

sound/core/sound.c EXPORT_SYMBOL(snd_hidden_kfree); · line 406

Quoted 11 lines

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */

I guess here missing EXPORT(snd_hidden_kstrdup)?

Takashi

#11 lore raw
Quoted 5 lines · Takashi Iwai

[...]

Thanks, that looks almost fine except:

Quoted 14 lines

sound/core/sound.c EXPORT_SYMBOL(snd_hidden_kfree); · line 406

Quoted 11 lines

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
  /* init.c */

I guess here missing EXPORT(snd_hidden_kstrdup)?

Good catch.

Here is the revised patch... I hope this time everything is ok

Signature · 4 lines
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
include/sound/core.h +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h
@@ -291,6 +291,7 @@ void *snd_hidden_kcalloc(size_t n, size_
 void snd_hidden_kfree(const void *obj);
 void *snd_hidden_vmalloc(unsigned long size);
 void snd_hidden_vfree(void *obj);
+char *snd_hidden_kstrdup(const char *s, int flags);
 #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
 #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
 #define kfree(obj) snd_hidden_kfree(obj)
@@ -300,6 +301,7 @@ void snd_hidden_vfree(void *obj);
 #define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
 #define kfree_nocheck(obj) snd_wrapper_kfree(obj)
 #define vfree_nocheck(obj) snd_wrapper_vfree(obj)
+#define kstrdup(s, flags)  snd_hidden_kstrdup(s, flags)
 #else
 #define snd_memory_init() /*NOP*/
 #define snd_memory_done() /*NOP*/
@@ -310,7 +312,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 
sound/core/info.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;
sound/core/info_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c
@@ -22,6 +22,7 @@
 #include <sound/driver.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;
sound/core/memory.c +14 -27

56 lines not on this page · raw message

sound/core/oss/mixer_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;
sound/core/oss/pcm_oss.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}
sound/core/sound.c +1 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c
@@ -400,8 +400,8 @@ EXPORT_SYMBOL(snd_hidden_kcalloc);
 EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
+EXPORT_SYMBOL(snd_hidden_kstrdup);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */
sound/core/timer.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;
sound/isa/gus/gus_mem.c +4 -3
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG
sound/synth/emux/emux.c +2 -1
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c
@@ -22,6 +22,7 @@
 #include <linux/wait.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;
#12 lore raw

At Tue, 01 Feb 2005 17:15:56 +0000,

Quoted 23 lines · Paulo Marques

[1 <text/plain; us-ascii (7bit)>]

Quoted 5 lines · Takashi Iwai

[...]

Thanks, that looks almost fine except:

Quoted 14 lines

sound/core/sound.c EXPORT_SYMBOL(snd_hidden_kfree); · line 406

Quoted 11 lines

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
  /* init.c */

I guess here missing EXPORT(snd_hidden_kstrdup)?

Quoted 3 lines

Good catch.

Here is the revised patch... I hope this time everything is ok

That's perfect :)

thanks,

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl

#13 lore raw
In reply to Paulo Marques

At Tue, 01 Feb 2005 15:39:25 +0000,

Quoted 28 lines · Paulo Marques

[1 <text/plain; us-ascii (7bit)>]

Quoted 25 lines · Takashi Iwai

At Tue, 01 Feb 2005 13:07:25 +0000,

Quoted 4 lines · Paulo Marques

I thought of going all the way and changing the callers of kstrdup in sound to use kfree, so that it would work without debugging memory allocated for strdup'ed strings.

Quoted 8 lines

However the code there already uses kfree, just not the standard kfree because it might have been defined to something else in core.h if CONFIG_SND_DEBUG_MEMORY is set.

We could still go all the way and carry on with this approach: use the standard kstrdup / kfree when not CONFIG_SND_DEBUG_MEMORY, and define kstrdup to be an internal sound function in sound/core/memory.c when CONFIG_SND_DEBUG_MEMORY is set.

This sounds good. We can do just like normal kmalloc:

#ifdef CONFIG_SND_DEBUG_MEMORY
...
#define kstrdup(s) my_kstrdup_wrapper(s)
#endif

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Do you prefer that I do another patch to do this, or that I just drop the patch and leave snd_kmalloc_strdup alone?

Heh, it's up to you ;) Using kstrdup() in normal cases would be better, of course.

Ok, how about this patch, then?

Thanks, that looks almost fine except:

sound/core/sound.c EXPORT_SYMBOL(snd_hidden_kfree); · line 406

Quoted 11 lines

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */

I guess here missing EXPORT(snd_hidden_kstrdup)?

Takashi

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl

#14 lore raw
In reply to [email protected]

At Tue, 1 Feb 2005 03:28:46 +0000,

Quoted 7 lines · "" <[email protected]> wrote:

[1 <text/plain; iso-8859-1 (quoted-printable)>]

This patch removes the strdup implementation from the sound core (snd_kmalloc_strdup), and updates it to use the kstrdup library function.

This patch won't work properly if CONFIG_SND_DEBUG_MEMORY is set...

Takashi

Quoted 210 lines

--
Paulo Marques - www.grupopie.com

All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke (1729 - 1797)
[2 patch7 <text/x-diff (base64)>]
diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/include/sound/core.h linux-2.6.11-rc2-bk9/include/sound/core.h

include/sound/core.h +0 -1
@@ -310,7 +310,6 @@ void snd_hidden_vfree(void *obj);
 #define kfree_nocheck(obj) kfree(obj)
 #define vfree_nocheck(obj) vfree(obj)
 #endif
-char *snd_kmalloc_strdup(const char *string, int flags);
 int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count);
 int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
 

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info.c linux-2.6.11-rc2-bk9/sound/core/info.c

sound/core/info.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/vmalloc.h>
 #include <linux/time.h>
 #include <linux/smp_lock.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/info.h>
@@ -755,7 +756,7 @@ static snd_info_entry_t *snd_info_create
 	entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
 	if (entry == NULL)
 		return NULL;
-	entry->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	entry->name = kstrdup(name, GFP_KERNEL);
 	if (entry->name == NULL) {
 		kfree(entry);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/info_oss.c linux-2.6.11-rc2-bk9/sound/core/info_oss.c

sound/core/info_oss.c +2 -1
@@ -27,6 +27,7 @@
 #include <sound/info.h>
 #include <sound/version.h>
 #include <linux/utsname.h>
+#include <linux/string.h>
 
 #if defined(CONFIG_SND_OSSEMUL) && defined(CONFIG_PROC_FS)
 
@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int n
 			x = NULL;
 		}
 	} else {
-		x = snd_kmalloc_strdup(string, GFP_KERNEL);
+		x = kstrdup(string, GFP_KERNEL);
 		if (x == NULL) {
 			up(&strings);
 			return -ENOMEM;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/memory.c linux-2.6.11-rc2-bk9/sound/core/memory.c

sound/core/memory.c +0 -23
@@ -221,29 +221,6 @@ int __exit snd_memory_info_done(void)
 #endif /* CONFIG_SND_DEBUG_MEMORY */
 
 /**
- * snd_kmalloc_strdup - copy the string
- * @string: the original string
- * @flags: allocation conditions, GFP_XXX
- *
- * Allocates a memory chunk via kmalloc() and copies the string to it.
- *
- * Returns the pointer, or NULL if no enoguh memory.
- */
-char *snd_kmalloc_strdup(const char *string, int flags)
-{
-	size_t len;
-	char *ptr;
-
-	if (!string)
-		return NULL;
-	len = strlen(string) + 1;
-	ptr = _snd_kmalloc(len, flags);
-	if (ptr)
-		memcpy(ptr, string, len);
-	return ptr;
-}
-
-/**
  * copy_to_user_fromio - copy data from mmio-space to user-space
  * @dst: the destination pointer on user-space
  * @src: the source pointer on mmio

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/mixer_oss.c

sound/core/oss/mixer_oss.c +2 -1
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <linux/time.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/control.h>
@@ -1122,7 +1123,7 @@ static void snd_mixer_oss_proc_write(snd
 			goto __unlock;
 		}
 		tbl->oss_id = ch;
-		tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL);
+		tbl->name = kstrdup(str, GFP_KERNEL);
 		if (! tbl->name) {
 			kfree(tbl);
 			goto __unlock;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c linux-2.6.11-rc2-bk9/sound/core/oss/pcm_oss.c

sound/core/oss/pcm_oss.c +2 -1
@@ -33,6 +33,7 @@
 #include <linux/time.h>
 #include <linux/vmalloc.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/minors.h>
 #include <sound/pcm.h>
@@ -2349,7 +2350,7 @@ static void snd_pcm_oss_proc_write(snd_i
 					for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
 					setup1->next = setup;
 				}
-				template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL);
+				template.task_name = kstrdup(task_name, GFP_KERNEL);
 			} else {
 				buffer->error = -ENOMEM;
 			}

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/sound.c linux-2.6.11-rc2-bk9/sound/core/sound.c

sound/core/sound.c +0 -1
@@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_hidden_kfree);
 EXPORT_SYMBOL(snd_hidden_vmalloc);
 EXPORT_SYMBOL(snd_hidden_vfree);
 #endif
-EXPORT_SYMBOL(snd_kmalloc_strdup);
 EXPORT_SYMBOL(copy_to_user_fromio);
 EXPORT_SYMBOL(copy_from_user_toio);
   /* init.c */

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/core/timer.c linux-2.6.11-rc2-bk9/sound/core/timer.c

sound/core/timer.c +2 -1
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/time.h>
 #include <linux/moduleparam.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/timer.h>
 #include <sound/control.h>
@@ -97,7 +98,7 @@ static snd_timer_instance_t *snd_timer_i
 	timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
 	if (timeri == NULL)
 		return NULL;
-	timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL);
+	timeri->owner = kstrdup(owner, GFP_KERNEL);
 	if (! timeri->owner) {
 		kfree(timeri);
 		return NULL;

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c linux-2.6.11-rc2-bk9/sound/isa/gus/gus_mem.c

sound/isa/gus/gus_mem.c +4 -3
@@ -21,6 +21,7 @@
 
 #include <sound/driver.h>
 #include <linux/slab.h>
+#include <linux/string.h>
 #include <sound/core.h>
 #include <sound/gus.h>
 #include <sound/info.h>
@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(s
 	if (share_id != NULL)
 		memcpy(&block.share_id, share_id, sizeof(block.share_id));
 	block.owner = owner;
-	block.name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	block.name = kstrdup(name, GFP_KERNEL);
 	nblock = snd_gf1_mem_xalloc(alloc, &block);
 	snd_gf1_mem_lock(alloc, 1);
 	return nblock;
@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gu
 	if (gus->gf1.enh_mode) {
 		block.ptr = 0;
 		block.size = 1024;
-		block.name = snd_kmalloc_strdup("InterWave LFOs", GFP_KERNEL);
+		block.name = kstrdup("InterWave LFOs", GFP_KERNEL);
 		if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 			return -ENOMEM;
 	}
 	block.ptr = gus->gf1.default_voice_address;
 	block.size = 4;
-	block.name = snd_kmalloc_strdup("Voice default (NULL's)", GFP_KERNEL);
+	block.name = kstrdup("Voice default (NULL's)", GFP_KERNEL);
 	if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
 		return -ENOMEM;
 #ifdef CONFIG_SND_DEBUG

diff -uprN -X dontdiff vanilla-2.6.11-rc2-bk9/sound/synth/emux/emux.c linux-2.6.11-rc2-bk9/sound/synth/emux/emux.c

sound/synth/emux/emux.c +1 -0
@@ -25,6 +25,7 @@
 #include <sound/core.h>
 #include <sound/emux_synth.h>
 #include <linux/init.h>
+#include <linux/string.h>
 #include "emux_voice.h"
 
 MODULE_AUTHOR("Takashi Iwai");

sound/synth/emux/emux.c int snd_emux_register(snd_emux_t *emu, s · line 83

Quoted 8 lines
sound/synth/emux/emux.c +1 -1
@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, s
 	snd_assert(name != NULL, return -EINVAL);
 
 	emu->card = card;
-	emu->name = snd_kmalloc_strdup(name, GFP_KERNEL);
+	emu->name = kstrdup(name, GFP_KERNEL);
 	emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
 	if (emu->voices == NULL)
 		return -ENOMEM;

-
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/

-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting Tool for open source databases. Create drag-&-drop reports. Save time by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc. Download a FREE copy at http://www.intelliview.com/go/osdn_nl