mirror of
https://github.com/torvalds/linux
synced 2024-09-06 18:01:05 +00:00
scsi: megaraid: Fix error check return value of register_chrdev()
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.cn Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
1497e95e22
commit
c5acd61dbb
|
@ -4607,7 +4607,7 @@ static int __init megaraid_init(void)
|
|||
* major number allocation.
|
||||
*/
|
||||
major = register_chrdev(0, "megadev_legacy", &megadev_fops);
|
||||
if (!major) {
|
||||
if (major < 0) {
|
||||
printk(KERN_WARNING
|
||||
"megaraid: failed to register char device\n");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue