Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp799263imu; Wed, 9 Jan 2019 06:37:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN6/yZBSDYdkcxsRyLpwozaRLb8mmsuw5VBtBUt2452n9Xc1jjj/V1UVUHJKlxiU9rKfPo2L X-Received: by 2002:a63:a452:: with SMTP id c18mr5711369pgp.204.1547044653144; Wed, 09 Jan 2019 06:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547044653; cv=none; d=google.com; s=arc-20160816; b=b/3oMdLSNT3+7z5K1A8cC8uZWhkQyTm3eFNlS8o9SnehXkt2EVKlPL2MM7pAr4Vk5S TXbkF+Ie+knMHkRM6RmQ4sICb/nAztLIaCcAtcRfkQXaw/kl7w0BIhTbBNcHmgj5WaAV kG4g9FVf4klfPw/dJFwCzyJ8xQw9HWCZwn8ZUlRca+LT4vlAVcj6WIjF//6JeqhP9CAW W2FChNiTTbNsAmhxQI6B12BVczWcbLx7SH118tsg64gSlOibAtZejaBngtjq9sJklLn8 snB1Fz34c5kEoRL0ysLDvFDuEuNzkQoTbolaU9Sx2nFKHhTSVb2l2/CpV5hRkD9+/DD6 zn3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=FSrPLOr0L4pktEQ70hUfIFUq2Gzg/X1TCgfFihMX2dc=; b=cuQ5LzTDZGYbeiEjio/SA9XmcnvEW869+4xCxOvP/uZH5xO4PVn7GNSLe/g37Y+0Bl CzV2cfT8gyIEPYTrWai2h4+XlfN483vm9cH4DbI9OrDCKJyVRujW9tlKkAhaJID2MmG0 Y7MUdJLTP5zKpMp9rtNv6G80zaYVvNTcjzkRo5fwvwtzkkVokhaL/ZbkjDrvt8mxJuFi /VmWCmAcPBLN767ZKauFvr9MdftK1UgpEVFG4//0AmLET9KaTOL8Pr+iQRjjOzGOHDnm CVPOeJxPaZAT38TmPaJOt8/Ku/lvhCq4Zv/o3bnHsTecTB28fRWqDKA3SkTLh9eFm9g0 KeMg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si13870924pgk.323.2019.01.09.06.37.15; Wed, 09 Jan 2019 06:37:33 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731492AbfAIOan (ORCPT + 99 others); Wed, 9 Jan 2019 09:30:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28815 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731220AbfAIOan (ORCPT ); Wed, 9 Jan 2019 09:30:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7514180F90; Wed, 9 Jan 2019 14:30:43 +0000 (UTC) Received: from redhat.com (ovpn-123-72.rdu2.redhat.com [10.10.123.72]) by smtp.corp.redhat.com (Postfix) with SMTP id 36C68546E0; Wed, 9 Jan 2019 14:30:38 +0000 (UTC) Date: Wed, 9 Jan 2019 09:30:37 -0500 From: "Michael S. Tsirkin" To: Yi Wang Cc: jasowang@redhat.com, davem@davemloft.net, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn, "huang.zijiang" Subject: Re: [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed Message-ID: <20190109093026-mutt-send-email-mst@kernel.org> References: <1546926033-31684-1-git-send-email-wang.yi59@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1546926033-31684-1-git-send-email-wang.yi59@zte.com.cn> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 09 Jan 2019 14:30:43 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 08, 2019 at 01:40:33PM +0800, Yi Wang wrote: > From: "huang.zijiang" > > NULL check is needed because kmalloc maybe return NULL. > > Signed-off-by: huang.zijiang Can't hurt I will queue it. > --- > tools/virtio/linux/kernel.h | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h > index 7ef45a4..2afcad8 100644 > --- a/tools/virtio/linux/kernel.h > +++ b/tools/virtio/linux/kernel.h > @@ -65,6 +65,8 @@ static inline void *kzalloc(size_t s, gfp_t gfp) > { > void *p = kmalloc(s, gfp); > > + if (!p) > + return -ENOMEM; > memset(p, 0, s); > return p; > } > -- > 1.8.3.1