[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ed1b1fbf91abb5b2d6388df48079bf45244e2d94.camel@redhat.com>
Date: Mon, 25 Mar 2019 13:48:51 +0200
From: Maxim Levitsky <mlevitsk@...hat.com>
To: Parav Pandit <parav@...lanox.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, kwankhede@...dia.com,
alex.williamson@...hat.com
Subject: Re: [PATCH 1/8] vfio/mdev: Fix to not do put_device on
device_register failure
On Fri, 2019-03-22 at 18:20 -0500, Parav Pandit wrote:
> device_register() performs put_device() if device_add() fails.
> This balances with device_initialize().
>
> mdev core performing put_device() when device_register() fails,
> is an error that puts already released device again.
> Therefore, don't put the device on error.
>
> Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
> Signed-off-by: Parav Pandit <parav@...lanox.com>
> ---
> drivers/vfio/mdev/mdev_core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
> index 0212f0e..3e5880a 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -318,10 +318,8 @@ int mdev_device_create(struct kobject *kobj, struct
> device *dev, uuid_le uuid)
> dev_set_name(&mdev->dev, "%pUl", uuid.b);
>
> ret = device_register(&mdev->dev);
> - if (ret) {
> - put_device(&mdev->dev);
> + if (ret)
> goto mdev_fail;
> - }
>
> ret = mdev_device_create_ops(kobj, mdev);
> if (ret)
Very good catch! Thanks!
Reviewed-by: Maxim Levitsky <mlevitsk@...hat.com>
Best regards,
Maxim Levitsky
Powered by blists - more mailing lists