答复: [PATCH] vfio: platform: fix reference leak in vfio_platform_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Auger

> On 10/30/20 4:47 PM, Zhang Qilong wrote:
> > pm_runtime_get_sync() will increment pm usage counter even it failed.
> > Forgetting to call pm_runtime_put_noidle will result in reference leak
> > in vfio_platform_open, so we should fix it.
> >
> > Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>
> > ---
> >  drivers/vfio/platform/vfio_platform_common.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/vfio/platform/vfio_platform_common.c
> > b/drivers/vfio/platform/vfio_platform_common.c
> > index c0771a9567fb..aa97f1678981 100644
> > --- a/drivers/vfio/platform/vfio_platform_common.c
> > +++ b/drivers/vfio/platform/vfio_platform_common.c
> > @@ -266,8 +266,10 @@ static int vfio_platform_open(void *device_data)
> >  			goto err_irq;
> >
> >  		ret = pm_runtime_get_sync(vdev->device);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			pm_runtime_put_noidle(vdev->device);
> can't we jump to err_rst then?

We could jump to err_rst here. The difference is that pm_runtime_put will leave this
device idle state if we decrease usage count failed that is meanless. Because this
module will be put. Generally speaking, the action of pm_runtime_put and
pm_runtime_put_noidle is the same here that only decreases usage count. Jumping to
err_rst could be more better for read view. I'll improve it in patch V2.

Thanks

Zhang Qilong
> 
> Thanks
> 
> Eric
> >  			goto err_pm;
> > +		}
> >
> >  		ret = vfio_platform_call_reset(vdev, &extra_dbg);
> >  		if (ret && vdev->reset_required) {
> >





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux