virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: weiping zhang <zhangweiping@didichuxing.com>
Cc: virtualization@lists.linux-foundation.org, mst@redhat.com
Subject: Re: [PATCH 2/3] virtio: use put_device instead of kfree
Date: Tue, 12 Dec 2017 11:17:42 +0100	[thread overview]
Message-ID: <20171212111742.4249c49e.cohuck@redhat.com> (raw)
In-Reply-To: <3c3ed58013b0266886e72dc11424e0b93a745e18.1513007310.git.zhangweiping@didichuxing.com>

On Mon, 11 Dec 2017 23:55:26 +0800
weiping zhang <zhangweiping@didichuxing.com> wrote:

> don't free vp_vdev until vp_vdev.dev.release be called.

Same comment as for the virtio_pci patch.

> 
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
>  drivers/misc/mic/vop/vop_main.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/misc/mic/vop/vop_main.c b/drivers/misc/mic/vop/vop_main.c
> index a341938..8c716a0 100644
> --- a/drivers/misc/mic/vop/vop_main.c
> +++ b/drivers/misc/mic/vop/vop_main.c
> @@ -452,10 +452,12 @@ static irqreturn_t vop_virtio_intr_handler(int irq, void *data)
>  
>  static void vop_virtio_release_dev(struct device *_d)
>  {
> -	/*
> -	 * No need for a release method similar to virtio PCI.
> -	 * Provide an empty one to avoid getting a warning from core.
> -	 */
> +	struct virtio_device *vdev =
> +			container_of(_d, struct virtio_device, dev);
> +	struct _vop_vdev *vop_vdev =
> +			container_of(vdev, struct _vop_vdev, vdev);
> +
> +	kfree(vop_vdev);
>  }
>  
>  /*
> @@ -501,7 +503,9 @@ static int _vop_add_device(struct mic_device_desc __iomem *d,
>  		dev_err(_vop_dev(vdev),
>  			"Failed to register vop device %u type %u\n",
>  			offset, type);
> -		goto free_irq;
> +		vpdev->hw_ops->free_irq(vpdev, vdev->virtio_cookie, vdev);
> +		put_device(&vdev->vdev.dev);
> +		return ret;
>  	}
>  	writeq((u64)vdev, &vdev->dc->vdev);
>  	dev_dbg(_vop_dev(vdev), "%s: registered vop device %u type %u vdev %p\n",
> @@ -509,8 +513,6 @@ static int _vop_add_device(struct mic_device_desc __iomem *d,
>  
>  	return 0;
>  
> -free_irq:
> -	vpdev->hw_ops->free_irq(vpdev, vdev->virtio_cookie, vdev);
>  kfree:
>  	kfree(vdev);
>  	return ret;

BTW, the kfree(vdev) in _vop_remove_device() is also wrong (needs to be
a put_device() as well).

  reply	other threads:[~2017-12-12 10:17 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
2017-12-11 15:55 ` [PATCH 2/3] virtio: " weiping zhang
2017-12-12 10:17   ` Cornelia Huck [this message]
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=20171212111742.4249c49e.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=zhangweiping@didichuxing.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;
as well as URLs for NNTP newsgroup(s).