Skip to contentSkip to conversation

fix drivers/base/cpu.c

PATCH In review Matthew Dobson 3 participants 4 messages Jan 22, 2003 – Jan 29, 2003 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix drivers/base/cpu.c

Both drivers/base/node.c & memblk.c check the return values of the devclass_register & driver_register calls. cpu.c doesn't. This little patch remedies that omission.

[mcd@arrakis push]$ diffstat sysfs_topo_cleanup-2.5.59.patch

 cpu.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Cheers!

-Matt

drivers/base/cpu.c +2 -2
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.58-vanilla/drivers/base/cpu.c linux-2.5.58-topo_cleanup/drivers/base/cpu.c
@@ -48,7 +48,7 @@
 
 static int __init register_cpu_type(void)
 {
-	devclass_register(&cpu_devclass);
-	return driver_register(&cpu_driver);
+	int error = devclass_register(&cpu_devclass);
+	return error ? error : driver_register(&cpu_driver);
 }
 postcore_initcall(register_cpu_type);
#1 lore raw

In message <[email protected]> you write:

Quoted 8 lines

This is a multi-part message in MIME format. --------------050105040306060502000102
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Both drivers/base/node.c & memblk.c check the return values of the devclass_register & driver_register calls. cpu.c doesn't. This little patch remedies that omission.

You'd want to to undo the devclass_register() on failure, too, I imagine.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#2 lore raw
Quoted 3 lines · In message <[email protected]> Matt Dobson (?) wrote:
Quoted 3 lines

Both drivers/base/node.c & memblk.c check the return values of the devclass_register & driver_register calls. cpu.c doesn't. This little patch remedies that omission.

Quoted 2 lines · Rusty Russell

You'd want to to undo the devclass_register() on failure, too, I imagine.

Ow, I forgot about that. Someone grind this out quick and take care of the other oopsing thingies. You know what I'm preoccupied with.

-- wli

#3 lore raw
Quoted 7 lines · William Lee Irwin III
Quoted 2 lines · In message <[email protected]> Matt Dobson (?) wrote:
Quoted 1 line

Both drivers/base/node.c & memblk.c check the return values of the devclass_register & driver_register calls. cpu.c doesn't. This little patch remedies that omission.

On Wed, Jan 29, 2003 at 03:51:04PM +1100, Rusty Russell wrote:

Quoted 8 lines
Quoted 2 lines

You'd want to to undo the devclass_register() on failure, too, I imagine.

Ow, I forgot about that. Someone grind this out quick and take care of the other oopsing thingies. You know what I'm preoccupied with.

-- wli

Good point Rusty, cleanup attatched...

Cheers!

-Matt

drivers/base/cpu.c +5 -2
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.59-vanilla/drivers/base/cpu.c linux-2.5.59-driver_base_cleanup/drivers/base/cpu.c
@@ -48,7 +48,10 @@
 
 static int __init register_cpu_type(void)
 {
-	devclass_register(&cpu_devclass);
-	return driver_register(&cpu_driver);
+	int error;
+	if (!(error = devclass_register(&cpu_devclass)))
+		if (error = driver_register(&cpu_driver))
+			devclass_unregister(&cpu_devclass);
+	return error;
 }
 postcore_initcall(register_cpu_type);
drivers/base/memblk.c +5 -2
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.59-vanilla/drivers/base/memblk.c linux-2.5.59-driver_base_cleanup/drivers/base/memblk.c
@@ -49,7 +49,10 @@
 
 static int __init register_memblk_type(void)
 {
-	int error = devclass_register(&memblk_devclass);
-	return error ? error : driver_register(&memblk_driver);
+	int error;
+	if (!(error = devclass_register(&memblk_devclass)))
+		if (error = driver_register(&memblk_driver))
+			devclass_unregister(&memblk_devclass);
+	return error;
 }
 postcore_initcall(register_memblk_type);
drivers/base/node.c +5 -2
diff -Nur --exclude-from=/usr/src/.dontdiff linux-2.5.59-vanilla/drivers/base/node.c linux-2.5.59-driver_base_cleanup/drivers/base/node.c
@@ -91,7 +91,10 @@
 
 static int __init register_node_type(void)
 {
-	int error = devclass_register(&node_devclass);
-	return error ? error : driver_register(&node_driver);
+	int error;
+	if (!(error = devclass_register(&node_devclass)))
+		if (error = driver_register(&node_driver))
+			devclass_unregister(&node_devclass);
+	return error;
 }
 postcore_initcall(register_node_type);