mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijun Hu <zijun_hu@icloud.com>
To: Arnd Bergmann <arnd@arndb.de>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zijun Hu <zijun_hu@icloud.com>,
	linux-kernel@vger.kernel.org,
	 Zijun Hu <zijun.hu@oss.qualcomm.com>
Subject: [PATCH 3/3] char: misc: Fix improper and inaccurate error code returned by misc_init()
Date: Fri, 20 Jun 2025 22:35:20 +0800	[thread overview]
Message-ID: <20250620-fix_mischar-v1-3-6c2716bbf1fa@oss.qualcomm.com> (raw)
In-Reply-To: <20250620-fix_mischar-v1-0-6c2716bbf1fa@oss.qualcomm.com>

From: Zijun Hu <zijun.hu@oss.qualcomm.com>

misc_init() returns -EIO for __register_chrdev() invocation failure, but:

- -EIO is for I/O error normally, but __register_chrdev() does not do I/O.
- -EIO can not cover various error codes returned by __register_chrdev().

Fix by returning error code of __register_chrdev().

Signed-off-by: Zijun Hu <zijun.hu@oss.qualcomm.com>
---
 drivers/char/misc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index f5ef8c175adb559e67dfe905d43d1404b249cc9e..e5ea36bbf6b3d1313eb35d3259617bf90c55727d 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -296,8 +296,8 @@ static int __init misc_init(void)
 	if (err)
 		goto fail_remove;
 
-	err = -EIO;
-	if (__register_chrdev(MISC_MAJOR, 0, MINORMASK + 1, "misc", &misc_fops))
+	err = __register_chrdev(MISC_MAJOR, 0, MINORMASK + 1, "misc", &misc_fops);
+	if (err < 0)
 		goto fail_printk;
 	return 0;
 

-- 
2.34.1


      parent reply	other threads:[~2025-06-20 14:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 14:35 [PATCH 0/3] char: misc: Trivial cleanup Zijun Hu
2025-06-20 14:35 ` [PATCH 1/3] char: misc: Remove redundant forward declarations Zijun Hu
2025-06-20 14:35 ` [PATCH 2/3] char: misc: Rename a local variable in misc_init() Zijun Hu
2025-06-24 15:47   ` Greg Kroah-Hartman
2025-06-20 14:35 ` Zijun Hu [this message]

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=20250620-fix_mischar-v1-3-6c2716bbf1fa@oss.qualcomm.com \
    --to=zijun_hu@icloud.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zijun.hu@oss.qualcomm.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®