Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4358541imu; Mon, 7 Jan 2019 21:50:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN5X2qR55BVt95pOUXpwoHdh2huMnNy+73yQMVeomLfPm9McsRdgKoT9uudbTdo6wsIFcm1K X-Received: by 2002:a17:902:820d:: with SMTP id x13mr439019pln.229.1546926656334; Mon, 07 Jan 2019 21:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546926656; cv=none; d=google.com; s=arc-20160816; b=B2dCTBGL7tQaBRCcYi+O0a21qzw3Z0rFxaZPMTcTI+jJ4Ovw0yLBW1memU2EXiiIWL EnVL0T24KBrxR4Dt6GMJHwdOKHwGgjE0GV0mYVZVUKrMgiFIEFo4SJouEgeYQxiGs58D xM1pbnplKLn9QgjNK4XzRz8qOxgswxRdOjNWm9Bi2NOqpU6jDcjKjXjjcokfbztRlCn9 ipZJX8DcXL76FJA7947OQcpU7BiDM2OnrW86bF3QqSX5YjkMEFzbp6GCsHtarrkgstIX 8pfSzcQUpljodJiiEjxa/pYRwdojI0oMlOyviPYi4uqANh0wf55h0AUvPwJzJb3B++T4 /7uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=prSmh/endM8Cmh1H4QQs25almpVRlKkIKxGOSus8+ts=; b=eNB4k6xtRNY+rzYLKQzCo1bCBiVNi4lrymaHMrcmd6f2wpHagj58JlKvoluaHo5wOU LID1TY6GAJvbzYzxSx2sBcgIacVnXU0Z83aM9Qj6aqL/tsWh7Us8507XSVtWIDEn7kDx v5XmMDxqlibOFbU3Oik1IytH0ZsgKjbIbR+07vy1106A6tuw489F2pECKZkziXI+aTSl 4sg6S4YzBXCY2lke3Hh1vAiQmRvj7QpDVXCn8yxpdRIM9ya3h7DTKgQ6PIh5c5EpFB8W jUK0f8txYFeblWicRr7BS2CfgnAXhQ2aK0yZxxb0dEIuN9qAJJH0fGaBksJR213a8U1s ywqg== 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 o184si6028600pgo.591.2019.01.07.21.50.39; Mon, 07 Jan 2019 21:50:56 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727773AbfAHFlJ (ORCPT + 99 others); Tue, 8 Jan 2019 00:41:09 -0500 Received: from out1.zte.com.cn ([202.103.147.172]:52132 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727625AbfAHFlI (ORCPT ); Tue, 8 Jan 2019 00:41:08 -0500 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id 93FFCABB885C946C4BF6; Tue, 8 Jan 2019 13:41:05 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id x085exjr003504; Tue, 8 Jan 2019 13:40:59 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2019010813411244-21023309 ; Tue, 8 Jan 2019 13:41:12 +0800 From: Yi Wang To: mst@redhat.com Cc: jasowang@redhat.com, davem@davemloft.net, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn, "huang.zijiang" Subject: [PATCH] virtio:linux:kernel:NULL check after kmalloc is needed Date: Tue, 8 Jan 2019 13:40:33 +0800 Message-Id: <1546926033-31684-1-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2019-01-08 13:41:12, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2019-01-08 13:40:55, Serialize complete at 2019-01-08 13:40:55 X-MAIL: mse01.zte.com.cn x085exjr003504 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "huang.zijiang" NULL check is needed because kmalloc maybe return NULL. Signed-off-by: huang.zijiang --- 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