提交 c25d541b 编写于 作者: L Lv Ruyi 提交者: Zheng Zengkai

scsi: megaraid: Fix error check return value of register_chrdev()

stable inclusion
from stable-v5.10.121
commit 508add11af0954a10abc76974d47240b223fd3b6
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=508add11af0954a10abc76974d47240b223fd3b6

--------------------------------

[ Upstream commit c5acd61d ]

If major equals 0, register_chrdev() returns an error code when it fails.
This function dynamically allocates a major and returns its number on
success, so we should use "< 0" to check it instead of "!".

Link: https://lore.kernel.org/r/20220418105755.2558828-1-lv.ruyi@zte.com.cnReported-by: NZeal Robot <zealci@zte.com.cn>
Signed-off-by: NLv Ruyi <lv.ruyi@zte.com.cn>
Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 7c797d53
...@@ -4634,7 +4634,7 @@ static int __init megaraid_init(void) ...@@ -4634,7 +4634,7 @@ static int __init megaraid_init(void)
* major number allocation. * major number allocation.
*/ */
major = register_chrdev(0, "megadev_legacy", &megadev_fops); major = register_chrdev(0, "megadev_legacy", &megadev_fops);
if (!major) { if (major < 0) {
printk(KERN_WARNING printk(KERN_WARNING
"megaraid: failed to register char device\n"); "megaraid: failed to register char device\n");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册