From: Lv Ruyi Date: Mon, 18 Apr 2022 10:58:34 +0000 (+0000) Subject: net: cosa: fix error check return value of register_chrdev() X-Git-Tag: v5.18-rc5~20^2~43 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d48fea8401cfa942c67cc3a522bf379143dbb576;p=tomoyo%2Ftomoyo-test1.git net: cosa: fix error check return value of register_chrdev() If major equal 0, register_chrdev() returns error code when it fails. This function dynamically allocate a major and return its number on success, so we should use "< 0" to check it instead of "!". Reported-by: Zeal Robot Signed-off-by: Lv Ruyi Acked-By: Jan "Yenya" Kasprzak Signed-off-by: David S. Miller --- diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 23d2954d9747..1e5672019922 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -349,7 +349,7 @@ static int __init cosa_init(void) } } else { cosa_major = register_chrdev(0, "cosa", &cosa_fops); - if (!cosa_major) { + if (cosa_major < 0) { pr_warn("unable to register chardev\n"); err = -EIO; goto out;