Skip to contentSkip to conversation

scsi: gdth: add error handling for register_chrdev

PATCH New Zhouyang Jia 1 participant 1 message Jun 11, 2018 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: gdth: add error handling for register_chrdev

When register_chrdev fails, the lack of error-handling code may cause unexpected results.

This patch adds error-handling code after calling register_chrdev.

---
 drivers/scsi/gdth.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/scsi/gdth.c +5 -0
index 8560479..d5a2af8 100644
@@ -5198,6 +5198,11 @@ static int __init gdth_init(void)
 	TRACE2(("gdth_detect() %d controller detected\n", gdth_ctr_count));
 
 	major = register_chrdev(0,"gdth", &gdth_fops);
+	if (major < 0) {
+		printk("GDT-HA: Unable to register char device gdth.\n");
+		return major;
+	}
+
 	register_reboot_notifier(&gdth_notifier);
 	gdth_polling = FALSE;
 	return 0;
Signature · 1 line
2.7.4