From patchwork Fri Feb 17 02:08:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 9578605 X-Patchwork-Delegate: luca@coelho.fi Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74B8460586 for ; Fri, 17 Feb 2017 02:09:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 662F128600 for ; Fri, 17 Feb 2017 02:09:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A4562869B; Fri, 17 Feb 2017 02:09:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C1E52860E for ; Fri, 17 Feb 2017 02:09:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932186AbdBQCJb (ORCPT ); Thu, 16 Feb 2017 21:09:31 -0500 Received: from mail.kernel.org ([198.145.29.136]:48252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932145AbdBQCJ3 (ORCPT ); Thu, 16 Feb 2017 21:09:29 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22112201B9; Fri, 17 Feb 2017 02:09:28 +0000 (UTC) Received: from garbanzo.do-not-panic.com (c-73-15-241-2.hsd1.ca.comcast.net [73.15.241.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4FE1C201C8; Fri, 17 Feb 2017 02:09:25 +0000 (UTC) From: "Luis R. Rodriguez" To: johannes.berg@intel.com, luciano.coelho@intel.com, emmanuel.grumbach@intel.com, tj@kernel.org, arjan@linux.intel.com, ming.lei@canonical.com, zajec5@gmail.com Cc: jeyu@redhat.com, rusty@rustcorp.com.au, pmladek@suse.com, gregkh@linuxfoundation.org, linuxwifi@intel.com, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [RFC 1/5] iwlwifi: fix drv cleanup on opmode registration failure Date: Thu, 16 Feb 2017 18:08:59 -0800 Message-Id: <20170217020903.6370-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170217020903.6370-1-mcgrof@kernel.org> References: <20170217020903.6370-1-mcgrof@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The firmware async callback handles the device's opmode start call, but optionally also allows opmode registration to take care of its opmode start. If the firmware callback handles it its error path in case of opmode start failure has a few pieces of code missing from the opmode registration. The opmode registration hanlder has no cleanup at all. Sync both error paths. This should in theory fix a detangled drv from the drv list should either of the opmode modules loaded and handled registration for the drv. The path of having the opmode registration deal with the drv opmode start is actually the more common path. The other path, from the async callback is rathe rare (1/8 or so times for me) -- it happens when the the opmode driver's init routine completed prior to the driver's async callback opmode start call. Signed-off-by: Luis R. Rodriguez --- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c index be466a074c1d..e198d6f5fcea 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c @@ -1611,8 +1611,13 @@ int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops) continue; op->ops = ops; /* TODO: need to handle exceptional case */ - list_for_each_entry(drv, &op->drv, list) + list_for_each_entry(drv, &op->drv, list) { drv->op_mode = _iwl_op_mode_start(drv, op); + if (!drv->op_mode) { + complete(&drv->request_firmware_complete); + device_release_driver(drv->trans->dev); + } + } mutex_unlock(&iwlwifi_opmode_table_mtx); return 0;