mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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 <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>
This commit is contained in:
parent
59f0c2447e
commit
d48fea8401
@ -349,7 +349,7 @@ static int __init cosa_init(void)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cosa_major = register_chrdev(0, "cosa", &cosa_fops);
|
cosa_major = register_chrdev(0, "cosa", &cosa_fops);
|
||||||
if (!cosa_major) {
|
if (cosa_major < 0) {
|
||||||
pr_warn("unable to register chardev\n");
|
pr_warn("unable to register chardev\n");
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user