Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: <wang.yi59@zte.com.cn>
To: zhenyuw@linux.intel.com
Cc: zhong.weidong@zte.com.cn, airlied@linux.ie,
	intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, rodrigo.vivi@intel.com,
	jiang.biao2@zte.com.cn, intel-gvt-dev@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/gvt: fix memory leak in intel_vgpu_ioctl()
Date: Wed, 8 Aug 2018 22:49:20 +0800 (CST)	[thread overview]
Message-ID: <201808082249201558548@zte.com.cn> (raw)
In-Reply-To: <20180808072320.GP22630@zhen-hp.sh.intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 1758 bytes --]

> On 2018.08.03 08:41:19 +0800, Yi Wang wrote:
> > The 'sparse' variable may leak when return in function
> > intel_vgpu_ioctl(), and this patch fixes this.
> >
> > Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
> > Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
> > ---
> >  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);
>
> Unfortunately this would cause a double-free error in normal path, as we
> tried to free sparse after use to add caps. So may be better to fix free
> in error path and move normal free of sparse in final point, e.g

Yeah, that's right! Thanks a lot for your advice. I will send a v2 patch.


---
Best wishes
Yi Wang

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2018-08-08 14:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-03  0:41 [PATCH] drm/i915/gvt: fix memory leak in intel_vgpu_ioctl() Yi Wang
2018-08-03  1:27 ` Zhenyu Wang
2018-08-03 17:50 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-08-03 19:08 ` ✓ Fi.CI.IGT: " Patchwork
2018-08-08  7:23 ` [PATCH] " Zhenyu Wang
2018-08-08 14:49   ` wang.yi59 [this message]
2018-08-08  7:40 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915/gvt: fix memory leak in intel_vgpu_ioctl() (rev2) Patchwork
2018-08-08  7:56 ` ✓ Fi.CI.BAT: success " Patchwork
2018-08-08  9:07 ` ✓ Fi.CI.IGT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201808082249201558548@zte.com.cn \
    --to=wang.yi59@zte.com.cn \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jiang.biao2@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhong.weidong@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox