Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c22618a1 authored by Grant Likely's avatar Grant Likely
Browse files

drivers/of: Constify device_node->name and ->path_component_name



Neither of these should ever be changed once set. Make them const and
fix up the users that try to modify it in-place. In one case
kmalloc+memcpy is replaced with kstrdup() to avoid modifying the string.

Build tested with defconfigs on ARM, PowerPC, Sparc, MIPS, x86 among
others.

Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Julian Calaby <julian.calaby@gmail.com>
parent 31982e52
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -686,7 +686,7 @@ static int pmf_add_functions(struct pmf_device *dev, void *driverdata)
	int count = 0;
	int count = 0;


	for (pp = dev->node->properties; pp != 0; pp = pp->next) {
	for (pp = dev->node->properties; pp != 0; pp = pp->next) {
		char *name;
		const char *name;
		if (strncmp(pp->name, PP_PREFIX, plen) != 0)
		if (strncmp(pp->name, PP_PREFIX, plen) != 0)
			continue;
			continue;
		name = pp->name + plen;
		name = pp->name + plen;
+1 −2
Original line number Original line Diff line number Diff line
@@ -281,12 +281,11 @@ static struct property *new_property(const char *name, const int length,
	if (!new)
	if (!new)
		return NULL;
		return NULL;


	if (!(new->name = kmalloc(strlen(name) + 1, GFP_KERNEL)))
	if (!(new->name = kstrdup(name, GFP_KERNEL)))
		goto cleanup;
		goto cleanup;
	if (!(new->value = kmalloc(length + 1, GFP_KERNEL)))
	if (!(new->value = kmalloc(length + 1, GFP_KERNEL)))
		goto cleanup;
		goto cleanup;


	strcpy(new->name, name);
	memcpy(new->value, value, length);
	memcpy(new->value, value, length);
	*(((char *)new->value) + length) = 0;
	*(((char *)new->value) + length) = 0;
	new->length = length;
	new->length = length;
+1 −1
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ static void __init setup_pci_atmu(struct pci_controller *hose,
	u32 pcicsrbar = 0, pcicsrbar_sz;
	u32 pcicsrbar = 0, pcicsrbar_sz;
	u32 piwar = PIWAR_EN | PIWAR_PF | PIWAR_TGI_LOCAL |
	u32 piwar = PIWAR_EN | PIWAR_PF | PIWAR_TGI_LOCAL |
			PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP;
			PIWAR_READ_SNOOP | PIWAR_WRITE_SNOOP;
	char *name = hose->dn->full_name;
	const char *name = hose->dn->full_name;
	const u64 *reg;
	const u64 *reg;
	int len;
	int len;


+1 −1
Original line number Original line Diff line number Diff line
@@ -88,7 +88,7 @@ struct pci_pbm_info {
	int				chip_revision;
	int				chip_revision;


	/* Name used for top-level resources. */
	/* Name used for top-level resources. */
	char				*name;
	const char			*name;


	/* OBP specific information. */
	/* OBP specific information. */
	struct platform_device		*op;
	struct platform_device		*op;
+5 −5
Original line number Original line Diff line number Diff line
@@ -199,10 +199,10 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
	np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
	np = unflatten_dt_alloc(&mem, sizeof(struct device_node) + allocl,
				__alignof__(struct device_node));
				__alignof__(struct device_node));
	if (allnextpp) {
	if (allnextpp) {
		char *fn;
		memset(np, 0, sizeof(*np));
		memset(np, 0, sizeof(*np));
		np->full_name = ((char *)np) + sizeof(struct device_node);
		np->full_name = fn = ((char *)np) + sizeof(*np);
		if (new_format) {
		if (new_format) {
			char *fn = np->full_name;
			/* rebuild full path for new format */
			/* rebuild full path for new format */
			if (dad && dad->parent) {
			if (dad && dad->parent) {
				strcpy(fn, dad->full_name);
				strcpy(fn, dad->full_name);
@@ -216,9 +216,9 @@ static unsigned long unflatten_dt_node(struct boot_param_header *blob,
				fn += strlen(fn);
				fn += strlen(fn);
			}
			}
			*(fn++) = '/';
			*(fn++) = '/';
		}
		memcpy(fn, pathp, l);
		memcpy(fn, pathp, l);
		} else

			memcpy(np->full_name, pathp, l);
		prev_pp = &np->properties;
		prev_pp = &np->properties;
		**allnextpp = np;
		**allnextpp = np;
		*allnextpp = &np->allnext;
		*allnextpp = &np->allnext;
Loading