From mboxrd@z Thu Jan 1 00:00:00 1970 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 49BB9C28D13 for ; Mon, 22 Aug 2022 06:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232875AbiHVGWZ (ORCPT ); Mon, 22 Aug 2022 02:22:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230161AbiHVGWY (ORCPT ); Mon, 22 Aug 2022 02:22:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B61275CB; Sun, 21 Aug 2022 23:22:23 -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=bJ/2mjvztYAzYKekFyqBsdfuFu74OvSupsxhbe+N+7Q=; b=xSH4J2Ie2GYpuJpxKd3Gru278q TFD8oCYlwSlK2llGy6iSm6ScNI8qYkBs96fywblVFqlBXj3UmFJxHoLpHGuMBQghfRwMhv6P/Gi2R rgVbPJ9QDCU8UeQD/+SDiQ/2sU6W0y7+7jUjpO3Q7Ur/w4rUhPAqUKaogc4xtObPzj/EUgq06u0yi ou8xz3BBaF7JS0+yj9ZJWz5wymOKV4LwQXtzdUtzsoh0tQtFeiDQnpu3ySpT7xK53R4MnzainqfP6 +2v/U/XLQCeTDfm7JlPLd3szZHXqzdxV+vI/CuXihzwMFNgNb+nEKETk8Li0ZqGB1AZCUgH6rZto2 x8XQSfBw==; Received: from [2001:4bb8:198:6528:7eb3:3a42:932d:eeba] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQ0pB-005NOp-5h; Mon, 22 Aug 2022 06:22:13 +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, 22 Aug 2022 08:21:55 +0200 Message-Id: <20220822062208.152745-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220822062208.152745-1-hch@lst.de> References: <20220822062208.152745-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: linux-s390@vger.kernel.org gvt->types needs to be freed on error. Fixes: c90d097ae144 ("drm/i915/gvt: define weight according to vGPU type") Reported-by: Kevin Tian Signed-off-by: Christoph Hellwig Reviewed-by: Jason Gunthorpe Reviewed-by: Kevin Tian Reviewed-by: Zhenyu Wang --- 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) -- 2.30.2