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 1A13AC433EF for ; Sat, 9 Jul 2022 04:55:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229521AbiGIEzS (ORCPT ); Sat, 9 Jul 2022 00:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbiGIEzQ (ORCPT ); Sat, 9 Jul 2022 00:55:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1079B140D5; Fri, 8 Jul 2022 21:55:13 -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=NrxSxJgm2XVKPMFKgjKv+cYNj4 AUo2GakyCY70OTG2Ed937aWrNVI2kj394GhDMicgYtw3+ZnJc0O3V0nID2qYXLBuGomyuSPK/9EdO LLdHNHXzMEmLIkroa8iP5ri+BPLoG7g/ttNuEI8Ttk4GEQwLQ41JfmQFC8aruZH3P/Wl/RwTs+sem 6K0Vy1S9S/MPfX4/dS7zD6UXNszn6R+j81VktRQ+VmIz405bq2RtC0x193n0IIpnuguIpowqjB2g5 suELu6zshYZs+efd10GIAKXp++30WRNhBmf9cGQJZR33ngmgqSt/RKr1FUvi7IpVc70BPOvvL1BUT 1+jbKL0w==; Received: from 213-225-4-185.nat.highway.a1.net ([213.225.4.185] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oA2Ub-006ztv-WD; Sat, 09 Jul 2022 04:54:58 +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: Sat, 9 Jul 2022 06:54:37 +0200 Message-Id: <20220709045450.609884-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220709045450.609884-1-hch@lst.de> References: <20220709045450.609884-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