Skip to contentSkip to conversation

char: hvc: check for error case

PATCH In review Vasiliy Kulikov 2 participants 3 messages Sep 12, 2010 – Sep 13, 2010

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

PATCH 1/1 char: hvc: check for error case

hvc_alloc() may fail, if so exit from init() with error.

---
I cannot compile this driver at all, so it is not tested.

 drivers/char/hvc_tile.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/char/hvc_tile.c +3 -2
index c4efb55..7a84a05 100644
@@ -61,7 +61,8 @@ console_initcall(hvc_tile_console_init);
 
 static int __init hvc_tile_init(void)
 {
-	hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
-	return 0;
+	struct hvc_struct *s;
+	s = hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
+	return IS_ERR(s) ? PTR_ERR(s) : 0;
 }
 device_initcall(hvc_tile_init);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 3 lines · Vasiliy Kulikov

hvc_alloc() may fail, if so exit from init() with error.

Thanks, accepted into my tree (for the next merge window). In practice all this means is in debug mode we'll get a warning from do_one_initcall() rather than silence, but you're right, it's technically better. :-)

Quoted 21 lines

---
I cannot compile this driver at all, so it is not tested.

 drivers/char/hvc_tile.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/char/hvc_tile.c +3 -2
index c4efb55..7a84a05 100644
@@ -61,7 +61,8 @@ console_initcall(hvc_tile_console_init);
 
 static int __init hvc_tile_init(void)
 {
-	hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
-	return 0;
+	struct hvc_struct *s;
+	s = hvc_alloc(0, 0, &hvc_tile_get_put_ops, 128);
+	return IS_ERR(s) ? PTR_ERR(s) : 0;
 }
 device_initcall(hvc_tile_init);
Signature · 2 lines
Chris Metcalf, Tilera Corp.
http://www.tilera.com
#2 lore raw
Quoted 3 lines · Chris Metcalf

Thanks, accepted into my tree (for the next merge window). In practice all this means is in debug mode we'll get a warning from do_one_initcall() rather than silence, but you're right, it's technically better. :-)

Anyway it's better, if user sees warning in the dmesg, he/she might response to this situation.

Best,

Signature · 1 line
Vasiliy