From: Yan Zhao Date: Wed, 16 Sep 2020 02:29:27 +0000 (+0800) Subject: vfio: fix a missed vfio group put in vfio_pin_pages X-Git-Tag: v5.8.17~194 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01bec5d78c05b1fb2e8b1141a7bfd9f9b7f1ad3c;p=thirdparty%2Fkernel%2Fstable.git vfio: fix a missed vfio group put in vfio_pin_pages [ Upstream commit 28b130244061863cf0437b7af1625fb45ec1a71e ] When error occurs, need to put vfio group after a successful get. Fixes: 95fc87b44104 ("vfio: Selective dirty page tracking if IOMMU backed device pins pages") Signed-off-by: Yan Zhao Reviewed-by: Cornelia Huck Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 2a70e25cfe954..fbff5c4743c5e 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1948,8 +1948,10 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage, if (!group) return -ENODEV; - if (group->dev_counter > 1) - return -EINVAL; + if (group->dev_counter > 1) { + ret = -EINVAL; + goto err_pin_pages; + } ret = vfio_group_add_container_user(group); if (ret)