From patchwork Wed Aug 19 14:43:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 11724323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9B85913 for ; Wed, 19 Aug 2020 14:47:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D1252083B for ; Wed, 19 Aug 2020 14:47:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="Mue+1f5q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D1252083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k8PMq-0003Qk-3W for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Aug 2020 10:47:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50886) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k8PJk-0008Mq-B6 for qemu-devel@nongnu.org; Wed, 19 Aug 2020 10:43:56 -0400 Received: from mail-m975.mail.163.com ([123.126.97.5]:51450) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k8PJb-0002yq-4P for qemu-devel@nongnu.org; Wed, 19 Aug 2020 10:43:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=czWCoDoniiCusoZIft v4yR5TcH9WsDlgWrCv42GCBK8=; b=Mue+1f5qVFvY7jLqb02aJDroByU9wQ2bb8 naOF7QUJ0zq5Jxkti+x5fdmBTJDdTRX/XDrYVJ60I5gFKOqF4lJKEDrEVkywnsAl hBN6L+u/CxNpxim3pDDzinudtkTnDmQ+XXi2kFatonfW67KtDSYASWwCXMU4azv3 BRvLZpk+A= Received: from localhost.localdomain (unknown [60.177.59.214]) by smtp5 (Coremail) with SMTP id HdxpCgC3mVSBOj1fZRtQEQ--.228S4; Wed, 19 Aug 2020 22:43:30 +0800 (CST) From: Li Qiang To: mst@redhat.com, jasowang@redhat.com Subject: [PATCH] virtio: vdpa: omit check return of g_malloc Date: Wed, 19 Aug 2020 07:43:09 -0700 Message-Id: <20200819144309.67579-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: HdxpCgC3mVSBOj1fZRtQEQ--.228S4 X-Coremail-Antispam: 1Uf129KBjvdXoW7Wry5Gw1fWFWkur47Jr47urg_yoWkXFc_WF yxAryvgF98CryjkFsFvr4SqF17ta1kX3WvkayS9ryxAwnrXw12v34xCFnrXF17u347AFy5 urWkArZ8tw1agjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8LF4JUUUUU== X-Originating-IP: [60.177.59.214] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbiFBKFbVaD7B7z6AAAsS Received-SPF: pass client-ip=123.126.97.5; envelope-from=liq3ea@163.com; helo=mail-m975.mail.163.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/19 10:16:01 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" If g_malloc fails, the application will be terminated. No need to check the return value of g_malloc. Signed-off-by: Li Qiang Reviewed-by: Laurent Vivier Reviewed-by: Alex Bennée --- hw/virtio/vhost-vdpa.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 4580f3efd8..403ae3ae07 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -320,10 +320,8 @@ static int vhost_vdpa_set_config(struct vhost_dev *dev, const uint8_t *data, struct vhost_vdpa_config *config; int ret; unsigned long config_size = offsetof(struct vhost_vdpa_config, buf); + config = g_malloc(size + config_size); - if (config == NULL) { - return -1; - } config->off = offset; config->len = size; memcpy(config->buf, data, size); @@ -340,9 +338,6 @@ static int vhost_vdpa_get_config(struct vhost_dev *dev, uint8_t *config, int ret; v_config = g_malloc(config_len + config_size); - if (v_config == NULL) { - return -1; - } v_config->len = config_len; v_config->off = 0; ret = vhost_vdpa_call(dev, VHOST_VDPA_GET_CONFIG, v_config);