From patchwork Wed Jul 6 07:42:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12907449 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 038E9CCA47C for ; Wed, 6 Jul 2022 07:42:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbiGFHme (ORCPT ); Wed, 6 Jul 2022 03:42:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbiGFHmb (ORCPT ); Wed, 6 Jul 2022 03:42:31 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F43522BE1; Wed, 6 Jul 2022 00:42:31 -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=V5w6FgheuTsR9XxwDPAz174hg2 ACcJvAXI9poYFbPohXf6b49pTv5x6JVkn/+aYcppTBZp8ymV8a0XA6IxWTlFzVnhpjURjLzoVkf4O TEjD8gAUgIU03IKbOVIhoVmbdQPA3fBJkDYeAx1M/UBU8UBJBZjaAwF9Rc/zmqhyFPg91DlI/bNxc QbeeLoG2Y3dcehue1R9uL81Vkn4vTrW1UwAOL/g3sB5Nc5Lxcj2pbVYGH7eueqZMC92s5gh/I+mHy /sj/bMptIsys4h88dmyafEcA2xv1nL54lFf9R0eAFMNeiVFYP2fK4/KWxgx247QQX0wQ+5f69jyNW JpA3g80A==; Received: from [2001:4bb8:189:3c4a:34cd:2d1d:8766:aad] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8zg0-0079io-5H; Wed, 06 Jul 2022 07:42:24 +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/15] drm/i915/gvt: fix a memory leak in intel_gvt_init_vgpu_types Date: Wed, 6 Jul 2022 09:42:05 +0200 Message-Id: <20220706074219.3614-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220706074219.3614-1-hch@lst.de> References: <20220706074219.3614-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. 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)