mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>
To: liulongfang <liulongfang@huawei.com>,
	Jason Gunthorpe <jgg@nvidia.com>,
	Alex Williamson <alex.williamson@redhat.com>
Cc: "cohuck@redhat.com" <cohuck@redhat.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linuxarm@openeuler.org" <linuxarm@openeuler.org>
Subject: RE: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug
Date: Wed, 21 Sep 2022 07:27:06 +0000	[thread overview]
Message-ID: <c39afd09b50b4d5e948369774e9c62c2@huawei.com> (raw)
In-Reply-To: <ad6cd915-89c4-299e-03d2-8caab500809a@huawei.com>



> -----Original Message-----
> From: liulongfang
> Sent: 21 September 2022 04:13
> To: Shameerali Kolothum Thodi <shameerali.kolothum.thodi@huawei.com>;
> Jason Gunthorpe <jgg@nvidia.com>; Alex Williamson
> <alex.williamson@redhat.com>
> Cc: cohuck@redhat.com; linux-kernel@vger.kernel.org;
> linuxarm@openeuler.org
> Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug
> 
> On 2022/9/21 1:03, Shameerali Kolothum Thodi wrote:
> >
> >
> >> -----Original Message-----
> >> From: Jason Gunthorpe [mailto:jgg@nvidia.com]
> >> Sent: 20 September 2022 17:38
> >> To: Alex Williamson <alex.williamson@redhat.com>
> >> Cc: liulongfang <liulongfang@huawei.com>; Shameerali Kolothum Thodi
> >> <shameerali.kolothum.thodi@huawei.com>; cohuck@redhat.com;
> >> linux-kernel@vger.kernel.org; linuxarm@openeuler.org
> >> Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug
> >>
> >> On Tue, Sep 20, 2022 at 10:34:43AM -0600, Alex Williamson wrote:
> >>> On Thu, 15 Sep 2022 09:31:53 +0800
> >>> Longfang Liu <liulongfang@huawei.com> wrote:
> >>>
> >>>> During the stop copy phase of live migration, the driver allocates a
> >>>> memory for the migrated data to save the data.
> >>>>
> >>>> When an exception occurs when the driver reads device data, the
> >>>> driver will report an error to qemu and exit the current migration state.
> >>>> But this memory is not released, which will lead to a memory leak
> >>>> problem.
> >>
> >> Why isn't it released? The fput() releases it:
> >>
> >> static int hisi_acc_vf_release_file(struct inode *inode, struct file *filp) {
> >> 	struct hisi_acc_vf_migration_file *migf = filp->private_data;
> >>
> >> 	hisi_acc_vf_disable_fd(migf);
> >> 	mutex_destroy(&migf->lock);
> >> 	kfree(migf);
> >>         ^^^^^^^^^^
> >>
> >> This patch looks wrong to me.
> >
> > That's right. Missed that. Sorry of the oversight.
> >
> Yes, fput will call release in ops of file, here will call hisi_acc_vf_release_file
> to complete the release operation of migf, so this patch is unnecessary.
> 
> But there is another place that needs to be modified:
> hisi_acc_vf_disable_fd in hisi_acc_vf_disable_fds is not needed,
> because it will have an fput next. Is this correct?

I don't think that is correct either. fput() decrements ref count and 
will only call release() if the count is zero. We have an explicit get_file()
for the hisi_acc_vf_disable_fds(). Isn't it?

Thanks,
Shameer


 
> > Thanks,
> > Shameer
> >
> > .
> Thanks,
> Longfang.
> >

  reply	other threads:[~2022-09-21  7:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  1:31 [PATCH 0/5] Fix some bugs and clean code issues Longfang Liu
2022-09-15  1:31 ` [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug Longfang Liu
2022-09-20 16:34   ` Alex Williamson
2022-09-20 16:38     ` Jason Gunthorpe
2022-09-20 17:03       ` Shameerali Kolothum Thodi
2022-09-21  3:13         ` liulongfang
2022-09-21  7:27           ` Shameerali Kolothum Thodi [this message]
2022-09-22  7:51             ` liulongfang
2022-09-15  1:31 ` [PATCH 2/5] hisi_acc_vfio_pci: Fixes error return code issue Longfang Liu
2022-09-15  1:31 ` [PATCH 3/5] hisi_acc_vfio_pci: Remove useless function parameter Longfang Liu
2022-09-15  1:31 ` [PATCH 4/5] hisi_acc_vfio_pci: Fix device data address combination problem Longfang Liu
2022-09-15  1:31 ` [PATCH 5/5] hisi_acc_vfio_pci: Fix some clean code issues Longfang Liu

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=c39afd09b50b4d5e948369774e9c62c2@huawei.com \
    --to=shameerali.kolothum.thodi@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxarm@openeuler.org \
    --cc=liulongfang@huawei.com \
    /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

all inboxes | Powered by JetHome®