From patchwork Mon Jul 4 12:51:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12905313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45C09CCA482 for ; Mon, 4 Jul 2022 12:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234013AbiGDMv7 (ORCPT ); Mon, 4 Jul 2022 08:51:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232909AbiGDMv5 (ORCPT ); Mon, 4 Jul 2022 08:51:57 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E637E10FC3; Mon, 4 Jul 2022 05:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=DXtBbkVREHluB0bQE8SDxaihur9/pek8hwTZBcL+Y2o=; b=qUFU4Ljog19N8V2HsPwdesXiUF 1CCiaJI8pIYhDtSOs+aDOFUoHqO+NEi2YnhTwxg3nXvrizRSAA+KULHFxtAiLmVNHyaEx6dig6NH8 /WsgUU9qVp+4BX0aJt/2yye7c6AwFg8/dwlfxYofv7LU4hhGPNts21rJTzCRJc+bPf5XJoG8JByfz 7cJvLzYiXOOE4fwgctqjv0tV+CaNLsWVCiKf51PyeeJrDUS417B1rMqnVoDa6Aa2sk4HCn5UHLA24 gACGrKH92EePHzktEsEylahk+K87r0NJogTYWY9aZAbNbvSDvJtIZrK0CvqsGdFlNKIiz9LiRxLkm /N+wjPPg==; Received: from [2001:4bb8:189:3c4a:8758:74d9:4df6:6417] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8LYL-008wCA-AQ; Mon, 04 Jul 2022 12:51:49 +0000 From: Christoph Hellwig To: Kirti Wankhede , Tony Krowiak , Halil Pasic , Jason Herne , Eric Farman , Matthew Rosato , Zhenyu Wang , Zhi Wang , Alex Williamson Cc: Jason Gunthorpe , kvm@vger.kernel.org, linux-s390@vger.kernel.org, intel-gvt-dev@lists.freedesktop.org, Kevin Tian Subject: [PATCH 01/14] drm/i915/gvt: fix a memory leak in intel_gvt_init_vgpu_types Date: Mon, 4 Jul 2022 14:51:31 +0200 Message-Id: <20220704125144.157288-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220704125144.157288-1-hch@lst.de> References: <20220704125144.157288-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org gvt->types needs to be freed on error. Reported-by: Kevin Tian Signed-off-by: Christoph Hellwig Reviewed-by: Kevin Tian Reviewed-by: Zhenyu Wang Reviewed-by: Jason Gunthorpe --- drivers/gpu/drm/i915/gvt/vgpu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 46da19b3225d2..5c828556cefd7 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c @@ -142,7 +142,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt) if (vgpu_types[i].weight < 1 || vgpu_types[i].weight > VGPU_MAX_WEIGHT) - return -EINVAL; + goto out_free_types; gvt->types[i].weight = vgpu_types[i].weight; gvt->types[i].resolution = vgpu_types[i].edid; @@ -167,6 +167,10 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt) gvt->num_types = i; return 0; + +out_free_types: + kfree(gvt->types); + return -EINVAL; } void intel_gvt_clean_vgpu_types(struct intel_gvt *gvt)