Commit 543537bd authored by Paulo Marques's avatar Paulo Marques Committed by Linus Torvalds

[PATCH] create a kstrdup library function

This patch creates a new kstrdup library function and changes the "local"
implementations in several places to use this function.

Most of the changes come from the sound and net subsystems.  The sound part
had already been acknowledged by Takashi Iwai and the net part by David S.
Miller.

I left UML alone for now because I would need more time to read the code
carefully before making changes there.
Signed-off-by: default avatarPaulo Marques <pmarques@grupopie.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 991114c6
...@@ -122,14 +122,6 @@ static struct hash_cell *__get_uuid_cell(const char *str) ...@@ -122,14 +122,6 @@ static struct hash_cell *__get_uuid_cell(const char *str)
/*----------------------------------------------------------------- /*-----------------------------------------------------------------
* Inserting, removing and renaming a device. * Inserting, removing and renaming a device.
*---------------------------------------------------------------*/ *---------------------------------------------------------------*/
static inline char *kstrdup(const char *str)
{
char *r = kmalloc(strlen(str) + 1, GFP_KERNEL);
if (r)
strcpy(r, str);
return r;
}
static struct hash_cell *alloc_cell(const char *name, const char *uuid, static struct hash_cell *alloc_cell(const char *name, const char *uuid,
struct mapped_device *md) struct mapped_device *md)
{ {
...@@ -139,7 +131,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid, ...@@ -139,7 +131,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid,
if (!hc) if (!hc)
return NULL; return NULL;
hc->name = kstrdup(name); hc->name = kstrdup(name, GFP_KERNEL);
if (!hc->name) { if (!hc->name) {
kfree(hc); kfree(hc);
return NULL; return NULL;
...@@ -149,7 +141,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid, ...@@ -149,7 +141,7 @@ static struct hash_cell *alloc_cell(const char *name, const char *uuid,
hc->uuid = NULL; hc->uuid = NULL;
else { else {
hc->uuid = kstrdup(uuid); hc->uuid = kstrdup(uuid, GFP_KERNEL);
if (!hc->uuid) { if (!hc->uuid) {
kfree(hc->name); kfree(hc->name);
kfree(hc); kfree(hc);
...@@ -273,7 +265,7 @@ static int dm_hash_rename(const char *old, const char *new) ...@@ -273,7 +265,7 @@ static int dm_hash_rename(const char *old, const char *new)
/* /*
* duplicate new. * duplicate new.
*/ */
new_name = kstrdup(new); new_name = kstrdup(new, GFP_KERNEL);
if (!new_name) if (!new_name)
return -ENOMEM; return -ENOMEM;
......
...@@ -48,14 +48,6 @@ static void pretty_print(struct parport *port, int device) ...@@ -48,14 +48,6 @@ static void pretty_print(struct parport *port, int device)
printk("\n"); printk("\n");
} }
static char *strdup(char *str)
{
int n = strlen(str)+1;
char *s = kmalloc(n, GFP_KERNEL);
if (!s) return NULL;
return strcpy(s, str);
}
static void parse_data(struct parport *port, int device, char *str) static void parse_data(struct parport *port, int device, char *str)
{ {
char *txt = kmalloc(strlen(str)+1, GFP_KERNEL); char *txt = kmalloc(strlen(str)+1, GFP_KERNEL);
...@@ -88,16 +80,16 @@ static void parse_data(struct parport *port, int device, char *str) ...@@ -88,16 +80,16 @@ static void parse_data(struct parport *port, int device, char *str)
if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) { if (!strcmp(p, "MFG") || !strcmp(p, "MANUFACTURER")) {
if (info->mfr) if (info->mfr)
kfree (info->mfr); kfree (info->mfr);
info->mfr = strdup(sep); info->mfr = kstrdup(sep, GFP_KERNEL);
} else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) { } else if (!strcmp(p, "MDL") || !strcmp(p, "MODEL")) {
if (info->model) if (info->model)
kfree (info->model); kfree (info->model);
info->model = strdup(sep); info->model = kstrdup(sep, GFP_KERNEL);
} else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) { } else if (!strcmp(p, "CLS") || !strcmp(p, "CLASS")) {
int i; int i;
if (info->class_name) if (info->class_name)
kfree (info->class_name); kfree (info->class_name);
info->class_name = strdup(sep); info->class_name = kstrdup(sep, GFP_KERNEL);
for (u = sep; *u; u++) for (u = sep; *u; u++)
*u = toupper(*u); *u = toupper(*u);
for (i = 0; classes[i].token; i++) { for (i = 0; classes[i].token; i++) {
...@@ -112,7 +104,7 @@ static void parse_data(struct parport *port, int device, char *str) ...@@ -112,7 +104,7 @@ static void parse_data(struct parport *port, int device, char *str)
!strcmp(p, "COMMAND SET")) { !strcmp(p, "COMMAND SET")) {
if (info->cmdset) if (info->cmdset)
kfree (info->cmdset); kfree (info->cmdset);
info->cmdset = strdup(sep); info->cmdset = kstrdup(sep, GFP_KERNEL);
/* if it speaks printer language, it's /* if it speaks printer language, it's
probably a printer */ probably a printer */
if (strstr(sep, "PJL") || strstr(sep, "PCL")) if (strstr(sep, "PJL") || strstr(sep, "PCL"))
...@@ -120,7 +112,7 @@ static void parse_data(struct parport *port, int device, char *str) ...@@ -120,7 +112,7 @@ static void parse_data(struct parport *port, int device, char *str)
} else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) { } else if (!strcmp(p, "DES") || !strcmp(p, "DESCRIPTION")) {
if (info->description) if (info->description)
kfree (info->description); kfree (info->description);
info->description = strdup(sep); info->description = kstrdup(sep, GFP_KERNEL);
} }
} }
rock_on: rock_on:
......
...@@ -925,10 +925,6 @@ extern int skb_checksum_help(struct sk_buff *skb, int inward); ...@@ -925,10 +925,6 @@ extern int skb_checksum_help(struct sk_buff *skb, int inward);
extern void net_enable_timestamp(void); extern void net_enable_timestamp(void);
extern void net_disable_timestamp(void); extern void net_disable_timestamp(void);
#ifdef CONFIG_SYSCTL
extern char *net_sysctl_strdup(const char *s);
#endif
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
#endif /* _LINUX_DEV_H */ #endif /* _LINUX_DEV_H */
...@@ -88,6 +88,8 @@ extern int memcmp(const void *,const void *,__kernel_size_t); ...@@ -88,6 +88,8 @@ extern int memcmp(const void *,const void *,__kernel_size_t);
extern void * memchr(const void *,int,__kernel_size_t); extern void * memchr(const void *,int,__kernel_size_t);
#endif #endif
extern char *kstrdup(const char *s, int gfp);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -292,6 +292,7 @@ void *snd_hidden_kcalloc(size_t n, size_t size, int flags); ...@@ -292,6 +292,7 @@ void *snd_hidden_kcalloc(size_t n, size_t size, int flags);
void snd_hidden_kfree(const void *obj); void snd_hidden_kfree(const void *obj);
void *snd_hidden_vmalloc(unsigned long size); void *snd_hidden_vmalloc(unsigned long size);
void snd_hidden_vfree(void *obj); 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 kmalloc(size, flags) snd_hidden_kmalloc(size, flags)
#define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags)
#define kfree(obj) snd_hidden_kfree(obj) #define kfree(obj) snd_hidden_kfree(obj)
...@@ -301,6 +302,7 @@ void snd_hidden_vfree(void *obj); ...@@ -301,6 +302,7 @@ void snd_hidden_vfree(void *obj);
#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size) #define vmalloc_nocheck(size) snd_wrapper_vmalloc(size)
#define kfree_nocheck(obj) snd_wrapper_kfree(obj) #define kfree_nocheck(obj) snd_wrapper_kfree(obj)
#define vfree_nocheck(obj) snd_wrapper_vfree(obj) #define vfree_nocheck(obj) snd_wrapper_vfree(obj)
#define kstrdup(s, flags) snd_hidden_kstrdup(s, flags)
#else #else
#define snd_memory_init() /*NOP*/ #define snd_memory_init() /*NOP*/
#define snd_memory_done() /*NOP*/ #define snd_memory_done() /*NOP*/
...@@ -311,7 +313,6 @@ void snd_hidden_vfree(void *obj); ...@@ -311,7 +313,6 @@ void snd_hidden_vfree(void *obj);
#define kfree_nocheck(obj) kfree(obj) #define kfree_nocheck(obj) kfree(obj)
#define vfree_nocheck(obj) vfree(obj) #define vfree_nocheck(obj) vfree(obj)
#endif #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_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); int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count);
......
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
#include <linux/sysctl.h> #include <linux/sysctl.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <linux/string.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
...@@ -3082,3 +3083,26 @@ unsigned int ksize(const void *objp) ...@@ -3082,3 +3083,26 @@ unsigned int ksize(const void *objp)
return size; return size;
} }
/*
* kstrdup - allocate space for and copy an existing string
*
* @s: the string to duplicate
* @gfp: the GFP mask used in the kmalloc() call when allocating memory
*/
char *kstrdup(const char *s, int gfp)
{
size_t len;
char *buf;
if (!s)
return NULL;
len = strlen(s) + 1;
buf = kmalloc(len, gfp);
if (buf)
memcpy(buf, s, len);
return buf;
}
EXPORT_SYMBOL(kstrdup);
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <net/sock.h> #include <net/sock.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/string.h>
#define NEIGH_DEBUG 1 #define NEIGH_DEBUG 1
...@@ -2592,7 +2593,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, ...@@ -2592,7 +2593,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
t->neigh_vars[17].extra1 = dev; t->neigh_vars[17].extra1 = dev;
} }
dev_name = net_sysctl_strdup(dev_name_source); dev_name = kstrdup(dev_name_source, GFP_KERNEL);
if (!dev_name) { if (!dev_name) {
err = -ENOBUFS; err = -ENOBUFS;
goto free; goto free;
......
...@@ -35,19 +35,6 @@ extern int sysctl_somaxconn; ...@@ -35,19 +35,6 @@ extern int sysctl_somaxconn;
extern char sysctl_divert_version[]; extern char sysctl_divert_version[];
#endif /* CONFIG_NET_DIVERT */ #endif /* CONFIG_NET_DIVERT */
/*
* This strdup() is used for creating copies of network
* device names to be handed over to sysctl.
*/
char *net_sysctl_strdup(const char *s)
{
char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
if (rv)
strcpy(rv, s);
return rv;
}
ctl_table core_table[] = { ctl_table core_table[] = {
#ifdef CONFIG_NET #ifdef CONFIG_NET
{ {
...@@ -177,6 +164,4 @@ ctl_table core_table[] = { ...@@ -177,6 +164,4 @@ ctl_table core_table[] = {
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
EXPORT_SYMBOL(net_sysctl_strdup);
#endif #endif
...@@ -1471,7 +1471,7 @@ static void devinet_sysctl_register(struct in_device *in_dev, ...@@ -1471,7 +1471,7 @@ static void devinet_sysctl_register(struct in_device *in_dev,
* by sysctl and we wouldn't want anyone to change it under our feet * by sysctl and we wouldn't want anyone to change it under our feet
* (see SIOCSIFNAME). * (see SIOCSIFNAME).
*/ */
dev_name = net_sysctl_strdup(dev_name); dev_name = kstrdup(dev_name, GFP_KERNEL);
if (!dev_name) if (!dev_name)
goto free; goto free;
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#endif #endif
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/string.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/snmp.h> #include <net/snmp.h>
...@@ -3437,7 +3438,7 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf ...@@ -3437,7 +3438,7 @@ static void addrconf_sysctl_register(struct inet6_dev *idev, struct ipv6_devconf
* by sysctl and we wouldn't want anyone to change it under our feet * by sysctl and we wouldn't want anyone to change it under our feet
* (see SIOCSIFNAME). * (see SIOCSIFNAME).
*/ */
dev_name = net_sysctl_strdup(dev_name); dev_name = kstrdup(dev_name, GFP_KERNEL);
if (!dev_name) if (!dev_name)
goto free; goto free;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/hash.h> #include <linux/hash.h>
#include <linux/string.h>
#define RPCDBG_FACILITY RPCDBG_AUTH #define RPCDBG_FACILITY RPCDBG_AUTH
...@@ -20,14 +21,6 @@ ...@@ -20,14 +21,6 @@
*/ */
static char *strdup(char *s)
{
char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
if (rv)
strcpy(rv, s);
return rv;
}
struct unix_domain { struct unix_domain {
struct auth_domain h; struct auth_domain h;
int addr_changes; int addr_changes;
...@@ -55,7 +48,7 @@ struct auth_domain *unix_domain_find(char *name) ...@@ -55,7 +48,7 @@ struct auth_domain *unix_domain_find(char *name)
if (new == NULL) if (new == NULL)
return NULL; return NULL;
cache_init(&new->h.h); cache_init(&new->h.h);
new->h.name = strdup(name); new->h.name = kstrdup(name, GFP_KERNEL);
new->h.flavour = RPC_AUTH_UNIX; new->h.flavour = RPC_AUTH_UNIX;
new->addr_changes = 0; new->addr_changes = 0;
new->h.h.expiry_time = NEVER; new->h.h.expiry_time = NEVER;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/info.h> #include <sound/info.h>
...@@ -754,7 +755,7 @@ static snd_info_entry_t *snd_info_create_entry(const char *name) ...@@ -754,7 +755,7 @@ static snd_info_entry_t *snd_info_create_entry(const char *name)
entry = kcalloc(1, sizeof(*entry), GFP_KERNEL); entry = kcalloc(1, sizeof(*entry), GFP_KERNEL);
if (entry == NULL) if (entry == NULL)
return NULL; return NULL;
entry->name = snd_kmalloc_strdup(name, GFP_KERNEL); entry->name = kstrdup(name, GFP_KERNEL);
if (entry->name == NULL) { if (entry->name == NULL) {
kfree(entry); kfree(entry);
return NULL; return NULL;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <sound/driver.h> #include <sound/driver.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/info.h> #include <sound/info.h>
...@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int num, char *string) ...@@ -51,7 +52,7 @@ int snd_oss_info_register(int dev, int num, char *string)
x = NULL; x = NULL;
} }
} else { } else {
x = snd_kmalloc_strdup(string, GFP_KERNEL); x = kstrdup(string, GFP_KERNEL);
if (x == NULL) { if (x == NULL) {
up(&strings); up(&strings);
return -ENOMEM; return -ENOMEM;
......
...@@ -184,6 +184,20 @@ void snd_hidden_vfree(void *obj) ...@@ -184,6 +184,20 @@ void snd_hidden_vfree(void *obj)
snd_wrapper_vfree(obj); snd_wrapper_vfree(obj);
} }
char *snd_hidden_kstrdup(const char *s, int flags)
{
int len;
char *buf;
if (!s) return NULL;
len = strlen(s) + 1;
buf = _snd_kmalloc(len, flags);
if (buf)
memcpy(buf, s, len);
return buf;
}
static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer)
{ {
snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc);
...@@ -214,35 +228,8 @@ int __exit snd_memory_info_done(void) ...@@ -214,35 +228,8 @@ int __exit snd_memory_info_done(void)
return 0; return 0;
} }
#else
#define _snd_kmalloc kmalloc
#endif /* CONFIG_SND_DEBUG_MEMORY */ #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 * copy_to_user_fromio - copy data from mmio-space to user-space
* @dst: the destination pointer on user-space * @dst: the destination pointer on user-space
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/control.h> #include <sound/control.h>
...@@ -1137,7 +1138,7 @@ static void snd_mixer_oss_proc_write(snd_info_entry_t *entry, ...@@ -1137,7 +1138,7 @@ static void snd_mixer_oss_proc_write(snd_info_entry_t *entry,
goto __unlock; goto __unlock;
} }
tbl->oss_id = ch; tbl->oss_id = ch;
tbl->name = snd_kmalloc_strdup(str, GFP_KERNEL); tbl->name = kstrdup(str, GFP_KERNEL);
if (! tbl->name) { if (! tbl->name) {
kfree(tbl); kfree(tbl);
goto __unlock; goto __unlock;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/time.h> #include <linux/time.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/minors.h> #include <sound/minors.h>
#include <sound/pcm.h> #include <sound/pcm.h>
...@@ -2360,7 +2361,7 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry, ...@@ -2360,7 +2361,7 @@ static void snd_pcm_oss_proc_write(snd_info_entry_t *entry,
for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next); for (setup1 = pstr->oss.setup_list; setup1->next; setup1 = setup1->next);
setup1->next = setup; setup1->next = setup;
} }
template.task_name = snd_kmalloc_strdup(task_name, GFP_KERNEL); template.task_name = kstrdup(task_name, GFP_KERNEL);
} else { } else {
buffer->error = -ENOMEM; buffer->error = -ENOMEM;
} }
......
...@@ -399,8 +399,8 @@ EXPORT_SYMBOL(snd_hidden_kcalloc); ...@@ -399,8 +399,8 @@ EXPORT_SYMBOL(snd_hidden_kcalloc);
EXPORT_SYMBOL(snd_hidden_kfree); EXPORT_SYMBOL(snd_hidden_kfree);
EXPORT_SYMBOL(snd_hidden_vmalloc); EXPORT_SYMBOL(snd_hidden_vmalloc);
EXPORT_SYMBOL(snd_hidden_vfree); EXPORT_SYMBOL(snd_hidden_vfree);
EXPORT_SYMBOL(snd_hidden_kstrdup);
#endif #endif
EXPORT_SYMBOL(snd_kmalloc_strdup);
EXPORT_SYMBOL(copy_to_user_fromio); EXPORT_SYMBOL(copy_to_user_fromio);
EXPORT_SYMBOL(copy_from_user_toio); EXPORT_SYMBOL(copy_from_user_toio);
/* init.c */ /* init.c */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/time.h> #include <linux/time.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/timer.h> #include <sound/timer.h>
#include <sound/control.h> #include <sound/control.h>
...@@ -100,7 +101,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti ...@@ -100,7 +101,7 @@ static snd_timer_instance_t *snd_timer_instance_new(char *owner, snd_timer_t *ti
timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL); timeri = kcalloc(1, sizeof(*timeri), GFP_KERNEL);
if (timeri == NULL) if (timeri == NULL)
return NULL; return NULL;
timeri->owner = snd_kmalloc_strdup(owner, GFP_KERNEL); timeri->owner = kstrdup(owner, GFP_KERNEL);
if (! timeri->owner) { if (! timeri->owner) {
kfree(timeri); kfree(timeri);
return NULL; return NULL;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <sound/driver.h> #include <sound/driver.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/gus.h> #include <sound/gus.h>
#include <sound/info.h> #include <sound/info.h>
...@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner, ...@@ -213,7 +214,7 @@ snd_gf1_mem_block_t *snd_gf1_mem_alloc(snd_gf1_mem_t * alloc, int owner,
if (share_id != NULL) if (share_id != NULL)
memcpy(&block.share_id, share_id, sizeof(block.share_id)); memcpy(&block.share_id, share_id, sizeof(block.share_id));
block.owner = owner; block.owner = owner;
block.name = snd_kmalloc_strdup(name, GFP_KERNEL); block.name = kstrdup(name, GFP_KERNEL);
nblock = snd_gf1_mem_xalloc(alloc, &block); nblock = snd_gf1_mem_xalloc(alloc, &block);
snd_gf1_mem_lock(alloc, 1); snd_gf1_mem_lock(alloc, 1);
return nblock; return nblock;
...@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gus) ...@@ -253,13 +254,13 @@ int snd_gf1_mem_init(snd_gus_card_t * gus)
if (gus->gf1.enh_mode) { if (gus->gf1.enh_mode) {
block.ptr = 0; block.ptr = 0;
block.size = 1024; 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) if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
return -ENOMEM; return -ENOMEM;
} }
block.ptr = gus->gf1.default_voice_address; block.ptr = gus->gf1.default_voice_address;
block.size = 4; 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) if (snd_gf1_mem_xalloc(alloc, &block) == NULL)
return -ENOMEM; return -ENOMEM;
#ifdef CONFIG_SND_DEBUG #ifdef CONFIG_SND_DEBUG
......
...@@ -1781,7 +1781,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign ...@@ -1781,7 +1781,7 @@ static int add_control(struct alc_spec *spec, int type, const char *name, unsign
knew = &spec->kctl_alloc[spec->num_kctl_used]; knew = &spec->kctl_alloc[spec->num_kctl_used];
*knew = alc880_control_templates[type]; *knew = alc880_control_templates[type];
knew->name = snd_kmalloc_strdup(name, GFP_KERNEL); knew->name = kstrdup(name, GFP_KERNEL);
if (! knew->name) if (! knew->name)
return -ENOMEM; return -ENOMEM;
knew->private_value = val; knew->private_value = val;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/wait.h> #include <linux/wait.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/string.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/emux_synth.h> #include <sound/emux_synth.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name) ...@@ -76,7 +77,7 @@ int snd_emux_register(snd_emux_t *emu, snd_card_t *card, int index, char *name)
snd_assert(name != NULL, return -EINVAL); snd_assert(name != NULL, return -EINVAL);
emu->card = card; 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); emu->voices = kcalloc(emu->max_voices, sizeof(snd_emux_voice_t), GFP_KERNEL);
if (emu->voices == NULL) if (emu->voices == NULL)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment