Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756146AbcK3HHO (ORCPT ); Wed, 30 Nov 2016 02:07:14 -0500 Received: from smtp11.smtpout.orange.fr ([80.12.242.133]:32982 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbcK3HHL (ORCPT ); Wed, 30 Nov 2016 02:07:11 -0500 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 30 Nov 2016 08:06:21 +0100 X-ME-IP: 92.140.165.130 From: Christophe JAILLET To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] vfio: Fix handling of error returned by 'vfio_group_get_from_dev()' Date: Wed, 30 Nov 2016 08:06:12 +0100 Message-Id: <20161130070612.16073-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.9.3 X-Antivirus: avast! (VPS 161129-1, 29/11/2016), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1855 Lines: 64 'vfio_group_get_from_dev()' seems to return only NULL on error, not an error pointer. Fixes: 2169037dc322 ("vfio iommu: Added pin and unpin callback functions to vfio_iommu_driver_ops") Fixes: c086de818dd8 ("vfio iommu: Add blocking notifier to notify DMA_UNMAP") Signed-off-by: Christophe JAILLET --- This could be split in 2 patches in order to have only one Fixes tag in each --- drivers/vfio/vfio.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index 0aac3ca54a53..7b39313abf0d 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -1933,8 +1933,8 @@ int vfio_pin_pages(struct device *dev, unsigned long *user_pfn, int npage, return -E2BIG; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -ENODEV; ret = vfio_group_add_container_user(group); if (ret) @@ -1982,8 +1982,8 @@ int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn, int npage) return -E2BIG; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -ENODEV; ret = vfio_group_add_container_user(group); if (ret) @@ -2019,8 +2019,8 @@ int vfio_register_notifier(struct device *dev, struct notifier_block *nb) return -EINVAL; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -ENODEV; ret = vfio_group_add_container_user(group); if (ret) @@ -2055,8 +2055,8 @@ int vfio_unregister_notifier(struct device *dev, struct notifier_block *nb) return -EINVAL; group = vfio_group_get_from_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (!group) + return -ENODEV; ret = vfio_group_add_container_user(group); if (ret) -- 2.9.3