From: Zhouyang Jia <jiazhouyang09@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@gmail.com>,
Achim Leubner <achim_leubner@adaptec.com>,
"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] scsi: gdth: add error handling for register_chrdev
Date: Mon, 11 Jun 2018 16:35:48 +0800 [thread overview]
Message-ID: <1528706148-35044-1-git-send-email-jiazhouyang09@gmail.com> (raw)
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
reply other threads:[~2018-06-11 8:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528706148-35044-1-git-send-email-jiazhouyang09@gmail.com \
--to=jiazhouyang09@gmail.com \
--cc=achim_leubner@adaptec.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®