Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp228378imm; Thu, 2 Aug 2018 17:42:44 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfGkfhGLByuvoJO3ZfmQgO2F56sj908lnWremQWajiIBBGXbcgFNYxypItYbX1QT38zk3Yz X-Received: by 2002:a62:8913:: with SMTP id v19-v6mr1843297pfd.127.1533256964235; Thu, 02 Aug 2018 17:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533256964; cv=none; d=google.com; s=arc-20160816; b=HN1OIXqTRCwbgjQpf1DUvPOl+kaYPNnEaf+qRi6MBZM/4r8tlZBSbZ5onu/QhpUiFB oMzmkGOI8FnKGyqEpo0NmjnB8Gceu7xMSF/5LxfMim/TCb6UB0JFhcOyXbrgw6fIcVCW 4Co5RQrTsc8COpWK8aG0gdBk1WyTLKTYgS5Ex4U0Ry1vELxbV3SpCx55KTVfPu4ApjAx r9usXgt5TY3QXjxoz2WSbOY65Gj2024YsvBSSMj5xX3TSgr9wdfQIF3r1DbZWWKyin19 Cn0/tNB1p+VOWjYxbMYo+zi1gxTvuGR9bvFxxJqJuFQNfeQKfzDmqepqBIpmWRMjG8pS UGKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=P7pCoseTlvYLHPBTrOrbs40rSC/q4CRMHOJ+nAqtEu8=; b=xE/yKS3vhViJanIbufoCi6fIrioLwuELNjfxdYtMnQh6nt6GHTddA53AMhk8FZ+0Yh 1y5PcPHdSKzLn7QHGoXn6jx3ve1XLJ2MYL5Kssk+sH9sVhsK0/RTJUPqcn+eWngzJD+J V7kCg4w2Jcd9GdzZ/7gFDZ1msEp8DsHPCEhfPbKahVrWm/uKRzug57C5osbB3CMq95UJ j73Wk/iAhdLrq4bFBiMX9Lhq+EqB2dEejFbNwl14n8KYXks9N1kJoD4F2XUClf6BbS8Y 9y1OxLceYh7EQ3vrZNxW4iyjMHrs9QVlXwsLp45yHI/kwp5ar4U56djb0XAKljltg71n 3OAQ== 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 bi1-v6si2479988plb.399.2018.08.02.17.42.29; Thu, 02 Aug 2018 17:42:44 -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 S1732286AbeHCCfK (ORCPT + 99 others); Thu, 2 Aug 2018 22:35:10 -0400 Received: from out1.zte.com.cn ([202.103.147.172]:44576 "EHLO mxct.zte.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729118AbeHCCfK (ORCPT ); Thu, 2 Aug 2018 22:35:10 -0400 Received: from mse01.zte.com.cn (unknown [10.30.3.20]) by Forcepoint Email with ESMTPS id CDD10B40C43CBDDFBCBF; Fri, 3 Aug 2018 08:41:28 +0800 (CST) Received: from notes_smtp.zte.com.cn ([10.30.1.239]) by mse01.zte.com.cn with ESMTP id w730fOiT039692; Fri, 3 Aug 2018 08:41:24 +0800 (GMT-8) (envelope-from wang.yi59@zte.com.cn) Received: from fox-host8.localdomain ([10.74.120.8]) by szsmtp06.zte.com.cn (Lotus Domino Release 8.5.3FP6) with ESMTP id 2018080308413180-3041620 ; Fri, 3 Aug 2018 08:41:31 +0800 From: Yi Wang To: zhenyuw@linux.intel.com Cc: zhi.a.wang@intel.com, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jiang.biao2@zte.com.cn, wang.yi59@zte.com.cn, zhong.weidong@zte.com.cn Subject: [PATCH] drm/i915/gvt: fix memory leak in intel_vgpu_ioctl() Date: Fri, 3 Aug 2018 08:41:19 +0800 Message-Id: <1533256879-10220-1-git-send-email-wang.yi59@zte.com.cn> X-Mailer: git-send-email 1.8.3.1 X-MIMETrack: Itemize by SMTP Server on SZSMTP06/server/zte_ltd(Release 8.5.3FP6|November 21, 2013) at 2018-08-03 08:41:31, Serialize by Router on notes_smtp/zte_ltd(Release 9.0.1FP7|August 17, 2016) at 2018-08-03 08:41:09, Serialize complete at 2018-08-03 08:41:09 X-MAIL: mse01.zte.com.cn w730fOiT039692 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'sparse' variable may leak when return in function intel_vgpu_ioctl(), and this patch fixes this. Signed-off-by: Yi Wang Reviewed-by: Jiang Biao --- drivers/gpu/drm/i915/gvt/kvmgt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/kvmgt.c index df4e4a0..6a6f199 100644 --- a/drivers/gpu/drm/i915/gvt/kvmgt.c +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c @@ -1200,6 +1200,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, return ret; break; default: + kfree(sparse); return -EINVAL; } } @@ -1215,6 +1216,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, sizeof(info), caps.buf, caps.size)) { kfree(caps.buf); + kfree(sparse); return -EFAULT; } info.cap_offset = sizeof(info); @@ -1223,6 +1225,7 @@ static long intel_vgpu_ioctl(struct mdev_device *mdev, unsigned int cmd, kfree(caps.buf); } + kfree(sparse); return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; } else if (cmd == VFIO_DEVICE_GET_IRQ_INFO) { -- 1.8.3.1