Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp166449pxx; Wed, 28 Oct 2020 01:20:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvQaUYUuggvIBglwtuRgqG4JxWfcXjMwK74JRXYmSnNRxYHXyI9NX1Zbi6sT9eF89KC/lf X-Received: by 2002:a17:906:1e04:: with SMTP id g4mr6351483ejj.72.1603873240075; Wed, 28 Oct 2020 01:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873240; cv=none; d=google.com; s=arc-20160816; b=BITihS1bK7V/1qt174KQdlU8RaIG26DltYME7pfUQHHbLjMbywEom7lCL3DMRl2EJw niWcfN2o+3RFTGRvyPdSY9k+GaYWKZSFg4OvMma7ycK+PkOZxHDjKsYRPWGPVXJPFHGw VYwJ5ZPNgj8043gyGn9xmOlTErtY5IynFCHDbTIQ51IFaNt7aQ5xfzlE99QYQ6VtuAy4 DyKREPPAZEoTIEkgxIkdf/LcxacETbvEiFtbsAUMuyJnMKc1oSZ6SbFFMIECDNnC8Qm1 EXMr/kziv6GzbRbJpXPfx5jufIN4SJPWj55tr2anjMyv8xVpQRf88RbiACc9lb+VDXOt nxqA== 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=ABl6D2DZronlMeThVi0WUkVI7APuArrawPgDyA93z+Y=; b=ZFPAvAr/aVdbu/KEwL9iX62w8y+/vh4YAWFLMTefmSsffniYRmAFvmiCmoyJM0S/Ua oXqAFWH1RZhSOGvpCL9hppGAnfMlLcIkahB3TefddJKP072ZmXmrqGQpgCKKhiTCMBxN Fwsx2tgK642kluRpyH5f7rU1Ztb/JQEqZkGUiTOQ1whB/xf+j802+sGZ4clpFarbHJe/ duucouEL9u70bOJa3jf/gA7PlkH7/hGct+aE+cmYzB3DZ03hyUn6NtgIQ1/fo1Kd7rd+ ULCvwghLsDHpFKBhIthRpmpxlpawQFwgcB4qCkUgbMBJhXPFZnTo3yBsde34m1QTW6tK SbJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TdsbhaSd; 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 p17si2879649ejg.48.2020.10.28.01.20.17; Wed, 28 Oct 2020 01:20:40 -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=TdsbhaSd; 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 S2409722AbgJ0OBx (ORCPT + 99 others); Tue, 27 Oct 2020 10:01:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753604AbgJ0OBC (ORCPT ); Tue, 27 Oct 2020 10:01:02 -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 D69E42068D; Tue, 27 Oct 2020 14:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807261; bh=I9abcd9KWuhpipgU+LGs2WDKTi0MFSc+wWieyXzN8Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TdsbhaSdr6BqM0BNCdcReBtMcNGqlCt6aOzr4Yy8r4FK6UlULQMVAUUPYPDGwBNRx 8Md5++ni8B+fo6t+HtsLPk6hLh15HDmLE4htACjae/hZdL1ePtwergFnLp92fVgGwR ap4LzAilSPwy+49+Kz8vw1q42KpL9eVFxZBweje4= 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.4 102/112] rtl8xxxu: prevent potential memory leak Date: Tue, 27 Oct 2020 14:50:12 +0100 Message-Id: <20201027134905.372293699@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@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.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c index 8254d4b22c50b..b8d387edde65c 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu.c @@ -5135,7 +5135,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; } @@ -5144,6 +5143,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; } @@ -5424,6 +5424,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; @@ -5472,6 +5473,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