Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10717696ybi; Thu, 25 Jul 2019 04:10:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqymlkXCTp9lvbwptOCP+GZKVbx9HTcJCbKoIOpHNcYiw0bEznOH28eOv1WLeM4Xo4G58EcQ X-Received: by 2002:a17:90a:d996:: with SMTP id d22mr92328343pjv.86.1564053010183; Thu, 25 Jul 2019 04:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564053010; cv=none; d=google.com; s=arc-20160816; b=pqkGvkdey7B0U5qHJQEMhcxF9vQHwd9vTMxDjAgC3vLXqZi1295gH0F9J7JG+0GVo8 eKaOfKdPfkGCgfemE/sIrCL+eT2GcEg5UB0EmwQRRQVS1s3bWj+mXJb7qOaoHawa0FtO fRrKW7KkH4gfynHuq/43acyIRycOdoiRubZYgimTul0xX2mBkwCi/sKmli6gHptDzDIz GLRkbjEkGaqMEhryE6VW0lPQdWvw9AH0PfJReorEmt1Eo4jdDDAcDyUpvjWstSEojt1x 0dAK6uWrs0HpLrzeKPCf/YwWZHVcHW9nuZb2h/GEd2Afr49vuiQ6rRMs7PqGPn15loUv D7SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Slq57DvFv5W6XebdEGNCfxEJnoEv4jlUs6e8HhsUv10=; b=yDRXogcq5TThLW3ix4tzPfJbcJgql3Byq6AhRc6EdPh2BOHdGymYp/oLYvJoG7pIuv 0G6be5sYysTFYfCzGjYQxED8UbDOqjA3KOO03qzBmNnzamjoHGv04YrYdBGsyKopdVko 9GGVVOruq0oqaxqWCp12VRG32/JYwMGRiMFej6OVCgY3mwwrj8o6nZanLyv0+t1BUUSY EsfK0hbOJ23Bx5AAdJO17MywILVciLn9qCMHnwQGdewz2pCzHHyKAzvFHVBd1sv7P5+p mFFkrCOphXx/1oUrJHErPva7651qHZru1fTWfU/3VejMaCq6nd2QbeDJlLug2F0HrVeW MGIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S4CfKy6I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u24si17376675pgf.76.2019.07.25.04.09.50; Thu, 25 Jul 2019 04:10:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S4CfKy6I; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404300AbfGYFkL (ORCPT + 99 others); Thu, 25 Jul 2019 01:40:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:54582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404285AbfGYFkI (ORCPT ); Thu, 25 Jul 2019 01:40:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1783922C7D; Thu, 25 Jul 2019 05:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033207; bh=ecra6NhndktQb1ABtB6XprMkB2KL9fmxi/wiwOzJF8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S4CfKy6Ir/4+69EGMalCCapXCOHjePHXymLeYdHJjmAx/GLqeifukSnbkIj3aB5oN G0sAlghhsMH3/BbcLx78fPDx3kMyWGeIkoIDKSMCwVisLj6yr8tOfI/dnSbRQt7Il4 WW8Kn1cancgkoxUjN9Yys0lhhosNA/lxQtGvSO4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ahmad Masri , Maya Erez , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 122/271] wil6210: drop old event after wmi_call timeout Date: Wed, 24 Jul 2019 21:19:51 +0200 Message-Id: <20190724191705.729673847@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1a276003111c0404f6bfeffe924c5a21f482428b ] This change fixes a rare race condition of handling WMI events after wmi_call expires. wmi_recv_cmd immediately handles an event when reply_buf is defined and a wmi_call is waiting for the event. However, in case the wmi_call has already timed-out, there will be no waiting/running wmi_call and the event will be queued in WMI queue and will be handled later in wmi_event_handle. Meanwhile, a new similar wmi_call for the same command and event may be issued. In this case, when handling the queued event we got WARN_ON printed. Fixing this case as a valid timeout and drop the unexpected event. Signed-off-by: Ahmad Masri Signed-off-by: Maya Erez Signed-off-by: Kalle Valo Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wil6210/wmi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/wil6210/wmi.c b/drivers/net/wireless/ath/wil6210/wmi.c index 6e3b3031f29b..2010f771478d 100644 --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c @@ -2816,7 +2816,18 @@ static void wmi_event_handle(struct wil6210_priv *wil, /* check if someone waits for this event */ if (wil->reply_id && wil->reply_id == id && wil->reply_mid == mid) { - WARN_ON(wil->reply_buf); + if (wil->reply_buf) { + /* event received while wmi_call is waiting + * with a buffer. Such event should be handled + * in wmi_recv_cmd function. Handling the event + * here means a previous wmi_call was timeout. + * Drop the event and do not handle it. + */ + wil_err(wil, + "Old event (%d, %s) while wmi_call is waiting. Drop it and Continue waiting\n", + id, eventid2name(id)); + return; + } wmi_evt_call_handler(vif, id, evt_data, len - sizeof(*wmi)); -- 2.20.1