]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: megaraid: Fix error check return value of register_chrdev()
authorLv Ruyi <lv.ruyi@zte.com.cn>
Mon, 18 Apr 2022 10:57:55 +0000 (10:57 +0000)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 Apr 2022 13:02:44 +0000 (09:02 -0400)
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>
drivers/scsi/megaraid.c

index a5d8cee2d5106d2964b9db765ec7f96a5db77b59..bf491af9f0d65fc545105157dbe55f9d022211e5 100644 (file)
@@ -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");
        }