From patchwork Fri May 12 16:42:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 9724629 X-Patchwork-Delegate: kvalo@adurom.com 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 CAEDA601E7 for ; Fri, 12 May 2017 16:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C8E28854 for ; Fri, 12 May 2017 16:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB81A2885E; Fri, 12 May 2017 16:45:01 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham 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 379E828854 for ; Fri, 12 May 2017 16:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755947AbdELQo6 (ORCPT ); Fri, 12 May 2017 12:44:58 -0400 Received: from mail-pf0-f175.google.com ([209.85.192.175]:33226 "EHLO mail-pf0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933188AbdELQm2 (ORCPT ); Fri, 12 May 2017 12:42:28 -0400 Received: by mail-pf0-f175.google.com with SMTP id e193so32709625pfh.0 for ; Fri, 12 May 2017 09:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FcLWhOMUyttrjSXF5lN0vTkpvxYe0sWgtRf07kyh9PA=; b=U/2i0WdRg8WBm0RVF7bz+V4VMtBPq6clqgbSX5rcs+uNWOIp895eA36Xg2YBIn08Xc fASG9glD3mPLN6ISZVVMaiyVb7c8hdkG7zpgM2R5KN8Vm8LN/T60PR/H9pABUXkDLiBZ yBHDHscXpx+eXqGYw6Lb0OrnpemTIKgml5qG8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FcLWhOMUyttrjSXF5lN0vTkpvxYe0sWgtRf07kyh9PA=; b=HT0SCFynhG5boPlCS55Qgyo2S2SIQsZafDlBY3lXgUgMPdSHEcDAL4OzXy05E4qyYX UNKG5ZxiLN8QL+zjB7MDfIBPABB0Ax5MdZ4l9wVls8sXVjjqRCnVf/gY59jqqgIQu3yE SNznGXHEpzbVT/GRIiSp+Gvs8Ma/QZyDSqIQBESsQp2UH0iaXLnSw/6SxEa18N6EC04e jcz2eA2Bpzwsrv3dH6EM0FO8LuCuJGTjAMjurD1sRILWWevpa/3cVqFCK93ETxDcc1NP dxwkaKxT4a0Z5vTrZSOzz0EZkS1RR+iKbgvL4m+FGtmTLSOXgjl8WalBnG7eNIOVtFjB 35qA== X-Gm-Message-State: AODbwcD7i22Z6e6HNj/fezJARZU8N6c+M4e3f3obk34moxKMy8MLAOsw Xa02O9By/ng6KErv X-Received: by 10.99.125.87 with SMTP id m23mr5344522pgn.79.1494607347466; Fri, 12 May 2017 09:42:27 -0700 (PDT) Received: from ban.mtv.corp.google.com ([172.22.64.120]) by smtp.gmail.com with ESMTPSA id u74sm7304499pfk.58.2017.05.12.09.42.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 May 2017 09:42:26 -0700 (PDT) From: Brian Norris To: Ganapathi Bhat , Nishant Sarmukadam Cc: , Dmitry Torokhov , Amitkumar Karwar , Kalle Valo , linux-wireless@vger.kernel.org, Doug Anderson , Brian Norris Subject: [PATCH 03/11] mwifiex: Don't release cmd_pending_q_lock while iterating Date: Fri, 12 May 2017 09:42:00 -0700 Message-Id: <20170512164208.38725-3-briannorris@chromium.org> X-Mailer: git-send-email 2.13.0.rc2.291.g57267f2277-goog In-Reply-To: <20170512164208.38725-1-briannorris@chromium.org> References: <20170512164208.38725-1-briannorris@chromium.org> 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 From: Douglas Anderson Just like in the previous patch ("mwifiex: Don't release tx_ba_stream_tbl_lock while iterating"), in mwifiex_cancel_all_pending_cmd() we were itearting over a list protected by a spinlock. Again, it is not safe to release the spinlock while iterating. Don't do it. Luckily in this case there should be no need to release the spinlock. This is evidenced by: 1. The only function called while the spinlock was released was mwifiex_recycle_cmd_node() 2. Aside from atomic functions (which are safe to call), the only function called by mwifiex_recycle_cmd_node() was mwifiex_insert_cmd_to_free_q(). 3. It can be seen in mwifiex_cancel_pending_scan_cmd() that it's OK to call mwifiex_insert_cmd_to_free_q() while holding a different spinlock (scan_pending_q_lock), so in general holding a spinlock should be OK. 4. It doesn't appear that mwifiex_insert_cmd_to_free_q() has any interaction with the cmd_pending_q_lock No known bugs are fixed with this change, but as with other similar changes this could fix random list corruption. Signed-off-by: Douglas Anderson Signed-off-by: Brian Norris --- drivers/net/wireless/marvell/mwifiex/cmdevt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c index 0c3b217247b1..5fd6c53d7b06 100644 --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c @@ -1056,12 +1056,10 @@ mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter) list_for_each_entry_safe(cmd_node, tmp_node, &adapter->cmd_pending_q, list) { list_del(&cmd_node->list); - spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); if (cmd_node->wait_q_enabled) adapter->cmd_wait_q.status = -1; mwifiex_recycle_cmd_node(adapter, cmd_node); - spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags); } spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags); spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);