Received: by 10.213.65.68 with SMTP id h4csp2201707imn; Thu, 29 Mar 2018 20:52:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx489+AbHj879CTVi5DY/FZkCekdCCtg5udfaqm5fpbVmmkmBDZhY8NxaAzRnlQOKYFKOKfo+ X-Received: by 10.101.100.202 with SMTP id t10mr7373490pgv.229.1522381949724; Thu, 29 Mar 2018 20:52:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522381949; cv=none; d=google.com; s=arc-20160816; b=A+ok4J1hdOnDYX5J0SAOaPh8pLIHKs7o8pV6vY1tpGxHs4o8I+5jzAlQA600oFn7a1 YRyeMOBOuwaSaShiRbR8OcUtGdd1pftMP6uBacFq7HbIkmeNGWAsFc8ev0eDOGnTOZDp kkTB3l12IbxUKdqxgfBL2ofp8AEtuJIZC9+f3e/1L98SSqB/Tnf2aZb2KDiDeQJyy0QL xt/WC3HCu9PkMk6TbBzsbZmRV+/kYhkgGk96gceqEwV+Y9ASRmNuUfwYVhl3tuhIQxJK r5V2z5DBg06e4QUz7f8kdDg5ZydbEXUY1z7CqXnRPireKHpJJNYEF9jDv3Tbtoh7Ntub AVLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type:user-agent :in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter:arc-authentication-results; bh=yYsfUMlsviuVsggEr+WRUlfm0y+tUrUggjry9dfyWtw=; b=ZLWuOPnMjnD6ht4jpziA4mt1WhmVRm+ZUMAi9dNNmbhwG6tCWF7rk9RSvuyj0MZ93P HbRC3or+WNTRPuIclrAssttbwqaKAiybeQ2IShyf1NNVRCexASxkgxivX+tdiRo4AObs EJ00Nb+PVbo3TyxobBn6Wx8H5ED0a0+tjTA0HhbKhiFSy8+fkTwejbrOZb/5tzhS+cx/ anARXyaT7Zgjnwyt3TYewWOm1GwhZU1B40hFtT1J87ne4X+KLTAKCgQGYstyKw4Rg/4l peTMDVaTYEm/UFCuBRC8+m/lQ0M0/0He4EvUON0WFdTFEkP0FNQRzqUsmqby2xQMcwGn ODUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=hsua0D93; 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=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si1417050pgn.191.2018.03.29.20.51.59; Thu, 29 Mar 2018 20:52:29 -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=@samsung.com header.s=mail20170921 header.b=hsua0D93; 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=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752879AbeC3DuL (ORCPT + 99 others); Thu, 29 Mar 2018 23:50:11 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:37761 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752232AbeC3DuJ (ORCPT ); Thu, 29 Mar 2018 23:50:09 -0400 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20180330035007epoutp02ec7f601e99554045a555970dd95e5dbf~gljAUYLHc2758927589epoutp02j; Fri, 30 Mar 2018 03:50:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20180330035007epoutp02ec7f601e99554045a555970dd95e5dbf~gljAUYLHc2758927589epoutp02j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1522381807; bh=yYsfUMlsviuVsggEr+WRUlfm0y+tUrUggjry9dfyWtw=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=hsua0D93F+63rD8wavPBHmAf+R+CLTIRCO9coNWE+3ZSNdYAU4DbNkXShi3oOWjJF ek9wqIq82whP86bm/LyYWozUu9nbpSWShCneNthMpMOVl6zfd9I7KDNU4TAMfCwOp0 ijQ/U68MgrxtQCflBnOqya7WLSusSLc52oUhEPP4= Received: from epsmges1p5.samsung.com (unknown [182.195.40.59]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20180330035006epcas1p246d7e977e0997ead6e227ca555300d06~gli-bZhkd0033300333epcas1p2a; Fri, 30 Mar 2018 03:50:06 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.86.04084.EE3BDBA5; Fri, 30 Mar 2018 12:50:06 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180330035005epcas1p37d4230f41bfde386b0d9cb7d76504469~gli_36RUr1539415394epcas1p3H; Fri, 30 Mar 2018 03:50:05 +0000 (GMT) X-AuditID: b6c32a39-579ff70000000ff4-eb-5abdb3eeeec3 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 42.5D.03849.DE3BDBA5; Fri, 30 Mar 2018 12:50:05 +0900 (KST) Received: from ubuntu ([10.253.107.61]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P6D008CAXBHN370@mmp2.samsung.com>; Fri, 30 Mar 2018 12:50:05 +0900 (KST) Date: Fri, 30 Mar 2018 12:50:03 +0900 From: Ji-Hun Kim To: Jia-Ju Bai Cc: gregkh@linuxfoundation.org, forest@alittletooquiet.net, dartnorris@gmail.com, santhameena13@gmail.com, julia.lawall@lip6.fr, y.k.oh@samsung.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH v3] staging: vt6655: check for memory allocation failures Message-id: <20180330035003.GA27619@ubuntu> MIME-version: 1.0 Content-type: text/plain; charset="us-ascii" Content-disposition: inline In-reply-to: User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpik+LIzCtJLcpLzFFi42LZdljTQPfd5r1RBoevCFmsm7iQyeLM+7NM FnvO/GK3uD/hEatF8+L1bBbLHpxmtNh6S9ri8q45bBYnt8lbbOn6werA5dHc+J7V496+wywe O2fdZffYP3cNu8feLVkefVtWMXp83iQXwB6VapORmpiSWqSQmpecn5KZl26r5B0c7xxvamZg qGtoaWGupJCXmJtqq+TiE6DrlpkDdJySQlliTilQKCCxuFhJ386mKL+0JFUhI7+4xFYp2tDQ SM/QwFzPyMhIz8Q81srIFKgkITVj2d5FrAW7+SpmTPzC0sDYzd3FyMkhIWAi0bXyKFMXIxeH kMAORomWzY/ZQRJCAt8ZJXp+WXYxcoAV/TwpDlGzgVHi7+Q7rBDOS0aJU3uOsoIUsQioSjxa mA3SyyagKbGx+xojiC0ioC5xetkuVhCbWeALo8SSYxwgtrCAv8S/7hcsIDavgLbE/1dT2SFs QYkfk++xQNTrSJw9to4RwpaWePR3BlgNp4CtxNuXh8FqRAVUJKac3MYGco+EwGM2iab1PewQ R7tILP5iBvGksMSr41ugwtISl47aQoSrJRZc2cECYddI3Py/lAnCNpbo7bnADLGWT+Ld1x5W iFZeiY42IYgSD4nb1z6xQ9iOErM+PWWGhMhZRomJ+x8xT2CUnYXkm1lIvpmF5JsFjMyrGMVS C4pz01OLDQtM9YoTc4tL89L1kvNzNzGC05+W5Q7GY+d8DjEKcDAq8fAqsOyNEmJNLCuuzD3E KMHBrCTCWz4V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BSwKuvEpwtP5az0jsapHvFUYinOSDTU Yi4qTgQAeC3DdHsCAAA= X-CMS-MailID: 20180330035005epcas1p37d4230f41bfde386b0d9cb7d76504469 X-Msg-Generator: CA CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180330024416epcas2p2f566f43a8f5af8b4ebc17659e3cf0ecf X-RootMTR: 20180330024416epcas2p2f566f43a8f5af8b4ebc17659e3cf0ecf References: <1522377844-23591-1-git-send-email-ji_hun.kim@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 30, 2018 at 11:15:03AM +0800, Jia-Ju Bai wrote: > > > On 2018/3/30 10:44, Ji-Hun Kim wrote: > >@@ -1165,10 +1205,18 @@ static int vnt_start(struct ieee80211_hw *hw) > > } > > dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n"); > >- device_init_rd0_ring(priv); > >- device_init_rd1_ring(priv); > >- device_init_td0_ring(priv); > >- device_init_td1_ring(priv); > >+ ret = device_init_rd0_ring(priv); > >+ if (ret) > >+ goto error; > >+ ret = device_init_rd1_ring(priv); > >+ if (ret) > >+ goto error; > >+ ret = device_init_td0_ring(priv); > >+ if (ret) > >+ goto error; > >+ ret = device_init_td1_ring(priv); > >+ if (ret) > >+ goto error; > > device_init_registers(priv); > >@@ -1178,6 +1226,8 @@ static int vnt_start(struct ieee80211_hw *hw) > > ieee80211_wake_queues(hw); > > return 0; > >+error: > >+ return ret; > > } > > This code will lead to memory leaks when device_init_rd1_ring() > fails, because the memory allocated by device_init_rd0_ring() is not > freed. > > I think this one will be better: > ret = device_init_rd0_ring(priv); > if (ret) > goto error_init_rd0_ring; > ret = device_init_rd1_ring(priv); > if (ret) > goto error_init_rd1_ring; > ret = device_init_td0_ring(priv); > if (ret) > goto error_init_td0_ring; > ret = device_init_td1_ring(priv); > if (ret) > goto error_init_td1_ring; > ...... > error_init_td1_ring: > device_free_td0_ring(priv); > error_init_td0_ring: > device_free_rd1_ring(priv); > error_init_rd1_ring: > device_free_rd0_ring(priv); > error_init_rd0_ring: > return ret; > > > Best wishes, > Jia-Ju Bai > > Oh, sorry, I got what you said. Yes, you are right. I am going to make patch v4. Thanks! Best regards, Ji-Hun