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 D6223C6FA82 for ; Fri, 23 Sep 2022 09:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231600AbiIWJ1O (ORCPT ); Fri, 23 Sep 2022 05:27:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbiIWJ1M (ORCPT ); Fri, 23 Sep 2022 05:27:12 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6759812F769; Fri, 23 Sep 2022 02:27:11 -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=miBiBu5eUDXhhQhkh3qMVJMsYf79Ozgd3QWLknqrnyE=; b=QbYShw2LCwi+JASmSYRVW+PEgp agH5ttlT1pKdmmUB1yX04nWYDE0JcjQ2zmd3L4igMXGKYIC2XEpTIsGWknrMeyjMmEOEUNY9aKMlS Qlhj33PcVOKqLMOA1BF9Xo37Sqh7/mndULUu9+osyWFhvjWOzal+CHZl/m6LSsiQ5eiHgPI52UWAs Ika7MSCcdt5zg7dKqRsSoLYqLkCfeRYZxTxl17HwRkpJYlIAUUNSbb+vRqImwaPtglqlnvS79rwrI 0EHjUaOa46Wn5ynxPfvueWCuD7vkgMOBKea96NUyhinH524SKB2yeV2uQJasdWiWTlyYwK5yG/Vij kARhiRMw==; Received: from ip4d15bec4.dynamic.kabel-deutschland.de ([77.21.190.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1obexV-003JfV-2y; Fri, 23 Sep 2022 09:26:57 +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: Fri, 23 Sep 2022 11:26:39 +0200 Message-Id: <20220923092652.100656-2-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220923092652.100656-1-hch@lst.de> References: <20220923092652.100656-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 5c533fbc2c8da..dbb2a971ba5d8 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