Skip to contentSkip to conversation

New: Function rsxx_pci_probe() does not set error code when the call to create_singlethread_workqueue() fails

Bug 188541 bugzilla-daemon-590EEB7GvNiWaY/[email protected] 1 participant 1 message Nov 25, 2016 InfiniBand

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=188541

Bug ID: 188541
Summary: Function rsxx_pci_probe() does not set error code when
the call to create_singlethread_workqueue() fails
Product: Drivers
Version: 2.5
Kernel Version: linux-4.9-rc6
Hardware: All
OS: Linux
Tree: Mainline
Status: NEW
Severity: normal
Priority: P1
Component: Infiniband/RDMA
Assignee: drivers_infiniband-rdma-ztI5WcYan/[email protected]
Reporter: [email protected]
Regression: No

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!

Signature · 6 lines
You are receiving this mail because:
You are watching the assignee of the bug.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html