From 69201fbf82d0d5b403ed42161e0f2e774c42fc8c Mon Sep 17 00:00:00 2001 From: Alex Forencich Date: Sat, 16 Apr 2022 23:30:39 -0700 Subject: [PATCH] modules/mqnic: Clean up error handling in common probe; do not fail probe if interface creation fails so userspace tools will still be usable via driver Signed-off-by: Alex Forencich --- modules/mqnic/mqnic_main.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/mqnic/mqnic_main.c b/modules/mqnic/mqnic_main.c index 98868a158..f2f5b9922 100644 --- a/modules/mqnic/mqnic_main.c +++ b/modules/mqnic/mqnic_main.c @@ -244,6 +244,8 @@ static int mqnic_platform_module_eeprom_get(struct mqnic_dev *mqnic) } #endif +static void mqnic_common_remove(struct mqnic_dev *mqnic); + static int mqnic_common_probe(struct mqnic_dev *mqnic) { int ret = 0; @@ -387,6 +389,7 @@ static int mqnic_common_probe(struct mqnic_dev *mqnic) } } +fail_create_if: mqnic->misc_dev.minor = MISC_DYNAMIC_MINOR; mqnic->misc_dev.name = mqnic->name; mqnic->misc_dev.fops = &mqnic_fops; @@ -394,6 +397,7 @@ static int mqnic_common_probe(struct mqnic_dev *mqnic) ret = misc_register(&mqnic->misc_dev); if (ret) { + mqnic->misc_dev.this_device = NULL; dev_err(dev, "misc_register failed: %d\n", ret); goto fail_miscdev; } @@ -405,17 +409,10 @@ static int mqnic_common_probe(struct mqnic_dev *mqnic) // error handling fail_miscdev: -fail_create_if: - for (k = 0; k < ARRAY_SIZE(mqnic->interface); k++) - if (mqnic->interface[k]) - mqnic_destroy_interface(&mqnic->interface[k]); - - mqnic_unregister_phc(mqnic); - mqnic_board_deinit(mqnic); fail_board: fail_bar_size: fail_rb_init: - free_reg_block_list(mqnic->rb_list); + mqnic_common_remove(mqnic); return ret; } @@ -423,7 +420,8 @@ static void mqnic_common_remove(struct mqnic_dev *mqnic) { int k = 0; - misc_deregister(&mqnic->misc_dev); + if (mqnic->misc_dev.this_device) + misc_deregister(&mqnic->misc_dev); for (k = 0; k < ARRAY_SIZE(mqnic->interface); k++) if (mqnic->interface[k]) @@ -437,7 +435,8 @@ static void mqnic_common_remove(struct mqnic_dev *mqnic) } else { mqnic_board_deinit(mqnic); } - free_reg_block_list(mqnic->rb_list); + if (mqnic->rb_list) + free_reg_block_list(mqnic->rb_list); } #ifdef CONFIG_PCI