Message ID | 20210517084706.1620399-1-kgraul@linux.ibm.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 444d7be9532dcfda8e0385226c862fd7e986f607 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] net/smc: remove device from smcd_dev_list after failed device_add() | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | fail | 2 blamed authors not CCed: ubraun@linux.ibm.com hwippel@linux.ibm.com; 2 maintainers not CCed: ubraun@linux.ibm.com hwippel@linux.ibm.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 23 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Mon, 17 May 2021 10:47:06 +0200 you wrote: > From: Julian Wiedmann <jwi@linux.ibm.com> > > If the device_add() for a smcd_dev fails, there's no cleanup step that > rolls back the earlier list_add(). The device subsequently gets freed, > and we end up with a corrupted list. > > Add some error handling that removes the device from the list. > > [...] Here is the summary with links: - [net] net/smc: remove device from smcd_dev_list after failed device_add() https://git.kernel.org/netdev/net/c/444d7be9532d You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/smc/smc_ism.c b/net/smc/smc_ism.c index 9c6e95882553..d24b96ea0eb5 100644 --- a/net/smc/smc_ism.c +++ b/net/smc/smc_ism.c @@ -428,6 +428,8 @@ EXPORT_SYMBOL_GPL(smcd_alloc_dev); int smcd_register_dev(struct smcd_dev *smcd) { + int rc; + mutex_lock(&smcd_dev_list.mutex); if (list_empty(&smcd_dev_list.list)) { u8 *system_eid = NULL; @@ -447,7 +449,14 @@ int smcd_register_dev(struct smcd_dev *smcd) dev_name(&smcd->dev), smcd->pnetid, smcd->pnetid_by_user ? " (user defined)" : ""); - return device_add(&smcd->dev); + rc = device_add(&smcd->dev); + if (rc) { + mutex_lock(&smcd_dev_list.mutex); + list_del(&smcd->list); + mutex_unlock(&smcd_dev_list.mutex); + } + + return rc; } EXPORT_SYMBOL_GPL(smcd_register_dev);