Bug 188541 - Function rsxx_pci_probe() does not set error code when the call to create_singlethread_workqueue() fails
Summary: Function rsxx_pci_probe() does not set error code when the call to create_sin...
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Infiniband/RDMA (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_infiniband-rdma
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:31 UTC by bianpan
Modified: 2016-11-25 10:31 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description bianpan 2016-11-25 10:31:23 UTC
Function create_singlethread_workqueue() returns a NULL pointer on failure. In function rsxx_pci_probe() defined in file drivers/block/rsxx/core.c, variable st keeps the error code, its value must be 0 at line 888. As a result, 0 (indicates no error) will be returned even when the call to function create_singlethread_workqueue() at line 890 fails. Though this error may occur rarely, it's better to explicitly assign "-ENOMEM" to st on the true branch of the if-statement at line 891.

 758 static int rsxx_pci_probe(struct pci_dev *dev,
 759                     const struct pci_device_id *id)
 760 {
 761     struct rsxx_cardinfo *card;
 762     int st;
         ...
 876     card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL);
 877     if (!card->ctrl) {
 878         st = -ENOMEM;
 879         goto failed_dma_setup;
 880     }
 881 
 882     st = rsxx_dma_setup(card);
 883     if (st) {
 884         dev_info(CARD_TO_DEV(card),
 885             "Failed to setup DMA engine\n");
 886         goto failed_dma_setup;
 887     }
 888     // the value of st must be 0 when the code reaches here
 889     /************* Setup Card Event Handler *************/
 890     card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
 891     if (!card->event_wq) {
 892         dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
 893         goto failed_event_handler;          // insert "st = -ENOMEM" before the jump instruction?
 894     }
         ...
 961     return 0;
 962 
 963 failed_create_dev:
 964     destroy_workqueue(card->event_wq);
 965     card->event_wq = NULL;
 966 failed_event_handler:
 967     rsxx_dma_destroy(card);
 968 failed_dma_setup:
 969 failed_compatiblity_check:
 970     destroy_workqueue(card->creg_ctrl.creg_wq);
 971     card->creg_ctrl.creg_wq = NULL;
         ...
 990 failed_ida_get:
 991     kfree(card);
 992 
 993     return st;
 994 }

Thanks very much!

Note You need to log in before you can comment on or make changes to this bug.