Skip to content

Commit

Permalink
NVMe: Fix error handling of class_create("nvme")
Browse files Browse the repository at this point in the history
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 <khoroshilov@ispras.ru>
Acked-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Alexey Khoroshilov authored and Jens Axboe committed Apr 8, 2015
1 parent de9ad6d commit c727040
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/block/nvme-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c727040

Please sign in to comment.