Commit d48fea84 authored by Lv Ruyi's avatar Lv Ruyi Committed by David S. Miller

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: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarLv Ruyi <lv.ruyi@zte.com.cn>
Acked-By: default avatarJan "Yenya" Kasprzak <kas@fi.muni.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59f0c244
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment