Received: by 10.213.65.68 with SMTP id h4csp1037883imn; Wed, 28 Mar 2018 18:57:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+vP3G5pMyLuFlHeAeaITmDUHadEBfZc2m2lcx1WdOVR/ZbjbfkIV/qlGddoumhNzF0JtWp X-Received: by 2002:a17:902:6884:: with SMTP id i4-v6mr6279908plk.259.1522288668797; Wed, 28 Mar 2018 18:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522288668; cv=none; d=google.com; s=arc-20160816; b=0PCqqVA1Lq6d3sKegc2tuw5P3hQii7AaJg6S8h/eXegVUCtsaWDppM5jDC/g6nL6BY gvvGjrbWkMl12hnF4l3fbuVhVxtPmXwxfgdL1VPQ2sg9px+koCmSfMcKybQJ37ff2uGC EMRwKi1UeJM5xLt0/osCmf9+nwru2ZZIXjcyip1Klaf9LCmz+Nsy/Ru6hKd4vNh6KSi7 cEiTCSaqDAJDvQdv18cVJrdBGa+5SOswt1VmSdO9nrm1QbS6w/0zgnV62RkreKz8/Ul8 4ePIpxfMB2WwnBqfbqcMQbobI++uL9KcklCFyK/w7xa6/rFUPBJsfigRh9TOFvMmYRcF Hbjg== 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=4nGBngXofpmNANUonp5LYHXH8rseo8nCV/y2D2nQjT8=; b=YOrTafcu1GkSG+87PE0dkgMKNTTCcmCuOWZxA5eq6H3GJHvTaL2g9OzwBmKMBhNQAh eq+i4njOQYbk2e1MAAWBQTwSMWAPXUoBXUQJSvxL7WBfrlfkCrxC7QmLAP+AN74PKMJf 6wh7eUxIUnRiJA8+U7HyFIWf3CY8clz6pb/ZMYoqYDQRFd7DCGRBjZI1dE7+UAGk5VYX HFp/3XbTHhI5/rVY53Lxk0a28u+jfDAcfcWP86cMbTtpKw14k60HSudhzsyOhkOETqwA gM2R9gciHyVah5QTOVweOwuZY1DYxIbSCTLs4B1JRgO6mLy9j80cOi1/sSexXL1TqRdm R/+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=MwEUkwR/; 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 x11si3293281pgr.147.2018.03.28.18.57.34; Wed, 28 Mar 2018 18:57:48 -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=MwEUkwR/; 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 S1752051AbeC2B4n (ORCPT + 99 others); Wed, 28 Mar 2018 21:56:43 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:63014 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeC2B4l (ORCPT ); Wed, 28 Mar 2018 21:56:41 -0400 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180329015639epoutp03c04f4938d40f5136b4ed7dab4d4423ce~gQWp1ORKq1015210152epoutp03n; Thu, 29 Mar 2018 01:56:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180329015639epoutp03c04f4938d40f5136b4ed7dab4d4423ce~gQWp1ORKq1015210152epoutp03n DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1522288599; bh=4nGBngXofpmNANUonp5LYHXH8rseo8nCV/y2D2nQjT8=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=MwEUkwR/41zKNgWfnXXq/5nXwTakuqnmGR6kHmjDhVxvxrPhTFgoCxd0sBgP7RsM9 94bkAkZ+Kk9tz01XXj21AKCifObOWo6uYqKr0g/EZbhQaV2FKzy0kjiKs8ZvX/MfHI pDXMxXWEcAxOYE9u3Y6S6Cc2SvDNGrLjxLCK/bB8= Received: from epsmges2p4.samsung.com (unknown [182.195.40.93]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180329015639epcas1p3bc7485d167254968247ecdb71ad7df37~gQWpaa1UA0694206942epcas1p3n; Thu, 29 Mar 2018 01:56:39 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p4.samsung.com (Symantec Messaging Gateway) with SMTP id 39.0B.04082.6D74CBA5; Thu, 29 Mar 2018 10:56:39 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180329015638epcas2p1b3684edb9c77a0e962cd1da0fc52c305~gQWpMQv122796827968epcas2p1f; Thu, 29 Mar 2018 01:56:38 +0000 (GMT) X-AuditID: b6c32a48-8d9ff70000000ff2-2c-5abc47d67303 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id B1.F8.03827.6D74CBA5; Thu, 29 Mar 2018 10:56:38 +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 <0P6B001D3XEEWH50@mmp2.samsung.com>; Thu, 29 Mar 2018 10:56:38 +0900 (KST) Date: Thu, 29 Mar 2018 10:56:37 +0900 From: Ji-Hun Kim To: baijiaju1990@gmail.com, gregkh@linuxfoundation.org, forest@alittletooquiet.net Cc: 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] staging: vt6655: check for memory allocation failures Message-id: <20180329015637.GA9416@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+NgFmpnk+LIzCtJLcpLzFFi42LZdljTTPe6+54og+3/GC3WTVzIZHHm/Vkm iz1nfrFb3J/wiNWiefF6NotlD04zWmy9JW1xedccNouT2+QttnT9YHXg8mhufM/qcW/fYRaP nbPusnvsn7uG3WPvliyPvi2rGD0+b5ILYI9KtclITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw 1DW0tDBXUshLzE21VXLxCdB1y8wBOk5JoSwxpxQoFJBYXKykb2dTlF9akqqQkV9cYqsUbWho pGdoYK5nZGSkZ2Iea2VkClSSkJqxdeNU1oJ9HBUnbt9kamB8wNbFyMkhIWAicWnVaSCbi0NI YAejxNF5HewQzndGie87mthhqjZs72eESGxglPh07SxU1UtGif9bHzGCVLEIqEpcvDINbC6b gKbExu5rYHERgRCJi9NngO1gFtjFKLH690lmkISwgJfE+tNtYCt4BbQk3p6bzwRhC0r8mHyP BcRmFtCROHtsHSOELS3x6O8MsHpOAVuJ9S3TWEFsUQEViSknt0E9dJ9N4s82fwjbReLTiffM ELawxKvjW6DekZZ4tmojI4RdLbHgyg4WCLtG4ub/pUwQtrFEb88FZoi9fBIdh/8C9XIAxXkl OtqEIEo8JO537Ica6Six5NM/aKCcYZSYdnQm2wRG2VlI3pmF5J1ZSN5ZwMi8ilEstaA4Nz21 2KjARK84Mbe4NC9dLzk/dxMjOBFqeexgPHDO5xCjAAejEg+vxaLdUUKsi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7UE286r+rebE35POdekd7jH8aMqsKVEkn/d5vv9CrUVmIpzkg01GIu Kk4EAAcZsKh/AgAA X-CMS-MailID: 20180329015638epcas2p1b3684edb9c77a0e962cd1da0fc52c305 X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180328063144epcas1p305216b582520b884b09c93a7ad591660 X-RootMTR: 20180328063144epcas1p305216b582520b884b09c93a7ad591660 References: <1522218691-7917-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 Wed, Mar 28, 2018 at 05:55:57PM +0800, Jia-Ju Bai wrote: > >@@ -646,7 +649,8 @@ static void device_init_td1_ring(struct vnt_private *priv) > > i++, curr += sizeof(struct vnt_tx_desc)) { > > desc = &priv->apTD1Rings[i]; > > desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL); > >- > >+ if (WARN_ON(!desc->td_info)) > >+ return; > > desc->td_info->buf = priv->tx1_bufs + i * PKT_BUF_SZ; > > desc->td_info->buf_dma = priv->tx_bufs_dma1 + i * PKT_BUF_SZ; > > I think the bugs you found are right. > But your patch is not correct, because it is dangerous to return directly. > I think you should return an error and then implement error handling > code for these functions. > Yes, it needs to free previous allocated values in the for loop. Directly return could make memory leaks. I am going to make patch v2. - Delete WARN_ON which could make crashes on some machines. - Add freeing sequences for previously allocated memory when kzalloc() failed instead of returning directly. Does these changes would be fine on this bug?