mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scsi: gdth: add error handling for register_chrdev
@ 2018-06-11  8:35 Zhouyang Jia
  0 siblings, 0 replies; only message in thread
From: Zhouyang Jia @ 2018-06-11  8:35 UTC (permalink / raw)
  Cc: Zhouyang Jia, Achim Leubner, James E.J. Bottomley,
	Martin K. Petersen, linux-scsi, linux-kernel

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

This patch adds error-handling code after calling register_chrdev.

Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
 drivers/scsi/gdth.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 8560479..d5a2af8 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -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;
-- 
2.7.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-06-11  8:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11  8:35 [PATCH] scsi: gdth: add error handling for register_chrdev Zhouyang Jia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®