* [PATCH] net: cosa: fix error check return value of register_chrdev()
@ 2022-04-18 10:58 cgel.zte
2022-04-19 8:32 ` Jan Kasprzak
2022-04-22 9:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: cgel.zte @ 2022-04-18 10:58 UTC (permalink / raw)
To: kas, davem; +Cc: kuba, pabeni, netdev, linux-kernel, Lv Ruyi, Zeal Robot
From: Lv Ruyi <lv.ruyi@zte.com.cn>
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>
---
drivers/net/wan/cosa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: cosa: fix error check return value of register_chrdev()
2022-04-18 10:58 [PATCH] net: cosa: fix error check return value of register_chrdev() cgel.zte
@ 2022-04-19 8:32 ` Jan Kasprzak
2022-04-22 9:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kasprzak @ 2022-04-19 8:32 UTC (permalink / raw)
To: cgel.zte; +Cc: davem, kuba, pabeni, netdev, linux-kernel, Lv Ruyi, Zeal Robot
Acked-By: Jan "Yenya" Kasprzak <kas@fi.muni.cz>
Thanks!
-Yenya
cgel.zte@gmail.com wrote:
: From: Lv Ruyi <lv.ruyi@zte.com.cn>
:
: 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>
: ---
: drivers/net/wan/cosa.c | 2 +-
: 1 file changed, 1 insertion(+), 1 deletion(-)
:
: 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;
: --
: 2.25.1
:
--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| http://www.fi.muni.cz/~kas/ GPG: 4096R/A45477D5 |
We all agree on the necessity of compromise. We just can't agree on
when it's necessary to compromise. --Larry Wall
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: cosa: fix error check return value of register_chrdev()
2022-04-18 10:58 [PATCH] net: cosa: fix error check return value of register_chrdev() cgel.zte
2022-04-19 8:32 ` Jan Kasprzak
@ 2022-04-22 9:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-22 9:30 UTC (permalink / raw)
To: Lv Ruyi; +Cc: kas, davem, kuba, pabeni, netdev, linux-kernel, lv.ruyi, zealci
Hello:
This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:
On Mon, 18 Apr 2022 10:58:34 +0000 you wrote:
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
>
> 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>
>
> [...]
Here is the summary with links:
- net: cosa: fix error check return value of register_chrdev()
https://git.kernel.org/netdev/net/c/d48fea8401cf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-22 9:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18 10:58 [PATCH] net: cosa: fix error check return value of register_chrdev() cgel.zte
2022-04-19 8:32 ` Jan Kasprzak
2022-04-22 9:30 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.