Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp573128pxx; Wed, 28 Oct 2020 11:25:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweHo0YfBFAcOOFQdgOJ9tFDnh6nMecyw0/cBzrlFzZehJPTZFyDQAfiwjItVAwdJ2rKhn0 X-Received: by 2002:a05:6402:50c:: with SMTP id m12mr156759edv.183.1603909505004; Wed, 28 Oct 2020 11:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603909504; cv=none; d=google.com; s=arc-20160816; b=ooJ5EHry6KZZEK25E+7Y259K+aPrKtZ/2XXbNmSyFx9bWxEc5rvUQkJij4bkONdZQt CGrPrXe3qPxjrC7KHdHLJBHQYBd8q4JVY0W2PnlHWR9Y323nTATAhlBhoS+RVns5WRSU h7HHn43VE1PyIPD3RPeL2U7WGjmft5FvqMirNIOQkDrh0fQnumJr89zl5lnE7CWZYR28 BtADXvkwoAjToorHjgWWI7motkzN8zKz7RHWQFL41RgAcXX2PxQlKkRFCYeasg9aivwZ Yo6g/iW9/DXUfDBNHTgmzY8aP3XXhjnw7Fou5iSXsdZQFuekLpWiAASb5xv5iaWsi3EK wP8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ppvy9W9abOJh+tHWn+AEK1e6NWXl1wVNoxhZs+cry9Y=; b=Z0VkvqC6d468MvetdeETmdoJJdF+NamI3I9RGOoYqaWrwcUq31dlivzJRCjzxS9UYM VB7j1Dk1JJ485I7TDkVUzU/1DXFT9Iq7vcB81sRUGwIL7rKXfgsprEkhjjqgsGS0uJ7z LIxthe9xRPEXte0NJpZHfgt5lc+1Y4V3BdMLFVqzqBoJZQtGhD6ArHyzNbkbKK43XlAf UhYROUjLnXGo4FbBCQq0S/nGmC7DSkpGvppAdmsXtxopNJlDp6jbb2wXMVNOLQaGonJC X62IBH9+COXycMp57sLhL1X0cIGLOcAuMtwgvPvSahJ5TfIZp7RH5/yaLQCLJxjQ4gGI l/Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RM5wYUjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 8si179023edx.375.2020.10.28.11.24.42; Wed, 28 Oct 2020 11:25:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RM5wYUjW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1824928AbgJ0SGt (ORCPT + 99 others); Tue, 27 Oct 2020 14:06:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:39168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390715AbgJ0OQq (ORCPT ); Tue, 27 Oct 2020 10:16:46 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 B166622263; Tue, 27 Oct 2020 14:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808206; bh=M5h23QEKSYzAsQW1pluqDkFL6Ex4/VF/E/xG4/7dcJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RM5wYUjW0ldIFgDFsVZEX/I4MQrs7ux6wn8JBuJDUFUAbY2Fpy1J8XwkYE3b65hlH nf2xDqJgpbFEtyRkUR43LeSm5edzbMD2GUQMZ59a20iMb7y/PSVfnlHGzocWBatZvB ckmDg7Vk0dmyzj82xbdnbqrMJKN+eBaEtDAUV+VA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Chiu , Kalle Valo , Sasha Levin Subject: [PATCH 4.14 174/191] rtl8xxxu: prevent potential memory leak Date: Tue, 27 Oct 2020 14:50:29 +0100 Message-Id: <20201027134918.095753042@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Chiu [ Upstream commit 86279456a4d47782398d3cb8193f78f672e36cac ] Free the skb if usb_submit_urb fails on rx_urb. And free the urb no matter usb_submit_urb succeeds or not in rtl8xxxu_submit_int_urb. Signed-off-by: Chris Chiu Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20200906040424.22022-1-chiu@endlessm.com Signed-off-by: Sasha Levin --- drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index 63f37fa72e4ba..5cf61710ae2f1 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -5453,7 +5453,6 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) ret = usb_submit_urb(urb, GFP_KERNEL); if (ret) { usb_unanchor_urb(urb); - usb_free_urb(urb); goto error; } @@ -5462,6 +5461,7 @@ static int rtl8xxxu_submit_int_urb(struct ieee80211_hw *hw) rtl8xxxu_write32(priv, REG_USB_HIMR, val32); error: + usb_free_urb(urb); return ret; } @@ -5787,6 +5787,7 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) struct rtl8xxxu_priv *priv = hw->priv; struct rtl8xxxu_rx_urb *rx_urb; struct rtl8xxxu_tx_urb *tx_urb; + struct sk_buff *skb; unsigned long flags; int ret, i; @@ -5837,6 +5838,13 @@ static int rtl8xxxu_start(struct ieee80211_hw *hw) rx_urb->hw = hw; ret = rtl8xxxu_submit_rx_urb(priv, rx_urb); + if (ret) { + if (ret != -ENOMEM) { + skb = (struct sk_buff *)rx_urb->urb.context; + dev_kfree_skb(skb); + } + rtl8xxxu_queue_rx_urb(priv, rx_urb); + } } exit: /* -- 2.25.1