From patchwork Thu Nov 28 17:22:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11266455 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 725E9921 for ; Thu, 28 Nov 2019 17:25:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52AF2217BC for ; Thu, 28 Nov 2019 17:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574961921; bh=b4/AmTEV92WrE9X3EffjoPEtgDbvxRWEPGW8xFeckBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BPIEuCogdNeFkqhLx3enlDqTNF6IPzDtdlKBnntt0oNzrhVYEI0InKZznnqr6NidC myx2S4rIdPVkBt4iqzMB9g6vXknGiXIO0d3OWU3RPo4RSt+QzJVAdgcaVAho3qWS/h ZSqAqRkqkWqFbdy1BWSRMVTQqk3w4YyrOWUc2hOE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726722AbfK1RYp (ORCPT ); Thu, 28 Nov 2019 12:24:45 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:42688 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbfK1RYo (ORCPT ); Thu, 28 Nov 2019 12:24:44 -0500 Received: by mail-lf1-f68.google.com with SMTP id y19so20572152lfl.9; Thu, 28 Nov 2019 09:24:42 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=trn2oJruIhuwCs6xMuGwp0kYiOcQXsbNZbrdFQNLYJE=; b=QteH4IQ22KTDPseojpdNhFGKl9L1O/chT62Cik94gJLML6M5X7nVARktSDXUmZZ8FL i07qSUjq7mGwrPVXO5ZUPGCQX+DXqenJR4dGvJN4Tq8OQ4WHLP96rBcVtw//+ypwXP+P CYTYtOHRVAL2BJnLMGGL6WkXamiEwomXIZrpr1buPUYnBY5sZ7bUsJagi3qNfZtZhQCp sJp+NivfJCZz8UwZt6mM5A0MT8KFkWidpMR8gIVCb22lgqosMvtxTzCcfrhMW9sTQceg EJOoMC2DVQTgZvCRMeLb3xS0VRq2YaIW4JOSwD4UHCO76LZKhsuc2zVFeof+kMJM8AAX apyg== X-Gm-Message-State: APjAAAWUEz9E8kLGd9smY7h2Kz44Loc3ODsNTd4F/9ClQnq511AXYXdM NN93MqYIWloPDAZu8CRt8cc= X-Google-Smtp-Source: APXvYqxtH+XIdpH4HnL/JWO08m2iRo/IyYF6xtb7plDsp4uwvtDcMSNpC+r46yKkqLPgibeG4e5ejg== X-Received: by 2002:a19:da1a:: with SMTP id r26mr34062739lfg.60.1574961881917; Thu, 28 Nov 2019 09:24:41 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id 145sm4249850ljj.69.2019.11.28.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 09:24:41 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iaNWz-0006wR-HU; Thu, 28 Nov 2019 18:24:41 +0100 From: Johan Hovold To: Amitkumar Karwar , Siva Rebbagondla , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , syzbot+b563b7f8dbe8223a51e8@syzkaller.appspotmail.com, stable , Siva Rebbagondla , Prameela Rani Garnepudi , Amitkumar Karwar , Fariya Fatima Subject: [PATCH 1/5] rsi: fix use-after-free on failed probe and unbind Date: Thu, 28 Nov 2019 18:22:00 +0100 Message-Id: <20191128172204.26600-2-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128172204.26600-1-johan@kernel.org> References: <20191128172204.26600-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Make sure to stop both URBs before returning after failed probe as well as on disconnect to avoid use-after-free in the completion handler. Reported-by: syzbot+b563b7f8dbe8223a51e8@syzkaller.appspotmail.com Fixes: a4302bff28e2 ("rsi: add bluetooth rx endpoint") Fixes: dad0d04fa7ba ("rsi: Add RS9113 wireless driver") Cc: stable # 3.15 Cc: Siva Rebbagondla Cc: Prameela Rani Garnepudi Cc: Amitkumar Karwar Cc: Fariya Fatima Signed-off-by: Johan Hovold --- drivers/net/wireless/rsi/rsi_91x_usb.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index 53f41fc2cadf..30bed719486e 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -292,6 +292,15 @@ static void rsi_rx_done_handler(struct urb *urb) dev_kfree_skb(rx_cb->rx_skb); } +static void rsi_rx_urb_kill(struct rsi_hw *adapter, u8 ep_num) +{ + struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev; + struct rx_usb_ctrl_block *rx_cb = &dev->rx_cb[ep_num - 1]; + struct urb *urb = rx_cb->rx_urb; + + usb_kill_urb(urb); +} + /** * rsi_rx_urb_submit() - This function submits the given URB to the USB stack. * @adapter: Pointer to the adapter structure. @@ -823,10 +832,13 @@ static int rsi_probe(struct usb_interface *pfunction, if (adapter->priv->coex_mode > 1) { status = rsi_rx_urb_submit(adapter, BT_EP); if (status) - goto err1; + goto err_kill_wlan_urb; } return 0; + +err_kill_wlan_urb: + rsi_rx_urb_kill(adapter, WLAN_EP); err1: rsi_deinit_usb_interface(adapter); err: @@ -857,6 +869,10 @@ static void rsi_disconnect(struct usb_interface *pfunction) adapter->priv->bt_adapter = NULL; } + if (adapter->priv->coex_mode > 1) + rsi_rx_urb_kill(adapter, BT_EP); + rsi_rx_urb_kill(adapter, WLAN_EP); + rsi_reset_card(adapter); rsi_deinit_usb_interface(adapter); rsi_91x_deinit(adapter); From patchwork Thu Nov 28 17:22:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11266445 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52E54921 for ; Thu, 28 Nov 2019 17:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3291C21787 for ; Thu, 28 Nov 2019 17:25:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574961902; bh=gsKLBwCaa8hPTQ9HbxM3MtQ1BolFfd3zoh920k1eRXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Lz5hFzf6MC5/HCQdkcPbxOIQFYyLsRUOyomtTCghd9kVdHn9w1gAeakK0gvhgHBiN hc/caf8ZyVp+PMLh7Kc+6iTMN8tDvVcf8m+I7Ev4m1TUMfWkKC+lb6ybyNGarzAJVu JmIbvvhDe2zoIc++YYu5zVXjNmnBIsQNBtI3mZao= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726963AbfK1RYr (ORCPT ); Thu, 28 Nov 2019 12:24:47 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44516 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726612AbfK1RYq (ORCPT ); Thu, 28 Nov 2019 12:24:46 -0500 Received: by mail-lf1-f68.google.com with SMTP id v201so19533332lfa.11; Thu, 28 Nov 2019 09:24:43 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=0k/whkObdvFEbr6P8BAMIPbGI3mpivEYyevE4zbpz+U=; b=YTnLBVxZmcA1S1GTv5vEk7bJZXnWjMCDCsAmEyrDJiEDDlhkDfV15S/ZN4Hm8aGOi6 g9vvRgAq4hV35JXUDcAFlRkL76AHO8/MKFrYzt6d8qycJuWpvNfTQOg9/L55l5T9A57Y Xz7jfyVCdngQxT+XCzW81vT3/V+BlL5hvS2p8ZqdGzJ+lMwGZSODFHGzzcQRPX1JHwuC wCSWTKuO8xtr9wmRPfWYg3THCaM0srPMPs7gZimBg8XM6jsWdkggElYEmj68ECFvw3FY /Yt8p1IVLqMZlHfEwo1RNU1fQO2k+CgvYCygvkxQQJKgaWlvJ9Ml8AKKpLsR6NisqoP6 6cUQ== X-Gm-Message-State: APjAAAVDnT714kj/1J0een5/etlGE69B73RaWLv5UfWplv+8eGHBNwpp wPEtHzLy2j2DSijXkNbs9zHb6/Us X-Google-Smtp-Source: APXvYqx07QR8XJ8G7WRnoRgk6KFeYR3k/7eUV4xZpOE+oly6I6TehZvJEdoQ6FJhKcL8PMi2nHK23Q== X-Received: by 2002:ac2:41d8:: with SMTP id d24mr17717001lfi.98.1574961883138; Thu, 28 Nov 2019 09:24:43 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id v28sm4310765lfd.93.2019.11.28.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 09:24:41 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iaNWz-0006wW-Jv; Thu, 28 Nov 2019 18:24:41 +0100 From: Johan Hovold To: Amitkumar Karwar , Siva Rebbagondla , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , syzbot+1d1597a5aa3679c65b9f@syzkaller.appspotmail.com, stable , Prameela Rani Garnepudi , Amitkumar Karwar Subject: [PATCH 2/5] rsi: fix use-after-free on probe errors Date: Thu, 28 Nov 2019 18:22:01 +0100 Message-Id: <20191128172204.26600-3-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128172204.26600-1-johan@kernel.org> References: <20191128172204.26600-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The driver would fail to stop the command timer in most error paths, something which specifically could lead to the timer being freed while still active on I/O errors during probe. Fix this by making sure that each function starting the timer also stops it in all relevant error paths. Reported-by: syzbot+1d1597a5aa3679c65b9f@syzkaller.appspotmail.com Fixes: b78e91bcfb33 ("rsi: Add new firmware loading method") Cc: stable # 4.12 Cc: Prameela Rani Garnepudi Cc: Amitkumar Karwar Signed-off-by: Johan Hovold --- drivers/net/wireless/rsi/rsi_91x_hal.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c index f84250bdb8cf..6f8d5f9a9f7e 100644 --- a/drivers/net/wireless/rsi/rsi_91x_hal.c +++ b/drivers/net/wireless/rsi/rsi_91x_hal.c @@ -622,6 +622,7 @@ static int bl_cmd(struct rsi_hw *adapter, u8 cmd, u8 exp_resp, char *str) bl_start_cmd_timer(adapter, timeout); status = bl_write_cmd(adapter, cmd, exp_resp, ®out_val); if (status < 0) { + bl_stop_cmd_timer(adapter); rsi_dbg(ERR_ZONE, "%s: Command %s (%0x) writing failed..\n", __func__, str, cmd); @@ -737,10 +738,9 @@ static int ping_pong_write(struct rsi_hw *adapter, u8 cmd, u8 *addr, u32 size) } status = bl_cmd(adapter, cmd_req, cmd_resp, str); - if (status) { - bl_stop_cmd_timer(adapter); + if (status) return status; - } + return 0; } @@ -828,10 +828,9 @@ static int auto_fw_upgrade(struct rsi_hw *adapter, u8 *flash_content, status = bl_cmd(adapter, EOF_REACHED, FW_LOADING_SUCCESSFUL, "EOF_REACHED"); - if (status) { - bl_stop_cmd_timer(adapter); + if (status) return status; - } + rsi_dbg(INFO_ZONE, "FW loading is done and FW is running..\n"); return 0; } @@ -849,6 +848,7 @@ static int rsi_hal_prepare_fwload(struct rsi_hw *adapter) ®out_val, RSI_COMMON_REG_SIZE); if (status < 0) { + bl_stop_cmd_timer(adapter); rsi_dbg(ERR_ZONE, "%s: REGOUT read failed\n", __func__); return status; From patchwork Thu Nov 28 17:22:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11266439 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1341515AB for ; Thu, 28 Nov 2019 17:24:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E655821835 for ; Thu, 28 Nov 2019 17:24:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574961887; bh=RAYe5u89j0gevqYuxVl//afQVDlQK+7EMpuQardxMTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GOPewCwvETQkvNEMnVOqwfqqoEdSU6BSWEBtuIaMUp+cnCQHGbo/r6AyOnBow9SAF i9rLXkmRWwr6d6Fh3cU8W/CPpJeaEofgc+gE0yvCTchU1o+KnRCDmC0GohRghQpVrF pnG8U1613TmG6KJIJcfKvPgWO0dscCZ0YsTJnOyY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfK1RYq (ORCPT ); Thu, 28 Nov 2019 12:24:46 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38285 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726634AbfK1RYp (ORCPT ); Thu, 28 Nov 2019 12:24:45 -0500 Received: by mail-lj1-f196.google.com with SMTP id k8so18720909ljh.5; Thu, 28 Nov 2019 09:24:44 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=pNXr26dRu/aWo/ZNTMnDAua6PjrBe7AfSoIfHjNsLPE=; b=DijGBPHU15acrYKJtI3L20TQdWuWDnCZSor5ygvTiyRAiiGAEmDvxn0Z5qRNVXt45G zDpfMzKD0N4lgGPT44ht37yOK2PgZPIMx8ry5ygfW836puozD/o4hcVZch/CnuEk66wP Qm4vAZP2bA+TTL5hGlX6uF3JT3PX9L4Iiv1NxuB9k09UuYVTaFFt10KeVQUcndPPFMpb 6DLtmkYgydOiI8vkeKWTwFZs3FD3JKKN3CUhqjyaDzP2VXcABZnUAElpRQvqsYHkDeu/ KheLYEroZGi4527HwJXR7Xe1YyExRRBy61FO6dxNFnKltJLejcK1RKYBVFm+04/el6OL UFFA== X-Gm-Message-State: APjAAAWn437P/sM2CLJ8Fc2Nx8dVMGVbk7YQdWFdooxdvPS2z6Tekjv+ vfzWsUvKDFbJIxGweaRlm9c= X-Google-Smtp-Source: APXvYqwTGHlPMSUQNTb3ZUCf6aq5gzdY12/WN1GGQebXicNweZ5WxFIrPWT9g4iavEJoZJ+5Nmt4vw== X-Received: by 2002:a05:651c:305:: with SMTP id a5mr35814469ljp.144.1574961883728; Thu, 28 Nov 2019 09:24:43 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id f11sm4733771lfa.9.2019.11.28.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 09:24:41 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iaNWz-0006wb-N6; Thu, 28 Nov 2019 18:24:41 +0100 From: Johan Hovold To: Amitkumar Karwar , Siva Rebbagondla , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , stable , Prameela Rani Garnepudi Subject: [PATCH 3/5] rsi: fix memory leak on failed URB submission Date: Thu, 28 Nov 2019 18:22:02 +0100 Message-Id: <20191128172204.26600-4-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128172204.26600-1-johan@kernel.org> References: <20191128172204.26600-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Make sure to free the skb on failed receive-URB submission (e.g. on disconnect or currently also due to a missing endpoint). Fixes: a1854fae1414 ("rsi: improve RX packet handling in USB interface") Cc: stable # 4.17 Cc: Prameela Rani Garnepudi Signed-off-by: Johan Hovold --- drivers/net/wireless/rsi/rsi_91x_usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index 30bed719486e..2c869df1c62e 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -338,8 +338,10 @@ static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num) rx_cb); status = usb_submit_urb(urb, GFP_KERNEL); - if (status) + if (status) { rsi_dbg(ERR_ZONE, "%s: Failed in urb submission\n", __func__); + dev_kfree_skb(skb); + } return status; } From patchwork Thu Nov 28 17:22:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11266453 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6DFC15AB for ; Thu, 28 Nov 2019 17:25:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9755C217BC for ; Thu, 28 Nov 2019 17:25:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574961916; bh=TJEAl71rmxZeQDQFzQGbQEafJzjNuTW3OiiQLv+5DMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iiKcSQiN/bFDATWeI9dX4kUqkwZiq+wIavHN4ZLZJOsLlp+KyMNpvzzS6QuAQSqin 8lOlFObWpb9cDhGWp1rzM0viTtN2Lan69h17zqHPuaRNiCJO6RowMFN41NHWXsLgda AEJtQpyY5cVgW7b7u+iLEzBEiSZJbbvtcPg0p5Xg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727126AbfK1RZG (ORCPT ); Thu, 28 Nov 2019 12:25:06 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:45002 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbfK1RYq (ORCPT ); Thu, 28 Nov 2019 12:24:46 -0500 Received: by mail-lj1-f195.google.com with SMTP id c19so2244048lji.11; Thu, 28 Nov 2019 09:24:45 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=zEpgrcz5cY6Ra8WYykk85CUZbzbFys1lSb0pPL5E4ss=; b=IZz51qFvTrq5K8SzBG4uH0UuzRAXCOVzKPEu8hKgjsKa2HYJbbKOi169jss2LnqM9s y/k1cQ1ffTE3qg4KMmjmRZrKh1gfIhc0M9v3LVWM4JTczyrtL3skOfaVofSPUjgY1R3H eXHS/aZDen3NZYhUJTSXIa9Piwvv0Q8sE0rp2trTmTJuzNrVZkEIXloEPtxe3v8aqpwk w2H0I4oPJwdQCp3pcUX6pEm7R3VT7p3QacYOYV4w+M1iK0cBmBjt8F80I5+62c+CjRgc Vzdz7voP0r56W8Qf+aRN3iN46s3K+h0oloBTXGd6kUvZAhS8N8DpP2giaRob/b4CWrtt +JvA== X-Gm-Message-State: APjAAAWfZkrTNZITy12z2oAn/zr17OmuCDeHjyWqa7WtMMfQbzmWpHPs GPoJ8GvADPEVRSwXPAv0hjI= X-Google-Smtp-Source: APXvYqxD73DK18Dce9vMPPWdSB6pO3ua+Sf+1evEb3MHPpO0BdRfc+0cLAeSf6U6oIO+cPPKHirUYA== X-Received: by 2002:a2e:8509:: with SMTP id j9mr33787504lji.247.1574961884451; Thu, 28 Nov 2019 09:24:44 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id t8sm8786109lfl.51.2019.11.28.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 09:24:42 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iaNWz-0006wg-Pg; Thu, 28 Nov 2019 18:24:41 +0100 From: Johan Hovold To: Amitkumar Karwar , Siva Rebbagondla , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold , stable , Prameela Rani Garnepudi Subject: [PATCH 4/5] rsi: fix non-atomic allocation in completion handler Date: Thu, 28 Nov 2019 18:22:03 +0100 Message-Id: <20191128172204.26600-5-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128172204.26600-1-johan@kernel.org> References: <20191128172204.26600-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org USB completion handlers are called in atomic context and must specifically not allocate memory using GFP_KERNEL. Fixes: a1854fae1414 ("rsi: improve RX packet handling in USB interface") Cc: stable # 4.17 Cc: Prameela Rani Garnepudi Signed-off-by: Johan Hovold --- drivers/net/wireless/rsi/rsi_91x_usb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index 2c869df1c62e..ead75574e10a 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -16,6 +16,7 @@ */ #include +#include #include #include "rsi_usb.h" #include "rsi_hal.h" @@ -29,7 +30,7 @@ MODULE_PARM_DESC(dev_oper_mode, "9[Wi-Fi STA + BT LE], 13[Wi-Fi STA + BT classic + BT LE]\n" "6[AP + BT classic], 14[AP + BT classic + BT LE]"); -static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num); +static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num, gfp_t flags); /** * rsi_usb_card_write() - This function writes to the USB Card. @@ -285,7 +286,7 @@ static void rsi_rx_done_handler(struct urb *urb) status = 0; out: - if (rsi_rx_urb_submit(dev->priv, rx_cb->ep_num)) + if (rsi_rx_urb_submit(dev->priv, rx_cb->ep_num, GFP_ATOMIC)) rsi_dbg(ERR_ZONE, "%s: Failed in urb submission", __func__); if (status) @@ -307,7 +308,7 @@ static void rsi_rx_urb_kill(struct rsi_hw *adapter, u8 ep_num) * * Return: 0 on success, a negative error code on failure. */ -static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num) +static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num, gfp_t mem_flags) { struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev; struct rx_usb_ctrl_block *rx_cb = &dev->rx_cb[ep_num - 1]; @@ -337,7 +338,7 @@ static int rsi_rx_urb_submit(struct rsi_hw *adapter, u8 ep_num) rsi_rx_done_handler, rx_cb); - status = usb_submit_urb(urb, GFP_KERNEL); + status = usb_submit_urb(urb, mem_flags); if (status) { rsi_dbg(ERR_ZONE, "%s: Failed in urb submission\n", __func__); dev_kfree_skb(skb); @@ -827,12 +828,12 @@ static int rsi_probe(struct usb_interface *pfunction, rsi_dbg(INIT_ZONE, "%s: Device Init Done\n", __func__); } - status = rsi_rx_urb_submit(adapter, WLAN_EP); + status = rsi_rx_urb_submit(adapter, WLAN_EP, GFP_KERNEL); if (status) goto err1; if (adapter->priv->coex_mode > 1) { - status = rsi_rx_urb_submit(adapter, BT_EP); + status = rsi_rx_urb_submit(adapter, BT_EP, GFP_KERNEL); if (status) goto err_kill_wlan_urb; } From patchwork Thu Nov 28 17:22:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 11266443 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C0EF921 for ; Thu, 28 Nov 2019 17:24:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C09C21787 for ; Thu, 28 Nov 2019 17:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574961897; bh=DT64ke75+N9UfVft8WgVfGGL4ShiWDLpTKcTf07A7mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=u4W8K2/0iBKK1h8FyCMYgRH/FSKmEmbidP+rshso7y8xpkuhjuBMOEFKSCXLXuvjI ydzbKNkrWNNF71Ap0lAgSHLcBAEARb+Uf54LIA5ZUYFJs30q+UAo16ocKYqyGf2PL1 Qzqre/oqjjbkcDANAoJlSXHu2TC23TsxA+lfbLA4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727084AbfK1RYx (ORCPT ); Thu, 28 Nov 2019 12:24:53 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:32919 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726446AbfK1RYr (ORCPT ); Thu, 28 Nov 2019 12:24:47 -0500 Received: by mail-lj1-f196.google.com with SMTP id t5so29295489ljk.0; Thu, 28 Nov 2019 09:24:45 -0800 (PST) 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:mime-version:content-transfer-encoding; bh=ZNDtdmETKvubKODy6INzZo8FVEmBbwko469tiDmk0AM=; b=FbOmGKINtKzawJJ2mUBzCDl0j5Vs/eTV3uife+bK7l0pOl4hZvCspIo0WOI+AKxqHC 6FgN3Zu9PDGNZH1yOA26RTz7zu7jg9afo8Ed7+M+OJb78P9gSi3y1K+qtK1sgHOfO79H RtrVNMpgPJAzRn4MIs0QIKNtowiPEUi+bILPwr2WJ39xzkJgdy0FoTiJfZBmiuWpTcm9 Md/hntZ78GkHXXV+w6YZgNm0qm5OHAhXMp/I09F7rEYcpCFQO4r0v0CPO2wnivlmHUru eawyNRjBtI5qn5i46X9e79QPJzKKEmcwYgfmdfY6M/CGSNNTr+OJ7DzKngvBcK525H7K CWjQ== X-Gm-Message-State: APjAAAWPvSkjr6rF2TqkJaBFZcqXIcc+L3r8HhXRD6EjCOzTC7ayfUvq Yh2VuOvMRf2ZK/+g9FScGPZb/Mb6 X-Google-Smtp-Source: APXvYqyunx60s7xYwHwsXv+RzmdWsqerfg4cVHpazXff3kOLxlOCkO82Mmc+9EGbretyrTDzA9hiVA== X-Received: by 2002:a2e:818e:: with SMTP id e14mr20712822ljg.245.1574961884955; Thu, 28 Nov 2019 09:24:44 -0800 (PST) Received: from xi.terra (c-14b8e655.07-184-6d6c6d4.bbcust.telenor.se. [85.230.184.20]) by smtp.gmail.com with ESMTPSA id u7sm1860356lfn.31.2019.11.28.09.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 09:24:43 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.92.3) (envelope-from ) id 1iaNWz-0006wk-SD; Thu, 28 Nov 2019 18:24:41 +0100 From: Johan Hovold To: Amitkumar Karwar , Siva Rebbagondla , Kalle Valo Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold Subject: [PATCH 5/5] rsi: add missing endpoint sanity checks Date: Thu, 28 Nov 2019 18:22:04 +0100 Message-Id: <20191128172204.26600-6-johan@kernel.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191128172204.26600-1-johan@kernel.org> References: <20191128172204.26600-1-johan@kernel.org> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org The driver expects at least one bulk-in endpoint when in "wifi-alone" operating mode and two bulk-in endpoints otherwise, and would otherwise fail to to submit the corresponding bulk URB to the default pipe during probe with a somewhat cryptic message: rsi_91x: rsi_rx_urb_submit: Failed in urb submission rsi_91x: rsi_probe: Failed in probe...Exiting RSI-USB WLAN: probe of 2-2.4:1.0 failed with error -8 The current endpoint sanity check looks broken and would only bail out early if there was no bulk-in endpoint but at least one bulk-out endpoint. Tighten this check to always require at least one bulk-in and one bulk-out endpoint, and add the missing sanity check for a Bluetooth bulk-in endpoint when in a BT operating mode. Also make sure to log an informative error message when the expected endpoints are missing. Signed-off-by: Johan Hovold --- drivers/net/wireless/rsi/rsi_91x_usb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_usb.c b/drivers/net/wireless/rsi/rsi_91x_usb.c index ead75574e10a..396b9b81c1cd 100644 --- a/drivers/net/wireless/rsi/rsi_91x_usb.c +++ b/drivers/net/wireless/rsi/rsi_91x_usb.c @@ -149,9 +149,17 @@ static int rsi_find_bulk_in_and_out_endpoints(struct usb_interface *interface, break; } - if (!(dev->bulkin_endpoint_addr[0]) && - dev->bulkout_endpoint_addr[0]) + if (!(dev->bulkin_endpoint_addr[0] && dev->bulkout_endpoint_addr[0])) { + dev_err(&interface->dev, "missing wlan bulk endpoints\n"); return -EINVAL; + } + + if (adapter->priv->coex_mode > 1) { + if (!dev->bulkin_endpoint_addr[1]) { + dev_err(&interface->dev, "missing bt bulk-in endpoint\n"); + return -EINVAL; + } + } return 0; }