Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1003128imm; Fri, 15 Jun 2018 09:35:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLRMroOBYUa/TXl4Fx6UL+Us7fXwkOGTjCLFqdOrP1YO/IdQk6uJzK9YogzyJN29B15b5kK X-Received: by 2002:a62:d913:: with SMTP id s19-v6mr2743183pfg.39.1529080524948; Fri, 15 Jun 2018 09:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529080524; cv=none; d=google.com; s=arc-20160816; b=F/mH/wiQ0moVmVkZEELLXoxiSFnPDQ2WbbTTRsN6tMscI5ltfED0cVrLiyfozvIxZF p+9H3HCVfEwWgmIs0bWtvfsTPmYQekF8sFS6BylOm6EV8zfF3Vxslb7fyF6nK4fEpzgq g2IW+rPJYAzlJH0Fh6mCt5lMkARuPz9L3nbDBiZqfn+rM+90xmUxicU+xrEzoosw/rBH x4lRxjiDVqUWvjLw2tInnkDFKm0PNfxsOfxJ8LyRE3BQeLf1f/3GqzNQZQl7AJxYavje vscwrq2D9uSnWNegN52BX1zkHVAfSfrUQFPoHzDLAQfDeqBpiLdOGgYB3+Hq2q22bTts d48w== 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=PqQuXxpUfhGpQvdA+ttAsEaHtx7c2QtD3g7GKobMNDw=; b=FcWJclvb3fT0Q1x3wjTkmChAE9JpJPLXq7WGbQkD1SJI+8lkazXMlFkm+jGsxbTjGK WsB3yJsxzsTBkvIUrfEDg+MoF7K4iE+hbGPVm1iK2mhMWML5BvdSD9d0uhhw+Np3K4ov 59l53d27qui8lF0PNQ/PHAL2Ryfb9RbXqQkN/oMPt5co3JiRTboMvq4HTMDzmipkebc8 C8yHYfqToxPNKZLcQHBrEYrxH7PVFnwcv5/J/S6qVavXIkEby6Zmn6NWgSjhxBPOnpWh 74+sXvoBc5HKfTZ8SgaJF0D+DiVl4vqE9bNCGLb76z3BR6La8lqIMFvKMqaGW+rfx8re 7aJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h+E1oAQy; 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 s187-v6si6698037pgc.447.2018.06.15.09.35.10; Fri, 15 Jun 2018 09:35:24 -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=@kernel.org header.s=default header.b=h+E1oAQy; 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 S966246AbeFOQdt (ORCPT + 99 others); Fri, 15 Jun 2018 12:33:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:36814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966002AbeFOQdp (ORCPT ); Fri, 15 Jun 2018 12:33:45 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 63E95208DD; Fri, 15 Jun 2018 16:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529080424; bh=N6xGEAGYdbla8PO3b/ClP4PjWf1gpuvNP/GuC+1J9k4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=h+E1oAQypF6r8GD4Jfmk/Eb4cF5immFBzuJ/NXOWg404X9rjewV5hlThEJigdk9q4 3UYU+4q1o6SHbV5Nciuv9m7xTkwyTt0B++CA7MbiGbf9BePhVh8ArGs5qNsodzWIuW bnoB95fnuQPizY2ME7t3zYKOalkQDu9oK7I9CMCw= Date: Fri, 15 Jun 2018 18:33:22 +0200 From: Greg Kroah-Hartman To: Zhouyang Jia Cc: devel@driverdev.osuosl.org, Kees Cook , linux-kernel@vger.kernel.org, Jia-Ju Bai , Christophe JAILLET , Shreeya Patel , Colin Ian King Subject: Re: [PATCH v2] staging: rtl8192u: add error handling for usb_alloc_urb Message-ID: <20180615163322.GB11493@kroah.com> References: <1528705874-34845-1-git-send-email-jiazhouyang09@gmail.com> <1529079930-58587-1-git-send-email-jiazhouyang09@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1529079930-58587-1-git-send-email-jiazhouyang09@gmail.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 16, 2018 at 12:25:23AM +0800, Zhouyang Jia wrote: > When usb_alloc_urb fails, the lack of error-handling code may > cause unexpected results. > > This patch adds error-handling code after calling usb_alloc_urb. > > Signed-off-by: Zhouyang Jia > --- > v1->v2: > - Fix memory leak. > --- > drivers/staging/rtl8192u/r8192U_core.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c > index 7a0dbc0..6afab4e 100644 > --- a/drivers/staging/rtl8192u/r8192U_core.c > +++ b/drivers/staging/rtl8192u/r8192U_core.c > @@ -1648,13 +1648,17 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) > #ifndef JACKSON_NEW_RX > for (i = 0; i < (MAX_RX_URB + 1); i++) { > priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); > - if (!priv->rx_urb[i]) > + if (!priv->rx_urb[i]) { > + kfree(priv->rx_urb); > return -ENOMEM; > + } {sigh} No, you are still leaking memory on all of these changes that you just made :( greg k-h