diff options
author | Lv Ruyi <[email protected]> | 2022-04-18 10:58:34 +0000 |
---|---|---|
committer | David S. Miller <[email protected]> | 2022-04-22 10:20:43 +0100 |
commit | d48fea8401cfa942c67cc3a522bf379143dbb576 (patch) | |
tree | f972e34640489a69e5f7e845447a2a87067ae576 | |
parent | 59f0c2447e2553b0918b4a9fd38763a5c0587d02 (diff) |
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]>
-rw-r--r-- | drivers/net/wan/cosa.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 23d2954d9747..1e5672019922 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -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; |