All of lore.kernel.org
 help / color / mirror / Atom feed
From: weiping zhang <zhangweiping@didichuxing.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: virtualization@lists.linux-foundation.org, mst@redhat.com
Subject: Re: [PATCH 1/3] virtio_pci: use put_device instead of kfree
Date: Tue, 12 Dec 2017 21:11:42 +0800	[thread overview]
Message-ID: <20171212131142.GA31104@localhost.didichuxing.com> (raw)
In-Reply-To: <20171212110025.5d029fce.cohuck@redhat.com>

On Tue, Dec 12, 2017 at 11:00:25AM +0100, Cornelia Huck wrote:
> On Mon, 11 Dec 2017 23:55:16 +0800
> weiping zhang <zhangweiping@didichuxing.com> wrote:
> 
> > don't free vp_dev until vp_dev->vdev.dev.release be called.
> 
> Maybe add the same description as in your virtio_mmio patch so that it
> is clear why the kfree() is not ok?
OK, I'll add it at V2.
> > 
> > Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> > ---
> >  drivers/virtio/virtio_pci_common.c | 17 +++++++++--------
> >  1 file changed, 9 insertions(+), 8 deletions(-)
> > 
> > diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c
> > index 1c4797e..91d20f7 100644
> > --- a/drivers/virtio/virtio_pci_common.c
> > +++ b/drivers/virtio/virtio_pci_common.c
> > @@ -551,16 +551,17 @@ static int virtio_pci_probe(struct pci_dev *pci_dev,
> >  	pci_set_master(pci_dev);
> >  
> >  	rc = register_virtio_device(&vp_dev->vdev);
> > -	if (rc)
> > -		goto err_register;
> > +	if (rc) {
> > +		if (vp_dev->ioaddr)
> > +		     virtio_pci_legacy_remove(vp_dev);
> > +		else
> > +		     virtio_pci_modern_remove(vp_dev);
> > +		pci_disable_device(pci_dev);
> > +		put_device(&vp_dev->vdev.dev);
> > +	}
> >  
> > -	return 0;
> > +	return rc;
> >  
> > -err_register:
> > -	if (vp_dev->ioaddr)
> > -	     virtio_pci_legacy_remove(vp_dev);
> > -	else
> > -	     virtio_pci_modern_remove(vp_dev);
> >  err_probe:
> >  	pci_disable_device(pci_dev);
> >  err_enable_device:
> 
> Otherwise, looks good.
> 
> Reviewed-by: Cornelia Huck <cohuck@redhat.com>

Thanks a ton

  reply	other threads:[~2017-12-12 13:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 15:53 [PATCH 0/3] fix cleanup for fail to register_virtio_device weiping zhang
2017-12-11 15:55 ` [PATCH 1/3] virtio_pci: use put_device instead of kfree weiping zhang
2017-12-12 10:00   ` Cornelia Huck
2017-12-12 13:11     ` weiping zhang [this message]
2017-12-11 15:55 ` [PATCH 2/3] virtio: " weiping zhang
2017-12-12 10:17   ` Cornelia Huck
2017-12-12 13:13     ` weiping zhang
2017-12-11 15:55 ` [PATCH 3/3] virtio: put reference count of virtio_device.dev weiping zhang
2017-12-12 10:33   ` Cornelia Huck

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=20171212131142.GA31104@localhost.didichuxing.com \
    --to=zhangweiping@didichuxing.com \
    --cc=cohuck@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.