diff mbox series

[09/18] vfio/mdev: Add missing error handling to dev_set_name()

Message ID 9-v1-7dedf20b2b75+4f785-vfio2_jgg@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Make vfio_mdev type safe | expand

Commit Message

Jason Gunthorpe March 23, 2021, 5:55 p.m. UTC
This can fail, and seems to be a popular target for syzkaller error
injection. Check the error return and unwind with put_device().

Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 drivers/vfio/mdev/mdev_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig March 23, 2021, 7:21 p.m. UTC | #1
On Tue, Mar 23, 2021 at 02:55:26PM -0300, Jason Gunthorpe wrote:
> This can fail, and seems to be a popular target for syzkaller error
> injection. Check the error return and unwind with put_device().
> 
> Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
Tian, Kevin March 26, 2021, 3:35 a.m. UTC | #2
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Wednesday, March 24, 2021 1:55 AM
> 
> This can fail, and seems to be a popular target for syzkaller error
> injection. Check the error return and unwind with put_device().
> 
> Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

> ---
>  drivers/vfio/mdev/mdev_core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vfio/mdev/mdev_core.c
> b/drivers/vfio/mdev/mdev_core.c
> index 517b6fd351b63a..4b5e372ed58f26 100644
> --- a/drivers/vfio/mdev/mdev_core.c
> +++ b/drivers/vfio/mdev/mdev_core.c
> @@ -258,7 +258,9 @@ int mdev_device_create(struct mdev_type *type,
> const guid_t *uuid)
>  	list_add(&mdev->next, &mdev_list);
>  	mutex_unlock(&mdev_list_lock);
> 
> -	dev_set_name(&mdev->dev, "%pUl", uuid);
> +	ret = dev_set_name(&mdev->dev, "%pUl", uuid);
> +	if (ret)
> +		goto mdev_fail;
> 
>  	/* Check if parent unregistration has started */
>  	if (!down_read_trylock(&parent->unreg_sem)) {
> --
> 2.31.0
Max Gurtovoy March 29, 2021, 8:50 a.m. UTC | #3
On 3/23/2021 7:55 PM, Jason Gunthorpe wrote:
> This can fail, and seems to be a popular target for syzkaller error
> injection. Check the error return and unwind with put_device().
>
> Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>   drivers/vfio/mdev/mdev_core.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)

Looks good,

Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Cornelia Huck March 30, 2021, 3:53 p.m. UTC | #4
On Tue, 23 Mar 2021 14:55:26 -0300
Jason Gunthorpe <jgg@nvidia.com> wrote:

> This can fail, and seems to be a popular target for syzkaller error
> injection. Check the error return and unwind with put_device().
> 
> Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>  drivers/vfio/mdev/mdev_core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
diff mbox series

Patch

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index 517b6fd351b63a..4b5e372ed58f26 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -258,7 +258,9 @@  int mdev_device_create(struct mdev_type *type, const guid_t *uuid)
 	list_add(&mdev->next, &mdev_list);
 	mutex_unlock(&mdev_list_lock);
 
-	dev_set_name(&mdev->dev, "%pUl", uuid);
+	ret = dev_set_name(&mdev->dev, "%pUl", uuid);
+	if (ret)
+		goto mdev_fail;
 
 	/* Check if parent unregistration has started */
 	if (!down_read_trylock(&parent->unreg_sem)) {