Received: by 10.213.65.68 with SMTP id h4csp213231imn; Wed, 28 Mar 2018 02:02:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+8iXLBiabXDdYJHRWDeHOi6EoHvpPYgqQRTwf4TFS632+jgrmX+4VomzLafGNsZ24w68BO X-Received: by 2002:a17:902:20ca:: with SMTP id v10-v6mr2988126plg.9.1522227769495; Wed, 28 Mar 2018 02:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522227769; cv=none; d=google.com; s=arc-20160816; b=QYbrzFWrsKgDM0yHb1lYjoCTY9u2WLacBwsAcWqORIwqQAiow3cYJAJ/BPV1tG4lzQ Ex5RhIfj5ty3ukjDXb4KMaCcxHzCHR6gfTxR2YHdM8hsxD2PuGxn5HLcsjhelQ516772 Kr+qdDqnaqzUF/A9Wsv/kWE/bHsJudolAVqWZYzLrdjI5YLGxAQwfk5hPrrxKowMJhyV GFdFjnkPr8uFA48sOtSHWe3i1OPyNIArwUTpbi0CVBXcfKrC10YujGrVZ9nP5MnkefyT D0Veir+ujDwiI2FcSWPVKuTuxC1nnQCgRNpVjibxd19tqyZhAFOzgxaFjeZ/deNnlDr0 bwjQ== 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:arc-authentication-results; bh=VpzPAOYppyaa2RJu+xG8GkPuqHvHQzLgmcdF10Yagv8=; b=sZKSVv6sXx3ZFJPre8pYT8oAsmm+lTEjnc2O7bJnvisuB/RrAhFhScpVYynTBBtmJ8 O8L5adx4XeKXZDOF9WX1bP9zeZE1NFDv7ntPFaPllfC0lhLmqeaoPZjpCIw+ayaOmGlX hYBfNqKOK/i5Vv7LagMTeL521og3F/O4ecU1saV/EQ88DM2hwoTCHhO1CvvtokxDbzUg 39ssuXntQZ08Gqrb7qdMQ2MLFPXdZ85kGgYOvq3UAZ+dNoyZH071adaGco2jTUEM6dqh mw4i293TtLPWiP6b71dh8ttsMkQQrzuu9qzsNvNWoILiEQZrUYFPEs4SZ7k6UpBbwBLz nnYA== ARC-Authentication-Results: i=1; mx.google.com; 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 l2si2119478pga.695.2018.03.28.02.02.34; Wed, 28 Mar 2018 02:02:49 -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; 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 S1752462AbeC1Idp (ORCPT + 99 others); Wed, 28 Mar 2018 04:33:45 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47150 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeC1Ido (ORCPT ); Wed, 28 Mar 2018 04:33:44 -0400 Received: from localhost (unknown [37.173.34.182]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D1B971018; Wed, 28 Mar 2018 08:33:42 +0000 (UTC) Date: Wed, 28 Mar 2018 10:33:37 +0200 From: Greg KH To: Ji-Hun Kim Cc: forest@alittletooquiet.net, devel@driverdev.osuosl.org, y.k.oh@samsung.com, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, baijiaju1990@gmail.com, santhameena13@gmail.com Subject: Re: [PATCH] staging: vt6655: check for memory allocation failures Message-ID: <20180328083337.GA15316@kroah.com> References: <1522218691-7917-1-git-send-email-ji_hun.kim@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522218691-7917-1-git-send-email-ji_hun.kim@samsung.com> User-Agent: Mutt/1.9.4 (2018-02-28) 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 03:31:31PM +0900, Ji-Hun Kim wrote: > 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; Eeek, no, this crashes any machine that runs with "panic on warn". You don't crash if you can not allocate any memory, you recover and move on. You don't even need to print anything out, as the call itself will do that if this happens. So this patch isn't ok at all, sorry. greg k-h