From patchwork Wed Mar 15 20:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fedor Pchelkin X-Patchwork-Id: 13176626 X-Patchwork-Delegate: toke@redhat.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2AA7FC7618D for ; Wed, 15 Mar 2023 20:22:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232991AbjCOUWi (ORCPT ); Wed, 15 Mar 2023 16:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232877AbjCOUWe (ORCPT ); Wed, 15 Mar 2023 16:22:34 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A0B9A21AE; Wed, 15 Mar 2023 13:22:24 -0700 (PDT) Received: from fpc.intra.ispras.ru (unknown [10.10.165.16]) by mail.ispras.ru (Postfix) with ESMTPSA id 000B144C101F; Wed, 15 Mar 2023 20:22:22 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 000B144C101F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1678911743; bh=KHlEKAhpUGzm2mZCMucQ8WbZWdQoP58ONPTTGbeX3MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pF8+mLdy40gtvvg8OB9D1OQDILvPJaHvvHMnT7RNekOc6QhJSM3bhgNu+no7WBUPh iEbbhudO8Dzq8G8WsxsNaChuyN0EA2dyfCCBcJVUnq7sj5jBuHY/bny1AQS0INSVZj 5t3iTEBkUd36YwJFAhhKN1TBuroFwJAK3VXphddo= From: Fedor Pchelkin To: =?utf-8?q?Toke_H=C3=B8iland-J=C3=B8rgensen?= Cc: Fedor Pchelkin , Kalle Valo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Senthil Balasubramanian , "John W. Linville" , Vasanthakumar Thiagarajan , Sujith , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH 3/3] wifi: ath9k: fix ath9k_wmi_cmd return value when device is unplugged Date: Wed, 15 Mar 2023 23:21:12 +0300 Message-Id: <20230315202112.163012-4-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230315202112.163012-1-pchelkin@ispras.ru> References: <20230315202112.163012-1-pchelkin@ispras.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Return with an error code in case the USB device has been already unplugged. Otherwise the callers of ath9k_wmi_cmd() are unaware of the fact that cmd_buf and rsp_buf are not initialized or handled properly inside this function. Found by Linux Verification Center (linuxtesting.org) with Syzkaller. Fixes: a3be14b76da1 ("ath9k_htc: Handle device unplug properly") Signed-off-by: Fedor Pchelkin --- drivers/net/wireless/ath/ath9k/wmi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ath/ath9k/wmi.c b/drivers/net/wireless/ath/ath9k/wmi.c index 99a91bbaace9..3e0ad4f8f0a0 100644 --- a/drivers/net/wireless/ath/ath9k/wmi.c +++ b/drivers/net/wireless/ath/ath9k/wmi.c @@ -320,8 +320,11 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id, unsigned long time_left; int ret = 0; - if (ah->ah_flags & AH_UNPLUGGED) - return 0; + if (ah->ah_flags & AH_UNPLUGGED) { + ath_dbg(common, WMI, "Device unplugged for WMI command: %s\n", + wmi_cmd_to_name(cmd_id)); + return -ENODEV; + } skb = alloc_skb(headroom + cmd_len, GFP_ATOMIC); if (!skb)