aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gunthorpe <[email protected]>2021-04-06 16:40:32 -0300
committerAlex Williamson <[email protected]>2021-04-07 15:39:18 -0600
commit18d731242d5c67c0783126c42d3f85870cec2df5 (patch)
treef1273273514af929c7d6f8c111fcbacf5f63fb61
parentfbd0e2b0c3d0b2eeaef471c9fe19ae5a7b2ee970 (diff)
vfio/mdev: Add missing error handling to dev_set_name()
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") Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Max Gurtovoy <[email protected]> Reviewed-by: Cornelia Huck <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]> Message-Id: <[email protected]> Signed-off-by: Alex Williamson <[email protected]>
-rw-r--r--drivers/vfio/mdev/mdev_core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index f7559835b061..4caedb3d4fbf 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 out_put_device;
/* Check if parent unregistration has started */
if (!down_read_trylock(&parent->unreg_sem)) {