You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
[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
|
||||
|
||||
+1
-1
@@ -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
|
||||
* (see SIOCSIFNAME).
|
||||
*/
|
||||
dev_name = net_sysctl_strdup(dev_name);
|
||||
dev_name = kstrdup(dev_name, GFP_KERNEL);
|
||||
if (!dev_name)
|
||||
goto free;
|
||||
|
||||
|
||||
+2
-1
@@ -57,6 +57,7 @@
|
||||
#endif
|
||||
#include <linux/delay.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#include <net/sock.h>
|
||||
#include <net/snmp.h>
|
||||
@@ -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
|
||||
* (see SIOCSIFNAME).
|
||||
*/
|
||||
dev_name = net_sysctl_strdup(dev_name);
|
||||
dev_name = kstrdup(dev_name, GFP_KERNEL);
|
||||
if (!dev_name)
|
||||
goto free;
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <linux/err.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/hash.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
#define RPCDBG_FACILITY RPCDBG_AUTH
|
||||
|
||||
@@ -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 auth_domain h;
|
||||
int addr_changes;
|
||||
@@ -55,7 +48,7 @@ struct auth_domain *unix_domain_find(char *name)
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
cache_init(&new->h.h);
|
||||
new->h.name = strdup(name);
|
||||
new->h.name = kstrdup(name, GFP_KERNEL);
|
||||
new->h.flavour = RPC_AUTH_UNIX;
|
||||
new->addr_changes = 0;
|
||||
new->h.h.expiry_time = NEVER;
|
||||
|
||||
Reference in New Issue
Block a user