[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: Paulo Marques <pmarques@grupopie.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
991114c6fa
commit
543537bd92
@@ -32,6 +32,7 @@
|
||||
#include <net/sock.h>
|
||||
#include <linux/rtnetlink.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#define NEIGH_DEBUG 1
|
||||
|
||||
@@ -2592,7 +2593,7 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p,
|
||||
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) {
|
||||
err = -ENOBUFS;
|
||||
goto free;
|
||||
|
@@ -35,19 +35,6 @@ extern int sysctl_somaxconn;
|
||||
extern char sysctl_divert_version[];
|
||||
#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[] = {
|
||||
#ifdef CONFIG_NET
|
||||
{
|
||||
@@ -177,6 +164,4 @@ ctl_table core_table[] = {
|
||||
{ .ctl_name = 0 }
|
||||
};
|
||||
|
||||
EXPORT_SYMBOL(net_sysctl_strdup);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user