Thread (19 messages) 19 messages, 5 authors, 2009-09-17

Re: [PATCH 4/5] kernel handling of memory DLPAR

flat view

From: Nathan Fontenot <hidden>
Date: 2009-09-14 18:18:37
Also in: lkml

Andrey Panin wrote:
On 254, 09 11, 2009 at 04:14:35PM -0500, Nathan Fontenot wrote:
quoted
This adds the capability to DLPAR add and remove memory from the kernel.  The
patch extends the powerpc handling of memory_add_physaddr_to_nid(), which is
called from the sysfs memory 'probe' file to first ensure that the memory
has been added to the system.  This is done by creating a platform specific
callout from the routine.  The pseries implementation of this handles the
DLPAR work to add the memory to the system and update the device tree.

The patch also creates a pseries only 'release' sys file,
/sys/devices/system/memory/release.  This file handles the DLPAR
release of
memory back to firmware and updating of the device-tree.

Signed-off-by: Nathan Fontenot <redacted>
quoted
+static struct property *clone_property(struct property *old_prop)
+{
+	struct property *new_prop;
+
+	new_prop = kzalloc((sizeof *new_prop), GFP_KERNEL);
+	if (!new_prop)
+		return NULL;
+
+	new_prop->name = kzalloc(strlen(old_prop->name) + 1, GFP_KERNEL);
+	new_prop->value = kzalloc(old_prop->length + 1, GFP_KERNEL);
Memory leak here. What if one kzalloc() succeeded and another failed ?
This should be fine.  The free_property routine will free the name or value
fields if they are allocated.

-Nathan
quoted
+	if (!new_prop->name || !new_prop->value) {
+		free_property(new_prop);
+		return NULL;
+	}
+
+	strcpy(new_prop->name, old_prop->name);
+	memcpy(new_prop->value, old_prop->value, old_prop->length);
+	new_prop->length = old_prop->length;
+
+	return new_prop;
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help