Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1709088imm; Sat, 16 Jun 2018 01:12:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKISy6Du5NqYqYnHbCaStfpW00KA66zm+cmNuto9pmSSjIsXyJcz+bsSCxZf2CHSYD6vT/f9 X-Received: by 2002:a65:6310:: with SMTP id g16-v6mr4512385pgv.271.1529136753714; Sat, 16 Jun 2018 01:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529136753; cv=none; d=google.com; s=arc-20160816; b=KBckUDXwUNrNbsKvgaMzrNTRaxPBYWX+A5uEzV2vGaB6Gvbvf4jz4RBnSXakBMICD6 DTvY4SBmJV9Ut5oj3cJBigjCqAVTi80NdllpMFOAnbU65+sjq6bnEzkMy0A9cub6W/01 DvLyg6wjX+iGLgarmUX0voh0TH+HpjQncMP7XUkAcQgx4PRXvGDlEgTqKTx6ghW6wmz/ RjhTB+VAoviD56u9ZjEJnWqBMCjmThxQuDBZJyuystjqcWx/dqUmFNEKIhv6NKOFtNIP jXuZfCt6UR5FWX4f4uxs9560f0/oeG3jTt2NjBMAlMYF+ECihFlegPEqZc2VpsvuoiWE wOng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=4Wjp8uT6jXqVz6RBSU2u9+urxE+HlI5VNcS7HcwsyVw=; b=HysIjL1mNVNnFosp3yssOY9b9ou4e2iJ9Yi44ilkbCeN+1nu+2VH6pX95La0LXmHV2 SHYnlcgp4QqJEP1nieYC+cjcUeEO+HILB5RRjJDEb9u42PVIycC5qg7q18HTfnhRtFuy D8fTcYy/Hon3r7PeujW3Zu0bnV7Ld63bfXQ/fIWv1DyftE9mLSUpHVhpxkQS2Nzhclwp uzdOlLFZgcDRfqnttM4KLJAPd12aXBbnvYDkfepLVJGxh8qcdQF7FkLe+8efU1PJaci9 PJueOqKJSl29HoDojRJUjueLlriNSHCABv9H4NMpwu4N8csrxEsdo0Ecl4OiKQ5oDjXL lRZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=AP1ktJp0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v5-v6si8080872pgq.32.2018.06.16.01.12.18; Sat, 16 Jun 2018 01:12:33 -0700 (PDT) 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=@oracle.com header.s=corp-2017-10-26 header.b=AP1ktJp0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932496AbeFPILw (ORCPT + 99 others); Sat, 16 Jun 2018 04:11:52 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:37184 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932188AbeFPILu (ORCPT ); Sat, 16 Jun 2018 04:11:50 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w5G89FcC131964; Sat, 16 Jun 2018 08:11:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2017-10-26; bh=4Wjp8uT6jXqVz6RBSU2u9+urxE+HlI5VNcS7HcwsyVw=; b=AP1ktJp0wLqWB5MeGsorbkelpgl2w2nVApLX38N6BuP7MKqG9pISLoLsYtcmM+VODwQu 69edNSyOuHzWT8OMTt6yrSQWERA+XlXbK6Pkbcw0XyHTaVKwWrdvKiAsKksgaCW7IzIA CXLan3j7Ivz84ZXEdW1xPR5Nag6wUo7tpMgmKYkV7NpJhhzL8ZUOl6e30jYf92lXQ5wE kmWN94DeJ7Qqgb4N6+zoj0t24UD3khW8snZlnEaXbNBmUQPInzAG1MN3U8T2Xrg2ZTll CFpjH6LgIxZXI+pv1PsDLmJzToFyPTpvSyjMs08CxgvV9hFLBuOT3QIN0yoWHgfflH0Y iQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2jmu6xg652-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Jun 2018 08:11:43 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w5G8Bgnn030349 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 16 Jun 2018 08:11:42 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w5G8BePs015013; Sat, 16 Jun 2018 08:11:41 GMT Received: from mwanda (/41.202.241.23) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 16 Jun 2018 01:11:40 -0700 Date: Sat, 16 Jun 2018 11:11:27 +0300 From: Dan Carpenter To: Zhouyang Jia Cc: devel@driverdev.osuosl.org, Kees Cook , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Jia-Ju Bai , Christophe JAILLET , Shreeya Patel , Colin Ian King Subject: Re: [PATCH v4] staging: rtl8192u: add error handling for usb_alloc_urb Message-ID: <20180616081127.oqendremoierdndg@mwanda> References: <1528705874-34845-1-git-send-email-jiazhouyang09@gmail.com> <1529114485-60684-1-git-send-email-jiazhouyang09@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1529114485-60684-1-git-send-email-jiazhouyang09@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8925 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=878 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806160102 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I was actually OK with v1 on the theory that everything else leaked and so this didn't really introduce anything new... :P On Sat, Jun 16, 2018 at 10:01:22AM +0800, Zhouyang Jia wrote: > --- a/drivers/staging/rtl8192u/r8192U_core.c > +++ b/drivers/staging/rtl8192u/r8192U_core.c > @@ -1639,8 +1639,9 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) > static short rtl8192_usb_initendpoints(struct net_device *dev) > { > struct r8192_priv *priv = ieee80211_priv(dev); > + int i; > > - priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1), > + priv->rx_urb = kcalloc(MAX_RX_URB + 1, sizeof(struct urb *), > GFP_KERNEL); > if (!priv->rx_urb) > return -ENOMEM; > @@ -1649,12 +1650,12 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) > for (i = 0; i < (MAX_RX_URB + 1); i++) { > priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); > if (!priv->rx_urb[i]) > - return -ENOMEM; > + goto out_release_mem; > > priv->rx_urb[i]->transfer_buffer = > kmalloc(RX_URB_SIZE, GFP_KERNEL); You need to free priv->rx_urb[i]->transfer_buffer as well and there are several other resources which are also not freed. regards, dan carpenter