]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: cosa: fix error check return value of register_chrdev()
authorLv Ruyi <lv.ruyi@zte.com.cn>
Mon, 18 Apr 2022 10:58:34 +0000 (10:58 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Apr 2022 09:20:43 +0000 (10:20 +0100)
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 <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wan/cosa.c

index 23d2954d97475a551192fee9085a11281896a672..1e5672019922fc2b2d192427ea033123b6f58b9a 100644 (file)
@@ -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;