From patchwork Wed May 5 04:58:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 12239077 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB25CC433B4 for ; Wed, 5 May 2021 05:15:41 +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 12B5A60FE9 for ; Wed, 5 May 2021 05:15:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12B5A60FE9 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+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1le9sp-0007MI-S2 for qemu-devel@archiver.kernel.org; Wed, 05 May 2021 01:15:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57272) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1le9rb-00067G-D5 for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 Received: from m12-16.163.com ([220.181.12.16]:57537) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1le9rW-00010J-LM for qemu-devel@nongnu.org; Wed, 05 May 2021 01:14:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=yjGgd yEI4yFRIsPij/wQlBf/XfQxp/AuLx+xqGJnJNo=; b=nplPebjSgbqFz4QsZqWX0 P3mDH9LUq7HCWpx+eqrKxlhnLyxM9Cm/0nbkxE0rDJcje0PsMyx0Mv6UsV8IoO4P gUzDkBmfaQ/WnrbKcLerIR13WKfTuayJQFXJ6xAnZZHEzFkbz4ybShvdoCV6lf/l UJ8MwC62AT8eqOY0C9Bg30= Received: from ubuntu.localdomain (unknown [36.22.237.185]) by smtp12 (Coremail) with SMTP id EMCowACXET7zJZJg8VpupQ--.18216S6; Wed, 05 May 2021 12:58:31 +0800 (CST) From: Li Qiang To: marcandre.lureau@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org Subject: [PATCH 2/7] vhost-user-gpu: fix resource leak in 'vg_resource_create_2d' Date: Tue, 4 May 2021 21:58:19 -0700 Message-Id: <20210505045824.33880-3-liq3ea@163.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505045824.33880-1-liq3ea@163.com> References: <20210505045824.33880-1-liq3ea@163.com> MIME-Version: 1.0 X-CM-TRANSID: EMCowACXET7zJZJg8VpupQ--.18216S6 X-Coremail-Antispam: 1Uf129KBjvdXoWruFW5Ary7tFy3Xr4UKryDZFb_yoW3XFb_Za 18AF4kCFsxWFy09w4Dtws8A3yayFW3Jr4xtFy0kF15CFyUtwnIqwn5tryktrW8Zw4DKFn8 ArWUJw48ZF12vjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU84xR3UUUUU== X-Originating-IP: [36.22.237.185] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBZhaJbVaD7t4NYgABsf Received-SPF: pass client-ip=220.181.12.16; envelope-from=liq3ea@163.com; helo=m12-16.163.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) BAYES_20=-0.001, 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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Call 'vugbm_buffer_destroy' in error path to avoid resource leak. Signed-off-by: Li Qiang Reviewed-by: Prasad J Pandit --- contrib/vhost-user-gpu/vhost-user-gpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c index f73f292c9f..b5e153d0d6 100644 --- a/contrib/vhost-user-gpu/vhost-user-gpu.c +++ b/contrib/vhost-user-gpu/vhost-user-gpu.c @@ -349,6 +349,7 @@ vg_resource_create_2d(VuGpu *g, g_critical("%s: resource creation failed %d %d %d", __func__, c2d.resource_id, c2d.width, c2d.height); g_free(res); + vugbm_buffer_destroy(&res->buffer); cmd->error = VIRTIO_GPU_RESP_ERR_OUT_OF_MEMORY; return; }