Received: by 10.213.65.68 with SMTP id h4csp3897487imn; Tue, 10 Apr 2018 06:22:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+bMEZVX8XlvWMiQ84KhNbdVbmEf+7y4PPu1C1WCgqvAhygDwwcaPindfWtV1v7NGI2WYgl X-Received: by 10.101.98.151 with SMTP id f23mr313859pgv.98.1523366578600; Tue, 10 Apr 2018 06:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523366578; cv=none; d=google.com; s=arc-20160816; b=CxbAT3tuPzfLOdEwsdboDzHZ8LbjtoVKl3YeRaY5KQaUBx9QNCsSAV882+59KoCGRW GZuLq/iBGSQljT+AYyr2AZjkO9mxfztTxoMlvyJuVbDQQEHKvV9CBNSMYTKh0gzxKD5d bNxto67hG1/q3WlZVkxBwFSSc5qriDLx1dcNyyV35b8CKeGOBuAcvg9B5amiEekTjvS+ QDoJ2JPrxNVnFw/pq13l/B0OS/LTjhLa2a+Z6RFKHKko4ASvYDUROboQog9BrlfKGQyu n91KMU4JQAp34Ktyq4OxKdrVZj5if2zHjDw3tzXFHIjrN2u8BqpZdL8aIIMibjjxWrbZ +7Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:subject:user-agent:message-id :references:cc:in-reply-to:from:to:content-transfer-encoding :mime-version:arc-authentication-results; bh=jd7on7QsnOU5V2yB4c/oUTPzpO4wR5HnGdwIa6DfcE0=; b=Vj5M31uuqvx8XFH44moztY1/4Rjq9QmMdCHKawFTb0yTpumNPD7M3H0fSTQVl16gTy iqDuL1hdCejqhN3K3Ea50CRZjlG5ENuMHSfNBwce33WYchX49SIEb5osr1QEavgwJkPt XfPJaZuHIQnPldyro4kKpBYYJYLg5PPVExrZG5C6X6U5bxqmcbnxppDS8Rw7rvHq6t38 pFsaXrRynj2opW9nGVdjRbjrfoSoc2gYDuNPu/S4V95BJVnNkBsaL1u8FurmrnI8ahTr zWx1x2I3jFsh0Aiy9ybxYvY3IYQC45nGnZmZvuERJNGZRSiMoRb5Df/hTPYd7aXkXdJP h7BQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8si1739355pgo.689.2018.04.10.06.22.21; Tue, 10 Apr 2018 06:22:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753911AbeDJNQN convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Apr 2018 09:16:13 -0400 Received: from mail.fireflyinternet.com ([109.228.58.192]:53567 "EHLO fireflyinternet.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753884AbeDJNQL (ORCPT ); Tue, 10 Apr 2018 09:16:11 -0400 X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from localhost (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP (TLS) id 11322587-1500050 for multiple; Tue, 10 Apr 2018 14:16:05 +0100 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT To: Colin King , "Zhenyu Wang" , "Zhi Wang" , "Jani Nikula" , "Joonas Lahtinen" , "Rodrigo Vivi" , "David Airlie" , intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org From: Chris Wilson In-Reply-To: <20180410123312.24631-1-colin.king@canonical.com> Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180410123312.24631-1-colin.king@canonical.com> Message-ID: <152336616409.3167.2652004727166779432@mail.alporthouse.com> User-Agent: alot/0.3.6 Subject: Re: [PATCH] drm/i915/gvt: fix memory leak of a cmd_entry struct on error exit path Date: Tue, 10 Apr 2018 14:16:04 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Colin King (2018-04-10 13:33:12) > From: Colin Ian King > > The error exit path when a duplicate is found does not kfree and cmd_entry > struct and hence there is a small memory leak. Fix this by kfree'ing it. > > Detected by CoverityScan, CID#1370198 ("Resource Leak") > > Fixes: be1da7070aea ("drm/i915/gvt: vGPU command scanner") > Signed-off-by: Colin Ian King > --- > drivers/gpu/drm/i915/gvt/cmd_parser.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c > index d85939bd7b47..3b6d26c44e37 100644 > --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c > +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c > @@ -2864,6 +2864,7 @@ static int init_cmd_table(struct intel_gvt *gvt) > if (info) { > gvt_err("%s %s duplicated\n", e->info->name, > info->name); > + kfree(e); e kzalloc'ed moments above, not yet added to any lists, so fine to use kfree. Alternatively, the find_cmd_entry_any_ring() could be moved ahead of the kzalloc as this function must be externally serialised. Reviewed-by: Chris Wilson -Chris