From: Alexey Khoroshilov Date: Fri, 6 Mar 2015 22:43:41 +0000 (+0300) Subject: NVMe: Fix error handling of class_create("nvme") X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c727040bdaa28cd7aa9dbc086eee7b236e0fb270;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git NVMe: Fix error handling of class_create("nvme") class_create() returns ERR_PTR on failure, so IS_ERR() should be used instead of check for NULL. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Keith Busch Signed-off-by: Jens Axboe --- diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index ef432786213b..9052553eda65 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -3163,8 +3163,10 @@ static int __init nvme_init(void) nvme_char_major = result; nvme_class = class_create(THIS_MODULE, "nvme"); - if (!nvme_class) + if (IS_ERR(nvme_class)) { + result = PTR_ERR(nvme_class); goto unregister_chrdev; + } result = pci_register_driver(&nvme_driver); if (result)