Skip to content

Commit

Permalink
net: cosa: fix error check return value of register_chrdev()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lv Ruyi authored and davem330 committed Apr 22, 2022
1 parent 59f0c24 commit d48fea8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/wan/cosa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d48fea8

Please sign in to comment.