Skip to contentSkip to conversation

mm:Return proper error code return if call to kzalloc_node falis in the function alloc_mem_cgroup_per_zone_info

PATCH In review Nicholas Krause 2 participants 2 messages Jun 29, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm:Return proper error code return if call to kzalloc_node falis in the function alloc_mem_cgroup_per_zone_info

This changes us returning the value of one to -ENOMEM when the call for allocating memory with the function kzalloc_node fails in order to better comply with kernel coding pratices of returning this particular error code when memory allocations that are unrecoverable occur.

---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index acb93c5..4e80811 100644
@@ -4442,7 +4442,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
 		tmp = -1;
 	pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, tmp);
 	if (!pn)
-		return 1;
+		return -ENOMEM;
 
 	for (zone = 0; zone < MAX_NR_ZONES; zone++) {
 		mz = &pn->zoneinfo[zone];
Signature · 7 lines
2.1.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 5 lines · Nicholas Krause

This changes us returning the value of one to -ENOMEM when the call for allocating memory with the function kzalloc_node fails in order to better comply with kernel coding pratices of returning this particular error code when memory allocations that are unrecoverable occur.

I do not see any point in such a patch. Let me repeat, and hopefully for the last time, the patch has to make _sense_ and the changelog should provide a _justification_ for the change. None of this is true for this patch.

Quoted 1 line

I am not interested in changes like this in the code I maintain.

Quoted 20 lines
---
 mm/memcontrol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memcontrol.c +1 -1
index acb93c5..4e80811 100644
@@ -4442,7 +4442,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
 		tmp = -1;
 	pn = kzalloc_node(sizeof(*pn), GFP_KERNEL, tmp);
 	if (!pn)
-		return 1;
+		return -ENOMEM;
 
 	for (zone = 0; zone < MAX_NR_ZONES; zone++) {
 		mz = &pn->zoneinfo[zone];
Signature · 1 line
2.1.4
Signature · 2 lines
Michal Hocko
SUSE Labs