Received: by 10.213.65.68 with SMTP id h4csp123937imn; Tue, 27 Mar 2018 23:42:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/RXRhI1nGInjraRqvjTUIIwvQ1m8gUm6oWaoUPvQL4QPsFEFz2euhNTdHaBGdpI0fOegPf X-Received: by 10.167.129.136 with SMTP id g8mr1953308pfi.19.1522219353797; Tue, 27 Mar 2018 23:42:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522219353; cv=none; d=google.com; s=arc-20160816; b=o2/tH+eR4k06WJ25BCCg+ohLSzWC49Fg/0fP+r7MxhgYdx/nWAtYO7wZz/Ct+3Kxpp 6BR+uUgjsGUdJAbfq0+uJxrx32o96jUxzq+ztriEEAYmjCtuxbkNMcX16yhp/JxFh1Dc 9NBXRsmIWPqE6VNBgjWMHr35IAex4oHx3ANPBnYVfRToIjBgEmDJAFW0VdF6tNN/VnhZ zxqL/732m0xU/yGT3GjmRA4uZzqEImreVPVys3pZhOPozeKm3Km1rXwO9agyl6f42jyw m3YtoeeX+Y0Fw+0ql9sB3nUYmcmohXoJ0PNXLTHP7MV9tbHMnPfBxmzOssumpmOkL8C/ blzQ== 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:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=ODS9z6aP0BFX92Yer/ySNg6BszvNQRXOi6GiYGpYdPE=; b=AdihnW/aAtonZxNsgvKRH7h1acl7cnrwGX7xxWHZDK8AjlGzAxlCpySYtFrP1RBPcZ tfGYSIzrJ/uyNYkoudJfFZrapfe/waZRAZlEnup5NHmxTp1p9XAKk0EY+XFCxeR66MAF j6ykElQmbZjNNrbGkQiwr/JRXTJMHG413Ciauo3iHyJnXjjTYfU0qWVkFQjlsiDKT6mM U1dlJUnhhkTFKGH6pLRHwIjuZhpFe3J8RmVeY/SeImTcfvbCq0/H16EEgxPBek3ADTLk YGVqs3nxVqPt0UfmCy11p+B+YJUCdtikMKV6zZ9eW2lsNOZskaXUlSlhZwpde54B/4zK 9P1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=WXjhgLZO; 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 g1-v6si2838914plt.54.2018.03.27.23.42.19; Tue, 27 Mar 2018 23:42: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=@samsung.com header.s=mail20170921 header.b=WXjhgLZO; 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 S1751994AbeC1GlY (ORCPT + 99 others); Wed, 28 Mar 2018 02:41:24 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:39728 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750703AbeC1GlW (ORCPT ); Wed, 28 Mar 2018 02:41:22 -0400 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180328064120epoutp04c2889609a9fd1d5340e6f0b5181a35ec~gAl7uVneX1771517715epoutp04i; Wed, 28 Mar 2018 06:41:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180328064120epoutp04c2889609a9fd1d5340e6f0b5181a35ec~gAl7uVneX1771517715epoutp04i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1522219280; bh=ODS9z6aP0BFX92Yer/ySNg6BszvNQRXOi6GiYGpYdPE=; h=From:To:Cc:Subject:Date:References:From; b=WXjhgLZOq15VUUfS0Is514aESUwS52kDVzmF6GSSoTjlxDlA4BpsWr+0GsXoEOFsP gyNk1mbFhT50bVjMS4GCqsl2emxnkgw79NxSWjWKQYmGSx6TgP/zV3gY6lc/CxmHCo xzHTO7CJMyjua6MVLJScv341ZTQtj9MG3jda1yW4= Received: from epsmges1p4.samsung.com (unknown [182.195.40.91]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20180328064120epcas1p15ae8a6f2dcba8c0b3de73784f3811208~gAl7cRKWH1708417084epcas1p1b; Wed, 28 Mar 2018 06:41:20 +0000 (GMT) Received: from epcas1p3.samsung.com ( [182.195.41.47]) by epsmges1p4.samsung.com (Symantec Messaging Gateway) with SMTP id 8E.4D.04226.1D63BBA5; Wed, 28 Mar 2018 15:31:45 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180328063144epcas1p305216b582520b884b09c93a7ad591660~gAdjdLbMk2638126381epcas1p3Q; Wed, 28 Mar 2018 06:31:44 +0000 (GMT) X-AuditID: b6c32a38-d73ff70000001082-89-5abb36d18c6e Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 6F.63.03849.0D63BBA5; Wed, 28 Mar 2018 15:31:44 +0900 (KST) Received: from localhost.localdomain ([10.253.107.61]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P6A00EQAFGLFFA0@mmp1.samsung.com>; Wed, 28 Mar 2018 15:31:44 +0900 (KST) From: Ji-Hun Kim To: gregkh@linuxfoundation.org, forest@alittletooquiet.net Cc: dartnorris@gmail.com, baijiaju1990@gmail.com, santhameena13@gmail.com, julia.lawall@lip6.fr, ji_hun.kim@samsung.com, y.k.oh@samsung.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] staging: vt6655: check for memory allocation failures Date: Wed, 28 Mar 2018 15:31:31 +0900 Message-id: <1522218691-7917-1-git-send-email-ji_hun.kim@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCKsWRmVeSWpSXmKPExsWy7bCmvu5Fs91RBndeiVusm7iQyeLM+7NM FnvO/GK3uD/hEatF8+L1bBb9p7czWix7cJrRYustaYvLu+awWZzcJm+xpesHqwO3R3Pje1aP e/sOs3jsnHWX3WP/3DXsHnu3ZHn0bVnF6PF5k1wAe1SqTUZqYkpqkUJqXnJ+SmZeuq2Sd3C8 c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QhUoKZYk5pUChgMTiYiV9O5ui/NKSVIWM/OIS W6VoQ0MjPUMDcz0jIyM9E/NYKyNToJKE1IzN316zFLwUqLj16A5LA+N73i5GTg4JAROJ/ot/ mbsYuTiEBHYwSkyZ/BPK+c4ocfXpBnaYqkPPt0IldjNKnPv+Acr5wShxauMNRpAqNgFNiY3d 14BsDg4RASuJSft0QcLMAm8YJX6u0gOxhQXcJB4tPQA2lEVAVWLTkb1gNq+Aq8Tr4zuZIJbJ SZw8NpkVZL6EwBw2iTcX5rKBzJQQcJGYfaAWokZY4tXxLewQYWmJS0dtIcLVEguu7GCBsGsk bv5fCjXSWKK35wIzxDl8Eu++9rBCtPJKdLQJQZR4SNzv2A/1rqPEkk//wGwhgViJrrU3mSYw Si5gZFjFKJZaUJybnlpsWGCiV5yYW1yal66XnJ+7iRGcYrQsdjDuOedziFGAg1GJh7cgZleU EGtiWXFl7iFGCQ5mJRHe9xq7o4R4UxIrq1KL8uOLSnNSiw8xmgIDYyKzlGhyPjD95ZXEG5pY GpiYGZmaGhpYmCiJ8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CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180328063144epcas1p305216b582520b884b09c93a7ad591660 X-RootMTR: 20180328063144epcas1p305216b582520b884b09c93a7ad591660 References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There are no null pointer checking on rd_info and td_info values which are allocated by kzalloc. It has potential null pointer dereferencing issues. Add return when allocation is failed. Signed-off-by: Ji-Hun Kim --- drivers/staging/vt6655/device_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index fbc4bc6..5d0ba94 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -539,7 +539,8 @@ static void device_init_rd0_ring(struct vnt_private *priv) i ++, curr += sizeof(struct vnt_rx_desc)) { desc = &priv->aRD0Ring[i]; desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL); - + if (WARN_ON(!desc->rd_info)) + return; if (!device_alloc_rx_buf(priv, desc)) dev_err(&priv->pcid->dev, "can not alloc rx bufs\n"); @@ -563,7 +564,8 @@ static void device_init_rd1_ring(struct vnt_private *priv) i ++, curr += sizeof(struct vnt_rx_desc)) { desc = &priv->aRD1Ring[i]; desc->rd_info = kzalloc(sizeof(*desc->rd_info), GFP_KERNEL); - + if (WARN_ON(!desc->rd_info)) + return; if (!device_alloc_rx_buf(priv, desc)) dev_err(&priv->pcid->dev, "can not alloc rx bufs\n"); @@ -621,7 +623,8 @@ static void device_init_td0_ring(struct vnt_private *priv) i++, curr += sizeof(struct vnt_tx_desc)) { desc = &priv->apTD0Rings[i]; desc->td_info = kzalloc(sizeof(*desc->td_info), GFP_KERNEL); - + if (WARN_ON(!desc->td_info)) + return; desc->td_info->buf = priv->tx0_bufs + i * PKT_BUF_SZ; desc->td_info->buf_dma = priv->tx_bufs_dma0 + i * PKT_BUF_SZ; @@ -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; -- 1.9.1