Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1247318ybi; Sun, 16 Jun 2019 00:33:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdeLVAFDoZ1m3mo2rq2cAVcbTDrU8SSpHR2FkW1tb2yCKnWsv4CTQi+eI93s9ttQTn/z8i X-Received: by 2002:a17:90b:8d2:: with SMTP id ds18mr20446264pjb.132.1560670408767; Sun, 16 Jun 2019 00:33:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560670408; cv=none; d=google.com; s=arc-20160816; b=BIKpNVbXJyXx8VFacJ0l18JwPWC/akGL++UcnTQLLYhpobtOnS0ljxtvJ9Rxjfd6y1 5vkgNHyywPrSbkQO+0yoptieV9/5LYmA6nHqRa1Gs50AMODxu1s1C9QDtbvcvoovOBeG 58KTdc4lOuDGDuebeB/HV9/+JMUe7U3PHXvheMdtrkWqTqZ/vUPfrulApGkcFuLQT6/N /4foS6E1CAJyJfLJEN4NRQPYEoIneNcBrjDu1Cq0d1Uh8BOm+RIUaZCXeOmS15cONjFE R6U7JZ5aJCV8T6b4qhGqPMpYrRFhmzRhFO4tANxQ842aCUde9tt25yaqwVZwaP/ahBhy CYIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=DzRK49syU8uejKUO3oXdoSjW0ksstky5cttEtEDZbTY=; b=Vx5JO7YmaNptK6stXVyFrlB5U32FnV78apk/LH0kAOu2s5gExQxpkR9jWGHLRgQyNK TrrnYuUKitoiKgneTdoNKfWrMIaHqawzsTDVV9rti0rFKm1xV2lCZpq8ZEfRMNfyNHS4 zfArcSU2HFCzD60QbyTEH8ZZiakH8gFR6IIdGqDpwnsXxIaLHWxze0BTpSmpIyo+j1Jx wZ8IO7/V08ojbt4OezpIOkVhw4on/fqAE3GcJEKWCVS7u25RWfhir/estfGSlil+R4bs cGxcCkQup3C0BM/SIYM79JAlOUiyNVkEsRs7sAM3fTQ3Ex/fMwgSRuaSbWeIJDBxPeQJ W0GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 d24si6397213pls.252.2019.06.16.00.33.06; Sun, 16 Jun 2019 00:33:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725935AbfFPHcY (ORCPT + 99 others); Sun, 16 Jun 2019 03:32:24 -0400 Received: from alexa-out-ams-02.qualcomm.com ([185.23.61.163]:58169 "EHLO alexa-out-ams-02.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725860AbfFPHcY (ORCPT ); Sun, 16 Jun 2019 03:32:24 -0400 X-Greylist: delayed 365 seconds by postgrey-1.27 at vger.kernel.org; Sun, 16 Jun 2019 03:32:22 EDT Received: from ironmsg02-ams.qualcomm.com ([10.251.56.3]) by alexa-out-ams-02.qualcomm.com with ESMTP; 16 Jun 2019 09:26:16 +0200 X-IronPort-AV: E=McAfee;i="6000,8403,9289"; a="8499841" Received: from lx-merez1.mea.qualcomm.com ([10.18.173.103]) by ironmsg02-ams.qualcomm.com with ESMTP; 16 Jun 2019 09:26:16 +0200 From: Maya Erez To: Kalle Valo Cc: Ahmad Masri , linux-wireless@vger.kernel.org, wil6210@qti.qualcomm.com, Maya Erez Subject: [PATCH 11/11] wil6210: drop old event after wmi_call timeout Date: Sun, 16 Jun 2019 10:26:07 +0300 Message-Id: <1560669967-23706-12-git-send-email-merez@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1560669967-23706-1-git-send-email-merez@codeaurora.org> References: <1560669967-23706-1-git-send-email-merez@codeaurora.org> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Ahmad Masri 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 --- 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 542ef15..475b1a2 100644 --- a/drivers/net/wireless/ath/wil6210/wmi.c +++ b/drivers/net/wireless/ath/wil6210/wmi.c @@ -3303,7 +3303,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)); -- 1.9.1