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 <[email protected]>
Signed-off-by: Lv Ruyi <[email protected]>
Acked-By: Jan "Yenya" Kasprzak <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
Lv Ruyi authored and David S. Miller committed 2022-04-22 10:20:43 +01:00
1 parent 59f0c2447e
commit d48fea8401
1 file changed
+1 -1
+1 -1
View 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;