Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13473666ybl; Sun, 29 Dec 2019 12:45:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzcvFzQ5SMwaf9U4QCBQW/v9AUeSVsjdUKnj8OLYB31TnpGxKKpDHhxCM9YIq/qJmsxJDpX X-Received: by 2002:a05:6830:1e2d:: with SMTP id t13mr72594233otr.128.1577652356982; Sun, 29 Dec 2019 12:45:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652356; cv=none; d=google.com; s=arc-20160816; b=eijjDlWAzRrep8Ch8qXnvUwTS6lyfZEChUlEmgdxSqX0BtIiAFQN1jnEaQTboUxnt1 DV/hGEFT7NHGjt0nrqSenOkhzfwsz96d8HpHpi2Lf5Pw9AgyzMG+DEW7JmL20junOGEs z/BPYpOunv0VzdfPS42UMpB0gLRUNTSBd0vPkq6TIWOrY7w1tLUIRsPO1GFmhakDQ+jk 0dT2dQTdZvAvPeVaIfYm/G3A0hOAtqX2icEsH+CwVJ8HuHw7Q+lA3pXeSMGDodWNBDzL cQ9iG2+TB5Fu28+I9k/QO2gDA5q51TvYuWM0LmNYMnjawDAIG5d+7WbrA8OR7o5uy3MU BjUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=no/a1G+KPSdsxEOijJs0LQqrwWfgC6CQHhweKWL3QWQ=; b=KnEIXk00fQNekce8k56K9KvF+pSlANkQ+UlsVx2dlqgijI3F2EB5m3l5sxb/V9B8P1 AX2UVeb5LIDwKtL3vVoYBWDtFww2fl2krcUIe1ZnGMFuO5G85SFWwNDhk6f4bUF2SmyO zb+MEyE985AnSnuc+uNInHT+j3wItGuAWP+rUpi+QJRChuJ3o9vrLhvMqmgfVhivjhcu /Qrlv4InJHrIFXBTMldefY22gdbT1BVAMoOJElHadhqxKeLogWNRkQiYLay914eCOlxh eeV3sTYm6cyNzbqbV3Jtka/5/RMSc8H4Ct3LwFaEEJdlIcQfvZDfI+winemuocZZkG4Z 8LnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CYMLlAan; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si18352182otk.18.2019.12.29.12.45.45; Sun, 29 Dec 2019 12:45:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CYMLlAan; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730915AbfL2Rpc (ORCPT + 99 others); Sun, 29 Dec 2019 12:45:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:54614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730909AbfL2Rp2 (ORCPT ); Sun, 29 Dec 2019 12:45:28 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 E4105206DB; Sun, 29 Dec 2019 17:45:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641528; bh=klA1dm5kgg50maNAiN19KUUA+b6yPhrYEOj84iFAtAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CYMLlAanXzhTETnBk8ortz1CulWoC0TNyVMfC8bKImWCX1Y2RtUCfoUreu2HXaiMk 6Sg7xBPx4i7gGA1UUYmwR20r2s4VQC1BIiA+sbt3D0CM7gRT0yEzmRwT7rp7uZQYX3 BmfgF1WJPDz0mNIHc6mt7pfJXEWUV/hooX1hHRwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Sasha Levin Subject: [PATCH 5.4 064/434] staging: rtl8192u: fix multiple memory leaks on error path Date: Sun, 29 Dec 2019 18:21:57 +0100 Message-Id: <20191229172706.023536797@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost [ Upstream commit ca312438cf176a16d4b89350cade8789ba8d7133 ] In rtl8192_tx on error handling path allocated urbs and also skb should be released. Signed-off-by: Navid Emamdoost Link: https://lore.kernel.org/r/20190920025137.29407-1-navid.emamdoost@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/rtl8192u/r8192U_core.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 2821411878ce..511136dce3a4 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -1422,7 +1422,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) (struct tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); struct usb_device *udev = priv->udev; int pend; - int status; + int status, rt = -1; struct urb *tx_urb = NULL, *tx_urb_zero = NULL; unsigned int idx_pipe; @@ -1566,8 +1566,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) } if (bSend0Byte) { tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC); - if (!tx_urb_zero) - return -ENOMEM; + if (!tx_urb_zero) { + rt = -ENOMEM; + goto error; + } usb_fill_bulk_urb(tx_urb_zero, udev, usb_sndbulkpipe(udev, idx_pipe), &zero, 0, tx_zero_isr, dev); @@ -1577,7 +1579,7 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); - return -1; + goto error; } } netif_trans_update(dev); @@ -1588,7 +1590,12 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); - return -1; + +error: + dev_kfree_skb_any(skb); + usb_free_urb(tx_urb); + usb_free_urb(tx_urb_zero); + return rt; } static short rtl8192_usb_initendpoints(struct net_device *dev) -- 2.20.1