Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1121672pxx; Tue, 27 Oct 2020 08:44:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzshwznEaGYJZHRTZt1YAe2eJKp4o1fqwA3J3bnCV+ddP7zUL/pd9udnN128FOh7P9fHH3l X-Received: by 2002:a05:6402:2070:: with SMTP id bd16mr2847800edb.358.1603813485968; Tue, 27 Oct 2020 08:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603813485; cv=none; d=google.com; s=arc-20160816; b=rn5xLI8OtmDvFopZ2JZG6lRb8vvO0vu5lSdpCaurim8t2NWuKf4uSUVis4FLzAI0ik kZxrMFtBMIMG7UIp8sr7LWLa/vGkdB9cbTGfA7V5ISeA+/xGmuET2nsxn9E8qN/hMkyv 9ZaJXuAp3tpUQWr3cqDG4Kxx06Eb6KqC792fiuXc3ei19zhX4THHz/HcGmWxs+hCB8+B i6Fjgph15wybbdvau6R1104DUqEQG01vvLUTEQDEeOR6JzL524M0CV7bI54lzSFmLyIc VCazmlBGTwc+eo16MgvDZ8VjDPIPftrSe8DWUQhA7Tt1ssN5qwHSY//UGNzh33Us1hO6 uJ4A== 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=RZRC8A7J21JdiyLSgvUEij+f9rUV8g9o7hN2Ga0rsaI=; b=0UiTRH36XFJC90WWOuyM1h4/Eoa1Eyp0BFuKc5eb+K7A1MUswudLwe5kJ4BTzoIbpa E96MN9oT+jsXjsDfjRjgfhTO5MOUs0cLVSdxfAPmueVtwT0fN9tU3SP9tN96IQu1HsWw uNE/2QIp8X7FBg0+rF6+wxaBbpJu+nFYtmWbYlaJT83u7nMBrZSfUolHe8huozyjP8HR DYEExZPjmwbr31/BTxYeKNeot3Z8n0LxGWXtPLP80MwcvVGqv201aFzF/9RKCyWpbgfP q6HBeoJVepfz27+MtmFeWKwExHLijaAavizxpM2nsw12OoeTCULU3ajVD2q50OFug1tK M38A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="mbmQwkt/"; 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 g19si1233256ejx.626.2020.10.27.08.44.23; Tue, 27 Oct 2020 08:44:45 -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="mbmQwkt/"; 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 S1766259AbgJ0Orx (ORCPT + 99 others); Tue, 27 Oct 2020 10:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:47596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1765137AbgJ0Orn (ORCPT ); Tue, 27 Oct 2020 10:47:43 -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 24835207DE; Tue, 27 Oct 2020 14:47:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810062; bh=XPxyetFb5/QDwKw/yv4CYnOI7oGby/kL3IvGqoCEE3A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mbmQwkt/Z6VohrueHxAG7ASNaKxpnOJfKjM1uo7bR302Hq6c9hcYTbZeXOfJw+CLy A+gwIguEpvDymDJeJ19vAkLwZ8uaIJJj5WvdID+ffk7T6imBUbc60rKSwZ7lczYuwK RE1hbRldr01CiNTiQc4oKXTh5GPbXM9xEA75lk+k= 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 5.4 379/408] rtl8xxxu: prevent potential memory leak Date: Tue, 27 Oct 2020 14:55:17 +0100 Message-Id: <20201027135512.587545282@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135455.027547757@linuxfoundation.org> References: <20201027135455.027547757@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 3499b211dad51..048984ca81fdb 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -5447,7 +5447,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; } @@ -5456,6 +5455,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; } @@ -5781,6 +5781,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; @@ -5831,6 +5832,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