[PATCH 03/13] vfio/mdev: simplify mdev_type handling
Zhenyu Wang
zhenyuw at linux.intel.com
Wed Jun 15 06:11:56 UTC 2022
On 2022.06.15 08:28:40 +0200, Christoph Hellwig wrote:
> On Tue, Jun 14, 2022 at 10:06:16AM +0000, Tian, Kevin wrote:
> > > + gvt->mdev_types = kcalloc(num_types, sizeof(*gvt->mdev_types),
> > > + GFP_KERNEL);
> > > + if (!gvt->mdev_types) {
> > > + kfree(gvt->types);
> > > + return -ENOMEM;
> > > + }
> > > +
> > > min_low = MB_TO_BYTES(32);
> > > for (i = 0; i < num_types; ++i) {
> > > if (low_avail / vgpu_types[i].low_mm == 0)
> > > @@ -150,19 +157,21 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
> > > high_avail /
> > > vgpu_types[i].high_mm);
> >
> > there is a memory leak a few lines above:
> >
> > if (vgpu_types[i].weight < 1 ||
> > vgpu_types[i].weight > VGPU_MAX_WEIGHT)
> > return -EINVAL;
> >
> > both old code and this patch forgot to free the buffers upon error.
Sorry about that! It should be my original fault...
>
> Yeah. I'll add a patch to the beginning of the series to fix the
> existing leak and will then make sure to not leak the new allocation
> either.
Thanks a lot!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20220615/ccd64bd4/attachment.sig>
More information about the intel-gvt-dev
mailing list