Message ID | 20220418105755.2558828-1-lv.ruyi@zte.com.cn |
---|---|
State | New |
Headers | show |
Series | megaraid: fix error check return value of register_chrdev() | expand |
> 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 "!". Applied to 5.19/scsi-staging, thanks!
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index a5d8cee2d510..bf491af9f0d6 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c @@ -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"); }